babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. 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;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. 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;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. 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);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * 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;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * 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).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * 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).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * 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.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * 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.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * 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.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * 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.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * 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.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * 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.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * 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).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * 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).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * 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.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * 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.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * 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.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * 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.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * 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.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * 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.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * 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).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * 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).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * 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.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * 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.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * 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.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * 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.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * 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.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * 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.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * 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).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * 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).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * 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.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * 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.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * 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.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * 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.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * 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.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * 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.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Nullable } from "babylonjs/types";
  9538. import { Scene } from "babylonjs/scene";
  9539. import { ActionManager } from "babylonjs/Actions/actionManager";
  9540. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9541. import { Node } from "babylonjs/node";
  9542. /**
  9543. * Interface used to define Action
  9544. */
  9545. export interface IAction {
  9546. /**
  9547. * Trigger for the action
  9548. */
  9549. trigger: number;
  9550. /** Options of the trigger */
  9551. triggerOptions: any;
  9552. /**
  9553. * Gets the trigger parameters
  9554. * @returns the trigger parameters
  9555. */
  9556. getTriggerParameter(): any;
  9557. /**
  9558. * Internal only - executes current action event
  9559. * @hidden
  9560. */
  9561. _executeCurrent(evt?: ActionEvent): void;
  9562. /**
  9563. * Serialize placeholder for child classes
  9564. * @param parent of child
  9565. * @returns the serialized object
  9566. */
  9567. serialize(parent: any): any;
  9568. /**
  9569. * Internal only
  9570. * @hidden
  9571. */
  9572. _prepare(): void;
  9573. /**
  9574. * Internal only - manager for action
  9575. * @hidden
  9576. */
  9577. _actionManager: Nullable<AbstractActionManager>;
  9578. /**
  9579. * Adds action to chain of actions, may be a DoNothingAction
  9580. * @param action defines the next action to execute
  9581. * @returns The action passed in
  9582. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9583. */
  9584. then(action: IAction): IAction;
  9585. }
  9586. /**
  9587. * The action to be carried out following a trigger
  9588. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9589. */
  9590. export class Action implements IAction {
  9591. /** the trigger, with or without parameters, for the action */
  9592. triggerOptions: any;
  9593. /**
  9594. * Trigger for the action
  9595. */
  9596. trigger: number;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. private _nextActiveAction;
  9603. private _child;
  9604. private _condition?;
  9605. private _triggerParameter;
  9606. /**
  9607. * An event triggered prior to action being executed.
  9608. */
  9609. onBeforeExecuteObservable: Observable<Action>;
  9610. /**
  9611. * Creates a new Action
  9612. * @param triggerOptions the trigger, with or without parameters, for the action
  9613. * @param condition an optional determinant of action
  9614. */
  9615. constructor(
  9616. /** the trigger, with or without parameters, for the action */
  9617. triggerOptions: any, condition?: Condition);
  9618. /**
  9619. * Internal only
  9620. * @hidden
  9621. */
  9622. _prepare(): void;
  9623. /**
  9624. * Gets the trigger parameters
  9625. * @returns the trigger parameters
  9626. */
  9627. getTriggerParameter(): any;
  9628. /**
  9629. * Internal only - executes current action event
  9630. * @hidden
  9631. */
  9632. _executeCurrent(evt?: ActionEvent): void;
  9633. /**
  9634. * Execute placeholder for child classes
  9635. * @param evt optional action event
  9636. */
  9637. execute(evt?: ActionEvent): void;
  9638. /**
  9639. * Skips to next active action
  9640. */
  9641. skipToNextActiveAction(): void;
  9642. /**
  9643. * Adds action to chain of actions, may be a DoNothingAction
  9644. * @param action defines the next action to execute
  9645. * @returns The action passed in
  9646. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9647. */
  9648. then(action: Action): Action;
  9649. /**
  9650. * Internal only
  9651. * @hidden
  9652. */
  9653. _getProperty(propertyPath: string): string;
  9654. /**
  9655. * Internal only
  9656. * @hidden
  9657. */
  9658. _getEffectiveTarget(target: any, propertyPath: string): any;
  9659. /**
  9660. * Serialize placeholder for child classes
  9661. * @param parent of child
  9662. * @returns the serialized object
  9663. */
  9664. serialize(parent: any): any;
  9665. /**
  9666. * Internal only called by serialize
  9667. * @hidden
  9668. */
  9669. protected _serialize(serializedAction: any, parent?: any): any;
  9670. /**
  9671. * Internal only
  9672. * @hidden
  9673. */
  9674. static _SerializeValueAsString: (value: any) => string;
  9675. /**
  9676. * Internal only
  9677. * @hidden
  9678. */
  9679. static _GetTargetProperty: (target: Scene | Node) => {
  9680. name: string;
  9681. targetType: string;
  9682. value: string;
  9683. };
  9684. }
  9685. }
  9686. declare module "babylonjs/Actions/condition" {
  9687. import { ActionManager } from "babylonjs/Actions/actionManager";
  9688. /**
  9689. * A Condition applied to an Action
  9690. */
  9691. export class Condition {
  9692. /**
  9693. * Internal only - manager for action
  9694. * @hidden
  9695. */
  9696. _actionManager: ActionManager;
  9697. /**
  9698. * Internal only
  9699. * @hidden
  9700. */
  9701. _evaluationId: number;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. _currentResult: boolean;
  9707. /**
  9708. * Creates a new Condition
  9709. * @param actionManager the manager of the action the condition is applied to
  9710. */
  9711. constructor(actionManager: ActionManager);
  9712. /**
  9713. * Check if the current condition is valid
  9714. * @returns a boolean
  9715. */
  9716. isValid(): boolean;
  9717. /**
  9718. * Internal only
  9719. * @hidden
  9720. */
  9721. _getProperty(propertyPath: string): string;
  9722. /**
  9723. * Internal only
  9724. * @hidden
  9725. */
  9726. _getEffectiveTarget(target: any, propertyPath: string): any;
  9727. /**
  9728. * Serialize placeholder for child classes
  9729. * @returns the serialized object
  9730. */
  9731. serialize(): any;
  9732. /**
  9733. * Internal only
  9734. * @hidden
  9735. */
  9736. protected _serialize(serializedCondition: any): any;
  9737. }
  9738. /**
  9739. * Defines specific conditional operators as extensions of Condition
  9740. */
  9741. export class ValueCondition extends Condition {
  9742. /** path to specify the property of the target the conditional operator uses */
  9743. propertyPath: string;
  9744. /** the value compared by the conditional operator against the current value of the property */
  9745. value: any;
  9746. /** the conditional operator, default ValueCondition.IsEqual */
  9747. operator: number;
  9748. /**
  9749. * Internal only
  9750. * @hidden
  9751. */
  9752. private static _IsEqual;
  9753. /**
  9754. * Internal only
  9755. * @hidden
  9756. */
  9757. private static _IsDifferent;
  9758. /**
  9759. * Internal only
  9760. * @hidden
  9761. */
  9762. private static _IsGreater;
  9763. /**
  9764. * Internal only
  9765. * @hidden
  9766. */
  9767. private static _IsLesser;
  9768. /**
  9769. * returns the number for IsEqual
  9770. */
  9771. static get IsEqual(): number;
  9772. /**
  9773. * Returns the number for IsDifferent
  9774. */
  9775. static get IsDifferent(): number;
  9776. /**
  9777. * Returns the number for IsGreater
  9778. */
  9779. static get IsGreater(): number;
  9780. /**
  9781. * Returns the number for IsLesser
  9782. */
  9783. static get IsLesser(): number;
  9784. /**
  9785. * Internal only The action manager for the condition
  9786. * @hidden
  9787. */
  9788. _actionManager: ActionManager;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. private _target;
  9794. /**
  9795. * Internal only
  9796. * @hidden
  9797. */
  9798. private _effectiveTarget;
  9799. /**
  9800. * Internal only
  9801. * @hidden
  9802. */
  9803. private _property;
  9804. /**
  9805. * Creates a new ValueCondition
  9806. * @param actionManager manager for the action the condition applies to
  9807. * @param target for the action
  9808. * @param propertyPath path to specify the property of the target the conditional operator uses
  9809. * @param value the value compared by the conditional operator against the current value of the property
  9810. * @param operator the conditional operator, default ValueCondition.IsEqual
  9811. */
  9812. constructor(actionManager: ActionManager, target: any,
  9813. /** path to specify the property of the target the conditional operator uses */
  9814. propertyPath: string,
  9815. /** the value compared by the conditional operator against the current value of the property */
  9816. value: any,
  9817. /** the conditional operator, default ValueCondition.IsEqual */
  9818. operator?: number);
  9819. /**
  9820. * Compares the given value with the property value for the specified conditional operator
  9821. * @returns the result of the comparison
  9822. */
  9823. isValid(): boolean;
  9824. /**
  9825. * Serialize the ValueCondition into a JSON compatible object
  9826. * @returns serialization object
  9827. */
  9828. serialize(): any;
  9829. /**
  9830. * Gets the name of the conditional operator for the ValueCondition
  9831. * @param operator the conditional operator
  9832. * @returns the name
  9833. */
  9834. static GetOperatorName(operator: number): string;
  9835. }
  9836. /**
  9837. * Defines a predicate condition as an extension of Condition
  9838. */
  9839. export class PredicateCondition extends Condition {
  9840. /** defines the predicate function used to validate the condition */
  9841. predicate: () => boolean;
  9842. /**
  9843. * Internal only - manager for action
  9844. * @hidden
  9845. */
  9846. _actionManager: ActionManager;
  9847. /**
  9848. * Creates a new PredicateCondition
  9849. * @param actionManager manager for the action the condition applies to
  9850. * @param predicate defines the predicate function used to validate the condition
  9851. */
  9852. constructor(actionManager: ActionManager,
  9853. /** defines the predicate function used to validate the condition */
  9854. predicate: () => boolean);
  9855. /**
  9856. * @returns the validity of the predicate condition
  9857. */
  9858. isValid(): boolean;
  9859. }
  9860. /**
  9861. * Defines a state condition as an extension of Condition
  9862. */
  9863. export class StateCondition extends Condition {
  9864. /** Value to compare with target state */
  9865. value: string;
  9866. /**
  9867. * Internal only - manager for action
  9868. * @hidden
  9869. */
  9870. _actionManager: ActionManager;
  9871. /**
  9872. * Internal only
  9873. * @hidden
  9874. */
  9875. private _target;
  9876. /**
  9877. * Creates a new StateCondition
  9878. * @param actionManager manager for the action the condition applies to
  9879. * @param target of the condition
  9880. * @param value to compare with target state
  9881. */
  9882. constructor(actionManager: ActionManager, target: any,
  9883. /** Value to compare with target state */
  9884. value: string);
  9885. /**
  9886. * Gets a boolean indicating if the current condition is met
  9887. * @returns the validity of the state
  9888. */
  9889. isValid(): boolean;
  9890. /**
  9891. * Serialize the StateCondition into a JSON compatible object
  9892. * @returns serialization object
  9893. */
  9894. serialize(): any;
  9895. }
  9896. }
  9897. declare module "babylonjs/Actions/directActions" {
  9898. import { Action } from "babylonjs/Actions/action";
  9899. import { Condition } from "babylonjs/Actions/condition";
  9900. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9901. /**
  9902. * This defines an action responsible to toggle a boolean once triggered.
  9903. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9904. */
  9905. export class SwitchBooleanAction extends Action {
  9906. /**
  9907. * The path to the boolean property in the target object
  9908. */
  9909. propertyPath: string;
  9910. private _target;
  9911. private _effectiveTarget;
  9912. private _property;
  9913. /**
  9914. * Instantiate the action
  9915. * @param triggerOptions defines the trigger options
  9916. * @param target defines the object containing the boolean
  9917. * @param propertyPath defines the path to the boolean property in the target object
  9918. * @param condition defines the trigger related conditions
  9919. */
  9920. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9921. /** @hidden */
  9922. _prepare(): void;
  9923. /**
  9924. * Execute the action toggle the boolean value.
  9925. */
  9926. execute(): void;
  9927. /**
  9928. * Serializes the actions and its related information.
  9929. * @param parent defines the object to serialize in
  9930. * @returns the serialized object
  9931. */
  9932. serialize(parent: any): any;
  9933. }
  9934. /**
  9935. * This defines an action responsible to set a the state field of the target
  9936. * to a desired value once triggered.
  9937. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9938. */
  9939. export class SetStateAction extends Action {
  9940. /**
  9941. * The value to store in the state field.
  9942. */
  9943. value: string;
  9944. private _target;
  9945. /**
  9946. * Instantiate the action
  9947. * @param triggerOptions defines the trigger options
  9948. * @param target defines the object containing the state property
  9949. * @param value defines the value to store in the state field
  9950. * @param condition defines the trigger related conditions
  9951. */
  9952. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9953. /**
  9954. * Execute the action and store the value on the target state property.
  9955. */
  9956. execute(): void;
  9957. /**
  9958. * Serializes the actions and its related information.
  9959. * @param parent defines the object to serialize in
  9960. * @returns the serialized object
  9961. */
  9962. serialize(parent: any): any;
  9963. }
  9964. /**
  9965. * This defines an action responsible to set a property of the target
  9966. * to a desired value once triggered.
  9967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9968. */
  9969. export class SetValueAction extends Action {
  9970. /**
  9971. * The path of the property to set in the target.
  9972. */
  9973. propertyPath: string;
  9974. /**
  9975. * The value to set in the property
  9976. */
  9977. value: any;
  9978. private _target;
  9979. private _effectiveTarget;
  9980. private _property;
  9981. /**
  9982. * Instantiate the action
  9983. * @param triggerOptions defines the trigger options
  9984. * @param target defines the object containing the property
  9985. * @param propertyPath defines the path of the property to set in the target
  9986. * @param value defines the value to set in the property
  9987. * @param condition defines the trigger related conditions
  9988. */
  9989. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9990. /** @hidden */
  9991. _prepare(): void;
  9992. /**
  9993. * Execute the action and set the targetted property to the desired value.
  9994. */
  9995. execute(): void;
  9996. /**
  9997. * Serializes the actions and its related information.
  9998. * @param parent defines the object to serialize in
  9999. * @returns the serialized object
  10000. */
  10001. serialize(parent: any): any;
  10002. }
  10003. /**
  10004. * This defines an action responsible to increment the target value
  10005. * to a desired value once triggered.
  10006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10007. */
  10008. export class IncrementValueAction extends Action {
  10009. /**
  10010. * The path of the property to increment in the target.
  10011. */
  10012. propertyPath: string;
  10013. /**
  10014. * The value we should increment the property by.
  10015. */
  10016. value: any;
  10017. private _target;
  10018. private _effectiveTarget;
  10019. private _property;
  10020. /**
  10021. * Instantiate the action
  10022. * @param triggerOptions defines the trigger options
  10023. * @param target defines the object containing the property
  10024. * @param propertyPath defines the path of the property to increment in the target
  10025. * @param value defines the value value we should increment the property by
  10026. * @param condition defines the trigger related conditions
  10027. */
  10028. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10029. /** @hidden */
  10030. _prepare(): void;
  10031. /**
  10032. * Execute the action and increment the target of the value amount.
  10033. */
  10034. execute(): void;
  10035. /**
  10036. * Serializes the actions and its related information.
  10037. * @param parent defines the object to serialize in
  10038. * @returns the serialized object
  10039. */
  10040. serialize(parent: any): any;
  10041. }
  10042. /**
  10043. * This defines an action responsible to start an animation once triggered.
  10044. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10045. */
  10046. export class PlayAnimationAction extends Action {
  10047. /**
  10048. * Where the animation should start (animation frame)
  10049. */
  10050. from: number;
  10051. /**
  10052. * Where the animation should stop (animation frame)
  10053. */
  10054. to: number;
  10055. /**
  10056. * Define if the animation should loop or stop after the first play.
  10057. */
  10058. loop?: boolean;
  10059. private _target;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param target defines the target animation or animation name
  10064. * @param from defines from where the animation should start (animation frame)
  10065. * @param end defines where the animation should stop (animation frame)
  10066. * @param loop defines if the animation should loop or stop after the first play
  10067. * @param condition defines the trigger related conditions
  10068. */
  10069. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10070. /** @hidden */
  10071. _prepare(): void;
  10072. /**
  10073. * Execute the action and play the animation.
  10074. */
  10075. execute(): void;
  10076. /**
  10077. * Serializes the actions and its related information.
  10078. * @param parent defines the object to serialize in
  10079. * @returns the serialized object
  10080. */
  10081. serialize(parent: any): any;
  10082. }
  10083. /**
  10084. * This defines an action responsible to stop an animation once triggered.
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10086. */
  10087. export class StopAnimationAction extends Action {
  10088. private _target;
  10089. /**
  10090. * Instantiate the action
  10091. * @param triggerOptions defines the trigger options
  10092. * @param target defines the target animation or animation name
  10093. * @param condition defines the trigger related conditions
  10094. */
  10095. constructor(triggerOptions: any, target: any, condition?: Condition);
  10096. /** @hidden */
  10097. _prepare(): void;
  10098. /**
  10099. * Execute the action and stop the animation.
  10100. */
  10101. execute(): void;
  10102. /**
  10103. * Serializes the actions and its related information.
  10104. * @param parent defines the object to serialize in
  10105. * @returns the serialized object
  10106. */
  10107. serialize(parent: any): any;
  10108. }
  10109. /**
  10110. * This defines an action responsible that does nothing once triggered.
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10112. */
  10113. export class DoNothingAction extends Action {
  10114. /**
  10115. * Instantiate the action
  10116. * @param triggerOptions defines the trigger options
  10117. * @param condition defines the trigger related conditions
  10118. */
  10119. constructor(triggerOptions?: any, condition?: Condition);
  10120. /**
  10121. * Execute the action and do nothing.
  10122. */
  10123. execute(): void;
  10124. /**
  10125. * Serializes the actions and its related information.
  10126. * @param parent defines the object to serialize in
  10127. * @returns the serialized object
  10128. */
  10129. serialize(parent: any): any;
  10130. }
  10131. /**
  10132. * This defines an action responsible to trigger several actions once triggered.
  10133. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class CombineAction extends Action {
  10136. /**
  10137. * The list of aggregated animations to run.
  10138. */
  10139. children: Action[];
  10140. /**
  10141. * Instantiate the action
  10142. * @param triggerOptions defines the trigger options
  10143. * @param children defines the list of aggregated animations to run
  10144. * @param condition defines the trigger related conditions
  10145. */
  10146. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10147. /** @hidden */
  10148. _prepare(): void;
  10149. /**
  10150. * Execute the action and executes all the aggregated actions.
  10151. */
  10152. execute(evt: ActionEvent): void;
  10153. /**
  10154. * Serializes the actions and its related information.
  10155. * @param parent defines the object to serialize in
  10156. * @returns the serialized object
  10157. */
  10158. serialize(parent: any): any;
  10159. }
  10160. /**
  10161. * This defines an action responsible to run code (external event) once triggered.
  10162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10163. */
  10164. export class ExecuteCodeAction extends Action {
  10165. /**
  10166. * The callback function to run.
  10167. */
  10168. func: (evt: ActionEvent) => void;
  10169. /**
  10170. * Instantiate the action
  10171. * @param triggerOptions defines the trigger options
  10172. * @param func defines the callback function to run
  10173. * @param condition defines the trigger related conditions
  10174. */
  10175. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10176. /**
  10177. * Execute the action and run the attached code.
  10178. */
  10179. execute(evt: ActionEvent): void;
  10180. }
  10181. /**
  10182. * This defines an action responsible to set the parent property of the target once triggered.
  10183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10184. */
  10185. export class SetParentAction extends Action {
  10186. private _parent;
  10187. private _target;
  10188. /**
  10189. * Instantiate the action
  10190. * @param triggerOptions defines the trigger options
  10191. * @param target defines the target containing the parent property
  10192. * @param parent defines from where the animation should start (animation frame)
  10193. * @param condition defines the trigger related conditions
  10194. */
  10195. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10196. /** @hidden */
  10197. _prepare(): void;
  10198. /**
  10199. * Execute the action and set the parent property.
  10200. */
  10201. execute(): void;
  10202. /**
  10203. * Serializes the actions and its related information.
  10204. * @param parent defines the object to serialize in
  10205. * @returns the serialized object
  10206. */
  10207. serialize(parent: any): any;
  10208. }
  10209. }
  10210. declare module "babylonjs/Actions/actionManager" {
  10211. import { Nullable } from "babylonjs/types";
  10212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10213. import { Scene } from "babylonjs/scene";
  10214. import { IAction } from "babylonjs/Actions/action";
  10215. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10216. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10217. /**
  10218. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10219. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10221. */
  10222. export class ActionManager extends AbstractActionManager {
  10223. /**
  10224. * Nothing
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly NothingTrigger: number;
  10228. /**
  10229. * On pick
  10230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10231. */
  10232. static readonly OnPickTrigger: number;
  10233. /**
  10234. * On left pick
  10235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10236. */
  10237. static readonly OnLeftPickTrigger: number;
  10238. /**
  10239. * On right pick
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10241. */
  10242. static readonly OnRightPickTrigger: number;
  10243. /**
  10244. * On center pick
  10245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10246. */
  10247. static readonly OnCenterPickTrigger: number;
  10248. /**
  10249. * On pick down
  10250. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10251. */
  10252. static readonly OnPickDownTrigger: number;
  10253. /**
  10254. * On double pick
  10255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10256. */
  10257. static readonly OnDoublePickTrigger: number;
  10258. /**
  10259. * On pick up
  10260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10261. */
  10262. static readonly OnPickUpTrigger: number;
  10263. /**
  10264. * On pick out.
  10265. * This trigger will only be raised if you also declared a OnPickDown
  10266. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10267. */
  10268. static readonly OnPickOutTrigger: number;
  10269. /**
  10270. * On long press
  10271. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10272. */
  10273. static readonly OnLongPressTrigger: number;
  10274. /**
  10275. * On pointer over
  10276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10277. */
  10278. static readonly OnPointerOverTrigger: number;
  10279. /**
  10280. * On pointer out
  10281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10282. */
  10283. static readonly OnPointerOutTrigger: number;
  10284. /**
  10285. * On every frame
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10287. */
  10288. static readonly OnEveryFrameTrigger: number;
  10289. /**
  10290. * On intersection enter
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly OnIntersectionEnterTrigger: number;
  10294. /**
  10295. * On intersection exit
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnIntersectionExitTrigger: number;
  10299. /**
  10300. * On key down
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnKeyDownTrigger: number;
  10304. /**
  10305. * On key up
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnKeyUpTrigger: number;
  10309. private _scene;
  10310. /**
  10311. * Creates a new action manager
  10312. * @param scene defines the hosting scene
  10313. */
  10314. constructor(scene: Scene);
  10315. /**
  10316. * Releases all associated resources
  10317. */
  10318. dispose(): void;
  10319. /**
  10320. * Gets hosting scene
  10321. * @returns the hosting scene
  10322. */
  10323. getScene(): Scene;
  10324. /**
  10325. * Does this action manager handles actions of any of the given triggers
  10326. * @param triggers defines the triggers to be tested
  10327. * @return a boolean indicating whether one (or more) of the triggers is handled
  10328. */
  10329. hasSpecificTriggers(triggers: number[]): boolean;
  10330. /**
  10331. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10332. * speed.
  10333. * @param triggerA defines the trigger to be tested
  10334. * @param triggerB defines the trigger to be tested
  10335. * @return a boolean indicating whether one (or more) of the triggers is handled
  10336. */
  10337. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10338. /**
  10339. * Does this action manager handles actions of a given trigger
  10340. * @param trigger defines the trigger to be tested
  10341. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10342. * @return whether the trigger is handled
  10343. */
  10344. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10345. /**
  10346. * Does this action manager has pointer triggers
  10347. */
  10348. get hasPointerTriggers(): boolean;
  10349. /**
  10350. * Does this action manager has pick triggers
  10351. */
  10352. get hasPickTriggers(): boolean;
  10353. /**
  10354. * Registers an action to this action manager
  10355. * @param action defines the action to be registered
  10356. * @return the action amended (prepared) after registration
  10357. */
  10358. registerAction(action: IAction): Nullable<IAction>;
  10359. /**
  10360. * Unregisters an action to this action manager
  10361. * @param action defines the action to be unregistered
  10362. * @return a boolean indicating whether the action has been unregistered
  10363. */
  10364. unregisterAction(action: IAction): Boolean;
  10365. /**
  10366. * Process a specific trigger
  10367. * @param trigger defines the trigger to process
  10368. * @param evt defines the event details to be processed
  10369. */
  10370. processTrigger(trigger: number, evt?: IActionEvent): void;
  10371. /** @hidden */
  10372. _getEffectiveTarget(target: any, propertyPath: string): any;
  10373. /** @hidden */
  10374. _getProperty(propertyPath: string): string;
  10375. /**
  10376. * Serialize this manager to a JSON object
  10377. * @param name defines the property name to store this manager
  10378. * @returns a JSON representation of this manager
  10379. */
  10380. serialize(name: string): any;
  10381. /**
  10382. * Creates a new ActionManager from a JSON data
  10383. * @param parsedActions defines the JSON data to read from
  10384. * @param object defines the hosting mesh
  10385. * @param scene defines the hosting scene
  10386. */
  10387. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10388. /**
  10389. * Get a trigger name by index
  10390. * @param trigger defines the trigger index
  10391. * @returns a trigger name
  10392. */
  10393. static GetTriggerName(trigger: number): string;
  10394. }
  10395. }
  10396. declare module "babylonjs/Sprites/sprite" {
  10397. import { Vector3 } from "babylonjs/Maths/math.vector";
  10398. import { Nullable } from "babylonjs/types";
  10399. import { ActionManager } from "babylonjs/Actions/actionManager";
  10400. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10401. import { Color4 } from "babylonjs/Maths/math.color";
  10402. import { Observable } from "babylonjs/Misc/observable";
  10403. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10404. import { Animation } from "babylonjs/Animations/animation";
  10405. /**
  10406. * Class used to represent a sprite
  10407. * @see https://doc.babylonjs.com/babylon101/sprites
  10408. */
  10409. export class Sprite implements IAnimatable {
  10410. /** defines the name */
  10411. name: string;
  10412. /** Gets or sets the current world position */
  10413. position: Vector3;
  10414. /** Gets or sets the main color */
  10415. color: Color4;
  10416. /** Gets or sets the width */
  10417. width: number;
  10418. /** Gets or sets the height */
  10419. height: number;
  10420. /** Gets or sets rotation angle */
  10421. angle: number;
  10422. /** Gets or sets the cell index in the sprite sheet */
  10423. cellIndex: number;
  10424. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10425. cellRef: string;
  10426. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10427. invertU: boolean;
  10428. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10429. invertV: boolean;
  10430. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10431. disposeWhenFinishedAnimating: boolean;
  10432. /** Gets the list of attached animations */
  10433. animations: Nullable<Array<Animation>>;
  10434. /** Gets or sets a boolean indicating if the sprite can be picked */
  10435. isPickable: boolean;
  10436. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10437. useAlphaForPicking: boolean;
  10438. /** @hidden */
  10439. _xOffset: number;
  10440. /** @hidden */
  10441. _yOffset: number;
  10442. /** @hidden */
  10443. _xSize: number;
  10444. /** @hidden */
  10445. _ySize: number;
  10446. /**
  10447. * Gets or sets the associated action manager
  10448. */
  10449. actionManager: Nullable<ActionManager>;
  10450. /**
  10451. * An event triggered when the control has been disposed
  10452. */
  10453. onDisposeObservable: Observable<Sprite>;
  10454. private _animationStarted;
  10455. private _loopAnimation;
  10456. private _fromIndex;
  10457. private _toIndex;
  10458. private _delay;
  10459. private _direction;
  10460. private _manager;
  10461. private _time;
  10462. private _onAnimationEnd;
  10463. /**
  10464. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10465. */
  10466. isVisible: boolean;
  10467. /**
  10468. * Gets or sets the sprite size
  10469. */
  10470. get size(): number;
  10471. set size(value: number);
  10472. /**
  10473. * Returns a boolean indicating if the animation is started
  10474. */
  10475. get animationStarted(): boolean;
  10476. /**
  10477. * Gets or sets the unique id of the sprite
  10478. */
  10479. uniqueId: number;
  10480. /**
  10481. * Gets the manager of this sprite
  10482. */
  10483. get manager(): ISpriteManager;
  10484. /**
  10485. * Creates a new Sprite
  10486. * @param name defines the name
  10487. * @param manager defines the manager
  10488. */
  10489. constructor(
  10490. /** defines the name */
  10491. name: string, manager: ISpriteManager);
  10492. /**
  10493. * Returns the string "Sprite"
  10494. * @returns "Sprite"
  10495. */
  10496. getClassName(): string;
  10497. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10498. get fromIndex(): number;
  10499. set fromIndex(value: number);
  10500. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10501. get toIndex(): number;
  10502. set toIndex(value: number);
  10503. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10504. get loopAnimation(): boolean;
  10505. set loopAnimation(value: boolean);
  10506. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10507. get delay(): number;
  10508. set delay(value: number);
  10509. /**
  10510. * Starts an animation
  10511. * @param from defines the initial key
  10512. * @param to defines the end key
  10513. * @param loop defines if the animation must loop
  10514. * @param delay defines the start delay (in ms)
  10515. * @param onAnimationEnd defines a callback to call when animation ends
  10516. */
  10517. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10518. /** Stops current animation (if any) */
  10519. stopAnimation(): void;
  10520. /** @hidden */
  10521. _animate(deltaTime: number): void;
  10522. /** Release associated resources */
  10523. dispose(): void;
  10524. /**
  10525. * Serializes the sprite to a JSON object
  10526. * @returns the JSON object
  10527. */
  10528. serialize(): any;
  10529. /**
  10530. * Parses a JSON object to create a new sprite
  10531. * @param parsedSprite The JSON object to parse
  10532. * @param manager defines the hosting manager
  10533. * @returns the new sprite
  10534. */
  10535. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10536. }
  10537. }
  10538. declare module "babylonjs/Collisions/pickingInfo" {
  10539. import { Nullable } from "babylonjs/types";
  10540. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10542. import { Sprite } from "babylonjs/Sprites/sprite";
  10543. import { Ray } from "babylonjs/Culling/ray";
  10544. /**
  10545. * Information about the result of picking within a scene
  10546. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10547. */
  10548. export class PickingInfo {
  10549. /** @hidden */
  10550. _pickingUnavailable: boolean;
  10551. /**
  10552. * If the pick collided with an object
  10553. */
  10554. hit: boolean;
  10555. /**
  10556. * Distance away where the pick collided
  10557. */
  10558. distance: number;
  10559. /**
  10560. * The location of pick collision
  10561. */
  10562. pickedPoint: Nullable<Vector3>;
  10563. /**
  10564. * The mesh corresponding the the pick collision
  10565. */
  10566. pickedMesh: Nullable<AbstractMesh>;
  10567. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10568. bu: number;
  10569. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10570. bv: number;
  10571. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10572. faceId: number;
  10573. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10574. subMeshFaceId: number;
  10575. /** Id of the the submesh that was picked */
  10576. subMeshId: number;
  10577. /** If a sprite was picked, this will be the sprite the pick collided with */
  10578. pickedSprite: Nullable<Sprite>;
  10579. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10580. thinInstanceIndex: number;
  10581. /**
  10582. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10583. */
  10584. originMesh: Nullable<AbstractMesh>;
  10585. /**
  10586. * The ray that was used to perform the picking.
  10587. */
  10588. ray: Nullable<Ray>;
  10589. /**
  10590. * Gets the normal correspodning to the face the pick collided with
  10591. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10592. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10593. * @returns The normal correspodning to the face the pick collided with
  10594. */
  10595. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10596. /**
  10597. * Gets the texture coordinates of where the pick occured
  10598. * @returns the vector containing the coordnates of the texture
  10599. */
  10600. getTextureCoordinates(): Nullable<Vector2>;
  10601. }
  10602. }
  10603. declare module "babylonjs/Culling/ray" {
  10604. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10605. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10607. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10608. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10609. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10610. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10611. import { Plane } from "babylonjs/Maths/math.plane";
  10612. /**
  10613. * Class representing a ray with position and direction
  10614. */
  10615. export class Ray {
  10616. /** origin point */
  10617. origin: Vector3;
  10618. /** direction */
  10619. direction: Vector3;
  10620. /** length of the ray */
  10621. length: number;
  10622. private static readonly _TmpVector3;
  10623. private _tmpRay;
  10624. /**
  10625. * Creates a new ray
  10626. * @param origin origin point
  10627. * @param direction direction
  10628. * @param length length of the ray
  10629. */
  10630. constructor(
  10631. /** origin point */
  10632. origin: Vector3,
  10633. /** direction */
  10634. direction: Vector3,
  10635. /** length of the ray */
  10636. length?: number);
  10637. /**
  10638. * Checks if the ray intersects a box
  10639. * This does not account for the ray lenght by design to improve perfs.
  10640. * @param minimum bound of the box
  10641. * @param maximum bound of the box
  10642. * @param intersectionTreshold extra extend to be added to the box in all direction
  10643. * @returns if the box was hit
  10644. */
  10645. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10646. /**
  10647. * Checks if the ray intersects a box
  10648. * This does not account for the ray lenght by design to improve perfs.
  10649. * @param box the bounding box to check
  10650. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10651. * @returns if the box was hit
  10652. */
  10653. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10654. /**
  10655. * If the ray hits a sphere
  10656. * @param sphere the bounding sphere to check
  10657. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10658. * @returns true if it hits the sphere
  10659. */
  10660. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10661. /**
  10662. * If the ray hits a triange
  10663. * @param vertex0 triangle vertex
  10664. * @param vertex1 triangle vertex
  10665. * @param vertex2 triangle vertex
  10666. * @returns intersection information if hit
  10667. */
  10668. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10669. /**
  10670. * Checks if ray intersects a plane
  10671. * @param plane the plane to check
  10672. * @returns the distance away it was hit
  10673. */
  10674. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10675. /**
  10676. * Calculate the intercept of a ray on a given axis
  10677. * @param axis to check 'x' | 'y' | 'z'
  10678. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10679. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10680. */
  10681. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10682. /**
  10683. * Checks if ray intersects a mesh
  10684. * @param mesh the mesh to check
  10685. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10686. * @returns picking info of the intersecton
  10687. */
  10688. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10689. /**
  10690. * Checks if ray intersects a mesh
  10691. * @param meshes the meshes to check
  10692. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10693. * @param results array to store result in
  10694. * @returns Array of picking infos
  10695. */
  10696. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10697. private _comparePickingInfo;
  10698. private static smallnum;
  10699. private static rayl;
  10700. /**
  10701. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10702. * @param sega the first point of the segment to test the intersection against
  10703. * @param segb the second point of the segment to test the intersection against
  10704. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10705. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10706. */
  10707. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10708. /**
  10709. * Update the ray from viewport position
  10710. * @param x position
  10711. * @param y y position
  10712. * @param viewportWidth viewport width
  10713. * @param viewportHeight viewport height
  10714. * @param world world matrix
  10715. * @param view view matrix
  10716. * @param projection projection matrix
  10717. * @returns this ray updated
  10718. */
  10719. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10720. /**
  10721. * Creates a ray with origin and direction of 0,0,0
  10722. * @returns the new ray
  10723. */
  10724. static Zero(): Ray;
  10725. /**
  10726. * Creates a new ray from screen space and viewport
  10727. * @param x position
  10728. * @param y y position
  10729. * @param viewportWidth viewport width
  10730. * @param viewportHeight viewport height
  10731. * @param world world matrix
  10732. * @param view view matrix
  10733. * @param projection projection matrix
  10734. * @returns new ray
  10735. */
  10736. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10737. /**
  10738. * 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
  10739. * transformed to the given world matrix.
  10740. * @param origin The origin point
  10741. * @param end The end point
  10742. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10743. * @returns the new ray
  10744. */
  10745. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10746. /**
  10747. * Transforms a ray by a matrix
  10748. * @param ray ray to transform
  10749. * @param matrix matrix to apply
  10750. * @returns the resulting new ray
  10751. */
  10752. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10753. /**
  10754. * Transforms a ray by a matrix
  10755. * @param ray ray to transform
  10756. * @param matrix matrix to apply
  10757. * @param result ray to store result in
  10758. */
  10759. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10760. /**
  10761. * Unproject a ray from screen space to object space
  10762. * @param sourceX defines the screen space x coordinate to use
  10763. * @param sourceY defines the screen space y coordinate to use
  10764. * @param viewportWidth defines the current width of the viewport
  10765. * @param viewportHeight defines the current height of the viewport
  10766. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10767. * @param view defines the view matrix to use
  10768. * @param projection defines the projection matrix to use
  10769. */
  10770. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10771. }
  10772. /**
  10773. * Type used to define predicate used to select faces when a mesh intersection is detected
  10774. */
  10775. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10776. module "babylonjs/scene" {
  10777. interface Scene {
  10778. /** @hidden */
  10779. _tempPickingRay: Nullable<Ray>;
  10780. /** @hidden */
  10781. _cachedRayForTransform: Ray;
  10782. /** @hidden */
  10783. _pickWithRayInverseMatrix: Matrix;
  10784. /** @hidden */
  10785. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10786. /** @hidden */
  10787. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10788. /** @hidden */
  10789. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10790. }
  10791. }
  10792. }
  10793. declare module "babylonjs/sceneComponent" {
  10794. import { Scene } from "babylonjs/scene";
  10795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10796. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10797. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10798. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10799. import { Nullable } from "babylonjs/types";
  10800. import { Camera } from "babylonjs/Cameras/camera";
  10801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10802. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10803. import { AbstractScene } from "babylonjs/abstractScene";
  10804. import { Mesh } from "babylonjs/Meshes/mesh";
  10805. /**
  10806. * Groups all the scene component constants in one place to ease maintenance.
  10807. * @hidden
  10808. */
  10809. export class SceneComponentConstants {
  10810. static readonly NAME_EFFECTLAYER: string;
  10811. static readonly NAME_LAYER: string;
  10812. static readonly NAME_LENSFLARESYSTEM: string;
  10813. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10814. static readonly NAME_PARTICLESYSTEM: string;
  10815. static readonly NAME_GAMEPAD: string;
  10816. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10817. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10818. static readonly NAME_PREPASSRENDERER: string;
  10819. static readonly NAME_DEPTHRENDERER: string;
  10820. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10821. static readonly NAME_SPRITE: string;
  10822. static readonly NAME_OUTLINERENDERER: string;
  10823. static readonly NAME_PROCEDURALTEXTURE: string;
  10824. static readonly NAME_SHADOWGENERATOR: string;
  10825. static readonly NAME_OCTREE: string;
  10826. static readonly NAME_PHYSICSENGINE: string;
  10827. static readonly NAME_AUDIO: string;
  10828. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10829. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10830. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10831. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10832. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10833. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10834. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10835. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10836. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10837. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10838. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10839. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10840. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10841. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10842. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10843. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10844. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10845. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10846. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10847. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10848. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10849. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10850. static readonly STEP_AFTERRENDER_AUDIO: number;
  10851. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10852. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10853. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10854. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10855. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10856. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10857. static readonly STEP_POINTERMOVE_SPRITE: number;
  10858. static readonly STEP_POINTERDOWN_SPRITE: number;
  10859. static readonly STEP_POINTERUP_SPRITE: number;
  10860. }
  10861. /**
  10862. * This represents a scene component.
  10863. *
  10864. * This is used to decouple the dependency the scene is having on the different workloads like
  10865. * layers, post processes...
  10866. */
  10867. export interface ISceneComponent {
  10868. /**
  10869. * The name of the component. Each component must have a unique name.
  10870. */
  10871. name: string;
  10872. /**
  10873. * The scene the component belongs to.
  10874. */
  10875. scene: Scene;
  10876. /**
  10877. * Register the component to one instance of a scene.
  10878. */
  10879. register(): void;
  10880. /**
  10881. * Rebuilds the elements related to this component in case of
  10882. * context lost for instance.
  10883. */
  10884. rebuild(): void;
  10885. /**
  10886. * Disposes the component and the associated ressources.
  10887. */
  10888. dispose(): void;
  10889. }
  10890. /**
  10891. * This represents a SERIALIZABLE scene component.
  10892. *
  10893. * This extends Scene Component to add Serialization methods on top.
  10894. */
  10895. export interface ISceneSerializableComponent extends ISceneComponent {
  10896. /**
  10897. * Adds all the elements from the container to the scene
  10898. * @param container the container holding the elements
  10899. */
  10900. addFromContainer(container: AbstractScene): void;
  10901. /**
  10902. * Removes all the elements in the container from the scene
  10903. * @param container contains the elements to remove
  10904. * @param dispose if the removed element should be disposed (default: false)
  10905. */
  10906. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10907. /**
  10908. * Serializes the component data to the specified json object
  10909. * @param serializationObject The object to serialize to
  10910. */
  10911. serialize(serializationObject: any): void;
  10912. }
  10913. /**
  10914. * Strong typing of a Mesh related stage step action
  10915. */
  10916. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10917. /**
  10918. * Strong typing of a Evaluate Sub Mesh related stage step action
  10919. */
  10920. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10921. /**
  10922. * Strong typing of a Active Mesh related stage step action
  10923. */
  10924. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10925. /**
  10926. * Strong typing of a Camera related stage step action
  10927. */
  10928. export type CameraStageAction = (camera: Camera) => void;
  10929. /**
  10930. * Strong typing of a Camera Frame buffer related stage step action
  10931. */
  10932. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10933. /**
  10934. * Strong typing of a Render Target related stage step action
  10935. */
  10936. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10937. /**
  10938. * Strong typing of a RenderingGroup related stage step action
  10939. */
  10940. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10941. /**
  10942. * Strong typing of a Mesh Render related stage step action
  10943. */
  10944. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10945. /**
  10946. * Strong typing of a simple stage step action
  10947. */
  10948. export type SimpleStageAction = () => void;
  10949. /**
  10950. * Strong typing of a render target action.
  10951. */
  10952. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10953. /**
  10954. * Strong typing of a pointer move action.
  10955. */
  10956. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10957. /**
  10958. * Strong typing of a pointer up/down action.
  10959. */
  10960. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10961. /**
  10962. * Representation of a stage in the scene (Basically a list of ordered steps)
  10963. * @hidden
  10964. */
  10965. export class Stage<T extends Function> extends Array<{
  10966. index: number;
  10967. component: ISceneComponent;
  10968. action: T;
  10969. }> {
  10970. /**
  10971. * Hide ctor from the rest of the world.
  10972. * @param items The items to add.
  10973. */
  10974. private constructor();
  10975. /**
  10976. * Creates a new Stage.
  10977. * @returns A new instance of a Stage
  10978. */
  10979. static Create<T extends Function>(): Stage<T>;
  10980. /**
  10981. * Registers a step in an ordered way in the targeted stage.
  10982. * @param index Defines the position to register the step in
  10983. * @param component Defines the component attached to the step
  10984. * @param action Defines the action to launch during the step
  10985. */
  10986. registerStep(index: number, component: ISceneComponent, action: T): void;
  10987. /**
  10988. * Clears all the steps from the stage.
  10989. */
  10990. clear(): void;
  10991. }
  10992. }
  10993. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10994. import { Nullable } from "babylonjs/types";
  10995. import { Observable } from "babylonjs/Misc/observable";
  10996. import { Scene } from "babylonjs/scene";
  10997. import { Sprite } from "babylonjs/Sprites/sprite";
  10998. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10999. import { Ray } from "babylonjs/Culling/ray";
  11000. import { Camera } from "babylonjs/Cameras/camera";
  11001. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11002. import { ISceneComponent } from "babylonjs/sceneComponent";
  11003. module "babylonjs/scene" {
  11004. interface Scene {
  11005. /** @hidden */
  11006. _pointerOverSprite: Nullable<Sprite>;
  11007. /** @hidden */
  11008. _pickedDownSprite: Nullable<Sprite>;
  11009. /** @hidden */
  11010. _tempSpritePickingRay: Nullable<Ray>;
  11011. /**
  11012. * All of the sprite managers added to this scene
  11013. * @see https://doc.babylonjs.com/babylon101/sprites
  11014. */
  11015. spriteManagers: Array<ISpriteManager>;
  11016. /**
  11017. * An event triggered when sprites rendering is about to start
  11018. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11019. */
  11020. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11021. /**
  11022. * An event triggered when sprites rendering is done
  11023. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11024. */
  11025. onAfterSpritesRenderingObservable: Observable<Scene>;
  11026. /** @hidden */
  11027. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11028. /** Launch a ray to try to pick a sprite in the scene
  11029. * @param x position on screen
  11030. * @param y position on screen
  11031. * @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
  11032. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11033. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11034. * @returns a PickingInfo
  11035. */
  11036. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11037. /** Use the given ray to pick a sprite in the scene
  11038. * @param ray The ray (in world space) to use to pick meshes
  11039. * @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
  11040. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11041. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11042. * @returns a PickingInfo
  11043. */
  11044. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11045. /** @hidden */
  11046. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11047. /** Launch a ray to try to pick sprites in the scene
  11048. * @param x position on screen
  11049. * @param y position on screen
  11050. * @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
  11051. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11052. * @returns a PickingInfo array
  11053. */
  11054. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11055. /** Use the given ray to pick sprites in the scene
  11056. * @param ray The ray (in world space) to use to pick meshes
  11057. * @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
  11058. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11059. * @returns a PickingInfo array
  11060. */
  11061. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11062. /**
  11063. * Force the sprite under the pointer
  11064. * @param sprite defines the sprite to use
  11065. */
  11066. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11067. /**
  11068. * Gets the sprite under the pointer
  11069. * @returns a Sprite or null if no sprite is under the pointer
  11070. */
  11071. getPointerOverSprite(): Nullable<Sprite>;
  11072. }
  11073. }
  11074. /**
  11075. * Defines the sprite scene component responsible to manage sprites
  11076. * in a given scene.
  11077. */
  11078. export class SpriteSceneComponent implements ISceneComponent {
  11079. /**
  11080. * The component name helpfull to identify the component in the list of scene components.
  11081. */
  11082. readonly name: string;
  11083. /**
  11084. * The scene the component belongs to.
  11085. */
  11086. scene: Scene;
  11087. /** @hidden */
  11088. private _spritePredicate;
  11089. /**
  11090. * Creates a new instance of the component for the given scene
  11091. * @param scene Defines the scene to register the component in
  11092. */
  11093. constructor(scene: Scene);
  11094. /**
  11095. * Registers the component in a given scene
  11096. */
  11097. register(): void;
  11098. /**
  11099. * Rebuilds the elements related to this component in case of
  11100. * context lost for instance.
  11101. */
  11102. rebuild(): void;
  11103. /**
  11104. * Disposes the component and the associated ressources.
  11105. */
  11106. dispose(): void;
  11107. private _pickSpriteButKeepRay;
  11108. private _pointerMove;
  11109. private _pointerDown;
  11110. private _pointerUp;
  11111. }
  11112. }
  11113. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11114. /** @hidden */
  11115. export var fogFragmentDeclaration: {
  11116. name: string;
  11117. shader: string;
  11118. };
  11119. }
  11120. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11121. /** @hidden */
  11122. export var fogFragment: {
  11123. name: string;
  11124. shader: string;
  11125. };
  11126. }
  11127. declare module "babylonjs/Shaders/sprites.fragment" {
  11128. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11129. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11130. /** @hidden */
  11131. export var spritesPixelShader: {
  11132. name: string;
  11133. shader: string;
  11134. };
  11135. }
  11136. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11137. /** @hidden */
  11138. export var fogVertexDeclaration: {
  11139. name: string;
  11140. shader: string;
  11141. };
  11142. }
  11143. declare module "babylonjs/Shaders/sprites.vertex" {
  11144. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11145. /** @hidden */
  11146. export var spritesVertexShader: {
  11147. name: string;
  11148. shader: string;
  11149. };
  11150. }
  11151. declare module "babylonjs/Sprites/spriteManager" {
  11152. import { IDisposable, Scene } from "babylonjs/scene";
  11153. import { Nullable } from "babylonjs/types";
  11154. import { Observable } from "babylonjs/Misc/observable";
  11155. import { Sprite } from "babylonjs/Sprites/sprite";
  11156. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11157. import { Camera } from "babylonjs/Cameras/camera";
  11158. import { Texture } from "babylonjs/Materials/Textures/texture";
  11159. import "babylonjs/Shaders/sprites.fragment";
  11160. import "babylonjs/Shaders/sprites.vertex";
  11161. import { Ray } from "babylonjs/Culling/ray";
  11162. /**
  11163. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11164. */
  11165. export interface ISpriteManager extends IDisposable {
  11166. /**
  11167. * Gets manager's name
  11168. */
  11169. name: string;
  11170. /**
  11171. * Restricts the camera to viewing objects with the same layerMask.
  11172. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11173. */
  11174. layerMask: number;
  11175. /**
  11176. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11177. */
  11178. isPickable: boolean;
  11179. /**
  11180. * Gets the hosting scene
  11181. */
  11182. scene: Scene;
  11183. /**
  11184. * Specifies the rendering group id for this mesh (0 by default)
  11185. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11186. */
  11187. renderingGroupId: number;
  11188. /**
  11189. * Defines the list of sprites managed by the manager.
  11190. */
  11191. sprites: Array<Sprite>;
  11192. /**
  11193. * Gets or sets the spritesheet texture
  11194. */
  11195. texture: Texture;
  11196. /** Defines the default width of a cell in the spritesheet */
  11197. cellWidth: number;
  11198. /** Defines the default height of a cell in the spritesheet */
  11199. cellHeight: number;
  11200. /**
  11201. * Tests the intersection of a sprite with a specific ray.
  11202. * @param ray The ray we are sending to test the collision
  11203. * @param camera The camera space we are sending rays in
  11204. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11205. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11206. * @returns picking info or null.
  11207. */
  11208. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11209. /**
  11210. * Intersects the sprites with a ray
  11211. * @param ray defines the ray to intersect with
  11212. * @param camera defines the current active camera
  11213. * @param predicate defines a predicate used to select candidate sprites
  11214. * @returns null if no hit or a PickingInfo array
  11215. */
  11216. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11217. /**
  11218. * Renders the list of sprites on screen.
  11219. */
  11220. render(): void;
  11221. }
  11222. /**
  11223. * Class used to manage multiple sprites on the same spritesheet
  11224. * @see https://doc.babylonjs.com/babylon101/sprites
  11225. */
  11226. export class SpriteManager implements ISpriteManager {
  11227. /** defines the manager's name */
  11228. name: string;
  11229. /** Define the Url to load snippets */
  11230. static SnippetUrl: string;
  11231. /** Snippet ID if the manager was created from the snippet server */
  11232. snippetId: string;
  11233. /** Gets the list of sprites */
  11234. sprites: Sprite[];
  11235. /** Gets or sets the rendering group id (0 by default) */
  11236. renderingGroupId: number;
  11237. /** Gets or sets camera layer mask */
  11238. layerMask: number;
  11239. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11240. fogEnabled: boolean;
  11241. /** Gets or sets a boolean indicating if the sprites are pickable */
  11242. isPickable: boolean;
  11243. /** Defines the default width of a cell in the spritesheet */
  11244. cellWidth: number;
  11245. /** Defines the default height of a cell in the spritesheet */
  11246. cellHeight: number;
  11247. /** Associative array from JSON sprite data file */
  11248. private _cellData;
  11249. /** Array of sprite names from JSON sprite data file */
  11250. private _spriteMap;
  11251. /** True when packed cell data from JSON file is ready*/
  11252. private _packedAndReady;
  11253. private _textureContent;
  11254. private _useInstancing;
  11255. /**
  11256. * An event triggered when the manager is disposed.
  11257. */
  11258. onDisposeObservable: Observable<SpriteManager>;
  11259. private _onDisposeObserver;
  11260. /**
  11261. * Callback called when the manager is disposed
  11262. */
  11263. set onDispose(callback: () => void);
  11264. private _capacity;
  11265. private _fromPacked;
  11266. private _spriteTexture;
  11267. private _epsilon;
  11268. private _scene;
  11269. private _vertexData;
  11270. private _buffer;
  11271. private _vertexBuffers;
  11272. private _spriteBuffer;
  11273. private _indexBuffer;
  11274. private _effectBase;
  11275. private _effectFog;
  11276. private _vertexBufferSize;
  11277. /**
  11278. * Gets or sets the unique id of the sprite
  11279. */
  11280. uniqueId: number;
  11281. /**
  11282. * Gets the array of sprites
  11283. */
  11284. get children(): Sprite[];
  11285. /**
  11286. * Gets the hosting scene
  11287. */
  11288. get scene(): Scene;
  11289. /**
  11290. * Gets the capacity of the manager
  11291. */
  11292. get capacity(): number;
  11293. /**
  11294. * Gets or sets the spritesheet texture
  11295. */
  11296. get texture(): Texture;
  11297. set texture(value: Texture);
  11298. private _blendMode;
  11299. /**
  11300. * Blend mode use to render the particle, it can be any of
  11301. * the static Constants.ALPHA_x properties provided in this class.
  11302. * Default value is Constants.ALPHA_COMBINE
  11303. */
  11304. get blendMode(): number;
  11305. set blendMode(blendMode: number);
  11306. /** Disables writing to the depth buffer when rendering the sprites.
  11307. * It can be handy to disable depth writing when using textures without alpha channel
  11308. * and setting some specific blend modes.
  11309. */
  11310. disableDepthWrite: boolean;
  11311. /**
  11312. * Creates a new sprite manager
  11313. * @param name defines the manager's name
  11314. * @param imgUrl defines the sprite sheet url
  11315. * @param capacity defines the maximum allowed number of sprites
  11316. * @param cellSize defines the size of a sprite cell
  11317. * @param scene defines the hosting scene
  11318. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11319. * @param samplingMode defines the smapling mode to use with spritesheet
  11320. * @param fromPacked set to false; do not alter
  11321. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11322. */
  11323. constructor(
  11324. /** defines the manager's name */
  11325. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11326. /**
  11327. * Returns the string "SpriteManager"
  11328. * @returns "SpriteManager"
  11329. */
  11330. getClassName(): string;
  11331. private _makePacked;
  11332. private _appendSpriteVertex;
  11333. private _checkTextureAlpha;
  11334. /**
  11335. * Intersects the sprites with a ray
  11336. * @param ray defines the ray to intersect with
  11337. * @param camera defines the current active camera
  11338. * @param predicate defines a predicate used to select candidate sprites
  11339. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11340. * @returns null if no hit or a PickingInfo
  11341. */
  11342. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11343. /**
  11344. * Intersects the sprites with a ray
  11345. * @param ray defines the ray to intersect with
  11346. * @param camera defines the current active camera
  11347. * @param predicate defines a predicate used to select candidate sprites
  11348. * @returns null if no hit or a PickingInfo array
  11349. */
  11350. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11351. /**
  11352. * Render all child sprites
  11353. */
  11354. render(): void;
  11355. /**
  11356. * Release associated resources
  11357. */
  11358. dispose(): void;
  11359. /**
  11360. * Serializes the sprite manager to a JSON object
  11361. * @param serializeTexture defines if the texture must be serialized as well
  11362. * @returns the JSON object
  11363. */
  11364. serialize(serializeTexture?: boolean): any;
  11365. /**
  11366. * Parses a JSON object to create a new sprite manager.
  11367. * @param parsedManager The JSON object to parse
  11368. * @param scene The scene to create the sprite managerin
  11369. * @param rootUrl The root url to use to load external dependencies like texture
  11370. * @returns the new sprite manager
  11371. */
  11372. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11373. /**
  11374. * Creates a sprite manager from a snippet saved in a remote file
  11375. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11376. * @param url defines the url to load from
  11377. * @param scene defines the hosting scene
  11378. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11379. * @returns a promise that will resolve to the new sprite manager
  11380. */
  11381. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11382. /**
  11383. * Creates a sprite manager from a snippet saved by the sprite editor
  11384. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11385. * @param scene defines the hosting scene
  11386. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11387. * @returns a promise that will resolve to the new sprite manager
  11388. */
  11389. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11390. }
  11391. }
  11392. declare module "babylonjs/Misc/gradients" {
  11393. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11394. /** Interface used by value gradients (color, factor, ...) */
  11395. export interface IValueGradient {
  11396. /**
  11397. * Gets or sets the gradient value (between 0 and 1)
  11398. */
  11399. gradient: number;
  11400. }
  11401. /** Class used to store color4 gradient */
  11402. export class ColorGradient implements IValueGradient {
  11403. /**
  11404. * Gets or sets the gradient value (between 0 and 1)
  11405. */
  11406. gradient: number;
  11407. /**
  11408. * Gets or sets first associated color
  11409. */
  11410. color1: Color4;
  11411. /**
  11412. * Gets or sets second associated color
  11413. */
  11414. color2?: Color4 | undefined;
  11415. /**
  11416. * Creates a new color4 gradient
  11417. * @param gradient gets or sets the gradient value (between 0 and 1)
  11418. * @param color1 gets or sets first associated color
  11419. * @param color2 gets or sets first second color
  11420. */
  11421. constructor(
  11422. /**
  11423. * Gets or sets the gradient value (between 0 and 1)
  11424. */
  11425. gradient: number,
  11426. /**
  11427. * Gets or sets first associated color
  11428. */
  11429. color1: Color4,
  11430. /**
  11431. * Gets or sets second associated color
  11432. */
  11433. color2?: Color4 | undefined);
  11434. /**
  11435. * Will get a color picked randomly between color1 and color2.
  11436. * If color2 is undefined then color1 will be used
  11437. * @param result defines the target Color4 to store the result in
  11438. */
  11439. getColorToRef(result: Color4): void;
  11440. }
  11441. /** Class used to store color 3 gradient */
  11442. export class Color3Gradient implements IValueGradient {
  11443. /**
  11444. * Gets or sets the gradient value (between 0 and 1)
  11445. */
  11446. gradient: number;
  11447. /**
  11448. * Gets or sets the associated color
  11449. */
  11450. color: Color3;
  11451. /**
  11452. * Creates a new color3 gradient
  11453. * @param gradient gets or sets the gradient value (between 0 and 1)
  11454. * @param color gets or sets associated color
  11455. */
  11456. constructor(
  11457. /**
  11458. * Gets or sets the gradient value (between 0 and 1)
  11459. */
  11460. gradient: number,
  11461. /**
  11462. * Gets or sets the associated color
  11463. */
  11464. color: Color3);
  11465. }
  11466. /** Class used to store factor gradient */
  11467. export class FactorGradient implements IValueGradient {
  11468. /**
  11469. * Gets or sets the gradient value (between 0 and 1)
  11470. */
  11471. gradient: number;
  11472. /**
  11473. * Gets or sets first associated factor
  11474. */
  11475. factor1: number;
  11476. /**
  11477. * Gets or sets second associated factor
  11478. */
  11479. factor2?: number | undefined;
  11480. /**
  11481. * Creates a new factor gradient
  11482. * @param gradient gets or sets the gradient value (between 0 and 1)
  11483. * @param factor1 gets or sets first associated factor
  11484. * @param factor2 gets or sets second associated factor
  11485. */
  11486. constructor(
  11487. /**
  11488. * Gets or sets the gradient value (between 0 and 1)
  11489. */
  11490. gradient: number,
  11491. /**
  11492. * Gets or sets first associated factor
  11493. */
  11494. factor1: number,
  11495. /**
  11496. * Gets or sets second associated factor
  11497. */
  11498. factor2?: number | undefined);
  11499. /**
  11500. * Will get a number picked randomly between factor1 and factor2.
  11501. * If factor2 is undefined then factor1 will be used
  11502. * @returns the picked number
  11503. */
  11504. getFactor(): number;
  11505. }
  11506. /**
  11507. * Helper used to simplify some generic gradient tasks
  11508. */
  11509. export class GradientHelper {
  11510. /**
  11511. * Gets the current gradient from an array of IValueGradient
  11512. * @param ratio defines the current ratio to get
  11513. * @param gradients defines the array of IValueGradient
  11514. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11515. */
  11516. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11517. }
  11518. }
  11519. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11520. import { Nullable } from "babylonjs/types";
  11521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11522. import { Scene } from "babylonjs/scene";
  11523. module "babylonjs/Engines/thinEngine" {
  11524. interface ThinEngine {
  11525. /**
  11526. * Creates a raw texture
  11527. * @param data defines the data to store in the texture
  11528. * @param width defines the width of the texture
  11529. * @param height defines the height of the texture
  11530. * @param format defines the format of the data
  11531. * @param generateMipMaps defines if the engine should generate the mip levels
  11532. * @param invertY defines if data must be stored with Y axis inverted
  11533. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11534. * @param compression defines the compression used (null by default)
  11535. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11536. * @returns the raw texture inside an InternalTexture
  11537. */
  11538. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11539. /**
  11540. * Update a raw texture
  11541. * @param texture defines the texture to update
  11542. * @param data defines the data to store in the texture
  11543. * @param format defines the format of the data
  11544. * @param invertY defines if data must be stored with Y axis inverted
  11545. */
  11546. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11547. /**
  11548. * Update a raw texture
  11549. * @param texture defines the texture to update
  11550. * @param data defines the data to store in the texture
  11551. * @param format defines the format of the data
  11552. * @param invertY defines if data must be stored with Y axis inverted
  11553. * @param compression defines the compression used (null by default)
  11554. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11555. */
  11556. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11557. /**
  11558. * Creates a new raw cube texture
  11559. * @param data defines the array of data to use to create each face
  11560. * @param size defines the size of the textures
  11561. * @param format defines the format of the data
  11562. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11563. * @param generateMipMaps defines if the engine should generate the mip levels
  11564. * @param invertY defines if data must be stored with Y axis inverted
  11565. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11566. * @param compression defines the compression used (null by default)
  11567. * @returns the cube texture as an InternalTexture
  11568. */
  11569. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11570. /**
  11571. * Update a raw cube texture
  11572. * @param texture defines the texture to udpdate
  11573. * @param data defines the data to store
  11574. * @param format defines the data format
  11575. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11576. * @param invertY defines if data must be stored with Y axis inverted
  11577. */
  11578. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11579. /**
  11580. * Update a raw cube texture
  11581. * @param texture defines the texture to udpdate
  11582. * @param data defines the data to store
  11583. * @param format defines the data format
  11584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11585. * @param invertY defines if data must be stored with Y axis inverted
  11586. * @param compression defines the compression used (null by default)
  11587. */
  11588. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11589. /**
  11590. * Update a raw cube texture
  11591. * @param texture defines the texture to udpdate
  11592. * @param data defines the data to store
  11593. * @param format defines the data format
  11594. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11595. * @param invertY defines if data must be stored with Y axis inverted
  11596. * @param compression defines the compression used (null by default)
  11597. * @param level defines which level of the texture to update
  11598. */
  11599. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11600. /**
  11601. * Creates a new raw cube texture from a specified url
  11602. * @param url defines the url where the data is located
  11603. * @param scene defines the current scene
  11604. * @param size defines the size of the textures
  11605. * @param format defines the format of the data
  11606. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11607. * @param noMipmap defines if the engine should avoid generating the mip levels
  11608. * @param callback defines a callback used to extract texture data from loaded data
  11609. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11610. * @param onLoad defines a callback called when texture is loaded
  11611. * @param onError defines a callback called if there is an error
  11612. * @returns the cube texture as an InternalTexture
  11613. */
  11614. 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;
  11615. /**
  11616. * Creates a new raw cube texture from a specified url
  11617. * @param url defines the url where the data is located
  11618. * @param scene defines the current scene
  11619. * @param size defines the size of the textures
  11620. * @param format defines the format of the data
  11621. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11622. * @param noMipmap defines if the engine should avoid generating the mip levels
  11623. * @param callback defines a callback used to extract texture data from loaded data
  11624. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11625. * @param onLoad defines a callback called when texture is loaded
  11626. * @param onError defines a callback called if there is an error
  11627. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11628. * @param invertY defines if data must be stored with Y axis inverted
  11629. * @returns the cube texture as an InternalTexture
  11630. */
  11631. 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;
  11632. /**
  11633. * Creates a new raw 3D texture
  11634. * @param data defines the data used to create the texture
  11635. * @param width defines the width of the texture
  11636. * @param height defines the height of the texture
  11637. * @param depth defines the depth of the texture
  11638. * @param format defines the format of the texture
  11639. * @param generateMipMaps defines if the engine must generate mip levels
  11640. * @param invertY defines if data must be stored with Y axis inverted
  11641. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11642. * @param compression defines the compressed used (can be null)
  11643. * @param textureType defines the compressed used (can be null)
  11644. * @returns a new raw 3D texture (stored in an InternalTexture)
  11645. */
  11646. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11647. /**
  11648. * Update a raw 3D texture
  11649. * @param texture defines the texture to update
  11650. * @param data defines the data to store
  11651. * @param format defines the data format
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. */
  11654. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11655. /**
  11656. * Update a raw 3D texture
  11657. * @param texture defines the texture to update
  11658. * @param data defines the data to store
  11659. * @param format defines the data format
  11660. * @param invertY defines if data must be stored with Y axis inverted
  11661. * @param compression defines the used compression (can be null)
  11662. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11663. */
  11664. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11665. /**
  11666. * Creates a new raw 2D array texture
  11667. * @param data defines the data used to create the texture
  11668. * @param width defines the width of the texture
  11669. * @param height defines the height of the texture
  11670. * @param depth defines the number of layers of the texture
  11671. * @param format defines the format of the texture
  11672. * @param generateMipMaps defines if the engine must generate mip levels
  11673. * @param invertY defines if data must be stored with Y axis inverted
  11674. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11675. * @param compression defines the compressed used (can be null)
  11676. * @param textureType defines the compressed used (can be null)
  11677. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11678. */
  11679. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11680. /**
  11681. * Update a raw 2D array texture
  11682. * @param texture defines the texture to update
  11683. * @param data defines the data to store
  11684. * @param format defines the data format
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. */
  11687. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11688. /**
  11689. * Update a raw 2D array texture
  11690. * @param texture defines the texture to update
  11691. * @param data defines the data to store
  11692. * @param format defines the data format
  11693. * @param invertY defines if data must be stored with Y axis inverted
  11694. * @param compression defines the used compression (can be null)
  11695. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11696. */
  11697. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11698. }
  11699. }
  11700. }
  11701. declare module "babylonjs/Materials/Textures/rawTexture" {
  11702. import { Texture } from "babylonjs/Materials/Textures/texture";
  11703. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11704. import { Nullable } from "babylonjs/types";
  11705. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11706. import { Scene } from "babylonjs/scene";
  11707. /**
  11708. * Raw texture can help creating a texture directly from an array of data.
  11709. * This can be super useful if you either get the data from an uncompressed source or
  11710. * if you wish to create your texture pixel by pixel.
  11711. */
  11712. export class RawTexture extends Texture {
  11713. /**
  11714. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11715. */
  11716. format: number;
  11717. /**
  11718. * Instantiates a new RawTexture.
  11719. * Raw texture can help creating a texture directly from an array of data.
  11720. * This can be super useful if you either get the data from an uncompressed source or
  11721. * if you wish to create your texture pixel by pixel.
  11722. * @param data define the array of data to use to create the texture
  11723. * @param width define the width of the texture
  11724. * @param height define the height of the texture
  11725. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11726. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11727. * @param generateMipMaps define whether mip maps should be generated or not
  11728. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11729. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11730. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11731. */
  11732. constructor(data: ArrayBufferView, width: number, height: number,
  11733. /**
  11734. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11735. */
  11736. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11737. /**
  11738. * Updates the texture underlying data.
  11739. * @param data Define the new data of the texture
  11740. */
  11741. update(data: ArrayBufferView): void;
  11742. /**
  11743. * Creates a luminance texture from some data.
  11744. * @param data Define the texture data
  11745. * @param width Define the width of the texture
  11746. * @param height Define the height of the texture
  11747. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11751. * @returns the luminance texture
  11752. */
  11753. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11754. /**
  11755. * Creates a luminance alpha texture from some data.
  11756. * @param data Define the texture data
  11757. * @param width Define the width of the texture
  11758. * @param height Define the height of the texture
  11759. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11760. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11761. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11762. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11763. * @returns the luminance alpha texture
  11764. */
  11765. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11766. /**
  11767. * Creates an alpha texture from some data.
  11768. * @param data Define the texture data
  11769. * @param width Define the width of the texture
  11770. * @param height Define the height of the texture
  11771. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11772. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11773. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11774. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11775. * @returns the alpha texture
  11776. */
  11777. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11778. /**
  11779. * Creates a RGB texture from some data.
  11780. * @param data Define the texture data
  11781. * @param width Define the width of the texture
  11782. * @param height Define the height of the texture
  11783. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11784. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11787. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11788. * @returns the RGB alpha texture
  11789. */
  11790. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11791. /**
  11792. * Creates a RGBA texture from some data.
  11793. * @param data Define the texture data
  11794. * @param width Define the width of the texture
  11795. * @param height Define the height of the texture
  11796. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11797. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11798. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11799. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11800. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11801. * @returns the RGBA texture
  11802. */
  11803. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11804. /**
  11805. * Creates a R texture from some data.
  11806. * @param data Define the texture data
  11807. * @param width Define the width of the texture
  11808. * @param height Define the height of the texture
  11809. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11810. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11811. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11812. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11813. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11814. * @returns the R texture
  11815. */
  11816. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11817. }
  11818. }
  11819. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11820. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11821. import { IndicesArray, DataArray } from "babylonjs/types";
  11822. module "babylonjs/Engines/thinEngine" {
  11823. interface ThinEngine {
  11824. /**
  11825. * Update a dynamic index buffer
  11826. * @param indexBuffer defines the target index buffer
  11827. * @param indices defines the data to update
  11828. * @param offset defines the offset in the target index buffer where update should start
  11829. */
  11830. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11831. /**
  11832. * Updates a dynamic vertex buffer.
  11833. * @param vertexBuffer the vertex buffer to update
  11834. * @param data the data used to update the vertex buffer
  11835. * @param byteOffset the byte offset of the data
  11836. * @param byteLength the byte length of the data
  11837. */
  11838. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11839. }
  11840. }
  11841. }
  11842. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11843. import { Scene } from "babylonjs/scene";
  11844. import { ISceneComponent } from "babylonjs/sceneComponent";
  11845. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11846. module "babylonjs/abstractScene" {
  11847. interface AbstractScene {
  11848. /**
  11849. * The list of procedural textures added to the scene
  11850. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11851. */
  11852. proceduralTextures: Array<ProceduralTexture>;
  11853. }
  11854. }
  11855. /**
  11856. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11857. * in a given scene.
  11858. */
  11859. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11860. /**
  11861. * The component name helpfull to identify the component in the list of scene components.
  11862. */
  11863. readonly name: string;
  11864. /**
  11865. * The scene the component belongs to.
  11866. */
  11867. scene: Scene;
  11868. /**
  11869. * Creates a new instance of the component for the given scene
  11870. * @param scene Defines the scene to register the component in
  11871. */
  11872. constructor(scene: Scene);
  11873. /**
  11874. * Registers the component in a given scene
  11875. */
  11876. register(): void;
  11877. /**
  11878. * Rebuilds the elements related to this component in case of
  11879. * context lost for instance.
  11880. */
  11881. rebuild(): void;
  11882. /**
  11883. * Disposes the component and the associated ressources.
  11884. */
  11885. dispose(): void;
  11886. private _beforeClear;
  11887. }
  11888. }
  11889. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11891. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11892. module "babylonjs/Engines/thinEngine" {
  11893. interface ThinEngine {
  11894. /**
  11895. * Creates a new render target cube texture
  11896. * @param size defines the size of the texture
  11897. * @param options defines the options used to create the texture
  11898. * @returns a new render target cube texture stored in an InternalTexture
  11899. */
  11900. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11901. }
  11902. }
  11903. }
  11904. declare module "babylonjs/Shaders/procedural.vertex" {
  11905. /** @hidden */
  11906. export var proceduralVertexShader: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11912. import { Observable } from "babylonjs/Misc/observable";
  11913. import { Nullable } from "babylonjs/types";
  11914. import { Scene } from "babylonjs/scene";
  11915. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11916. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11917. import { Effect } from "babylonjs/Materials/effect";
  11918. import { Texture } from "babylonjs/Materials/Textures/texture";
  11919. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11920. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11921. import "babylonjs/Shaders/procedural.vertex";
  11922. /**
  11923. * 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.
  11924. * This is the base class of any Procedural texture and contains most of the shareable code.
  11925. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11926. */
  11927. export class ProceduralTexture extends Texture {
  11928. /**
  11929. * Define if the texture is enabled or not (disabled texture will not render)
  11930. */
  11931. isEnabled: boolean;
  11932. /**
  11933. * Define if the texture must be cleared before rendering (default is true)
  11934. */
  11935. autoClear: boolean;
  11936. /**
  11937. * Callback called when the texture is generated
  11938. */
  11939. onGenerated: () => void;
  11940. /**
  11941. * Event raised when the texture is generated
  11942. */
  11943. onGeneratedObservable: Observable<ProceduralTexture>;
  11944. /** @hidden */
  11945. _generateMipMaps: boolean;
  11946. /** @hidden **/
  11947. _effect: Effect;
  11948. /** @hidden */
  11949. _textures: {
  11950. [key: string]: Texture;
  11951. };
  11952. /** @hidden */
  11953. protected _fallbackTexture: Nullable<Texture>;
  11954. private _size;
  11955. private _currentRefreshId;
  11956. private _frameId;
  11957. private _refreshRate;
  11958. private _vertexBuffers;
  11959. private _indexBuffer;
  11960. private _uniforms;
  11961. private _samplers;
  11962. private _fragment;
  11963. private _floats;
  11964. private _ints;
  11965. private _floatsArrays;
  11966. private _colors3;
  11967. private _colors4;
  11968. private _vectors2;
  11969. private _vectors3;
  11970. private _matrices;
  11971. private _fallbackTextureUsed;
  11972. private _fullEngine;
  11973. private _cachedDefines;
  11974. private _contentUpdateId;
  11975. private _contentData;
  11976. /**
  11977. * Instantiates a new procedural texture.
  11978. * 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.
  11979. * This is the base class of any Procedural texture and contains most of the shareable code.
  11980. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11981. * @param name Define the name of the texture
  11982. * @param size Define the size of the texture to create
  11983. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11984. * @param scene Define the scene the texture belongs to
  11985. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11986. * @param generateMipMaps Define if the texture should creates mip maps or not
  11987. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11988. */
  11989. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11990. /**
  11991. * The effect that is created when initializing the post process.
  11992. * @returns The created effect corresponding the the postprocess.
  11993. */
  11994. getEffect(): Effect;
  11995. /**
  11996. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11997. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11998. */
  11999. getContent(): Nullable<ArrayBufferView>;
  12000. private _createIndexBuffer;
  12001. /** @hidden */
  12002. _rebuild(): void;
  12003. /**
  12004. * Resets the texture in order to recreate its associated resources.
  12005. * This can be called in case of context loss
  12006. */
  12007. reset(): void;
  12008. protected _getDefines(): string;
  12009. /**
  12010. * Is the texture ready to be used ? (rendered at least once)
  12011. * @returns true if ready, otherwise, false.
  12012. */
  12013. isReady(): boolean;
  12014. /**
  12015. * Resets the refresh counter of the texture and start bak from scratch.
  12016. * Could be useful to regenerate the texture if it is setup to render only once.
  12017. */
  12018. resetRefreshCounter(): void;
  12019. /**
  12020. * Set the fragment shader to use in order to render the texture.
  12021. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12022. */
  12023. setFragment(fragment: any): void;
  12024. /**
  12025. * Define the refresh rate of the texture or the rendering frequency.
  12026. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12027. */
  12028. get refreshRate(): number;
  12029. set refreshRate(value: number);
  12030. /** @hidden */
  12031. _shouldRender(): boolean;
  12032. /**
  12033. * Get the size the texture is rendering at.
  12034. * @returns the size (texture is always squared)
  12035. */
  12036. getRenderSize(): number;
  12037. /**
  12038. * Resize the texture to new value.
  12039. * @param size Define the new size the texture should have
  12040. * @param generateMipMaps Define whether the new texture should create mip maps
  12041. */
  12042. resize(size: number, generateMipMaps: boolean): void;
  12043. private _checkUniform;
  12044. /**
  12045. * Set a texture in the shader program used to render.
  12046. * @param name Define the name of the uniform samplers as defined in the shader
  12047. * @param texture Define the texture to bind to this sampler
  12048. * @return the texture itself allowing "fluent" like uniform updates
  12049. */
  12050. setTexture(name: string, texture: Texture): ProceduralTexture;
  12051. /**
  12052. * Set a float in the shader.
  12053. * @param name Define the name of the uniform as defined in the shader
  12054. * @param value Define the value to give to the uniform
  12055. * @return the texture itself allowing "fluent" like uniform updates
  12056. */
  12057. setFloat(name: string, value: number): ProceduralTexture;
  12058. /**
  12059. * Set a int in the shader.
  12060. * @param name Define the name of the uniform as defined in the shader
  12061. * @param value Define the value to give to the uniform
  12062. * @return the texture itself allowing "fluent" like uniform updates
  12063. */
  12064. setInt(name: string, value: number): ProceduralTexture;
  12065. /**
  12066. * Set an array of floats in the shader.
  12067. * @param name Define the name of the uniform as defined in the shader
  12068. * @param value Define the value to give to the uniform
  12069. * @return the texture itself allowing "fluent" like uniform updates
  12070. */
  12071. setFloats(name: string, value: number[]): ProceduralTexture;
  12072. /**
  12073. * Set a vec3 in the shader from a Color3.
  12074. * @param name Define the name of the uniform as defined in the shader
  12075. * @param value Define the value to give to the uniform
  12076. * @return the texture itself allowing "fluent" like uniform updates
  12077. */
  12078. setColor3(name: string, value: Color3): ProceduralTexture;
  12079. /**
  12080. * Set a vec4 in the shader from a Color4.
  12081. * @param name Define the name of the uniform as defined in the shader
  12082. * @param value Define the value to give to the uniform
  12083. * @return the texture itself allowing "fluent" like uniform updates
  12084. */
  12085. setColor4(name: string, value: Color4): ProceduralTexture;
  12086. /**
  12087. * Set a vec2 in the shader from a Vector2.
  12088. * @param name Define the name of the uniform as defined in the shader
  12089. * @param value Define the value to give to the uniform
  12090. * @return the texture itself allowing "fluent" like uniform updates
  12091. */
  12092. setVector2(name: string, value: Vector2): ProceduralTexture;
  12093. /**
  12094. * Set a vec3 in the shader from a Vector3.
  12095. * @param name Define the name of the uniform as defined in the shader
  12096. * @param value Define the value to give to the uniform
  12097. * @return the texture itself allowing "fluent" like uniform updates
  12098. */
  12099. setVector3(name: string, value: Vector3): ProceduralTexture;
  12100. /**
  12101. * Set a mat4 in the shader from a MAtrix.
  12102. * @param name Define the name of the uniform as defined in the shader
  12103. * @param value Define the value to give to the uniform
  12104. * @return the texture itself allowing "fluent" like uniform updates
  12105. */
  12106. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12107. /**
  12108. * Render the texture to its associated render target.
  12109. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12110. */
  12111. render(useCameraPostProcess?: boolean): void;
  12112. /**
  12113. * Clone the texture.
  12114. * @returns the cloned texture
  12115. */
  12116. clone(): ProceduralTexture;
  12117. /**
  12118. * Dispose the texture and release its asoociated resources.
  12119. */
  12120. dispose(): void;
  12121. }
  12122. }
  12123. declare module "babylonjs/Particles/baseParticleSystem" {
  12124. import { Nullable } from "babylonjs/types";
  12125. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12127. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12128. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12129. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12131. import { Color4 } from "babylonjs/Maths/math.color";
  12132. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12133. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12134. import { Animation } from "babylonjs/Animations/animation";
  12135. import { Scene } from "babylonjs/scene";
  12136. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12137. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12138. /**
  12139. * This represents the base class for particle system in Babylon.
  12140. * 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.
  12141. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12142. * @example https://doc.babylonjs.com/babylon101/particles
  12143. */
  12144. export class BaseParticleSystem {
  12145. /**
  12146. * Source color is added to the destination color without alpha affecting the result
  12147. */
  12148. static BLENDMODE_ONEONE: number;
  12149. /**
  12150. * Blend current color and particle color using particle’s alpha
  12151. */
  12152. static BLENDMODE_STANDARD: number;
  12153. /**
  12154. * Add current color and particle color multiplied by particle’s alpha
  12155. */
  12156. static BLENDMODE_ADD: number;
  12157. /**
  12158. * Multiply current color with particle color
  12159. */
  12160. static BLENDMODE_MULTIPLY: number;
  12161. /**
  12162. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12163. */
  12164. static BLENDMODE_MULTIPLYADD: number;
  12165. /**
  12166. * List of animations used by the particle system.
  12167. */
  12168. animations: Animation[];
  12169. /**
  12170. * Gets or sets the unique id of the particle system
  12171. */
  12172. uniqueId: number;
  12173. /**
  12174. * The id of the Particle system.
  12175. */
  12176. id: string;
  12177. /**
  12178. * The friendly name of the Particle system.
  12179. */
  12180. name: string;
  12181. /**
  12182. * Snippet ID if the particle system was created from the snippet server
  12183. */
  12184. snippetId: string;
  12185. /**
  12186. * The rendering group used by the Particle system to chose when to render.
  12187. */
  12188. renderingGroupId: number;
  12189. /**
  12190. * The emitter represents the Mesh or position we are attaching the particle system to.
  12191. */
  12192. emitter: Nullable<AbstractMesh | Vector3>;
  12193. /**
  12194. * The maximum number of particles to emit per frame
  12195. */
  12196. emitRate: number;
  12197. /**
  12198. * If you want to launch only a few particles at once, that can be done, as well.
  12199. */
  12200. manualEmitCount: number;
  12201. /**
  12202. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12203. */
  12204. updateSpeed: number;
  12205. /**
  12206. * The amount of time the particle system is running (depends of the overall update speed).
  12207. */
  12208. targetStopDuration: number;
  12209. /**
  12210. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12211. */
  12212. disposeOnStop: boolean;
  12213. /**
  12214. * Minimum power of emitting particles.
  12215. */
  12216. minEmitPower: number;
  12217. /**
  12218. * Maximum power of emitting particles.
  12219. */
  12220. maxEmitPower: number;
  12221. /**
  12222. * Minimum life time of emitting particles.
  12223. */
  12224. minLifeTime: number;
  12225. /**
  12226. * Maximum life time of emitting particles.
  12227. */
  12228. maxLifeTime: number;
  12229. /**
  12230. * Minimum Size of emitting particles.
  12231. */
  12232. minSize: number;
  12233. /**
  12234. * Maximum Size of emitting particles.
  12235. */
  12236. maxSize: number;
  12237. /**
  12238. * Minimum scale of emitting particles on X axis.
  12239. */
  12240. minScaleX: number;
  12241. /**
  12242. * Maximum scale of emitting particles on X axis.
  12243. */
  12244. maxScaleX: number;
  12245. /**
  12246. * Minimum scale of emitting particles on Y axis.
  12247. */
  12248. minScaleY: number;
  12249. /**
  12250. * Maximum scale of emitting particles on Y axis.
  12251. */
  12252. maxScaleY: number;
  12253. /**
  12254. * Gets or sets the minimal initial rotation in radians.
  12255. */
  12256. minInitialRotation: number;
  12257. /**
  12258. * Gets or sets the maximal initial rotation in radians.
  12259. */
  12260. maxInitialRotation: number;
  12261. /**
  12262. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12263. */
  12264. minAngularSpeed: number;
  12265. /**
  12266. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12267. */
  12268. maxAngularSpeed: number;
  12269. /**
  12270. * The texture used to render each particle. (this can be a spritesheet)
  12271. */
  12272. particleTexture: Nullable<BaseTexture>;
  12273. /**
  12274. * The layer mask we are rendering the particles through.
  12275. */
  12276. layerMask: number;
  12277. /**
  12278. * This can help using your own shader to render the particle system.
  12279. * The according effect will be created
  12280. */
  12281. customShader: any;
  12282. /**
  12283. * By default particle system starts as soon as they are created. This prevents the
  12284. * automatic start to happen and let you decide when to start emitting particles.
  12285. */
  12286. preventAutoStart: boolean;
  12287. private _noiseTexture;
  12288. /**
  12289. * Gets or sets a texture used to add random noise to particle positions
  12290. */
  12291. get noiseTexture(): Nullable<ProceduralTexture>;
  12292. set noiseTexture(value: Nullable<ProceduralTexture>);
  12293. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12294. noiseStrength: Vector3;
  12295. /**
  12296. * Callback triggered when the particle animation is ending.
  12297. */
  12298. onAnimationEnd: Nullable<() => void>;
  12299. /**
  12300. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12301. */
  12302. blendMode: number;
  12303. /**
  12304. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12305. * to override the particles.
  12306. */
  12307. forceDepthWrite: boolean;
  12308. /** 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 */
  12309. preWarmCycles: number;
  12310. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12311. preWarmStepOffset: number;
  12312. /**
  12313. * 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)
  12314. */
  12315. spriteCellChangeSpeed: number;
  12316. /**
  12317. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12318. */
  12319. startSpriteCellID: number;
  12320. /**
  12321. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12322. */
  12323. endSpriteCellID: number;
  12324. /**
  12325. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12326. */
  12327. spriteCellWidth: number;
  12328. /**
  12329. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12330. */
  12331. spriteCellHeight: number;
  12332. /**
  12333. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12334. */
  12335. spriteRandomStartCell: boolean;
  12336. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12337. translationPivot: Vector2;
  12338. /** @hidden */
  12339. protected _isAnimationSheetEnabled: boolean;
  12340. /**
  12341. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12342. */
  12343. beginAnimationOnStart: boolean;
  12344. /**
  12345. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12346. */
  12347. beginAnimationFrom: number;
  12348. /**
  12349. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12350. */
  12351. beginAnimationTo: number;
  12352. /**
  12353. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12354. */
  12355. beginAnimationLoop: boolean;
  12356. /**
  12357. * Gets or sets a world offset applied to all particles
  12358. */
  12359. worldOffset: Vector3;
  12360. /**
  12361. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12362. */
  12363. get isAnimationSheetEnabled(): boolean;
  12364. set isAnimationSheetEnabled(value: boolean);
  12365. /**
  12366. * Get hosting scene
  12367. * @returns the scene
  12368. */
  12369. getScene(): Nullable<Scene>;
  12370. /**
  12371. * You can use gravity if you want to give an orientation to your particles.
  12372. */
  12373. gravity: Vector3;
  12374. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12375. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12376. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12377. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12378. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12379. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12380. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12381. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12382. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12383. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12384. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12385. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12386. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12387. /**
  12388. * Defines the delay in milliseconds before starting the system (0 by default)
  12389. */
  12390. startDelay: number;
  12391. /**
  12392. * Gets the current list of drag gradients.
  12393. * You must use addDragGradient and removeDragGradient to udpate this list
  12394. * @returns the list of drag gradients
  12395. */
  12396. getDragGradients(): Nullable<Array<FactorGradient>>;
  12397. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12398. limitVelocityDamping: number;
  12399. /**
  12400. * Gets the current list of limit velocity gradients.
  12401. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12402. * @returns the list of limit velocity gradients
  12403. */
  12404. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12405. /**
  12406. * Gets the current list of color gradients.
  12407. * You must use addColorGradient and removeColorGradient to udpate this list
  12408. * @returns the list of color gradients
  12409. */
  12410. getColorGradients(): Nullable<Array<ColorGradient>>;
  12411. /**
  12412. * Gets the current list of size gradients.
  12413. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12414. * @returns the list of size gradients
  12415. */
  12416. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12417. /**
  12418. * Gets the current list of color remap gradients.
  12419. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12420. * @returns the list of color remap gradients
  12421. */
  12422. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12423. /**
  12424. * Gets the current list of alpha remap gradients.
  12425. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12426. * @returns the list of alpha remap gradients
  12427. */
  12428. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12429. /**
  12430. * Gets the current list of life time gradients.
  12431. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12432. * @returns the list of life time gradients
  12433. */
  12434. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12435. /**
  12436. * Gets the current list of angular speed gradients.
  12437. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12438. * @returns the list of angular speed gradients
  12439. */
  12440. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12441. /**
  12442. * Gets the current list of velocity gradients.
  12443. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12444. * @returns the list of velocity gradients
  12445. */
  12446. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12447. /**
  12448. * Gets the current list of start size gradients.
  12449. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12450. * @returns the list of start size gradients
  12451. */
  12452. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12453. /**
  12454. * Gets the current list of emit rate gradients.
  12455. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12456. * @returns the list of emit rate gradients
  12457. */
  12458. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12459. /**
  12460. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12461. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12462. */
  12463. get direction1(): Vector3;
  12464. set direction1(value: Vector3);
  12465. /**
  12466. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12467. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12468. */
  12469. get direction2(): Vector3;
  12470. set direction2(value: Vector3);
  12471. /**
  12472. * 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.
  12473. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12474. */
  12475. get minEmitBox(): Vector3;
  12476. set minEmitBox(value: Vector3);
  12477. /**
  12478. * 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.
  12479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12480. */
  12481. get maxEmitBox(): Vector3;
  12482. set maxEmitBox(value: Vector3);
  12483. /**
  12484. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12485. */
  12486. color1: Color4;
  12487. /**
  12488. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12489. */
  12490. color2: Color4;
  12491. /**
  12492. * Color the particle will have at the end of its lifetime
  12493. */
  12494. colorDead: Color4;
  12495. /**
  12496. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12497. */
  12498. textureMask: Color4;
  12499. /**
  12500. * The particle emitter type defines the emitter used by the particle system.
  12501. * It can be for example box, sphere, or cone...
  12502. */
  12503. particleEmitterType: IParticleEmitterType;
  12504. /** @hidden */
  12505. _isSubEmitter: boolean;
  12506. /**
  12507. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12508. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12509. */
  12510. billboardMode: number;
  12511. protected _isBillboardBased: boolean;
  12512. /**
  12513. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12514. */
  12515. get isBillboardBased(): boolean;
  12516. set isBillboardBased(value: boolean);
  12517. /**
  12518. * The scene the particle system belongs to.
  12519. */
  12520. protected _scene: Nullable<Scene>;
  12521. /**
  12522. * The engine the particle system belongs to.
  12523. */
  12524. protected _engine: ThinEngine;
  12525. /**
  12526. * Local cache of defines for image processing.
  12527. */
  12528. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12529. /**
  12530. * Default configuration related to image processing available in the standard Material.
  12531. */
  12532. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12533. /**
  12534. * Gets the image processing configuration used either in this material.
  12535. */
  12536. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12537. /**
  12538. * Sets the Default image processing configuration used either in the this material.
  12539. *
  12540. * If sets to null, the scene one is in use.
  12541. */
  12542. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12543. /**
  12544. * Attaches a new image processing configuration to the Standard Material.
  12545. * @param configuration
  12546. */
  12547. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12548. /** @hidden */
  12549. protected _reset(): void;
  12550. /** @hidden */
  12551. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12552. /**
  12553. * Instantiates a particle system.
  12554. * 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.
  12555. * @param name The name of the particle system
  12556. */
  12557. constructor(name: string);
  12558. /**
  12559. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12562. * @returns the emitter
  12563. */
  12564. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12565. /**
  12566. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12567. * @param radius The radius of the hemisphere to emit from
  12568. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12569. * @returns the emitter
  12570. */
  12571. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12572. /**
  12573. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12574. * @param radius The radius of the sphere to emit from
  12575. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12576. * @returns the emitter
  12577. */
  12578. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12579. /**
  12580. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12581. * @param radius The radius of the sphere to emit from
  12582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12584. * @returns the emitter
  12585. */
  12586. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12587. /**
  12588. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12589. * @param radius The radius of the emission cylinder
  12590. * @param height The height of the emission cylinder
  12591. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12592. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12593. * @returns the emitter
  12594. */
  12595. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12596. /**
  12597. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12598. * @param radius The radius of the cylinder to emit from
  12599. * @param height The height of the emission cylinder
  12600. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12603. * @returns the emitter
  12604. */
  12605. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12606. /**
  12607. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12608. * @param radius The radius of the cone to emit from
  12609. * @param angle The base angle of the cone
  12610. * @returns the emitter
  12611. */
  12612. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12613. /**
  12614. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12617. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12618. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12619. * @returns the emitter
  12620. */
  12621. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12622. }
  12623. }
  12624. declare module "babylonjs/Particles/subEmitter" {
  12625. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12626. import { Scene } from "babylonjs/scene";
  12627. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12628. /**
  12629. * Type of sub emitter
  12630. */
  12631. export enum SubEmitterType {
  12632. /**
  12633. * Attached to the particle over it's lifetime
  12634. */
  12635. ATTACHED = 0,
  12636. /**
  12637. * Created when the particle dies
  12638. */
  12639. END = 1
  12640. }
  12641. /**
  12642. * Sub emitter class used to emit particles from an existing particle
  12643. */
  12644. export class SubEmitter {
  12645. /**
  12646. * the particle system to be used by the sub emitter
  12647. */
  12648. particleSystem: ParticleSystem;
  12649. /**
  12650. * Type of the submitter (Default: END)
  12651. */
  12652. type: SubEmitterType;
  12653. /**
  12654. * 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)
  12655. * Note: This only is supported when using an emitter of type Mesh
  12656. */
  12657. inheritDirection: boolean;
  12658. /**
  12659. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12660. */
  12661. inheritedVelocityAmount: number;
  12662. /**
  12663. * Creates a sub emitter
  12664. * @param particleSystem the particle system to be used by the sub emitter
  12665. */
  12666. constructor(
  12667. /**
  12668. * the particle system to be used by the sub emitter
  12669. */
  12670. particleSystem: ParticleSystem);
  12671. /**
  12672. * Clones the sub emitter
  12673. * @returns the cloned sub emitter
  12674. */
  12675. clone(): SubEmitter;
  12676. /**
  12677. * Serialize current object to a JSON object
  12678. * @returns the serialized object
  12679. */
  12680. serialize(): any;
  12681. /** @hidden */
  12682. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12683. /**
  12684. * Creates a new SubEmitter from a serialized JSON version
  12685. * @param serializationObject defines the JSON object to read from
  12686. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12687. * @param rootUrl defines the rootUrl for data loading
  12688. * @returns a new SubEmitter
  12689. */
  12690. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12691. /** Release associated resources */
  12692. dispose(): void;
  12693. }
  12694. }
  12695. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12696. /** @hidden */
  12697. export var imageProcessingDeclaration: {
  12698. name: string;
  12699. shader: string;
  12700. };
  12701. }
  12702. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12703. /** @hidden */
  12704. export var imageProcessingFunctions: {
  12705. name: string;
  12706. shader: string;
  12707. };
  12708. }
  12709. declare module "babylonjs/Shaders/particles.fragment" {
  12710. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12711. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12712. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12713. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12714. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12715. /** @hidden */
  12716. export var particlesPixelShader: {
  12717. name: string;
  12718. shader: string;
  12719. };
  12720. }
  12721. declare module "babylonjs/Shaders/particles.vertex" {
  12722. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12723. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12724. /** @hidden */
  12725. export var particlesVertexShader: {
  12726. name: string;
  12727. shader: string;
  12728. };
  12729. }
  12730. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12731. import { Nullable } from "babylonjs/types";
  12732. import { Plane } from "babylonjs/Maths/math";
  12733. /**
  12734. * Interface used to define entities containing multiple clip planes
  12735. */
  12736. export interface IClipPlanesHolder {
  12737. /**
  12738. * Gets or sets the active clipplane 1
  12739. */
  12740. clipPlane: Nullable<Plane>;
  12741. /**
  12742. * Gets or sets the active clipplane 2
  12743. */
  12744. clipPlane2: Nullable<Plane>;
  12745. /**
  12746. * Gets or sets the active clipplane 3
  12747. */
  12748. clipPlane3: Nullable<Plane>;
  12749. /**
  12750. * Gets or sets the active clipplane 4
  12751. */
  12752. clipPlane4: Nullable<Plane>;
  12753. /**
  12754. * Gets or sets the active clipplane 5
  12755. */
  12756. clipPlane5: Nullable<Plane>;
  12757. /**
  12758. * Gets or sets the active clipplane 6
  12759. */
  12760. clipPlane6: Nullable<Plane>;
  12761. }
  12762. }
  12763. declare module "babylonjs/Materials/thinMaterialHelper" {
  12764. import { Effect } from "babylonjs/Materials/effect";
  12765. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12766. /**
  12767. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12768. *
  12769. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12770. *
  12771. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12772. */
  12773. export class ThinMaterialHelper {
  12774. /**
  12775. * Binds the clip plane information from the holder to the effect.
  12776. * @param effect The effect we are binding the data to
  12777. * @param holder The entity containing the clip plane information
  12778. */
  12779. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12780. }
  12781. }
  12782. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12783. module "babylonjs/Engines/thinEngine" {
  12784. interface ThinEngine {
  12785. /**
  12786. * Sets alpha constants used by some alpha blending modes
  12787. * @param r defines the red component
  12788. * @param g defines the green component
  12789. * @param b defines the blue component
  12790. * @param a defines the alpha component
  12791. */
  12792. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12793. /**
  12794. * Sets the current alpha mode
  12795. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12796. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12797. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12798. */
  12799. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12800. /**
  12801. * Gets the current alpha mode
  12802. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12803. * @returns the current alpha mode
  12804. */
  12805. getAlphaMode(): number;
  12806. /**
  12807. * Sets the current alpha equation
  12808. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12809. */
  12810. setAlphaEquation(equation: number): void;
  12811. /**
  12812. * Gets the current alpha equation.
  12813. * @returns the current alpha equation
  12814. */
  12815. getAlphaEquation(): number;
  12816. }
  12817. }
  12818. }
  12819. declare module "babylonjs/Particles/particleSystem" {
  12820. import { Nullable } from "babylonjs/types";
  12821. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12822. import { Observable } from "babylonjs/Misc/observable";
  12823. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12824. import { Effect } from "babylonjs/Materials/effect";
  12825. import { IDisposable } from "babylonjs/scene";
  12826. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12827. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12828. import { Particle } from "babylonjs/Particles/particle";
  12829. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12831. import "babylonjs/Shaders/particles.fragment";
  12832. import "babylonjs/Shaders/particles.vertex";
  12833. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12835. import "babylonjs/Engines/Extensions/engine.alpha";
  12836. import { Scene } from "babylonjs/scene";
  12837. /**
  12838. * This represents a particle system in Babylon.
  12839. * 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.
  12840. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12841. * @example https://doc.babylonjs.com/babylon101/particles
  12842. */
  12843. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12844. /**
  12845. * Billboard mode will only apply to Y axis
  12846. */
  12847. static readonly BILLBOARDMODE_Y: number;
  12848. /**
  12849. * Billboard mode will apply to all axes
  12850. */
  12851. static readonly BILLBOARDMODE_ALL: number;
  12852. /**
  12853. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12854. */
  12855. static readonly BILLBOARDMODE_STRETCHED: number;
  12856. /**
  12857. * This function can be defined to provide custom update for active particles.
  12858. * This function will be called instead of regular update (age, position, color, etc.).
  12859. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12860. */
  12861. updateFunction: (particles: Particle[]) => void;
  12862. private _emitterWorldMatrix;
  12863. /**
  12864. * This function can be defined to specify initial direction for every new particle.
  12865. * It by default use the emitterType defined function
  12866. */
  12867. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12868. /**
  12869. * This function can be defined to specify initial position for every new particle.
  12870. * It by default use the emitterType defined function
  12871. */
  12872. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12873. /**
  12874. * @hidden
  12875. */
  12876. _inheritedVelocityOffset: Vector3;
  12877. /**
  12878. * An event triggered when the system is disposed
  12879. */
  12880. onDisposeObservable: Observable<IParticleSystem>;
  12881. private _onDisposeObserver;
  12882. /**
  12883. * Sets a callback that will be triggered when the system is disposed
  12884. */
  12885. set onDispose(callback: () => void);
  12886. private _particles;
  12887. private _epsilon;
  12888. private _capacity;
  12889. private _stockParticles;
  12890. private _newPartsExcess;
  12891. private _vertexData;
  12892. private _vertexBuffer;
  12893. private _vertexBuffers;
  12894. private _spriteBuffer;
  12895. private _indexBuffer;
  12896. private _effect;
  12897. private _customEffect;
  12898. private _cachedDefines;
  12899. private _scaledColorStep;
  12900. private _colorDiff;
  12901. private _scaledDirection;
  12902. private _scaledGravity;
  12903. private _currentRenderId;
  12904. private _alive;
  12905. private _useInstancing;
  12906. private _started;
  12907. private _stopped;
  12908. private _actualFrame;
  12909. private _scaledUpdateSpeed;
  12910. private _vertexBufferSize;
  12911. /** @hidden */
  12912. _currentEmitRateGradient: Nullable<FactorGradient>;
  12913. /** @hidden */
  12914. _currentEmitRate1: number;
  12915. /** @hidden */
  12916. _currentEmitRate2: number;
  12917. /** @hidden */
  12918. _currentStartSizeGradient: Nullable<FactorGradient>;
  12919. /** @hidden */
  12920. _currentStartSize1: number;
  12921. /** @hidden */
  12922. _currentStartSize2: number;
  12923. private readonly _rawTextureWidth;
  12924. private _rampGradientsTexture;
  12925. private _useRampGradients;
  12926. /** Gets or sets a matrix to use to compute projection */
  12927. defaultProjectionMatrix: Matrix;
  12928. /** Gets or sets a matrix to use to compute view */
  12929. defaultViewMatrix: Matrix;
  12930. /** Gets or sets a boolean indicating that ramp gradients must be used
  12931. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12932. */
  12933. get useRampGradients(): boolean;
  12934. set useRampGradients(value: boolean);
  12935. /**
  12936. * 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.
  12937. * 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: [])
  12938. */
  12939. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12940. private _subEmitters;
  12941. /**
  12942. * @hidden
  12943. * If the particle systems emitter should be disposed when the particle system is disposed
  12944. */
  12945. _disposeEmitterOnDispose: boolean;
  12946. /**
  12947. * The current active Sub-systems, this property is used by the root particle system only.
  12948. */
  12949. activeSubSystems: Array<ParticleSystem>;
  12950. /**
  12951. * Specifies if the particles are updated in emitter local space or world space
  12952. */
  12953. isLocal: boolean;
  12954. private _rootParticleSystem;
  12955. /**
  12956. * Gets the current list of active particles
  12957. */
  12958. get particles(): Particle[];
  12959. /**
  12960. * Gets the number of particles active at the same time.
  12961. * @returns The number of active particles.
  12962. */
  12963. getActiveCount(): number;
  12964. /**
  12965. * Returns the string "ParticleSystem"
  12966. * @returns a string containing the class name
  12967. */
  12968. getClassName(): string;
  12969. /**
  12970. * Gets a boolean indicating that the system is stopping
  12971. * @returns true if the system is currently stopping
  12972. */
  12973. isStopping(): boolean;
  12974. /**
  12975. * Gets the custom effect used to render the particles
  12976. * @param blendMode Blend mode for which the effect should be retrieved
  12977. * @returns The effect
  12978. */
  12979. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12980. /**
  12981. * Sets the custom effect used to render the particles
  12982. * @param effect The effect to set
  12983. * @param blendMode Blend mode for which the effect should be set
  12984. */
  12985. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12986. /** @hidden */
  12987. private _onBeforeDrawParticlesObservable;
  12988. /**
  12989. * Observable that will be called just before the particles are drawn
  12990. */
  12991. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12992. /**
  12993. * Gets the name of the particle vertex shader
  12994. */
  12995. get vertexShaderName(): string;
  12996. /**
  12997. * Instantiates a particle system.
  12998. * 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.
  12999. * @param name The name of the particle system
  13000. * @param capacity The max number of particles alive at the same time
  13001. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13002. * @param customEffect a custom effect used to change the way particles are rendered by default
  13003. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13004. * @param epsilon Offset used to render the particles
  13005. */
  13006. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13007. private _addFactorGradient;
  13008. private _removeFactorGradient;
  13009. /**
  13010. * Adds a new life time gradient
  13011. * @param gradient defines the gradient to use (between 0 and 1)
  13012. * @param factor defines the life time factor to affect to the specified gradient
  13013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13014. * @returns the current particle system
  13015. */
  13016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13017. /**
  13018. * Remove a specific life time gradient
  13019. * @param gradient defines the gradient to remove
  13020. * @returns the current particle system
  13021. */
  13022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13023. /**
  13024. * Adds a new size gradient
  13025. * @param gradient defines the gradient to use (between 0 and 1)
  13026. * @param factor defines the size factor to affect to the specified gradient
  13027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13028. * @returns the current particle system
  13029. */
  13030. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13031. /**
  13032. * Remove a specific size gradient
  13033. * @param gradient defines the gradient to remove
  13034. * @returns the current particle system
  13035. */
  13036. removeSizeGradient(gradient: number): IParticleSystem;
  13037. /**
  13038. * Adds a new color remap gradient
  13039. * @param gradient defines the gradient to use (between 0 and 1)
  13040. * @param min defines the color remap minimal range
  13041. * @param max defines the color remap maximal range
  13042. * @returns the current particle system
  13043. */
  13044. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13045. /**
  13046. * Remove a specific color remap gradient
  13047. * @param gradient defines the gradient to remove
  13048. * @returns the current particle system
  13049. */
  13050. removeColorRemapGradient(gradient: number): IParticleSystem;
  13051. /**
  13052. * Adds a new alpha remap gradient
  13053. * @param gradient defines the gradient to use (between 0 and 1)
  13054. * @param min defines the alpha remap minimal range
  13055. * @param max defines the alpha remap maximal range
  13056. * @returns the current particle system
  13057. */
  13058. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13059. /**
  13060. * Remove a specific alpha remap gradient
  13061. * @param gradient defines the gradient to remove
  13062. * @returns the current particle system
  13063. */
  13064. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13065. /**
  13066. * Adds a new angular speed gradient
  13067. * @param gradient defines the gradient to use (between 0 and 1)
  13068. * @param factor defines the angular speed to affect to the specified gradient
  13069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13070. * @returns the current particle system
  13071. */
  13072. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13073. /**
  13074. * Remove a specific angular speed gradient
  13075. * @param gradient defines the gradient to remove
  13076. * @returns the current particle system
  13077. */
  13078. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13079. /**
  13080. * Adds a new velocity gradient
  13081. * @param gradient defines the gradient to use (between 0 and 1)
  13082. * @param factor defines the velocity to affect to the specified gradient
  13083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13084. * @returns the current particle system
  13085. */
  13086. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13087. /**
  13088. * Remove a specific velocity gradient
  13089. * @param gradient defines the gradient to remove
  13090. * @returns the current particle system
  13091. */
  13092. removeVelocityGradient(gradient: number): IParticleSystem;
  13093. /**
  13094. * Adds a new limit velocity gradient
  13095. * @param gradient defines the gradient to use (between 0 and 1)
  13096. * @param factor defines the limit velocity value to affect to the specified gradient
  13097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13098. * @returns the current particle system
  13099. */
  13100. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13101. /**
  13102. * Remove a specific limit velocity gradient
  13103. * @param gradient defines the gradient to remove
  13104. * @returns the current particle system
  13105. */
  13106. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13107. /**
  13108. * Adds a new drag gradient
  13109. * @param gradient defines the gradient to use (between 0 and 1)
  13110. * @param factor defines the drag value to affect to the specified gradient
  13111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13112. * @returns the current particle system
  13113. */
  13114. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13115. /**
  13116. * Remove a specific drag gradient
  13117. * @param gradient defines the gradient to remove
  13118. * @returns the current particle system
  13119. */
  13120. removeDragGradient(gradient: number): IParticleSystem;
  13121. /**
  13122. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13123. * @param gradient defines the gradient to use (between 0 and 1)
  13124. * @param factor defines the emit rate value to affect to the specified gradient
  13125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13126. * @returns the current particle system
  13127. */
  13128. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13129. /**
  13130. * Remove a specific emit rate gradient
  13131. * @param gradient defines the gradient to remove
  13132. * @returns the current particle system
  13133. */
  13134. removeEmitRateGradient(gradient: number): IParticleSystem;
  13135. /**
  13136. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13137. * @param gradient defines the gradient to use (between 0 and 1)
  13138. * @param factor defines the start size value to affect to the specified gradient
  13139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13140. * @returns the current particle system
  13141. */
  13142. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13143. /**
  13144. * Remove a specific start size gradient
  13145. * @param gradient defines the gradient to remove
  13146. * @returns the current particle system
  13147. */
  13148. removeStartSizeGradient(gradient: number): IParticleSystem;
  13149. private _createRampGradientTexture;
  13150. /**
  13151. * Gets the current list of ramp gradients.
  13152. * You must use addRampGradient and removeRampGradient to udpate this list
  13153. * @returns the list of ramp gradients
  13154. */
  13155. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13156. /** Force the system to rebuild all gradients that need to be resync */
  13157. forceRefreshGradients(): void;
  13158. private _syncRampGradientTexture;
  13159. /**
  13160. * Adds a new ramp gradient used to remap particle colors
  13161. * @param gradient defines the gradient to use (between 0 and 1)
  13162. * @param color defines the color to affect to the specified gradient
  13163. * @returns the current particle system
  13164. */
  13165. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13166. /**
  13167. * Remove a specific ramp gradient
  13168. * @param gradient defines the gradient to remove
  13169. * @returns the current particle system
  13170. */
  13171. removeRampGradient(gradient: number): ParticleSystem;
  13172. /**
  13173. * Adds a new color gradient
  13174. * @param gradient defines the gradient to use (between 0 and 1)
  13175. * @param color1 defines the color to affect to the specified gradient
  13176. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13177. * @returns this particle system
  13178. */
  13179. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13180. /**
  13181. * Remove a specific color gradient
  13182. * @param gradient defines the gradient to remove
  13183. * @returns this particle system
  13184. */
  13185. removeColorGradient(gradient: number): IParticleSystem;
  13186. private _fetchR;
  13187. protected _reset(): void;
  13188. private _resetEffect;
  13189. private _createVertexBuffers;
  13190. private _createIndexBuffer;
  13191. /**
  13192. * Gets the maximum number of particles active at the same time.
  13193. * @returns The max number of active particles.
  13194. */
  13195. getCapacity(): number;
  13196. /**
  13197. * Gets whether there are still active particles in the system.
  13198. * @returns True if it is alive, otherwise false.
  13199. */
  13200. isAlive(): boolean;
  13201. /**
  13202. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13203. * @returns True if it has been started, otherwise false.
  13204. */
  13205. isStarted(): boolean;
  13206. private _prepareSubEmitterInternalArray;
  13207. /**
  13208. * Starts the particle system and begins to emit
  13209. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13210. */
  13211. start(delay?: number): void;
  13212. /**
  13213. * Stops the particle system.
  13214. * @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.
  13215. */
  13216. stop(stopSubEmitters?: boolean): void;
  13217. /**
  13218. * Remove all active particles
  13219. */
  13220. reset(): void;
  13221. /**
  13222. * @hidden (for internal use only)
  13223. */
  13224. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13225. /**
  13226. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13227. * Its lifetime will start back at 0.
  13228. */
  13229. recycleParticle: (particle: Particle) => void;
  13230. private _stopSubEmitters;
  13231. private _createParticle;
  13232. private _removeFromRoot;
  13233. private _emitFromParticle;
  13234. private _update;
  13235. /** @hidden */
  13236. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13237. /** @hidden */
  13238. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13239. /**
  13240. * Fill the defines array according to the current settings of the particle system
  13241. * @param defines Array to be updated
  13242. * @param blendMode blend mode to take into account when updating the array
  13243. */
  13244. fillDefines(defines: Array<string>, blendMode: number): void;
  13245. /**
  13246. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13247. * @param uniforms Uniforms array to fill
  13248. * @param attributes Attributes array to fill
  13249. * @param samplers Samplers array to fill
  13250. */
  13251. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13252. /** @hidden */
  13253. private _getEffect;
  13254. /**
  13255. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13256. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13257. */
  13258. animate(preWarmOnly?: boolean): void;
  13259. private _appendParticleVertices;
  13260. /**
  13261. * Rebuilds the particle system.
  13262. */
  13263. rebuild(): void;
  13264. /**
  13265. * Is this system ready to be used/rendered
  13266. * @return true if the system is ready
  13267. */
  13268. isReady(): boolean;
  13269. private _render;
  13270. /**
  13271. * Renders the particle system in its current state.
  13272. * @returns the current number of particles
  13273. */
  13274. render(): number;
  13275. /**
  13276. * Disposes the particle system and free the associated resources
  13277. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13278. */
  13279. dispose(disposeTexture?: boolean): void;
  13280. /**
  13281. * Clones the particle system.
  13282. * @param name The name of the cloned object
  13283. * @param newEmitter The new emitter to use
  13284. * @returns the cloned particle system
  13285. */
  13286. clone(name: string, newEmitter: any): ParticleSystem;
  13287. /**
  13288. * Serializes the particle system to a JSON object
  13289. * @param serializeTexture defines if the texture must be serialized as well
  13290. * @returns the JSON object
  13291. */
  13292. serialize(serializeTexture?: boolean): any;
  13293. /** @hidden */
  13294. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13295. /** @hidden */
  13296. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13297. /**
  13298. * Parses a JSON object to create a particle system.
  13299. * @param parsedParticleSystem The JSON object to parse
  13300. * @param sceneOrEngine The scene or the engine to create the particle system in
  13301. * @param rootUrl The root url to use to load external dependencies like texture
  13302. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13303. * @returns the Parsed particle system
  13304. */
  13305. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13306. }
  13307. }
  13308. declare module "babylonjs/Particles/particle" {
  13309. import { Nullable } from "babylonjs/types";
  13310. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13311. import { Color4 } from "babylonjs/Maths/math.color";
  13312. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13313. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13314. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13315. /**
  13316. * A particle represents one of the element emitted by a particle system.
  13317. * This is mainly define by its coordinates, direction, velocity and age.
  13318. */
  13319. export class Particle {
  13320. /**
  13321. * The particle system the particle belongs to.
  13322. */
  13323. particleSystem: ParticleSystem;
  13324. private static _Count;
  13325. /**
  13326. * Unique ID of the particle
  13327. */
  13328. id: number;
  13329. /**
  13330. * The world position of the particle in the scene.
  13331. */
  13332. position: Vector3;
  13333. /**
  13334. * The world direction of the particle in the scene.
  13335. */
  13336. direction: Vector3;
  13337. /**
  13338. * The color of the particle.
  13339. */
  13340. color: Color4;
  13341. /**
  13342. * The color change of the particle per step.
  13343. */
  13344. colorStep: Color4;
  13345. /**
  13346. * Defines how long will the life of the particle be.
  13347. */
  13348. lifeTime: number;
  13349. /**
  13350. * The current age of the particle.
  13351. */
  13352. age: number;
  13353. /**
  13354. * The current size of the particle.
  13355. */
  13356. size: number;
  13357. /**
  13358. * The current scale of the particle.
  13359. */
  13360. scale: Vector2;
  13361. /**
  13362. * The current angle of the particle.
  13363. */
  13364. angle: number;
  13365. /**
  13366. * Defines how fast is the angle changing.
  13367. */
  13368. angularSpeed: number;
  13369. /**
  13370. * Defines the cell index used by the particle to be rendered from a sprite.
  13371. */
  13372. cellIndex: number;
  13373. /**
  13374. * The information required to support color remapping
  13375. */
  13376. remapData: Vector4;
  13377. /** @hidden */
  13378. _randomCellOffset?: number;
  13379. /** @hidden */
  13380. _initialDirection: Nullable<Vector3>;
  13381. /** @hidden */
  13382. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13383. /** @hidden */
  13384. _initialStartSpriteCellID: number;
  13385. /** @hidden */
  13386. _initialEndSpriteCellID: number;
  13387. /** @hidden */
  13388. _currentColorGradient: Nullable<ColorGradient>;
  13389. /** @hidden */
  13390. _currentColor1: Color4;
  13391. /** @hidden */
  13392. _currentColor2: Color4;
  13393. /** @hidden */
  13394. _currentSizeGradient: Nullable<FactorGradient>;
  13395. /** @hidden */
  13396. _currentSize1: number;
  13397. /** @hidden */
  13398. _currentSize2: number;
  13399. /** @hidden */
  13400. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13401. /** @hidden */
  13402. _currentAngularSpeed1: number;
  13403. /** @hidden */
  13404. _currentAngularSpeed2: number;
  13405. /** @hidden */
  13406. _currentVelocityGradient: Nullable<FactorGradient>;
  13407. /** @hidden */
  13408. _currentVelocity1: number;
  13409. /** @hidden */
  13410. _currentVelocity2: number;
  13411. /** @hidden */
  13412. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13413. /** @hidden */
  13414. _currentLimitVelocity1: number;
  13415. /** @hidden */
  13416. _currentLimitVelocity2: number;
  13417. /** @hidden */
  13418. _currentDragGradient: Nullable<FactorGradient>;
  13419. /** @hidden */
  13420. _currentDrag1: number;
  13421. /** @hidden */
  13422. _currentDrag2: number;
  13423. /** @hidden */
  13424. _randomNoiseCoordinates1: Vector3;
  13425. /** @hidden */
  13426. _randomNoiseCoordinates2: Vector3;
  13427. /** @hidden */
  13428. _localPosition?: Vector3;
  13429. /**
  13430. * Creates a new instance Particle
  13431. * @param particleSystem the particle system the particle belongs to
  13432. */
  13433. constructor(
  13434. /**
  13435. * The particle system the particle belongs to.
  13436. */
  13437. particleSystem: ParticleSystem);
  13438. private updateCellInfoFromSystem;
  13439. /**
  13440. * Defines how the sprite cell index is updated for the particle
  13441. */
  13442. updateCellIndex(): void;
  13443. /** @hidden */
  13444. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13445. /** @hidden */
  13446. _inheritParticleInfoToSubEmitters(): void;
  13447. /** @hidden */
  13448. _reset(): void;
  13449. /**
  13450. * Copy the properties of particle to another one.
  13451. * @param other the particle to copy the information to.
  13452. */
  13453. copyTo(other: Particle): void;
  13454. }
  13455. }
  13456. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13458. import { Effect } from "babylonjs/Materials/effect";
  13459. import { Particle } from "babylonjs/Particles/particle";
  13460. import { Nullable } from "babylonjs/types";
  13461. import { Scene } from "babylonjs/scene";
  13462. /**
  13463. * Particle emitter represents a volume emitting particles.
  13464. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13465. */
  13466. export interface IParticleEmitterType {
  13467. /**
  13468. * Called by the particle System when the direction is computed for the created particle.
  13469. * @param worldMatrix is the world matrix of the particle system
  13470. * @param directionToUpdate is the direction vector to update with the result
  13471. * @param particle is the particle we are computed the direction for
  13472. * @param isLocal defines if the direction should be set in local space
  13473. */
  13474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13475. /**
  13476. * Called by the particle System when the position is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param positionToUpdate is the position vector to update with the result
  13479. * @param particle is the particle we are computed the position for
  13480. * @param isLocal defines if the position should be set in local space
  13481. */
  13482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Clones the current emitter and returns a copy of it
  13485. * @returns the new emitter
  13486. */
  13487. clone(): IParticleEmitterType;
  13488. /**
  13489. * Called by the GPUParticleSystem to setup the update shader
  13490. * @param effect defines the update shader
  13491. */
  13492. applyToShader(effect: Effect): void;
  13493. /**
  13494. * Returns a string to use to update the GPU particles update shader
  13495. * @returns the effect defines string
  13496. */
  13497. getEffectDefines(): string;
  13498. /**
  13499. * Returns a string representing the class name
  13500. * @returns a string containing the class name
  13501. */
  13502. getClassName(): string;
  13503. /**
  13504. * Serializes the particle system to a JSON object.
  13505. * @returns the JSON object
  13506. */
  13507. serialize(): any;
  13508. /**
  13509. * Parse properties from a JSON object
  13510. * @param serializationObject defines the JSON object
  13511. * @param scene defines the hosting scene
  13512. */
  13513. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13514. }
  13515. }
  13516. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13517. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13518. import { Effect } from "babylonjs/Materials/effect";
  13519. import { Particle } from "babylonjs/Particles/particle";
  13520. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13521. /**
  13522. * Particle emitter emitting particles from the inside of a box.
  13523. * It emits the particles randomly between 2 given directions.
  13524. */
  13525. export class BoxParticleEmitter implements IParticleEmitterType {
  13526. /**
  13527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13528. */
  13529. direction1: Vector3;
  13530. /**
  13531. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13532. */
  13533. direction2: Vector3;
  13534. /**
  13535. * 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.
  13536. */
  13537. minEmitBox: Vector3;
  13538. /**
  13539. * 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.
  13540. */
  13541. maxEmitBox: Vector3;
  13542. /**
  13543. * Creates a new instance BoxParticleEmitter
  13544. */
  13545. constructor();
  13546. /**
  13547. * Called by the particle System when the direction is computed for the created particle.
  13548. * @param worldMatrix is the world matrix of the particle system
  13549. * @param directionToUpdate is the direction vector to update with the result
  13550. * @param particle is the particle we are computed the direction for
  13551. * @param isLocal defines if the direction should be set in local space
  13552. */
  13553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13554. /**
  13555. * Called by the particle System when the position is computed for the created particle.
  13556. * @param worldMatrix is the world matrix of the particle system
  13557. * @param positionToUpdate is the position vector to update with the result
  13558. * @param particle is the particle we are computed the position for
  13559. * @param isLocal defines if the position should be set in local space
  13560. */
  13561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13562. /**
  13563. * Clones the current emitter and returns a copy of it
  13564. * @returns the new emitter
  13565. */
  13566. clone(): BoxParticleEmitter;
  13567. /**
  13568. * Called by the GPUParticleSystem to setup the update shader
  13569. * @param effect defines the update shader
  13570. */
  13571. applyToShader(effect: Effect): void;
  13572. /**
  13573. * Returns a string to use to update the GPU particles update shader
  13574. * @returns a string containng the defines string
  13575. */
  13576. getEffectDefines(): string;
  13577. /**
  13578. * Returns the string "BoxParticleEmitter"
  13579. * @returns a string containing the class name
  13580. */
  13581. getClassName(): string;
  13582. /**
  13583. * Serializes the particle system to a JSON object.
  13584. * @returns the JSON object
  13585. */
  13586. serialize(): any;
  13587. /**
  13588. * Parse properties from a JSON object
  13589. * @param serializationObject defines the JSON object
  13590. */
  13591. parse(serializationObject: any): void;
  13592. }
  13593. }
  13594. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13595. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Effect } from "babylonjs/Materials/effect";
  13597. import { Particle } from "babylonjs/Particles/particle";
  13598. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13599. /**
  13600. * Particle emitter emitting particles from the inside of a cone.
  13601. * It emits the particles alongside the cone volume from the base to the particle.
  13602. * The emission direction might be randomized.
  13603. */
  13604. export class ConeParticleEmitter implements IParticleEmitterType {
  13605. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13606. directionRandomizer: number;
  13607. private _radius;
  13608. private _angle;
  13609. private _height;
  13610. /**
  13611. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13612. */
  13613. radiusRange: number;
  13614. /**
  13615. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13616. */
  13617. heightRange: number;
  13618. /**
  13619. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13620. */
  13621. emitFromSpawnPointOnly: boolean;
  13622. /**
  13623. * Gets or sets the radius of the emission cone
  13624. */
  13625. get radius(): number;
  13626. set radius(value: number);
  13627. /**
  13628. * Gets or sets the angle of the emission cone
  13629. */
  13630. get angle(): number;
  13631. set angle(value: number);
  13632. private _buildHeight;
  13633. /**
  13634. * Creates a new instance ConeParticleEmitter
  13635. * @param radius the radius of the emission cone (1 by default)
  13636. * @param angle the cone base angle (PI by default)
  13637. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13638. */
  13639. constructor(radius?: number, angle?: number,
  13640. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13641. directionRandomizer?: number);
  13642. /**
  13643. * Called by the particle System when the direction is computed for the created particle.
  13644. * @param worldMatrix is the world matrix of the particle system
  13645. * @param directionToUpdate is the direction vector to update with the result
  13646. * @param particle is the particle we are computed the direction for
  13647. * @param isLocal defines if the direction should be set in local space
  13648. */
  13649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13650. /**
  13651. * Called by the particle System when the position is computed for the created particle.
  13652. * @param worldMatrix is the world matrix of the particle system
  13653. * @param positionToUpdate is the position vector to update with the result
  13654. * @param particle is the particle we are computed the position for
  13655. * @param isLocal defines if the position should be set in local space
  13656. */
  13657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13658. /**
  13659. * Clones the current emitter and returns a copy of it
  13660. * @returns the new emitter
  13661. */
  13662. clone(): ConeParticleEmitter;
  13663. /**
  13664. * Called by the GPUParticleSystem to setup the update shader
  13665. * @param effect defines the update shader
  13666. */
  13667. applyToShader(effect: Effect): void;
  13668. /**
  13669. * Returns a string to use to update the GPU particles update shader
  13670. * @returns a string containng the defines string
  13671. */
  13672. getEffectDefines(): string;
  13673. /**
  13674. * Returns the string "ConeParticleEmitter"
  13675. * @returns a string containing the class name
  13676. */
  13677. getClassName(): string;
  13678. /**
  13679. * Serializes the particle system to a JSON object.
  13680. * @returns the JSON object
  13681. */
  13682. serialize(): any;
  13683. /**
  13684. * Parse properties from a JSON object
  13685. * @param serializationObject defines the JSON object
  13686. */
  13687. parse(serializationObject: any): void;
  13688. }
  13689. }
  13690. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13691. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13692. import { Effect } from "babylonjs/Materials/effect";
  13693. import { Particle } from "babylonjs/Particles/particle";
  13694. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13695. /**
  13696. * Particle emitter emitting particles from the inside of a cylinder.
  13697. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13698. */
  13699. export class CylinderParticleEmitter implements IParticleEmitterType {
  13700. /**
  13701. * The radius of the emission cylinder.
  13702. */
  13703. radius: number;
  13704. /**
  13705. * The height of the emission cylinder.
  13706. */
  13707. height: number;
  13708. /**
  13709. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13710. */
  13711. radiusRange: number;
  13712. /**
  13713. * How much to randomize the particle direction [0-1].
  13714. */
  13715. directionRandomizer: number;
  13716. /**
  13717. * Creates a new instance CylinderParticleEmitter
  13718. * @param radius the radius of the emission cylinder (1 by default)
  13719. * @param height the height of the emission cylinder (1 by default)
  13720. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13721. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13722. */
  13723. constructor(
  13724. /**
  13725. * The radius of the emission cylinder.
  13726. */
  13727. radius?: number,
  13728. /**
  13729. * The height of the emission cylinder.
  13730. */
  13731. height?: number,
  13732. /**
  13733. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13734. */
  13735. radiusRange?: number,
  13736. /**
  13737. * How much to randomize the particle direction [0-1].
  13738. */
  13739. directionRandomizer?: number);
  13740. /**
  13741. * Called by the particle System when the direction is computed for the created particle.
  13742. * @param worldMatrix is the world matrix of the particle system
  13743. * @param directionToUpdate is the direction vector to update with the result
  13744. * @param particle is the particle we are computed the direction for
  13745. * @param isLocal defines if the direction should be set in local space
  13746. */
  13747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13748. /**
  13749. * Called by the particle System when the position is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param positionToUpdate is the position vector to update with the result
  13752. * @param particle is the particle we are computed the position for
  13753. * @param isLocal defines if the position should be set in local space
  13754. */
  13755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Clones the current emitter and returns a copy of it
  13758. * @returns the new emitter
  13759. */
  13760. clone(): CylinderParticleEmitter;
  13761. /**
  13762. * Called by the GPUParticleSystem to setup the update shader
  13763. * @param effect defines the update shader
  13764. */
  13765. applyToShader(effect: Effect): void;
  13766. /**
  13767. * Returns a string to use to update the GPU particles update shader
  13768. * @returns a string containng the defines string
  13769. */
  13770. getEffectDefines(): string;
  13771. /**
  13772. * Returns the string "CylinderParticleEmitter"
  13773. * @returns a string containing the class name
  13774. */
  13775. getClassName(): string;
  13776. /**
  13777. * Serializes the particle system to a JSON object.
  13778. * @returns the JSON object
  13779. */
  13780. serialize(): any;
  13781. /**
  13782. * Parse properties from a JSON object
  13783. * @param serializationObject defines the JSON object
  13784. */
  13785. parse(serializationObject: any): void;
  13786. }
  13787. /**
  13788. * Particle emitter emitting particles from the inside of a cylinder.
  13789. * It emits the particles randomly between two vectors.
  13790. */
  13791. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13792. /**
  13793. * The min limit of the emission direction.
  13794. */
  13795. direction1: Vector3;
  13796. /**
  13797. * The max limit of the emission direction.
  13798. */
  13799. direction2: Vector3;
  13800. /**
  13801. * Creates a new instance CylinderDirectedParticleEmitter
  13802. * @param radius the radius of the emission cylinder (1 by default)
  13803. * @param height the height of the emission cylinder (1 by default)
  13804. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13805. * @param direction1 the min limit of the emission direction (up vector by default)
  13806. * @param direction2 the max limit of the emission direction (up vector by default)
  13807. */
  13808. constructor(radius?: number, height?: number, radiusRange?: number,
  13809. /**
  13810. * The min limit of the emission direction.
  13811. */
  13812. direction1?: Vector3,
  13813. /**
  13814. * The max limit of the emission direction.
  13815. */
  13816. direction2?: Vector3);
  13817. /**
  13818. * Called by the particle System when the direction is computed for the created particle.
  13819. * @param worldMatrix is the world matrix of the particle system
  13820. * @param directionToUpdate is the direction vector to update with the result
  13821. * @param particle is the particle we are computed the direction for
  13822. */
  13823. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13824. /**
  13825. * Clones the current emitter and returns a copy of it
  13826. * @returns the new emitter
  13827. */
  13828. clone(): CylinderDirectedParticleEmitter;
  13829. /**
  13830. * Called by the GPUParticleSystem to setup the update shader
  13831. * @param effect defines the update shader
  13832. */
  13833. applyToShader(effect: Effect): void;
  13834. /**
  13835. * Returns a string to use to update the GPU particles update shader
  13836. * @returns a string containng the defines string
  13837. */
  13838. getEffectDefines(): string;
  13839. /**
  13840. * Returns the string "CylinderDirectedParticleEmitter"
  13841. * @returns a string containing the class name
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Serializes the particle system to a JSON object.
  13846. * @returns the JSON object
  13847. */
  13848. serialize(): any;
  13849. /**
  13850. * Parse properties from a JSON object
  13851. * @param serializationObject defines the JSON object
  13852. */
  13853. parse(serializationObject: any): void;
  13854. }
  13855. }
  13856. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13857. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13858. import { Effect } from "babylonjs/Materials/effect";
  13859. import { Particle } from "babylonjs/Particles/particle";
  13860. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13861. /**
  13862. * Particle emitter emitting particles from the inside of a hemisphere.
  13863. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13864. */
  13865. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13866. /**
  13867. * The radius of the emission hemisphere.
  13868. */
  13869. radius: number;
  13870. /**
  13871. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13872. */
  13873. radiusRange: number;
  13874. /**
  13875. * How much to randomize the particle direction [0-1].
  13876. */
  13877. directionRandomizer: number;
  13878. /**
  13879. * Creates a new instance HemisphericParticleEmitter
  13880. * @param radius the radius of the emission hemisphere (1 by default)
  13881. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13882. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13883. */
  13884. constructor(
  13885. /**
  13886. * The radius of the emission hemisphere.
  13887. */
  13888. radius?: number,
  13889. /**
  13890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13891. */
  13892. radiusRange?: number,
  13893. /**
  13894. * How much to randomize the particle direction [0-1].
  13895. */
  13896. directionRandomizer?: number);
  13897. /**
  13898. * Called by the particle System when the direction is computed for the created particle.
  13899. * @param worldMatrix is the world matrix of the particle system
  13900. * @param directionToUpdate is the direction vector to update with the result
  13901. * @param particle is the particle we are computed the direction for
  13902. * @param isLocal defines if the direction should be set in local space
  13903. */
  13904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13905. /**
  13906. * Called by the particle System when the position is computed for the created particle.
  13907. * @param worldMatrix is the world matrix of the particle system
  13908. * @param positionToUpdate is the position vector to update with the result
  13909. * @param particle is the particle we are computed the position for
  13910. * @param isLocal defines if the position should be set in local space
  13911. */
  13912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13913. /**
  13914. * Clones the current emitter and returns a copy of it
  13915. * @returns the new emitter
  13916. */
  13917. clone(): HemisphericParticleEmitter;
  13918. /**
  13919. * Called by the GPUParticleSystem to setup the update shader
  13920. * @param effect defines the update shader
  13921. */
  13922. applyToShader(effect: Effect): void;
  13923. /**
  13924. * Returns a string to use to update the GPU particles update shader
  13925. * @returns a string containng the defines string
  13926. */
  13927. getEffectDefines(): string;
  13928. /**
  13929. * Returns the string "HemisphericParticleEmitter"
  13930. * @returns a string containing the class name
  13931. */
  13932. getClassName(): string;
  13933. /**
  13934. * Serializes the particle system to a JSON object.
  13935. * @returns the JSON object
  13936. */
  13937. serialize(): any;
  13938. /**
  13939. * Parse properties from a JSON object
  13940. * @param serializationObject defines the JSON object
  13941. */
  13942. parse(serializationObject: any): void;
  13943. }
  13944. }
  13945. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13947. import { Effect } from "babylonjs/Materials/effect";
  13948. import { Particle } from "babylonjs/Particles/particle";
  13949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13950. /**
  13951. * Particle emitter emitting particles from a point.
  13952. * It emits the particles randomly between 2 given directions.
  13953. */
  13954. export class PointParticleEmitter implements IParticleEmitterType {
  13955. /**
  13956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13957. */
  13958. direction1: Vector3;
  13959. /**
  13960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13961. */
  13962. direction2: Vector3;
  13963. /**
  13964. * Creates a new instance PointParticleEmitter
  13965. */
  13966. constructor();
  13967. /**
  13968. * Called by the particle System when the direction is computed for the created particle.
  13969. * @param worldMatrix is the world matrix of the particle system
  13970. * @param directionToUpdate is the direction vector to update with the result
  13971. * @param particle is the particle we are computed the direction for
  13972. * @param isLocal defines if the direction should be set in local space
  13973. */
  13974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13975. /**
  13976. * Called by the particle System when the position is computed for the created particle.
  13977. * @param worldMatrix is the world matrix of the particle system
  13978. * @param positionToUpdate is the position vector to update with the result
  13979. * @param particle is the particle we are computed the position for
  13980. * @param isLocal defines if the position should be set in local space
  13981. */
  13982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13983. /**
  13984. * Clones the current emitter and returns a copy of it
  13985. * @returns the new emitter
  13986. */
  13987. clone(): PointParticleEmitter;
  13988. /**
  13989. * Called by the GPUParticleSystem to setup the update shader
  13990. * @param effect defines the update shader
  13991. */
  13992. applyToShader(effect: Effect): void;
  13993. /**
  13994. * Returns a string to use to update the GPU particles update shader
  13995. * @returns a string containng the defines string
  13996. */
  13997. getEffectDefines(): string;
  13998. /**
  13999. * Returns the string "PointParticleEmitter"
  14000. * @returns a string containing the class name
  14001. */
  14002. getClassName(): string;
  14003. /**
  14004. * Serializes the particle system to a JSON object.
  14005. * @returns the JSON object
  14006. */
  14007. serialize(): any;
  14008. /**
  14009. * Parse properties from a JSON object
  14010. * @param serializationObject defines the JSON object
  14011. */
  14012. parse(serializationObject: any): void;
  14013. }
  14014. }
  14015. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14016. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14017. import { Effect } from "babylonjs/Materials/effect";
  14018. import { Particle } from "babylonjs/Particles/particle";
  14019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14020. /**
  14021. * Particle emitter emitting particles from the inside of a sphere.
  14022. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14023. */
  14024. export class SphereParticleEmitter implements IParticleEmitterType {
  14025. /**
  14026. * The radius of the emission sphere.
  14027. */
  14028. radius: number;
  14029. /**
  14030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14031. */
  14032. radiusRange: number;
  14033. /**
  14034. * How much to randomize the particle direction [0-1].
  14035. */
  14036. directionRandomizer: number;
  14037. /**
  14038. * Creates a new instance SphereParticleEmitter
  14039. * @param radius the radius of the emission sphere (1 by default)
  14040. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14041. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14042. */
  14043. constructor(
  14044. /**
  14045. * The radius of the emission sphere.
  14046. */
  14047. radius?: number,
  14048. /**
  14049. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14050. */
  14051. radiusRange?: number,
  14052. /**
  14053. * How much to randomize the particle direction [0-1].
  14054. */
  14055. directionRandomizer?: number);
  14056. /**
  14057. * Called by the particle System when the direction is computed for the created particle.
  14058. * @param worldMatrix is the world matrix of the particle system
  14059. * @param directionToUpdate is the direction vector to update with the result
  14060. * @param particle is the particle we are computed the direction for
  14061. * @param isLocal defines if the direction should be set in local space
  14062. */
  14063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14064. /**
  14065. * Called by the particle System when the position is computed for the created particle.
  14066. * @param worldMatrix is the world matrix of the particle system
  14067. * @param positionToUpdate is the position vector to update with the result
  14068. * @param particle is the particle we are computed the position for
  14069. * @param isLocal defines if the position should be set in local space
  14070. */
  14071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14072. /**
  14073. * Clones the current emitter and returns a copy of it
  14074. * @returns the new emitter
  14075. */
  14076. clone(): SphereParticleEmitter;
  14077. /**
  14078. * Called by the GPUParticleSystem to setup the update shader
  14079. * @param effect defines the update shader
  14080. */
  14081. applyToShader(effect: Effect): void;
  14082. /**
  14083. * Returns a string to use to update the GPU particles update shader
  14084. * @returns a string containng the defines string
  14085. */
  14086. getEffectDefines(): string;
  14087. /**
  14088. * Returns the string "SphereParticleEmitter"
  14089. * @returns a string containing the class name
  14090. */
  14091. getClassName(): string;
  14092. /**
  14093. * Serializes the particle system to a JSON object.
  14094. * @returns the JSON object
  14095. */
  14096. serialize(): any;
  14097. /**
  14098. * Parse properties from a JSON object
  14099. * @param serializationObject defines the JSON object
  14100. */
  14101. parse(serializationObject: any): void;
  14102. }
  14103. /**
  14104. * Particle emitter emitting particles from the inside of a sphere.
  14105. * It emits the particles randomly between two vectors.
  14106. */
  14107. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14108. /**
  14109. * The min limit of the emission direction.
  14110. */
  14111. direction1: Vector3;
  14112. /**
  14113. * The max limit of the emission direction.
  14114. */
  14115. direction2: Vector3;
  14116. /**
  14117. * Creates a new instance SphereDirectedParticleEmitter
  14118. * @param radius the radius of the emission sphere (1 by default)
  14119. * @param direction1 the min limit of the emission direction (up vector by default)
  14120. * @param direction2 the max limit of the emission direction (up vector by default)
  14121. */
  14122. constructor(radius?: number,
  14123. /**
  14124. * The min limit of the emission direction.
  14125. */
  14126. direction1?: Vector3,
  14127. /**
  14128. * The max limit of the emission direction.
  14129. */
  14130. direction2?: Vector3);
  14131. /**
  14132. * Called by the particle System when the direction is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param directionToUpdate is the direction vector to update with the result
  14135. * @param particle is the particle we are computed the direction for
  14136. */
  14137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14138. /**
  14139. * Clones the current emitter and returns a copy of it
  14140. * @returns the new emitter
  14141. */
  14142. clone(): SphereDirectedParticleEmitter;
  14143. /**
  14144. * Called by the GPUParticleSystem to setup the update shader
  14145. * @param effect defines the update shader
  14146. */
  14147. applyToShader(effect: Effect): void;
  14148. /**
  14149. * Returns a string to use to update the GPU particles update shader
  14150. * @returns a string containng the defines string
  14151. */
  14152. getEffectDefines(): string;
  14153. /**
  14154. * Returns the string "SphereDirectedParticleEmitter"
  14155. * @returns a string containing the class name
  14156. */
  14157. getClassName(): string;
  14158. /**
  14159. * Serializes the particle system to a JSON object.
  14160. * @returns the JSON object
  14161. */
  14162. serialize(): any;
  14163. /**
  14164. * Parse properties from a JSON object
  14165. * @param serializationObject defines the JSON object
  14166. */
  14167. parse(serializationObject: any): void;
  14168. }
  14169. }
  14170. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14171. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14172. import { Effect } from "babylonjs/Materials/effect";
  14173. import { Particle } from "babylonjs/Particles/particle";
  14174. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14175. import { Nullable } from "babylonjs/types";
  14176. /**
  14177. * Particle emitter emitting particles from a custom list of positions.
  14178. */
  14179. export class CustomParticleEmitter implements IParticleEmitterType {
  14180. /**
  14181. * Gets or sets the position generator that will create the inital position of each particle.
  14182. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14183. */
  14184. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14185. /**
  14186. * Gets or sets the destination generator that will create the final destination of each particle.
  14187. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14188. */
  14189. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14190. /**
  14191. * Creates a new instance CustomParticleEmitter
  14192. */
  14193. constructor();
  14194. /**
  14195. * Called by the particle System when the direction is computed for the created particle.
  14196. * @param worldMatrix is the world matrix of the particle system
  14197. * @param directionToUpdate is the direction vector to update with the result
  14198. * @param particle is the particle we are computed the direction for
  14199. * @param isLocal defines if the direction should be set in local space
  14200. */
  14201. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14202. /**
  14203. * Called by the particle System when the position is computed for the created particle.
  14204. * @param worldMatrix is the world matrix of the particle system
  14205. * @param positionToUpdate is the position vector to update with the result
  14206. * @param particle is the particle we are computed the position for
  14207. * @param isLocal defines if the position should be set in local space
  14208. */
  14209. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14210. /**
  14211. * Clones the current emitter and returns a copy of it
  14212. * @returns the new emitter
  14213. */
  14214. clone(): CustomParticleEmitter;
  14215. /**
  14216. * Called by the GPUParticleSystem to setup the update shader
  14217. * @param effect defines the update shader
  14218. */
  14219. applyToShader(effect: Effect): void;
  14220. /**
  14221. * Returns a string to use to update the GPU particles update shader
  14222. * @returns a string containng the defines string
  14223. */
  14224. getEffectDefines(): string;
  14225. /**
  14226. * Returns the string "PointParticleEmitter"
  14227. * @returns a string containing the class name
  14228. */
  14229. getClassName(): string;
  14230. /**
  14231. * Serializes the particle system to a JSON object.
  14232. * @returns the JSON object
  14233. */
  14234. serialize(): any;
  14235. /**
  14236. * Parse properties from a JSON object
  14237. * @param serializationObject defines the JSON object
  14238. */
  14239. parse(serializationObject: any): void;
  14240. }
  14241. }
  14242. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14243. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14244. import { Effect } from "babylonjs/Materials/effect";
  14245. import { Particle } from "babylonjs/Particles/particle";
  14246. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14247. import { Nullable } from "babylonjs/types";
  14248. import { Scene } from "babylonjs/scene";
  14249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14250. /**
  14251. * Particle emitter emitting particles from the inside of a box.
  14252. * It emits the particles randomly between 2 given directions.
  14253. */
  14254. export class MeshParticleEmitter implements IParticleEmitterType {
  14255. private _indices;
  14256. private _positions;
  14257. private _normals;
  14258. private _storedNormal;
  14259. private _mesh;
  14260. /**
  14261. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14262. */
  14263. direction1: Vector3;
  14264. /**
  14265. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14266. */
  14267. direction2: Vector3;
  14268. /**
  14269. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14270. */
  14271. useMeshNormalsForDirection: boolean;
  14272. /** Defines the mesh to use as source */
  14273. get mesh(): Nullable<AbstractMesh>;
  14274. set mesh(value: Nullable<AbstractMesh>);
  14275. /**
  14276. * Creates a new instance MeshParticleEmitter
  14277. * @param mesh defines the mesh to use as source
  14278. */
  14279. constructor(mesh?: Nullable<AbstractMesh>);
  14280. /**
  14281. * Called by the particle System when the direction is computed for the created particle.
  14282. * @param worldMatrix is the world matrix of the particle system
  14283. * @param directionToUpdate is the direction vector to update with the result
  14284. * @param particle is the particle we are computed the direction for
  14285. * @param isLocal defines if the direction should be set in local space
  14286. */
  14287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14288. /**
  14289. * Called by the particle System when the position is computed for the created particle.
  14290. * @param worldMatrix is the world matrix of the particle system
  14291. * @param positionToUpdate is the position vector to update with the result
  14292. * @param particle is the particle we are computed the position for
  14293. * @param isLocal defines if the position should be set in local space
  14294. */
  14295. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14296. /**
  14297. * Clones the current emitter and returns a copy of it
  14298. * @returns the new emitter
  14299. */
  14300. clone(): MeshParticleEmitter;
  14301. /**
  14302. * Called by the GPUParticleSystem to setup the update shader
  14303. * @param effect defines the update shader
  14304. */
  14305. applyToShader(effect: Effect): void;
  14306. /**
  14307. * Returns a string to use to update the GPU particles update shader
  14308. * @returns a string containng the defines string
  14309. */
  14310. getEffectDefines(): string;
  14311. /**
  14312. * Returns the string "BoxParticleEmitter"
  14313. * @returns a string containing the class name
  14314. */
  14315. getClassName(): string;
  14316. /**
  14317. * Serializes the particle system to a JSON object.
  14318. * @returns the JSON object
  14319. */
  14320. serialize(): any;
  14321. /**
  14322. * Parse properties from a JSON object
  14323. * @param serializationObject defines the JSON object
  14324. * @param scene defines the hosting scene
  14325. */
  14326. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14327. }
  14328. }
  14329. declare module "babylonjs/Particles/EmitterTypes/index" {
  14330. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14331. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14332. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14333. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14334. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14335. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14336. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14337. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14338. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14339. }
  14340. declare module "babylonjs/Particles/IParticleSystem" {
  14341. import { Nullable } from "babylonjs/types";
  14342. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14343. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14345. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14346. import { Scene } from "babylonjs/scene";
  14347. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14348. import { Effect } from "babylonjs/Materials/effect";
  14349. import { Observable } from "babylonjs/Misc/observable";
  14350. import { Animation } from "babylonjs/Animations/animation";
  14351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14352. /**
  14353. * Interface representing a particle system in Babylon.js.
  14354. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14355. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14356. */
  14357. export interface IParticleSystem {
  14358. /**
  14359. * List of animations used by the particle system.
  14360. */
  14361. animations: Animation[];
  14362. /**
  14363. * The id of the Particle system.
  14364. */
  14365. id: string;
  14366. /**
  14367. * The name of the Particle system.
  14368. */
  14369. name: string;
  14370. /**
  14371. * The emitter represents the Mesh or position we are attaching the particle system to.
  14372. */
  14373. emitter: Nullable<AbstractMesh | Vector3>;
  14374. /**
  14375. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14376. */
  14377. isBillboardBased: boolean;
  14378. /**
  14379. * The rendering group used by the Particle system to chose when to render.
  14380. */
  14381. renderingGroupId: number;
  14382. /**
  14383. * The layer mask we are rendering the particles through.
  14384. */
  14385. layerMask: number;
  14386. /**
  14387. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14388. */
  14389. updateSpeed: number;
  14390. /**
  14391. * The amount of time the particle system is running (depends of the overall update speed).
  14392. */
  14393. targetStopDuration: number;
  14394. /**
  14395. * The texture used to render each particle. (this can be a spritesheet)
  14396. */
  14397. particleTexture: Nullable<BaseTexture>;
  14398. /**
  14399. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14400. */
  14401. blendMode: number;
  14402. /**
  14403. * Minimum life time of emitting particles.
  14404. */
  14405. minLifeTime: number;
  14406. /**
  14407. * Maximum life time of emitting particles.
  14408. */
  14409. maxLifeTime: number;
  14410. /**
  14411. * Minimum Size of emitting particles.
  14412. */
  14413. minSize: number;
  14414. /**
  14415. * Maximum Size of emitting particles.
  14416. */
  14417. maxSize: number;
  14418. /**
  14419. * Minimum scale of emitting particles on X axis.
  14420. */
  14421. minScaleX: number;
  14422. /**
  14423. * Maximum scale of emitting particles on X axis.
  14424. */
  14425. maxScaleX: number;
  14426. /**
  14427. * Minimum scale of emitting particles on Y axis.
  14428. */
  14429. minScaleY: number;
  14430. /**
  14431. * Maximum scale of emitting particles on Y axis.
  14432. */
  14433. maxScaleY: number;
  14434. /**
  14435. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14436. */
  14437. color1: Color4;
  14438. /**
  14439. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14440. */
  14441. color2: Color4;
  14442. /**
  14443. * Color the particle will have at the end of its lifetime.
  14444. */
  14445. colorDead: Color4;
  14446. /**
  14447. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14448. */
  14449. emitRate: number;
  14450. /**
  14451. * You can use gravity if you want to give an orientation to your particles.
  14452. */
  14453. gravity: Vector3;
  14454. /**
  14455. * Minimum power of emitting particles.
  14456. */
  14457. minEmitPower: number;
  14458. /**
  14459. * Maximum power of emitting particles.
  14460. */
  14461. maxEmitPower: number;
  14462. /**
  14463. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14464. */
  14465. minAngularSpeed: number;
  14466. /**
  14467. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14468. */
  14469. maxAngularSpeed: number;
  14470. /**
  14471. * Gets or sets the minimal initial rotation in radians.
  14472. */
  14473. minInitialRotation: number;
  14474. /**
  14475. * Gets or sets the maximal initial rotation in radians.
  14476. */
  14477. maxInitialRotation: number;
  14478. /**
  14479. * The particle emitter type defines the emitter used by the particle system.
  14480. * It can be for example box, sphere, or cone...
  14481. */
  14482. particleEmitterType: Nullable<IParticleEmitterType>;
  14483. /**
  14484. * Defines the delay in milliseconds before starting the system (0 by default)
  14485. */
  14486. startDelay: number;
  14487. /**
  14488. * 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
  14489. */
  14490. preWarmCycles: number;
  14491. /**
  14492. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14493. */
  14494. preWarmStepOffset: number;
  14495. /**
  14496. * 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)
  14497. */
  14498. spriteCellChangeSpeed: number;
  14499. /**
  14500. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14501. */
  14502. startSpriteCellID: number;
  14503. /**
  14504. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14505. */
  14506. endSpriteCellID: number;
  14507. /**
  14508. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14509. */
  14510. spriteCellWidth: number;
  14511. /**
  14512. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14513. */
  14514. spriteCellHeight: number;
  14515. /**
  14516. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14517. */
  14518. spriteRandomStartCell: boolean;
  14519. /**
  14520. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14521. */
  14522. isAnimationSheetEnabled: boolean;
  14523. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14524. translationPivot: Vector2;
  14525. /**
  14526. * Gets or sets a texture used to add random noise to particle positions
  14527. */
  14528. noiseTexture: Nullable<BaseTexture>;
  14529. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14530. noiseStrength: Vector3;
  14531. /**
  14532. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14533. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14534. */
  14535. billboardMode: number;
  14536. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14537. limitVelocityDamping: number;
  14538. /**
  14539. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14540. */
  14541. beginAnimationOnStart: boolean;
  14542. /**
  14543. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14544. */
  14545. beginAnimationFrom: number;
  14546. /**
  14547. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14548. */
  14549. beginAnimationTo: number;
  14550. /**
  14551. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14552. */
  14553. beginAnimationLoop: boolean;
  14554. /**
  14555. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14556. */
  14557. disposeOnStop: boolean;
  14558. /**
  14559. * Specifies if the particles are updated in emitter local space or world space
  14560. */
  14561. isLocal: boolean;
  14562. /** Snippet ID if the particle system was created from the snippet server */
  14563. snippetId: string;
  14564. /** Gets or sets a matrix to use to compute projection */
  14565. defaultProjectionMatrix: Matrix;
  14566. /**
  14567. * Gets the maximum number of particles active at the same time.
  14568. * @returns The max number of active particles.
  14569. */
  14570. getCapacity(): number;
  14571. /**
  14572. * Gets the number of particles active at the same time.
  14573. * @returns The number of active particles.
  14574. */
  14575. getActiveCount(): number;
  14576. /**
  14577. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14578. * @returns True if it has been started, otherwise false.
  14579. */
  14580. isStarted(): boolean;
  14581. /**
  14582. * Animates the particle system for this frame.
  14583. */
  14584. animate(): void;
  14585. /**
  14586. * Renders the particle system in its current state.
  14587. * @returns the current number of particles
  14588. */
  14589. render(): number;
  14590. /**
  14591. * Dispose the particle system and frees its associated resources.
  14592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14593. */
  14594. dispose(disposeTexture?: boolean): void;
  14595. /**
  14596. * An event triggered when the system is disposed
  14597. */
  14598. onDisposeObservable: Observable<IParticleSystem>;
  14599. /**
  14600. * Clones the particle system.
  14601. * @param name The name of the cloned object
  14602. * @param newEmitter The new emitter to use
  14603. * @returns the cloned particle system
  14604. */
  14605. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14606. /**
  14607. * Serializes the particle system to a JSON object
  14608. * @param serializeTexture defines if the texture must be serialized as well
  14609. * @returns the JSON object
  14610. */
  14611. serialize(serializeTexture: boolean): any;
  14612. /**
  14613. * Rebuild the particle system
  14614. */
  14615. rebuild(): void;
  14616. /** Force the system to rebuild all gradients that need to be resync */
  14617. forceRefreshGradients(): void;
  14618. /**
  14619. * Starts the particle system and begins to emit
  14620. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14621. */
  14622. start(delay?: number): void;
  14623. /**
  14624. * Stops the particle system.
  14625. */
  14626. stop(): void;
  14627. /**
  14628. * Remove all active particles
  14629. */
  14630. reset(): void;
  14631. /**
  14632. * Gets a boolean indicating that the system is stopping
  14633. * @returns true if the system is currently stopping
  14634. */
  14635. isStopping(): boolean;
  14636. /**
  14637. * Is this system ready to be used/rendered
  14638. * @return true if the system is ready
  14639. */
  14640. isReady(): boolean;
  14641. /**
  14642. * Returns the string "ParticleSystem"
  14643. * @returns a string containing the class name
  14644. */
  14645. getClassName(): string;
  14646. /**
  14647. * Gets the custom effect used to render the particles
  14648. * @param blendMode Blend mode for which the effect should be retrieved
  14649. * @returns The effect
  14650. */
  14651. getCustomEffect(blendMode: number): Nullable<Effect>;
  14652. /**
  14653. * Sets the custom effect used to render the particles
  14654. * @param effect The effect to set
  14655. * @param blendMode Blend mode for which the effect should be set
  14656. */
  14657. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14658. /**
  14659. * Fill the defines array according to the current settings of the particle system
  14660. * @param defines Array to be updated
  14661. * @param blendMode blend mode to take into account when updating the array
  14662. */
  14663. fillDefines(defines: Array<string>, blendMode: number): void;
  14664. /**
  14665. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14666. * @param uniforms Uniforms array to fill
  14667. * @param attributes Attributes array to fill
  14668. * @param samplers Samplers array to fill
  14669. */
  14670. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14671. /**
  14672. * Observable that will be called just before the particles are drawn
  14673. */
  14674. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14675. /**
  14676. * Gets the name of the particle vertex shader
  14677. */
  14678. vertexShaderName: string;
  14679. /**
  14680. * Adds a new color gradient
  14681. * @param gradient defines the gradient to use (between 0 and 1)
  14682. * @param color1 defines the color to affect to the specified gradient
  14683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14684. * @returns the current particle system
  14685. */
  14686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14687. /**
  14688. * Remove a specific color gradient
  14689. * @param gradient defines the gradient to remove
  14690. * @returns the current particle system
  14691. */
  14692. removeColorGradient(gradient: number): IParticleSystem;
  14693. /**
  14694. * Adds a new size gradient
  14695. * @param gradient defines the gradient to use (between 0 and 1)
  14696. * @param factor defines the size factor to affect to the specified gradient
  14697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14698. * @returns the current particle system
  14699. */
  14700. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14701. /**
  14702. * Remove a specific size gradient
  14703. * @param gradient defines the gradient to remove
  14704. * @returns the current particle system
  14705. */
  14706. removeSizeGradient(gradient: number): IParticleSystem;
  14707. /**
  14708. * Gets the current list of color gradients.
  14709. * You must use addColorGradient and removeColorGradient to udpate this list
  14710. * @returns the list of color gradients
  14711. */
  14712. getColorGradients(): Nullable<Array<ColorGradient>>;
  14713. /**
  14714. * Gets the current list of size gradients.
  14715. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14716. * @returns the list of size gradients
  14717. */
  14718. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14719. /**
  14720. * Gets the current list of angular speed gradients.
  14721. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14722. * @returns the list of angular speed gradients
  14723. */
  14724. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14725. /**
  14726. * Adds a new angular speed gradient
  14727. * @param gradient defines the gradient to use (between 0 and 1)
  14728. * @param factor defines the angular speed to affect to the specified gradient
  14729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14730. * @returns the current particle system
  14731. */
  14732. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14733. /**
  14734. * Remove a specific angular speed gradient
  14735. * @param gradient defines the gradient to remove
  14736. * @returns the current particle system
  14737. */
  14738. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14739. /**
  14740. * Gets the current list of velocity gradients.
  14741. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14742. * @returns the list of velocity gradients
  14743. */
  14744. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14745. /**
  14746. * Adds a new velocity gradient
  14747. * @param gradient defines the gradient to use (between 0 and 1)
  14748. * @param factor defines the velocity to affect to the specified gradient
  14749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14750. * @returns the current particle system
  14751. */
  14752. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14753. /**
  14754. * Remove a specific velocity gradient
  14755. * @param gradient defines the gradient to remove
  14756. * @returns the current particle system
  14757. */
  14758. removeVelocityGradient(gradient: number): IParticleSystem;
  14759. /**
  14760. * Gets the current list of limit velocity gradients.
  14761. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14762. * @returns the list of limit velocity gradients
  14763. */
  14764. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14765. /**
  14766. * Adds a new limit velocity gradient
  14767. * @param gradient defines the gradient to use (between 0 and 1)
  14768. * @param factor defines the limit velocity to affect to the specified gradient
  14769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14770. * @returns the current particle system
  14771. */
  14772. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14773. /**
  14774. * Remove a specific limit velocity gradient
  14775. * @param gradient defines the gradient to remove
  14776. * @returns the current particle system
  14777. */
  14778. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14779. /**
  14780. * Adds a new drag gradient
  14781. * @param gradient defines the gradient to use (between 0 and 1)
  14782. * @param factor defines the drag to affect to the specified gradient
  14783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14784. * @returns the current particle system
  14785. */
  14786. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14787. /**
  14788. * Remove a specific drag gradient
  14789. * @param gradient defines the gradient to remove
  14790. * @returns the current particle system
  14791. */
  14792. removeDragGradient(gradient: number): IParticleSystem;
  14793. /**
  14794. * Gets the current list of drag gradients.
  14795. * You must use addDragGradient and removeDragGradient to udpate this list
  14796. * @returns the list of drag gradients
  14797. */
  14798. getDragGradients(): Nullable<Array<FactorGradient>>;
  14799. /**
  14800. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14801. * @param gradient defines the gradient to use (between 0 and 1)
  14802. * @param factor defines the emit rate to affect to the specified gradient
  14803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14804. * @returns the current particle system
  14805. */
  14806. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14807. /**
  14808. * Remove a specific emit rate gradient
  14809. * @param gradient defines the gradient to remove
  14810. * @returns the current particle system
  14811. */
  14812. removeEmitRateGradient(gradient: number): IParticleSystem;
  14813. /**
  14814. * Gets the current list of emit rate gradients.
  14815. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14816. * @returns the list of emit rate gradients
  14817. */
  14818. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14819. /**
  14820. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14821. * @param gradient defines the gradient to use (between 0 and 1)
  14822. * @param factor defines the start size to affect to the specified gradient
  14823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14824. * @returns the current particle system
  14825. */
  14826. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14827. /**
  14828. * Remove a specific start size gradient
  14829. * @param gradient defines the gradient to remove
  14830. * @returns the current particle system
  14831. */
  14832. removeStartSizeGradient(gradient: number): IParticleSystem;
  14833. /**
  14834. * Gets the current list of start size gradients.
  14835. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14836. * @returns the list of start size gradients
  14837. */
  14838. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14839. /**
  14840. * Adds a new life time gradient
  14841. * @param gradient defines the gradient to use (between 0 and 1)
  14842. * @param factor defines the life time factor to affect to the specified gradient
  14843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14844. * @returns the current particle system
  14845. */
  14846. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14847. /**
  14848. * Remove a specific life time gradient
  14849. * @param gradient defines the gradient to remove
  14850. * @returns the current particle system
  14851. */
  14852. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14853. /**
  14854. * Gets the current list of life time gradients.
  14855. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14856. * @returns the list of life time gradients
  14857. */
  14858. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14859. /**
  14860. * Gets the current list of color gradients.
  14861. * You must use addColorGradient and removeColorGradient to udpate this list
  14862. * @returns the list of color gradients
  14863. */
  14864. getColorGradients(): Nullable<Array<ColorGradient>>;
  14865. /**
  14866. * Adds a new ramp gradient used to remap particle colors
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param color defines the color to affect to the specified gradient
  14869. * @returns the current particle system
  14870. */
  14871. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14872. /**
  14873. * Gets the current list of ramp gradients.
  14874. * You must use addRampGradient and removeRampGradient to udpate this list
  14875. * @returns the list of ramp gradients
  14876. */
  14877. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14878. /** Gets or sets a boolean indicating that ramp gradients must be used
  14879. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14880. */
  14881. useRampGradients: boolean;
  14882. /**
  14883. * Adds a new color remap gradient
  14884. * @param gradient defines the gradient to use (between 0 and 1)
  14885. * @param min defines the color remap minimal range
  14886. * @param max defines the color remap maximal range
  14887. * @returns the current particle system
  14888. */
  14889. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14890. /**
  14891. * Gets the current list of color remap gradients.
  14892. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14893. * @returns the list of color remap gradients
  14894. */
  14895. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14896. /**
  14897. * Adds a new alpha remap gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param min defines the alpha remap minimal range
  14900. * @param max defines the alpha remap maximal range
  14901. * @returns the current particle system
  14902. */
  14903. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14904. /**
  14905. * Gets the current list of alpha remap gradients.
  14906. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14907. * @returns the list of alpha remap gradients
  14908. */
  14909. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14910. /**
  14911. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14912. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14913. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14914. * @returns the emitter
  14915. */
  14916. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14917. /**
  14918. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14919. * @param radius The radius of the hemisphere to emit from
  14920. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14921. * @returns the emitter
  14922. */
  14923. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14924. /**
  14925. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14926. * @param radius The radius of the sphere to emit from
  14927. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14928. * @returns the emitter
  14929. */
  14930. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14931. /**
  14932. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14933. * @param radius The radius of the sphere to emit from
  14934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14936. * @returns the emitter
  14937. */
  14938. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14939. /**
  14940. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14941. * @param radius The radius of the emission cylinder
  14942. * @param height The height of the emission cylinder
  14943. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14944. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14945. * @returns the emitter
  14946. */
  14947. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14948. /**
  14949. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14950. * @param radius The radius of the cylinder to emit from
  14951. * @param height The height of the emission cylinder
  14952. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14953. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14954. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14955. * @returns the emitter
  14956. */
  14957. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14958. /**
  14959. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14960. * @param radius The radius of the cone to emit from
  14961. * @param angle The base angle of the cone
  14962. * @returns the emitter
  14963. */
  14964. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14965. /**
  14966. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14967. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14968. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14969. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14970. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14971. * @returns the emitter
  14972. */
  14973. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14974. /**
  14975. * Get hosting scene
  14976. * @returns the scene
  14977. */
  14978. getScene(): Nullable<Scene>;
  14979. }
  14980. }
  14981. declare module "babylonjs/Meshes/transformNode" {
  14982. import { DeepImmutable } from "babylonjs/types";
  14983. import { Observable } from "babylonjs/Misc/observable";
  14984. import { Nullable } from "babylonjs/types";
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { Scene } from "babylonjs/scene";
  14987. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14988. import { Node } from "babylonjs/node";
  14989. import { Bone } from "babylonjs/Bones/bone";
  14990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14991. import { Space } from "babylonjs/Maths/math.axis";
  14992. /**
  14993. * 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.
  14994. * @see https://doc.babylonjs.com/how_to/transformnode
  14995. */
  14996. export class TransformNode extends Node {
  14997. /**
  14998. * Object will not rotate to face the camera
  14999. */
  15000. static BILLBOARDMODE_NONE: number;
  15001. /**
  15002. * Object will rotate to face the camera but only on the x axis
  15003. */
  15004. static BILLBOARDMODE_X: number;
  15005. /**
  15006. * Object will rotate to face the camera but only on the y axis
  15007. */
  15008. static BILLBOARDMODE_Y: number;
  15009. /**
  15010. * Object will rotate to face the camera but only on the z axis
  15011. */
  15012. static BILLBOARDMODE_Z: number;
  15013. /**
  15014. * Object will rotate to face the camera
  15015. */
  15016. static BILLBOARDMODE_ALL: number;
  15017. /**
  15018. * Object will rotate to face the camera's position instead of orientation
  15019. */
  15020. static BILLBOARDMODE_USE_POSITION: number;
  15021. private static _TmpRotation;
  15022. private static _TmpScaling;
  15023. private static _TmpTranslation;
  15024. private _forward;
  15025. private _forwardInverted;
  15026. private _up;
  15027. private _right;
  15028. private _rightInverted;
  15029. private _position;
  15030. private _rotation;
  15031. private _rotationQuaternion;
  15032. protected _scaling: Vector3;
  15033. protected _isDirty: boolean;
  15034. private _transformToBoneReferal;
  15035. private _isAbsoluteSynced;
  15036. private _billboardMode;
  15037. /**
  15038. * Gets or sets the billboard mode. Default is 0.
  15039. *
  15040. * | Value | Type | Description |
  15041. * | --- | --- | --- |
  15042. * | 0 | BILLBOARDMODE_NONE | |
  15043. * | 1 | BILLBOARDMODE_X | |
  15044. * | 2 | BILLBOARDMODE_Y | |
  15045. * | 4 | BILLBOARDMODE_Z | |
  15046. * | 7 | BILLBOARDMODE_ALL | |
  15047. *
  15048. */
  15049. get billboardMode(): number;
  15050. set billboardMode(value: number);
  15051. private _preserveParentRotationForBillboard;
  15052. /**
  15053. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15054. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15055. */
  15056. get preserveParentRotationForBillboard(): boolean;
  15057. set preserveParentRotationForBillboard(value: boolean);
  15058. /**
  15059. * 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
  15060. */
  15061. scalingDeterminant: number;
  15062. private _infiniteDistance;
  15063. /**
  15064. * Gets or sets the distance of the object to max, often used by skybox
  15065. */
  15066. get infiniteDistance(): boolean;
  15067. set infiniteDistance(value: boolean);
  15068. /**
  15069. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15070. * By default the system will update normals to compensate
  15071. */
  15072. ignoreNonUniformScaling: boolean;
  15073. /**
  15074. * 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
  15075. */
  15076. reIntegrateRotationIntoRotationQuaternion: boolean;
  15077. /** @hidden */
  15078. _poseMatrix: Nullable<Matrix>;
  15079. /** @hidden */
  15080. _localMatrix: Matrix;
  15081. private _usePivotMatrix;
  15082. private _absolutePosition;
  15083. private _absoluteScaling;
  15084. private _absoluteRotationQuaternion;
  15085. private _pivotMatrix;
  15086. private _pivotMatrixInverse;
  15087. /** @hidden */
  15088. _postMultiplyPivotMatrix: boolean;
  15089. protected _isWorldMatrixFrozen: boolean;
  15090. /** @hidden */
  15091. _indexInSceneTransformNodesArray: number;
  15092. /**
  15093. * An event triggered after the world matrix is updated
  15094. */
  15095. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15096. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15097. /**
  15098. * Gets a string identifying the name of the class
  15099. * @returns "TransformNode" string
  15100. */
  15101. getClassName(): string;
  15102. /**
  15103. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15104. */
  15105. get position(): Vector3;
  15106. set position(newPosition: Vector3);
  15107. /**
  15108. * 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)).
  15109. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15110. */
  15111. get rotation(): Vector3;
  15112. set rotation(newRotation: Vector3);
  15113. /**
  15114. * 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)).
  15115. */
  15116. get scaling(): Vector3;
  15117. set scaling(newScaling: Vector3);
  15118. /**
  15119. * 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).
  15120. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15121. */
  15122. get rotationQuaternion(): Nullable<Quaternion>;
  15123. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15124. /**
  15125. * The forward direction of that transform in world space.
  15126. */
  15127. get forward(): Vector3;
  15128. /**
  15129. * The up direction of that transform in world space.
  15130. */
  15131. get up(): Vector3;
  15132. /**
  15133. * The right direction of that transform in world space.
  15134. */
  15135. get right(): Vector3;
  15136. /**
  15137. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15138. * @param matrix the matrix to copy the pose from
  15139. * @returns this TransformNode.
  15140. */
  15141. updatePoseMatrix(matrix: Matrix): TransformNode;
  15142. /**
  15143. * Returns the mesh Pose matrix.
  15144. * @returns the pose matrix
  15145. */
  15146. getPoseMatrix(): Matrix;
  15147. /** @hidden */
  15148. _isSynchronized(): boolean;
  15149. /** @hidden */
  15150. _initCache(): void;
  15151. /**
  15152. * Flag the transform node as dirty (Forcing it to update everything)
  15153. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15154. * @returns this transform node
  15155. */
  15156. markAsDirty(property: string): TransformNode;
  15157. /**
  15158. * Returns the current mesh absolute position.
  15159. * Returns a Vector3.
  15160. */
  15161. get absolutePosition(): Vector3;
  15162. /**
  15163. * Returns the current mesh absolute scaling.
  15164. * Returns a Vector3.
  15165. */
  15166. get absoluteScaling(): Vector3;
  15167. /**
  15168. * Returns the current mesh absolute rotation.
  15169. * Returns a Quaternion.
  15170. */
  15171. get absoluteRotationQuaternion(): Quaternion;
  15172. /**
  15173. * Sets a new matrix to apply before all other transformation
  15174. * @param matrix defines the transform matrix
  15175. * @returns the current TransformNode
  15176. */
  15177. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15178. /**
  15179. * Sets a new pivot matrix to the current node
  15180. * @param matrix defines the new pivot matrix to use
  15181. * @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
  15182. * @returns the current TransformNode
  15183. */
  15184. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15185. /**
  15186. * Returns the mesh pivot matrix.
  15187. * Default : Identity.
  15188. * @returns the matrix
  15189. */
  15190. getPivotMatrix(): Matrix;
  15191. /**
  15192. * Instantiate (when possible) or clone that node with its hierarchy
  15193. * @param newParent defines the new parent to use for the instance (or clone)
  15194. * @param options defines options to configure how copy is done
  15195. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15196. * @returns an instance (or a clone) of the current node with its hiearchy
  15197. */
  15198. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15199. doNotInstantiate: boolean;
  15200. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15201. /**
  15202. * Prevents the World matrix to be computed any longer
  15203. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15204. * @returns the TransformNode.
  15205. */
  15206. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15207. /**
  15208. * Allows back the World matrix computation.
  15209. * @returns the TransformNode.
  15210. */
  15211. unfreezeWorldMatrix(): this;
  15212. /**
  15213. * True if the World matrix has been frozen.
  15214. */
  15215. get isWorldMatrixFrozen(): boolean;
  15216. /**
  15217. * Retuns the mesh absolute position in the World.
  15218. * @returns a Vector3.
  15219. */
  15220. getAbsolutePosition(): Vector3;
  15221. /**
  15222. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15223. * @param absolutePosition the absolute position to set
  15224. * @returns the TransformNode.
  15225. */
  15226. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15227. /**
  15228. * Sets the mesh position in its local space.
  15229. * @param vector3 the position to set in localspace
  15230. * @returns the TransformNode.
  15231. */
  15232. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15233. /**
  15234. * Returns the mesh position in the local space from the current World matrix values.
  15235. * @returns a new Vector3.
  15236. */
  15237. getPositionExpressedInLocalSpace(): Vector3;
  15238. /**
  15239. * Translates the mesh along the passed Vector3 in its local space.
  15240. * @param vector3 the distance to translate in localspace
  15241. * @returns the TransformNode.
  15242. */
  15243. locallyTranslate(vector3: Vector3): TransformNode;
  15244. private static _lookAtVectorCache;
  15245. /**
  15246. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15247. * @param targetPoint the position (must be in same space as current mesh) to look at
  15248. * @param yawCor optional yaw (y-axis) correction in radians
  15249. * @param pitchCor optional pitch (x-axis) correction in radians
  15250. * @param rollCor optional roll (z-axis) correction in radians
  15251. * @param space the choosen space of the target
  15252. * @returns the TransformNode.
  15253. */
  15254. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15255. /**
  15256. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15257. * This Vector3 is expressed in the World space.
  15258. * @param localAxis axis to rotate
  15259. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15260. */
  15261. getDirection(localAxis: Vector3): Vector3;
  15262. /**
  15263. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15264. * localAxis is expressed in the mesh local space.
  15265. * result is computed in the Wordl space from the mesh World matrix.
  15266. * @param localAxis axis to rotate
  15267. * @param result the resulting transformnode
  15268. * @returns this TransformNode.
  15269. */
  15270. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15271. /**
  15272. * Sets this transform node rotation to the given local axis.
  15273. * @param localAxis the axis in local space
  15274. * @param yawCor optional yaw (y-axis) correction in radians
  15275. * @param pitchCor optional pitch (x-axis) correction in radians
  15276. * @param rollCor optional roll (z-axis) correction in radians
  15277. * @returns this TransformNode
  15278. */
  15279. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15280. /**
  15281. * Sets a new pivot point to the current node
  15282. * @param point defines the new pivot point to use
  15283. * @param space defines if the point is in world or local space (local by default)
  15284. * @returns the current TransformNode
  15285. */
  15286. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15287. /**
  15288. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15289. * @returns the pivot point
  15290. */
  15291. getPivotPoint(): Vector3;
  15292. /**
  15293. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15294. * @param result the vector3 to store the result
  15295. * @returns this TransformNode.
  15296. */
  15297. getPivotPointToRef(result: Vector3): TransformNode;
  15298. /**
  15299. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15300. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15301. */
  15302. getAbsolutePivotPoint(): Vector3;
  15303. /**
  15304. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15305. * @param result vector3 to store the result
  15306. * @returns this TransformNode.
  15307. */
  15308. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15309. /**
  15310. * Defines the passed node as the parent of the current node.
  15311. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15312. * @see https://doc.babylonjs.com/how_to/parenting
  15313. * @param node the node ot set as the parent
  15314. * @returns this TransformNode.
  15315. */
  15316. setParent(node: Nullable<Node>): TransformNode;
  15317. private _nonUniformScaling;
  15318. /**
  15319. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15320. */
  15321. get nonUniformScaling(): boolean;
  15322. /** @hidden */
  15323. _updateNonUniformScalingState(value: boolean): boolean;
  15324. /**
  15325. * Attach the current TransformNode to another TransformNode associated with a bone
  15326. * @param bone Bone affecting the TransformNode
  15327. * @param affectedTransformNode TransformNode associated with the bone
  15328. * @returns this object
  15329. */
  15330. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15331. /**
  15332. * Detach the transform node if its associated with a bone
  15333. * @returns this object
  15334. */
  15335. detachFromBone(): TransformNode;
  15336. private static _rotationAxisCache;
  15337. /**
  15338. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15339. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15340. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15341. * The passed axis is also normalized.
  15342. * @param axis the axis to rotate around
  15343. * @param amount the amount to rotate in radians
  15344. * @param space Space to rotate in (Default: local)
  15345. * @returns the TransformNode.
  15346. */
  15347. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15348. /**
  15349. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15350. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15351. * The passed axis is also normalized. .
  15352. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15353. * @param point the point to rotate around
  15354. * @param axis the axis to rotate around
  15355. * @param amount the amount to rotate in radians
  15356. * @returns the TransformNode
  15357. */
  15358. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15359. /**
  15360. * Translates the mesh along the axis vector for the passed distance in the given space.
  15361. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15362. * @param axis the axis to translate in
  15363. * @param distance the distance to translate
  15364. * @param space Space to rotate in (Default: local)
  15365. * @returns the TransformNode.
  15366. */
  15367. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15368. /**
  15369. * Adds a rotation step to the mesh current rotation.
  15370. * x, y, z are Euler angles expressed in radians.
  15371. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15372. * This means this rotation is made in the mesh local space only.
  15373. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15374. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15375. * ```javascript
  15376. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15377. * ```
  15378. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15379. * 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.
  15380. * @param x Rotation to add
  15381. * @param y Rotation to add
  15382. * @param z Rotation to add
  15383. * @returns the TransformNode.
  15384. */
  15385. addRotation(x: number, y: number, z: number): TransformNode;
  15386. /**
  15387. * @hidden
  15388. */
  15389. protected _getEffectiveParent(): Nullable<Node>;
  15390. /**
  15391. * Computes the world matrix of the node
  15392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15393. * @returns the world matrix
  15394. */
  15395. computeWorldMatrix(force?: boolean): Matrix;
  15396. /**
  15397. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15398. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15399. */
  15400. resetLocalMatrix(independentOfChildren?: boolean): void;
  15401. protected _afterComputeWorldMatrix(): void;
  15402. /**
  15403. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15404. * @param func callback function to add
  15405. *
  15406. * @returns the TransformNode.
  15407. */
  15408. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15409. /**
  15410. * Removes a registered callback function.
  15411. * @param func callback function to remove
  15412. * @returns the TransformNode.
  15413. */
  15414. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15415. /**
  15416. * Gets the position of the current mesh in camera space
  15417. * @param camera defines the camera to use
  15418. * @returns a position
  15419. */
  15420. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15421. /**
  15422. * Returns the distance from the mesh to the active camera
  15423. * @param camera defines the camera to use
  15424. * @returns the distance
  15425. */
  15426. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15427. /**
  15428. * Clone the current transform node
  15429. * @param name Name of the new clone
  15430. * @param newParent New parent for the clone
  15431. * @param doNotCloneChildren Do not clone children hierarchy
  15432. * @returns the new transform node
  15433. */
  15434. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15435. /**
  15436. * Serializes the objects information.
  15437. * @param currentSerializationObject defines the object to serialize in
  15438. * @returns the serialized object
  15439. */
  15440. serialize(currentSerializationObject?: any): any;
  15441. /**
  15442. * Returns a new TransformNode object parsed from the source provided.
  15443. * @param parsedTransformNode is the source.
  15444. * @param scene the scne the object belongs to
  15445. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15446. * @returns a new TransformNode object parsed from the source provided.
  15447. */
  15448. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15449. /**
  15450. * Get all child-transformNodes of this node
  15451. * @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
  15452. * @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
  15453. * @returns an array of TransformNode
  15454. */
  15455. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15456. /**
  15457. * Releases resources associated with this transform node.
  15458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15460. */
  15461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15462. /**
  15463. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15464. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15465. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15466. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15467. * @returns the current mesh
  15468. */
  15469. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15470. private _syncAbsoluteScalingAndRotation;
  15471. }
  15472. }
  15473. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15474. /**
  15475. * Class used to override all child animations of a given target
  15476. */
  15477. export class AnimationPropertiesOverride {
  15478. /**
  15479. * Gets or sets a value indicating if animation blending must be used
  15480. */
  15481. enableBlending: boolean;
  15482. /**
  15483. * Gets or sets the blending speed to use when enableBlending is true
  15484. */
  15485. blendingSpeed: number;
  15486. /**
  15487. * Gets or sets the default loop mode to use
  15488. */
  15489. loopMode: number;
  15490. }
  15491. }
  15492. declare module "babylonjs/Bones/bone" {
  15493. import { Skeleton } from "babylonjs/Bones/skeleton";
  15494. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15495. import { Nullable } from "babylonjs/types";
  15496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15497. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15498. import { Node } from "babylonjs/node";
  15499. import { Space } from "babylonjs/Maths/math.axis";
  15500. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15501. /**
  15502. * Class used to store bone information
  15503. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15504. */
  15505. export class Bone extends Node {
  15506. /**
  15507. * defines the bone name
  15508. */
  15509. name: string;
  15510. private static _tmpVecs;
  15511. private static _tmpQuat;
  15512. private static _tmpMats;
  15513. /**
  15514. * Gets the list of child bones
  15515. */
  15516. children: Bone[];
  15517. /** Gets the animations associated with this bone */
  15518. animations: import("babylonjs/Animations/animation").Animation[];
  15519. /**
  15520. * Gets or sets bone length
  15521. */
  15522. length: number;
  15523. /**
  15524. * @hidden Internal only
  15525. * Set this value to map this bone to a different index in the transform matrices
  15526. * Set this value to -1 to exclude the bone from the transform matrices
  15527. */
  15528. _index: Nullable<number>;
  15529. private _skeleton;
  15530. private _localMatrix;
  15531. private _restPose;
  15532. private _bindPose;
  15533. private _baseMatrix;
  15534. private _absoluteTransform;
  15535. private _invertedAbsoluteTransform;
  15536. private _parent;
  15537. private _scalingDeterminant;
  15538. private _worldTransform;
  15539. private _localScaling;
  15540. private _localRotation;
  15541. private _localPosition;
  15542. private _needToDecompose;
  15543. private _needToCompose;
  15544. /** @hidden */
  15545. _linkedTransformNode: Nullable<TransformNode>;
  15546. /** @hidden */
  15547. _waitingTransformNodeId: Nullable<string>;
  15548. /** @hidden */
  15549. get _matrix(): Matrix;
  15550. /** @hidden */
  15551. set _matrix(value: Matrix);
  15552. /**
  15553. * Create a new bone
  15554. * @param name defines the bone name
  15555. * @param skeleton defines the parent skeleton
  15556. * @param parentBone defines the parent (can be null if the bone is the root)
  15557. * @param localMatrix defines the local matrix
  15558. * @param restPose defines the rest pose matrix
  15559. * @param baseMatrix defines the base matrix
  15560. * @param index defines index of the bone in the hiearchy
  15561. */
  15562. constructor(
  15563. /**
  15564. * defines the bone name
  15565. */
  15566. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15567. /**
  15568. * Gets the current object class name.
  15569. * @return the class name
  15570. */
  15571. getClassName(): string;
  15572. /**
  15573. * Gets the parent skeleton
  15574. * @returns a skeleton
  15575. */
  15576. getSkeleton(): Skeleton;
  15577. /**
  15578. * Gets parent bone
  15579. * @returns a bone or null if the bone is the root of the bone hierarchy
  15580. */
  15581. getParent(): Nullable<Bone>;
  15582. /**
  15583. * Returns an array containing the root bones
  15584. * @returns an array containing the root bones
  15585. */
  15586. getChildren(): Array<Bone>;
  15587. /**
  15588. * Gets the node index in matrix array generated for rendering
  15589. * @returns the node index
  15590. */
  15591. getIndex(): number;
  15592. /**
  15593. * Sets the parent bone
  15594. * @param parent defines the parent (can be null if the bone is the root)
  15595. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15596. */
  15597. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15598. /**
  15599. * Gets the local matrix
  15600. * @returns a matrix
  15601. */
  15602. getLocalMatrix(): Matrix;
  15603. /**
  15604. * Gets the base matrix (initial matrix which remains unchanged)
  15605. * @returns a matrix
  15606. */
  15607. getBaseMatrix(): Matrix;
  15608. /**
  15609. * Gets the rest pose matrix
  15610. * @returns a matrix
  15611. */
  15612. getRestPose(): Matrix;
  15613. /**
  15614. * Sets the rest pose matrix
  15615. * @param matrix the local-space rest pose to set for this bone
  15616. */
  15617. setRestPose(matrix: Matrix): void;
  15618. /**
  15619. * Gets the bind pose matrix
  15620. * @returns the bind pose matrix
  15621. */
  15622. getBindPose(): Matrix;
  15623. /**
  15624. * Sets the bind pose matrix
  15625. * @param matrix the local-space bind pose to set for this bone
  15626. */
  15627. setBindPose(matrix: Matrix): void;
  15628. /**
  15629. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15630. */
  15631. getWorldMatrix(): Matrix;
  15632. /**
  15633. * Sets the local matrix to rest pose matrix
  15634. */
  15635. returnToRest(): void;
  15636. /**
  15637. * Gets the inverse of the absolute transform matrix.
  15638. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15639. * @returns a matrix
  15640. */
  15641. getInvertedAbsoluteTransform(): Matrix;
  15642. /**
  15643. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15644. * @returns a matrix
  15645. */
  15646. getAbsoluteTransform(): Matrix;
  15647. /**
  15648. * Links with the given transform node.
  15649. * The local matrix of this bone is copied from the transform node every frame.
  15650. * @param transformNode defines the transform node to link to
  15651. */
  15652. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15653. /**
  15654. * Gets the node used to drive the bone's transformation
  15655. * @returns a transform node or null
  15656. */
  15657. getTransformNode(): Nullable<TransformNode>;
  15658. /** Gets or sets current position (in local space) */
  15659. get position(): Vector3;
  15660. set position(newPosition: Vector3);
  15661. /** Gets or sets current rotation (in local space) */
  15662. get rotation(): Vector3;
  15663. set rotation(newRotation: Vector3);
  15664. /** Gets or sets current rotation quaternion (in local space) */
  15665. get rotationQuaternion(): Quaternion;
  15666. set rotationQuaternion(newRotation: Quaternion);
  15667. /** Gets or sets current scaling (in local space) */
  15668. get scaling(): Vector3;
  15669. set scaling(newScaling: Vector3);
  15670. /**
  15671. * Gets the animation properties override
  15672. */
  15673. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15674. private _decompose;
  15675. private _compose;
  15676. /**
  15677. * Update the base and local matrices
  15678. * @param matrix defines the new base or local matrix
  15679. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15680. * @param updateLocalMatrix defines if the local matrix should be updated
  15681. */
  15682. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15683. /** @hidden */
  15684. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15685. /**
  15686. * Flag the bone as dirty (Forcing it to update everything)
  15687. */
  15688. markAsDirty(): void;
  15689. /** @hidden */
  15690. _markAsDirtyAndCompose(): void;
  15691. private _markAsDirtyAndDecompose;
  15692. /**
  15693. * Translate the bone in local or world space
  15694. * @param vec The amount to translate the bone
  15695. * @param space The space that the translation is in
  15696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15697. */
  15698. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15699. /**
  15700. * Set the postion of the bone in local or world space
  15701. * @param position The position to set the bone
  15702. * @param space The space that the position is in
  15703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15704. */
  15705. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15706. /**
  15707. * Set the absolute position of the bone (world space)
  15708. * @param position The position to set the bone
  15709. * @param mesh The mesh that this bone is attached to
  15710. */
  15711. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15712. /**
  15713. * Scale the bone on the x, y and z axes (in local space)
  15714. * @param x The amount to scale the bone on the x axis
  15715. * @param y The amount to scale the bone on the y axis
  15716. * @param z The amount to scale the bone on the z axis
  15717. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15718. */
  15719. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15720. /**
  15721. * Set the bone scaling in local space
  15722. * @param scale defines the scaling vector
  15723. */
  15724. setScale(scale: Vector3): void;
  15725. /**
  15726. * Gets the current scaling in local space
  15727. * @returns the current scaling vector
  15728. */
  15729. getScale(): Vector3;
  15730. /**
  15731. * Gets the current scaling in local space and stores it in a target vector
  15732. * @param result defines the target vector
  15733. */
  15734. getScaleToRef(result: Vector3): void;
  15735. /**
  15736. * Set the yaw, pitch, and roll of the bone in local or world space
  15737. * @param yaw The rotation of the bone on the y axis
  15738. * @param pitch The rotation of the bone on the x axis
  15739. * @param roll The rotation of the bone on the z axis
  15740. * @param space The space that the axes of rotation are in
  15741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15742. */
  15743. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15744. /**
  15745. * Add a rotation to the bone on an axis in local or world space
  15746. * @param axis The axis to rotate the bone on
  15747. * @param amount The amount to rotate the bone
  15748. * @param space The space that the axis is in
  15749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15750. */
  15751. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15752. /**
  15753. * Set the rotation of the bone to a particular axis angle in local or world space
  15754. * @param axis The axis to rotate the bone on
  15755. * @param angle The angle that the bone should be rotated to
  15756. * @param space The space that the axis is in
  15757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15758. */
  15759. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15760. /**
  15761. * Set the euler rotation of the bone in local of world space
  15762. * @param rotation The euler rotation that the bone should be set to
  15763. * @param space The space that the rotation is in
  15764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15765. */
  15766. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15767. /**
  15768. * Set the quaternion rotation of the bone in local of world space
  15769. * @param quat The quaternion rotation that the bone should be set to
  15770. * @param space The space that the rotation is in
  15771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15772. */
  15773. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15774. /**
  15775. * Set the rotation matrix of the bone in local of world space
  15776. * @param rotMat The rotation matrix that the bone should be set to
  15777. * @param space The space that the rotation is in
  15778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15779. */
  15780. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15781. private _rotateWithMatrix;
  15782. private _getNegativeRotationToRef;
  15783. /**
  15784. * Get the position of the bone in local or world space
  15785. * @param space The space that the returned position is in
  15786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15787. * @returns The position of the bone
  15788. */
  15789. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15790. /**
  15791. * Copy the position of the bone to a vector3 in local or world space
  15792. * @param space The space that the returned position is in
  15793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15794. * @param result The vector3 to copy the position to
  15795. */
  15796. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15797. /**
  15798. * Get the absolute position of the bone (world space)
  15799. * @param mesh The mesh that this bone is attached to
  15800. * @returns The absolute position of the bone
  15801. */
  15802. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15803. /**
  15804. * Copy the absolute position of the bone (world space) to the result param
  15805. * @param mesh The mesh that this bone is attached to
  15806. * @param result The vector3 to copy the absolute position to
  15807. */
  15808. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15809. /**
  15810. * Compute the absolute transforms of this bone and its children
  15811. */
  15812. computeAbsoluteTransforms(): void;
  15813. /**
  15814. * Get the world direction from an axis that is in the local space of the bone
  15815. * @param localAxis The local direction that is used to compute the world direction
  15816. * @param mesh The mesh that this bone is attached to
  15817. * @returns The world direction
  15818. */
  15819. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15820. /**
  15821. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15822. * @param localAxis The local direction that is used to compute the world direction
  15823. * @param mesh The mesh that this bone is attached to
  15824. * @param result The vector3 that the world direction will be copied to
  15825. */
  15826. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15827. /**
  15828. * Get the euler rotation of the bone in local or world space
  15829. * @param space The space that the rotation should be in
  15830. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15831. * @returns The euler rotation
  15832. */
  15833. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15834. /**
  15835. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15836. * @param space The space that the rotation should be in
  15837. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15838. * @param result The vector3 that the rotation should be copied to
  15839. */
  15840. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15841. /**
  15842. * Get the quaternion rotation of the bone in either local or world space
  15843. * @param space The space that the rotation should be in
  15844. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15845. * @returns The quaternion rotation
  15846. */
  15847. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15848. /**
  15849. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15850. * @param space The space that the rotation should be in
  15851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15852. * @param result The quaternion that the rotation should be copied to
  15853. */
  15854. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15855. /**
  15856. * Get the rotation matrix of the bone in local or world space
  15857. * @param space The space that the rotation should be in
  15858. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15859. * @returns The rotation matrix
  15860. */
  15861. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15862. /**
  15863. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15864. * @param space The space that the rotation should be in
  15865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15866. * @param result The quaternion that the rotation should be copied to
  15867. */
  15868. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15869. /**
  15870. * Get the world position of a point that is in the local space of the bone
  15871. * @param position The local position
  15872. * @param mesh The mesh that this bone is attached to
  15873. * @returns The world position
  15874. */
  15875. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15876. /**
  15877. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15878. * @param position The local position
  15879. * @param mesh The mesh that this bone is attached to
  15880. * @param result The vector3 that the world position should be copied to
  15881. */
  15882. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15883. /**
  15884. * Get the local position of a point that is in world space
  15885. * @param position The world position
  15886. * @param mesh The mesh that this bone is attached to
  15887. * @returns The local position
  15888. */
  15889. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15890. /**
  15891. * Get the local position of a point that is in world space and copy it to the result param
  15892. * @param position The world position
  15893. * @param mesh The mesh that this bone is attached to
  15894. * @param result The vector3 that the local position should be copied to
  15895. */
  15896. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15897. }
  15898. }
  15899. declare module "babylonjs/Animations/runtimeAnimation" {
  15900. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15901. import { Animatable } from "babylonjs/Animations/animatable";
  15902. import { Scene } from "babylonjs/scene";
  15903. /**
  15904. * Defines a runtime animation
  15905. */
  15906. export class RuntimeAnimation {
  15907. private _events;
  15908. /**
  15909. * The current frame of the runtime animation
  15910. */
  15911. private _currentFrame;
  15912. /**
  15913. * The animation used by the runtime animation
  15914. */
  15915. private _animation;
  15916. /**
  15917. * The target of the runtime animation
  15918. */
  15919. private _target;
  15920. /**
  15921. * The initiating animatable
  15922. */
  15923. private _host;
  15924. /**
  15925. * The original value of the runtime animation
  15926. */
  15927. private _originalValue;
  15928. /**
  15929. * The original blend value of the runtime animation
  15930. */
  15931. private _originalBlendValue;
  15932. /**
  15933. * The offsets cache of the runtime animation
  15934. */
  15935. private _offsetsCache;
  15936. /**
  15937. * The high limits cache of the runtime animation
  15938. */
  15939. private _highLimitsCache;
  15940. /**
  15941. * Specifies if the runtime animation has been stopped
  15942. */
  15943. private _stopped;
  15944. /**
  15945. * The blending factor of the runtime animation
  15946. */
  15947. private _blendingFactor;
  15948. /**
  15949. * The BabylonJS scene
  15950. */
  15951. private _scene;
  15952. /**
  15953. * The current value of the runtime animation
  15954. */
  15955. private _currentValue;
  15956. /** @hidden */
  15957. _animationState: _IAnimationState;
  15958. /**
  15959. * The active target of the runtime animation
  15960. */
  15961. private _activeTargets;
  15962. private _currentActiveTarget;
  15963. private _directTarget;
  15964. /**
  15965. * The target path of the runtime animation
  15966. */
  15967. private _targetPath;
  15968. /**
  15969. * The weight of the runtime animation
  15970. */
  15971. private _weight;
  15972. /**
  15973. * The ratio offset of the runtime animation
  15974. */
  15975. private _ratioOffset;
  15976. /**
  15977. * The previous delay of the runtime animation
  15978. */
  15979. private _previousDelay;
  15980. /**
  15981. * The previous ratio of the runtime animation
  15982. */
  15983. private _previousRatio;
  15984. private _enableBlending;
  15985. private _keys;
  15986. private _minFrame;
  15987. private _maxFrame;
  15988. private _minValue;
  15989. private _maxValue;
  15990. private _targetIsArray;
  15991. /**
  15992. * Gets the current frame of the runtime animation
  15993. */
  15994. get currentFrame(): number;
  15995. /**
  15996. * Gets the weight of the runtime animation
  15997. */
  15998. get weight(): number;
  15999. /**
  16000. * Gets the current value of the runtime animation
  16001. */
  16002. get currentValue(): any;
  16003. /**
  16004. * Gets the target path of the runtime animation
  16005. */
  16006. get targetPath(): string;
  16007. /**
  16008. * Gets the actual target of the runtime animation
  16009. */
  16010. get target(): any;
  16011. /**
  16012. * Gets the additive state of the runtime animation
  16013. */
  16014. get isAdditive(): boolean;
  16015. /** @hidden */
  16016. _onLoop: () => void;
  16017. /**
  16018. * Create a new RuntimeAnimation object
  16019. * @param target defines the target of the animation
  16020. * @param animation defines the source animation object
  16021. * @param scene defines the hosting scene
  16022. * @param host defines the initiating Animatable
  16023. */
  16024. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16025. private _preparePath;
  16026. /**
  16027. * Gets the animation from the runtime animation
  16028. */
  16029. get animation(): Animation;
  16030. /**
  16031. * Resets the runtime animation to the beginning
  16032. * @param restoreOriginal defines whether to restore the target property to the original value
  16033. */
  16034. reset(restoreOriginal?: boolean): void;
  16035. /**
  16036. * Specifies if the runtime animation is stopped
  16037. * @returns Boolean specifying if the runtime animation is stopped
  16038. */
  16039. isStopped(): boolean;
  16040. /**
  16041. * Disposes of the runtime animation
  16042. */
  16043. dispose(): void;
  16044. /**
  16045. * Apply the interpolated value to the target
  16046. * @param currentValue defines the value computed by the animation
  16047. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16048. */
  16049. setValue(currentValue: any, weight: number): void;
  16050. private _getOriginalValues;
  16051. private _setValue;
  16052. /**
  16053. * Gets the loop pmode of the runtime animation
  16054. * @returns Loop Mode
  16055. */
  16056. private _getCorrectLoopMode;
  16057. /**
  16058. * Move the current animation to a given frame
  16059. * @param frame defines the frame to move to
  16060. */
  16061. goToFrame(frame: number): void;
  16062. /**
  16063. * @hidden Internal use only
  16064. */
  16065. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16066. /**
  16067. * Execute the current animation
  16068. * @param delay defines the delay to add to the current frame
  16069. * @param from defines the lower bound of the animation range
  16070. * @param to defines the upper bound of the animation range
  16071. * @param loop defines if the current animation must loop
  16072. * @param speedRatio defines the current speed ratio
  16073. * @param weight defines the weight of the animation (default is -1 so no weight)
  16074. * @param onLoop optional callback called when animation loops
  16075. * @returns a boolean indicating if the animation is running
  16076. */
  16077. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16078. }
  16079. }
  16080. declare module "babylonjs/Animations/animatable" {
  16081. import { Animation } from "babylonjs/Animations/animation";
  16082. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16083. import { Nullable } from "babylonjs/types";
  16084. import { Observable } from "babylonjs/Misc/observable";
  16085. import { Scene } from "babylonjs/scene";
  16086. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16087. import { Node } from "babylonjs/node";
  16088. /**
  16089. * Class used to store an actual running animation
  16090. */
  16091. export class Animatable {
  16092. /** defines the target object */
  16093. target: any;
  16094. /** defines the starting frame number (default is 0) */
  16095. fromFrame: number;
  16096. /** defines the ending frame number (default is 100) */
  16097. toFrame: number;
  16098. /** defines if the animation must loop (default is false) */
  16099. loopAnimation: boolean;
  16100. /** defines a callback to call when animation ends if it is not looping */
  16101. onAnimationEnd?: (() => void) | null | undefined;
  16102. /** defines a callback to call when animation loops */
  16103. onAnimationLoop?: (() => void) | null | undefined;
  16104. /** defines whether the animation should be evaluated additively */
  16105. isAdditive: boolean;
  16106. private _localDelayOffset;
  16107. private _pausedDelay;
  16108. private _runtimeAnimations;
  16109. private _paused;
  16110. private _scene;
  16111. private _speedRatio;
  16112. private _weight;
  16113. private _syncRoot;
  16114. /**
  16115. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16116. * This will only apply for non looping animation (default is true)
  16117. */
  16118. disposeOnEnd: boolean;
  16119. /**
  16120. * Gets a boolean indicating if the animation has started
  16121. */
  16122. animationStarted: boolean;
  16123. /**
  16124. * Observer raised when the animation ends
  16125. */
  16126. onAnimationEndObservable: Observable<Animatable>;
  16127. /**
  16128. * Observer raised when the animation loops
  16129. */
  16130. onAnimationLoopObservable: Observable<Animatable>;
  16131. /**
  16132. * Gets the root Animatable used to synchronize and normalize animations
  16133. */
  16134. get syncRoot(): Nullable<Animatable>;
  16135. /**
  16136. * Gets the current frame of the first RuntimeAnimation
  16137. * Used to synchronize Animatables
  16138. */
  16139. get masterFrame(): number;
  16140. /**
  16141. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16142. */
  16143. get weight(): number;
  16144. set weight(value: number);
  16145. /**
  16146. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16147. */
  16148. get speedRatio(): number;
  16149. set speedRatio(value: number);
  16150. /**
  16151. * Creates a new Animatable
  16152. * @param scene defines the hosting scene
  16153. * @param target defines the target object
  16154. * @param fromFrame defines the starting frame number (default is 0)
  16155. * @param toFrame defines the ending frame number (default is 100)
  16156. * @param loopAnimation defines if the animation must loop (default is false)
  16157. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16158. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16159. * @param animations defines a group of animation to add to the new Animatable
  16160. * @param onAnimationLoop defines a callback to call when animation loops
  16161. * @param isAdditive defines whether the animation should be evaluated additively
  16162. */
  16163. constructor(scene: Scene,
  16164. /** defines the target object */
  16165. target: any,
  16166. /** defines the starting frame number (default is 0) */
  16167. fromFrame?: number,
  16168. /** defines the ending frame number (default is 100) */
  16169. toFrame?: number,
  16170. /** defines if the animation must loop (default is false) */
  16171. loopAnimation?: boolean, speedRatio?: number,
  16172. /** defines a callback to call when animation ends if it is not looping */
  16173. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16174. /** defines a callback to call when animation loops */
  16175. onAnimationLoop?: (() => void) | null | undefined,
  16176. /** defines whether the animation should be evaluated additively */
  16177. isAdditive?: boolean);
  16178. /**
  16179. * Synchronize and normalize current Animatable with a source Animatable
  16180. * This is useful when using animation weights and when animations are not of the same length
  16181. * @param root defines the root Animatable to synchronize with
  16182. * @returns the current Animatable
  16183. */
  16184. syncWith(root: Animatable): Animatable;
  16185. /**
  16186. * Gets the list of runtime animations
  16187. * @returns an array of RuntimeAnimation
  16188. */
  16189. getAnimations(): RuntimeAnimation[];
  16190. /**
  16191. * Adds more animations to the current animatable
  16192. * @param target defines the target of the animations
  16193. * @param animations defines the new animations to add
  16194. */
  16195. appendAnimations(target: any, animations: Animation[]): void;
  16196. /**
  16197. * Gets the source animation for a specific property
  16198. * @param property defines the propertyu to look for
  16199. * @returns null or the source animation for the given property
  16200. */
  16201. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16202. /**
  16203. * Gets the runtime animation for a specific property
  16204. * @param property defines the propertyu to look for
  16205. * @returns null or the runtime animation for the given property
  16206. */
  16207. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16208. /**
  16209. * Resets the animatable to its original state
  16210. */
  16211. reset(): void;
  16212. /**
  16213. * Allows the animatable to blend with current running animations
  16214. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16215. * @param blendingSpeed defines the blending speed to use
  16216. */
  16217. enableBlending(blendingSpeed: number): void;
  16218. /**
  16219. * Disable animation blending
  16220. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16221. */
  16222. disableBlending(): void;
  16223. /**
  16224. * Jump directly to a given frame
  16225. * @param frame defines the frame to jump to
  16226. */
  16227. goToFrame(frame: number): void;
  16228. /**
  16229. * Pause the animation
  16230. */
  16231. pause(): void;
  16232. /**
  16233. * Restart the animation
  16234. */
  16235. restart(): void;
  16236. private _raiseOnAnimationEnd;
  16237. /**
  16238. * Stop and delete the current animation
  16239. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16240. * @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)
  16241. */
  16242. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16243. /**
  16244. * Wait asynchronously for the animation to end
  16245. * @returns a promise which will be fullfilled when the animation ends
  16246. */
  16247. waitAsync(): Promise<Animatable>;
  16248. /** @hidden */
  16249. _animate(delay: number): boolean;
  16250. }
  16251. module "babylonjs/scene" {
  16252. interface Scene {
  16253. /** @hidden */
  16254. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16255. /** @hidden */
  16256. _processLateAnimationBindingsForMatrices(holder: {
  16257. totalWeight: number;
  16258. totalAdditiveWeight: number;
  16259. animations: RuntimeAnimation[];
  16260. additiveAnimations: RuntimeAnimation[];
  16261. originalValue: Matrix;
  16262. }): any;
  16263. /** @hidden */
  16264. _processLateAnimationBindingsForQuaternions(holder: {
  16265. totalWeight: number;
  16266. totalAdditiveWeight: number;
  16267. animations: RuntimeAnimation[];
  16268. additiveAnimations: RuntimeAnimation[];
  16269. originalValue: Quaternion;
  16270. }, refQuaternion: Quaternion): Quaternion;
  16271. /** @hidden */
  16272. _processLateAnimationBindings(): void;
  16273. /**
  16274. * Will start the animation sequence of a given target
  16275. * @param target defines the target
  16276. * @param from defines from which frame should animation start
  16277. * @param to defines until which frame should animation run.
  16278. * @param weight defines the weight to apply to the animation (1.0 by default)
  16279. * @param loop defines if the animation loops
  16280. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16281. * @param onAnimationEnd defines the function to be executed when the animation ends
  16282. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16283. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16284. * @param onAnimationLoop defines the callback to call when an animation loops
  16285. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16286. * @returns the animatable object created for this animation
  16287. */
  16288. 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;
  16289. /**
  16290. * Will start the animation sequence of a given target
  16291. * @param target defines the target
  16292. * @param from defines from which frame should animation start
  16293. * @param to defines until which frame should animation run.
  16294. * @param loop defines if the animation loops
  16295. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16296. * @param onAnimationEnd defines the function to be executed when the animation ends
  16297. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16298. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16299. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16300. * @param onAnimationLoop defines the callback to call when an animation loops
  16301. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16302. * @returns the animatable object created for this animation
  16303. */
  16304. 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;
  16305. /**
  16306. * Will start the animation sequence of a given target and its hierarchy
  16307. * @param target defines the target
  16308. * @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.
  16309. * @param from defines from which frame should animation start
  16310. * @param to defines until which frame should animation run.
  16311. * @param loop defines if the animation loops
  16312. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16313. * @param onAnimationEnd defines the function to be executed when the animation ends
  16314. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16315. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16316. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16317. * @param onAnimationLoop defines the callback to call when an animation loops
  16318. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16319. * @returns the list of created animatables
  16320. */
  16321. 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[];
  16322. /**
  16323. * Begin a new animation on a given node
  16324. * @param target defines the target where the animation will take place
  16325. * @param animations defines the list of animations to start
  16326. * @param from defines the initial value
  16327. * @param to defines the final value
  16328. * @param loop defines if you want animation to loop (off by default)
  16329. * @param speedRatio defines the speed ratio to apply to all animations
  16330. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16331. * @param onAnimationLoop defines the callback to call when an animation loops
  16332. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16333. * @returns the list of created animatables
  16334. */
  16335. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16336. /**
  16337. * Begin a new animation on a given node and its hierarchy
  16338. * @param target defines the root node where the animation will take place
  16339. * @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.
  16340. * @param animations defines the list of animations to start
  16341. * @param from defines the initial value
  16342. * @param to defines the final value
  16343. * @param loop defines if you want animation to loop (off by default)
  16344. * @param speedRatio defines the speed ratio to apply to all animations
  16345. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16346. * @param onAnimationLoop defines the callback to call when an animation loops
  16347. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16348. * @returns the list of animatables created for all nodes
  16349. */
  16350. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16351. /**
  16352. * Gets the animatable associated with a specific target
  16353. * @param target defines the target of the animatable
  16354. * @returns the required animatable if found
  16355. */
  16356. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16357. /**
  16358. * Gets all animatables associated with a given target
  16359. * @param target defines the target to look animatables for
  16360. * @returns an array of Animatables
  16361. */
  16362. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16363. /**
  16364. * Stops and removes all animations that have been applied to the scene
  16365. */
  16366. stopAllAnimations(): void;
  16367. /**
  16368. * Gets the current delta time used by animation engine
  16369. */
  16370. deltaTime: number;
  16371. }
  16372. }
  16373. module "babylonjs/Bones/bone" {
  16374. interface Bone {
  16375. /**
  16376. * Copy an animation range from another bone
  16377. * @param source defines the source bone
  16378. * @param rangeName defines the range name to copy
  16379. * @param frameOffset defines the frame offset
  16380. * @param rescaleAsRequired defines if rescaling must be applied if required
  16381. * @param skelDimensionsRatio defines the scaling ratio
  16382. * @returns true if operation was successful
  16383. */
  16384. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16385. }
  16386. }
  16387. }
  16388. declare module "babylonjs/Bones/skeleton" {
  16389. import { Bone } from "babylonjs/Bones/bone";
  16390. import { Observable } from "babylonjs/Misc/observable";
  16391. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16392. import { Scene } from "babylonjs/scene";
  16393. import { Nullable } from "babylonjs/types";
  16394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16395. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16396. import { Animatable } from "babylonjs/Animations/animatable";
  16397. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16398. import { Animation } from "babylonjs/Animations/animation";
  16399. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16400. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16401. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16402. /**
  16403. * Class used to handle skinning animations
  16404. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16405. */
  16406. export class Skeleton implements IAnimatable {
  16407. /** defines the skeleton name */
  16408. name: string;
  16409. /** defines the skeleton Id */
  16410. id: string;
  16411. /**
  16412. * Defines the list of child bones
  16413. */
  16414. bones: Bone[];
  16415. /**
  16416. * Defines an estimate of the dimension of the skeleton at rest
  16417. */
  16418. dimensionsAtRest: Vector3;
  16419. /**
  16420. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16421. */
  16422. needInitialSkinMatrix: boolean;
  16423. /**
  16424. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16425. */
  16426. overrideMesh: Nullable<AbstractMesh>;
  16427. /**
  16428. * Gets the list of animations attached to this skeleton
  16429. */
  16430. animations: Array<Animation>;
  16431. private _scene;
  16432. private _isDirty;
  16433. private _transformMatrices;
  16434. private _transformMatrixTexture;
  16435. private _meshesWithPoseMatrix;
  16436. private _animatables;
  16437. private _identity;
  16438. private _synchronizedWithMesh;
  16439. private _ranges;
  16440. private _lastAbsoluteTransformsUpdateId;
  16441. private _canUseTextureForBones;
  16442. private _uniqueId;
  16443. /** @hidden */
  16444. _numBonesWithLinkedTransformNode: number;
  16445. /** @hidden */
  16446. _hasWaitingData: Nullable<boolean>;
  16447. /** @hidden */
  16448. _waitingOverrideMeshId: Nullable<string>;
  16449. /**
  16450. * Specifies if the skeleton should be serialized
  16451. */
  16452. doNotSerialize: boolean;
  16453. private _useTextureToStoreBoneMatrices;
  16454. /**
  16455. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16456. * Please note that this option is not available if the hardware does not support it
  16457. */
  16458. get useTextureToStoreBoneMatrices(): boolean;
  16459. set useTextureToStoreBoneMatrices(value: boolean);
  16460. private _animationPropertiesOverride;
  16461. /**
  16462. * Gets or sets the animation properties override
  16463. */
  16464. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16465. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16466. /**
  16467. * List of inspectable custom properties (used by the Inspector)
  16468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16469. */
  16470. inspectableCustomProperties: IInspectable[];
  16471. /**
  16472. * An observable triggered before computing the skeleton's matrices
  16473. */
  16474. onBeforeComputeObservable: Observable<Skeleton>;
  16475. /**
  16476. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16477. */
  16478. get isUsingTextureForMatrices(): boolean;
  16479. /**
  16480. * Gets the unique ID of this skeleton
  16481. */
  16482. get uniqueId(): number;
  16483. /**
  16484. * Creates a new skeleton
  16485. * @param name defines the skeleton name
  16486. * @param id defines the skeleton Id
  16487. * @param scene defines the hosting scene
  16488. */
  16489. constructor(
  16490. /** defines the skeleton name */
  16491. name: string,
  16492. /** defines the skeleton Id */
  16493. id: string, scene: Scene);
  16494. /**
  16495. * Gets the current object class name.
  16496. * @return the class name
  16497. */
  16498. getClassName(): string;
  16499. /**
  16500. * Returns an array containing the root bones
  16501. * @returns an array containing the root bones
  16502. */
  16503. getChildren(): Array<Bone>;
  16504. /**
  16505. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16506. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16507. * @returns a Float32Array containing matrices data
  16508. */
  16509. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16510. /**
  16511. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16512. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16513. * @returns a raw texture containing the data
  16514. */
  16515. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16516. /**
  16517. * Gets the current hosting scene
  16518. * @returns a scene object
  16519. */
  16520. getScene(): Scene;
  16521. /**
  16522. * Gets a string representing the current skeleton data
  16523. * @param fullDetails defines a boolean indicating if we want a verbose version
  16524. * @returns a string representing the current skeleton data
  16525. */
  16526. toString(fullDetails?: boolean): string;
  16527. /**
  16528. * Get bone's index searching by name
  16529. * @param name defines bone's name to search for
  16530. * @return the indice of the bone. Returns -1 if not found
  16531. */
  16532. getBoneIndexByName(name: string): number;
  16533. /**
  16534. * Creater a new animation range
  16535. * @param name defines the name of the range
  16536. * @param from defines the start key
  16537. * @param to defines the end key
  16538. */
  16539. createAnimationRange(name: string, from: number, to: number): void;
  16540. /**
  16541. * Delete a specific animation range
  16542. * @param name defines the name of the range
  16543. * @param deleteFrames defines if frames must be removed as well
  16544. */
  16545. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16546. /**
  16547. * Gets a specific animation range
  16548. * @param name defines the name of the range to look for
  16549. * @returns the requested animation range or null if not found
  16550. */
  16551. getAnimationRange(name: string): Nullable<AnimationRange>;
  16552. /**
  16553. * Gets the list of all animation ranges defined on this skeleton
  16554. * @returns an array
  16555. */
  16556. getAnimationRanges(): Nullable<AnimationRange>[];
  16557. /**
  16558. * Copy animation range from a source skeleton.
  16559. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16560. * @param source defines the source skeleton
  16561. * @param name defines the name of the range to copy
  16562. * @param rescaleAsRequired defines if rescaling must be applied if required
  16563. * @returns true if operation was successful
  16564. */
  16565. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16566. /**
  16567. * Forces the skeleton to go to rest pose
  16568. */
  16569. returnToRest(): void;
  16570. private _getHighestAnimationFrame;
  16571. /**
  16572. * Begin a specific animation range
  16573. * @param name defines the name of the range to start
  16574. * @param loop defines if looping must be turned on (false by default)
  16575. * @param speedRatio defines the speed ratio to apply (1 by default)
  16576. * @param onAnimationEnd defines a callback which will be called when animation will end
  16577. * @returns a new animatable
  16578. */
  16579. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16580. /**
  16581. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16582. * @param skeleton defines the Skeleton containing the animation range to convert
  16583. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16584. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16585. * @returns the original skeleton
  16586. */
  16587. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16588. /** @hidden */
  16589. _markAsDirty(): void;
  16590. /** @hidden */
  16591. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16592. /** @hidden */
  16593. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16594. private _computeTransformMatrices;
  16595. /**
  16596. * Build all resources required to render a skeleton
  16597. */
  16598. prepare(): void;
  16599. /**
  16600. * Gets the list of animatables currently running for this skeleton
  16601. * @returns an array of animatables
  16602. */
  16603. getAnimatables(): IAnimatable[];
  16604. /**
  16605. * Clone the current skeleton
  16606. * @param name defines the name of the new skeleton
  16607. * @param id defines the id of the new skeleton
  16608. * @returns the new skeleton
  16609. */
  16610. clone(name: string, id?: string): Skeleton;
  16611. /**
  16612. * Enable animation blending for this skeleton
  16613. * @param blendingSpeed defines the blending speed to apply
  16614. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16615. */
  16616. enableBlending(blendingSpeed?: number): void;
  16617. /**
  16618. * Releases all resources associated with the current skeleton
  16619. */
  16620. dispose(): void;
  16621. /**
  16622. * Serialize the skeleton in a JSON object
  16623. * @returns a JSON object
  16624. */
  16625. serialize(): any;
  16626. /**
  16627. * Creates a new skeleton from serialized data
  16628. * @param parsedSkeleton defines the serialized data
  16629. * @param scene defines the hosting scene
  16630. * @returns a new skeleton
  16631. */
  16632. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16633. /**
  16634. * Compute all node absolute transforms
  16635. * @param forceUpdate defines if computation must be done even if cache is up to date
  16636. */
  16637. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16638. /**
  16639. * Gets the root pose matrix
  16640. * @returns a matrix
  16641. */
  16642. getPoseMatrix(): Nullable<Matrix>;
  16643. /**
  16644. * Sorts bones per internal index
  16645. */
  16646. sortBones(): void;
  16647. private _sortBones;
  16648. }
  16649. }
  16650. declare module "babylonjs/Meshes/instancedMesh" {
  16651. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16652. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16653. import { Camera } from "babylonjs/Cameras/camera";
  16654. import { Node } from "babylonjs/node";
  16655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16656. import { Mesh } from "babylonjs/Meshes/mesh";
  16657. import { Material } from "babylonjs/Materials/material";
  16658. import { Skeleton } from "babylonjs/Bones/skeleton";
  16659. import { Light } from "babylonjs/Lights/light";
  16660. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16661. /**
  16662. * Creates an instance based on a source mesh.
  16663. */
  16664. export class InstancedMesh extends AbstractMesh {
  16665. private _sourceMesh;
  16666. private _currentLOD;
  16667. /** @hidden */
  16668. _indexInSourceMeshInstanceArray: number;
  16669. constructor(name: string, source: Mesh);
  16670. /**
  16671. * Returns the string "InstancedMesh".
  16672. */
  16673. getClassName(): string;
  16674. /** Gets the list of lights affecting that mesh */
  16675. get lightSources(): Light[];
  16676. _resyncLightSources(): void;
  16677. _resyncLightSource(light: Light): void;
  16678. _removeLightSource(light: Light, dispose: boolean): void;
  16679. /**
  16680. * If the source mesh receives shadows
  16681. */
  16682. get receiveShadows(): boolean;
  16683. /**
  16684. * The material of the source mesh
  16685. */
  16686. get material(): Nullable<Material>;
  16687. /**
  16688. * Visibility of the source mesh
  16689. */
  16690. get visibility(): number;
  16691. /**
  16692. * Skeleton of the source mesh
  16693. */
  16694. get skeleton(): Nullable<Skeleton>;
  16695. /**
  16696. * Rendering ground id of the source mesh
  16697. */
  16698. get renderingGroupId(): number;
  16699. set renderingGroupId(value: number);
  16700. /**
  16701. * Returns the total number of vertices (integer).
  16702. */
  16703. getTotalVertices(): number;
  16704. /**
  16705. * Returns a positive integer : the total number of indices in this mesh geometry.
  16706. * @returns the numner of indices or zero if the mesh has no geometry.
  16707. */
  16708. getTotalIndices(): number;
  16709. /**
  16710. * The source mesh of the instance
  16711. */
  16712. get sourceMesh(): Mesh;
  16713. /**
  16714. * Creates a new InstancedMesh object from the mesh model.
  16715. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16716. * @param name defines the name of the new instance
  16717. * @returns a new InstancedMesh
  16718. */
  16719. createInstance(name: string): InstancedMesh;
  16720. /**
  16721. * Is this node ready to be used/rendered
  16722. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16723. * @return {boolean} is it ready
  16724. */
  16725. isReady(completeCheck?: boolean): boolean;
  16726. /**
  16727. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16728. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16729. * @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.
  16730. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16731. */
  16732. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16733. /**
  16734. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16735. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16736. * The `data` are either a numeric array either a Float32Array.
  16737. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16738. * 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).
  16739. * Note that a new underlying VertexBuffer object is created each call.
  16740. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16741. *
  16742. * Possible `kind` values :
  16743. * - VertexBuffer.PositionKind
  16744. * - VertexBuffer.UVKind
  16745. * - VertexBuffer.UV2Kind
  16746. * - VertexBuffer.UV3Kind
  16747. * - VertexBuffer.UV4Kind
  16748. * - VertexBuffer.UV5Kind
  16749. * - VertexBuffer.UV6Kind
  16750. * - VertexBuffer.ColorKind
  16751. * - VertexBuffer.MatricesIndicesKind
  16752. * - VertexBuffer.MatricesIndicesExtraKind
  16753. * - VertexBuffer.MatricesWeightsKind
  16754. * - VertexBuffer.MatricesWeightsExtraKind
  16755. *
  16756. * Returns the Mesh.
  16757. */
  16758. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16759. /**
  16760. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16761. * If the mesh has no geometry, it is simply returned as it is.
  16762. * The `data` are either a numeric array either a Float32Array.
  16763. * No new underlying VertexBuffer object is created.
  16764. * 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.
  16765. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16766. *
  16767. * Possible `kind` values :
  16768. * - VertexBuffer.PositionKind
  16769. * - VertexBuffer.UVKind
  16770. * - VertexBuffer.UV2Kind
  16771. * - VertexBuffer.UV3Kind
  16772. * - VertexBuffer.UV4Kind
  16773. * - VertexBuffer.UV5Kind
  16774. * - VertexBuffer.UV6Kind
  16775. * - VertexBuffer.ColorKind
  16776. * - VertexBuffer.MatricesIndicesKind
  16777. * - VertexBuffer.MatricesIndicesExtraKind
  16778. * - VertexBuffer.MatricesWeightsKind
  16779. * - VertexBuffer.MatricesWeightsExtraKind
  16780. *
  16781. * Returns the Mesh.
  16782. */
  16783. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16784. /**
  16785. * Sets the mesh indices.
  16786. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16787. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16788. * This method creates a new index buffer each call.
  16789. * Returns the Mesh.
  16790. */
  16791. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16792. /**
  16793. * Boolean : True if the mesh owns the requested kind of data.
  16794. */
  16795. isVerticesDataPresent(kind: string): boolean;
  16796. /**
  16797. * Returns an array of indices (IndicesArray).
  16798. */
  16799. getIndices(): Nullable<IndicesArray>;
  16800. get _positions(): Nullable<Vector3[]>;
  16801. /**
  16802. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16803. * This means the mesh underlying bounding box and sphere are recomputed.
  16804. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16805. * @returns the current mesh
  16806. */
  16807. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16808. /** @hidden */
  16809. _preActivate(): InstancedMesh;
  16810. /** @hidden */
  16811. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16812. /** @hidden */
  16813. _postActivate(): void;
  16814. getWorldMatrix(): Matrix;
  16815. get isAnInstance(): boolean;
  16816. /**
  16817. * Returns the current associated LOD AbstractMesh.
  16818. */
  16819. getLOD(camera: Camera): AbstractMesh;
  16820. /** @hidden */
  16821. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16822. /** @hidden */
  16823. _syncSubMeshes(): InstancedMesh;
  16824. /** @hidden */
  16825. _generatePointsArray(): boolean;
  16826. /** @hidden */
  16827. _updateBoundingInfo(): AbstractMesh;
  16828. /**
  16829. * Creates a new InstancedMesh from the current mesh.
  16830. * - name (string) : the cloned mesh name
  16831. * - newParent (optional Node) : the optional Node to parent the clone to.
  16832. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16833. *
  16834. * Returns the clone.
  16835. */
  16836. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16837. /**
  16838. * Disposes the InstancedMesh.
  16839. * Returns nothing.
  16840. */
  16841. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16842. }
  16843. module "babylonjs/Meshes/mesh" {
  16844. interface Mesh {
  16845. /**
  16846. * Register a custom buffer that will be instanced
  16847. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16848. * @param kind defines the buffer kind
  16849. * @param stride defines the stride in floats
  16850. */
  16851. registerInstancedBuffer(kind: string, stride: number): void;
  16852. /**
  16853. * true to use the edge renderer for all instances of this mesh
  16854. */
  16855. edgesShareWithInstances: boolean;
  16856. /** @hidden */
  16857. _userInstancedBuffersStorage: {
  16858. data: {
  16859. [key: string]: Float32Array;
  16860. };
  16861. sizes: {
  16862. [key: string]: number;
  16863. };
  16864. vertexBuffers: {
  16865. [key: string]: Nullable<VertexBuffer>;
  16866. };
  16867. strides: {
  16868. [key: string]: number;
  16869. };
  16870. };
  16871. }
  16872. }
  16873. module "babylonjs/Meshes/abstractMesh" {
  16874. interface AbstractMesh {
  16875. /**
  16876. * Object used to store instanced buffers defined by user
  16877. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16878. */
  16879. instancedBuffers: {
  16880. [key: string]: any;
  16881. };
  16882. }
  16883. }
  16884. }
  16885. declare module "babylonjs/Materials/shaderMaterial" {
  16886. import { Nullable } from "babylonjs/types";
  16887. import { Scene } from "babylonjs/scene";
  16888. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16890. import { Mesh } from "babylonjs/Meshes/mesh";
  16891. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16893. import { Effect } from "babylonjs/Materials/effect";
  16894. import { Material } from "babylonjs/Materials/material";
  16895. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16896. /**
  16897. * Defines the options associated with the creation of a shader material.
  16898. */
  16899. export interface IShaderMaterialOptions {
  16900. /**
  16901. * Does the material work in alpha blend mode
  16902. */
  16903. needAlphaBlending: boolean;
  16904. /**
  16905. * Does the material work in alpha test mode
  16906. */
  16907. needAlphaTesting: boolean;
  16908. /**
  16909. * The list of attribute names used in the shader
  16910. */
  16911. attributes: string[];
  16912. /**
  16913. * The list of unifrom names used in the shader
  16914. */
  16915. uniforms: string[];
  16916. /**
  16917. * The list of UBO names used in the shader
  16918. */
  16919. uniformBuffers: string[];
  16920. /**
  16921. * The list of sampler names used in the shader
  16922. */
  16923. samplers: string[];
  16924. /**
  16925. * The list of defines used in the shader
  16926. */
  16927. defines: string[];
  16928. }
  16929. /**
  16930. * 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.
  16931. *
  16932. * This returned material effects how the mesh will look based on the code in the shaders.
  16933. *
  16934. * @see https://doc.babylonjs.com/how_to/shader_material
  16935. */
  16936. export class ShaderMaterial extends Material {
  16937. private _shaderPath;
  16938. private _options;
  16939. private _textures;
  16940. private _textureArrays;
  16941. private _floats;
  16942. private _ints;
  16943. private _floatsArrays;
  16944. private _colors3;
  16945. private _colors3Arrays;
  16946. private _colors4;
  16947. private _colors4Arrays;
  16948. private _vectors2;
  16949. private _vectors3;
  16950. private _vectors4;
  16951. private _matrices;
  16952. private _matrixArrays;
  16953. private _matrices3x3;
  16954. private _matrices2x2;
  16955. private _vectors2Arrays;
  16956. private _vectors3Arrays;
  16957. private _vectors4Arrays;
  16958. private _cachedWorldViewMatrix;
  16959. private _cachedWorldViewProjectionMatrix;
  16960. private _renderId;
  16961. private _multiview;
  16962. private _cachedDefines;
  16963. /** Define the Url to load snippets */
  16964. static SnippetUrl: string;
  16965. /** Snippet ID if the material was created from the snippet server */
  16966. snippetId: string;
  16967. /**
  16968. * Instantiate a new shader material.
  16969. * 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.
  16970. * This returned material effects how the mesh will look based on the code in the shaders.
  16971. * @see https://doc.babylonjs.com/how_to/shader_material
  16972. * @param name Define the name of the material in the scene
  16973. * @param scene Define the scene the material belongs to
  16974. * @param shaderPath Defines the route to the shader code in one of three ways:
  16975. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16976. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16977. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16978. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16979. * @param options Define the options used to create the shader
  16980. */
  16981. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16982. /**
  16983. * Gets the shader path used to define the shader code
  16984. * It can be modified to trigger a new compilation
  16985. */
  16986. get shaderPath(): any;
  16987. /**
  16988. * Sets the shader path used to define the shader code
  16989. * It can be modified to trigger a new compilation
  16990. */
  16991. set shaderPath(shaderPath: any);
  16992. /**
  16993. * Gets the options used to compile the shader.
  16994. * They can be modified to trigger a new compilation
  16995. */
  16996. get options(): IShaderMaterialOptions;
  16997. /**
  16998. * Gets the current class name of the material e.g. "ShaderMaterial"
  16999. * Mainly use in serialization.
  17000. * @returns the class name
  17001. */
  17002. getClassName(): string;
  17003. /**
  17004. * Specifies if the material will require alpha blending
  17005. * @returns a boolean specifying if alpha blending is needed
  17006. */
  17007. needAlphaBlending(): boolean;
  17008. /**
  17009. * Specifies if this material should be rendered in alpha test mode
  17010. * @returns a boolean specifying if an alpha test is needed.
  17011. */
  17012. needAlphaTesting(): boolean;
  17013. private _checkUniform;
  17014. /**
  17015. * Set a texture in the shader.
  17016. * @param name Define the name of the uniform samplers as defined in the shader
  17017. * @param texture Define the texture to bind to this sampler
  17018. * @return the material itself allowing "fluent" like uniform updates
  17019. */
  17020. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17021. /**
  17022. * Set a texture array in the shader.
  17023. * @param name Define the name of the uniform sampler array as defined in the shader
  17024. * @param textures Define the list of textures to bind to this sampler
  17025. * @return the material itself allowing "fluent" like uniform updates
  17026. */
  17027. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17028. /**
  17029. * Set a float in the shader.
  17030. * @param name Define the name of the uniform as defined in the shader
  17031. * @param value Define the value to give to the uniform
  17032. * @return the material itself allowing "fluent" like uniform updates
  17033. */
  17034. setFloat(name: string, value: number): ShaderMaterial;
  17035. /**
  17036. * Set a int in the shader.
  17037. * @param name Define the name of the uniform as defined in the shader
  17038. * @param value Define the value to give to the uniform
  17039. * @return the material itself allowing "fluent" like uniform updates
  17040. */
  17041. setInt(name: string, value: number): ShaderMaterial;
  17042. /**
  17043. * Set an array of floats in the shader.
  17044. * @param name Define the name of the uniform as defined in the shader
  17045. * @param value Define the value to give to the uniform
  17046. * @return the material itself allowing "fluent" like uniform updates
  17047. */
  17048. setFloats(name: string, value: number[]): ShaderMaterial;
  17049. /**
  17050. * Set a vec3 in the shader from a Color3.
  17051. * @param name Define the name of the uniform as defined in the shader
  17052. * @param value Define the value to give to the uniform
  17053. * @return the material itself allowing "fluent" like uniform updates
  17054. */
  17055. setColor3(name: string, value: Color3): ShaderMaterial;
  17056. /**
  17057. * Set a vec3 array in the shader from a Color3 array.
  17058. * @param name Define the name of the uniform as defined in the shader
  17059. * @param value Define the value to give to the uniform
  17060. * @return the material itself allowing "fluent" like uniform updates
  17061. */
  17062. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17063. /**
  17064. * Set a vec4 in the shader from a Color4.
  17065. * @param name Define the name of the uniform as defined in the shader
  17066. * @param value Define the value to give to the uniform
  17067. * @return the material itself allowing "fluent" like uniform updates
  17068. */
  17069. setColor4(name: string, value: Color4): ShaderMaterial;
  17070. /**
  17071. * Set a vec4 array in the shader from a Color4 array.
  17072. * @param name Define the name of the uniform as defined in the shader
  17073. * @param value Define the value to give to the uniform
  17074. * @return the material itself allowing "fluent" like uniform updates
  17075. */
  17076. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17077. /**
  17078. * Set a vec2 in the shader from a Vector2.
  17079. * @param name Define the name of the uniform as defined in the shader
  17080. * @param value Define the value to give to the uniform
  17081. * @return the material itself allowing "fluent" like uniform updates
  17082. */
  17083. setVector2(name: string, value: Vector2): ShaderMaterial;
  17084. /**
  17085. * Set a vec3 in the shader from a Vector3.
  17086. * @param name Define the name of the uniform as defined in the shader
  17087. * @param value Define the value to give to the uniform
  17088. * @return the material itself allowing "fluent" like uniform updates
  17089. */
  17090. setVector3(name: string, value: Vector3): ShaderMaterial;
  17091. /**
  17092. * Set a vec4 in the shader from a Vector4.
  17093. * @param name Define the name of the uniform as defined in the shader
  17094. * @param value Define the value to give to the uniform
  17095. * @return the material itself allowing "fluent" like uniform updates
  17096. */
  17097. setVector4(name: string, value: Vector4): ShaderMaterial;
  17098. /**
  17099. * Set a mat4 in the shader from a Matrix.
  17100. * @param name Define the name of the uniform as defined in the shader
  17101. * @param value Define the value to give to the uniform
  17102. * @return the material itself allowing "fluent" like uniform updates
  17103. */
  17104. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17105. /**
  17106. * Set a float32Array in the shader from a matrix array.
  17107. * @param name Define the name of the uniform as defined in the shader
  17108. * @param value Define the value to give to the uniform
  17109. * @return the material itself allowing "fluent" like uniform updates
  17110. */
  17111. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17112. /**
  17113. * Set a mat3 in the shader from a Float32Array.
  17114. * @param name Define the name of the uniform as defined in the shader
  17115. * @param value Define the value to give to the uniform
  17116. * @return the material itself allowing "fluent" like uniform updates
  17117. */
  17118. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17119. /**
  17120. * Set a mat2 in the shader from a Float32Array.
  17121. * @param name Define the name of the uniform as defined in the shader
  17122. * @param value Define the value to give to the uniform
  17123. * @return the material itself allowing "fluent" like uniform updates
  17124. */
  17125. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17126. /**
  17127. * Set a vec2 array in the shader from a number array.
  17128. * @param name Define the name of the uniform as defined in the shader
  17129. * @param value Define the value to give to the uniform
  17130. * @return the material itself allowing "fluent" like uniform updates
  17131. */
  17132. setArray2(name: string, value: number[]): ShaderMaterial;
  17133. /**
  17134. * Set a vec3 array in the shader from a number array.
  17135. * @param name Define the name of the uniform as defined in the shader
  17136. * @param value Define the value to give to the uniform
  17137. * @return the material itself allowing "fluent" like uniform updates
  17138. */
  17139. setArray3(name: string, value: number[]): ShaderMaterial;
  17140. /**
  17141. * Set a vec4 array in the shader from a number array.
  17142. * @param name Define the name of the uniform as defined in the shader
  17143. * @param value Define the value to give to the uniform
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setArray4(name: string, value: number[]): ShaderMaterial;
  17147. private _checkCache;
  17148. /**
  17149. * Specifies that the submesh is ready to be used
  17150. * @param mesh defines the mesh to check
  17151. * @param subMesh defines which submesh to check
  17152. * @param useInstances specifies that instances should be used
  17153. * @returns a boolean indicating that the submesh is ready or not
  17154. */
  17155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17156. /**
  17157. * Checks if the material is ready to render the requested mesh
  17158. * @param mesh Define the mesh to render
  17159. * @param useInstances Define whether or not the material is used with instances
  17160. * @returns true if ready, otherwise false
  17161. */
  17162. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17163. /**
  17164. * Binds the world matrix to the material
  17165. * @param world defines the world transformation matrix
  17166. * @param effectOverride - If provided, use this effect instead of internal effect
  17167. */
  17168. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17169. /**
  17170. * Binds the submesh to this material by preparing the effect and shader to draw
  17171. * @param world defines the world transformation matrix
  17172. * @param mesh defines the mesh containing the submesh
  17173. * @param subMesh defines the submesh to bind the material to
  17174. */
  17175. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17176. /**
  17177. * Binds the material to the mesh
  17178. * @param world defines the world transformation matrix
  17179. * @param mesh defines the mesh to bind the material to
  17180. * @param effectOverride - If provided, use this effect instead of internal effect
  17181. */
  17182. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17183. protected _afterBind(mesh?: Mesh): void;
  17184. /**
  17185. * Gets the active textures from the material
  17186. * @returns an array of textures
  17187. */
  17188. getActiveTextures(): BaseTexture[];
  17189. /**
  17190. * Specifies if the material uses a texture
  17191. * @param texture defines the texture to check against the material
  17192. * @returns a boolean specifying if the material uses the texture
  17193. */
  17194. hasTexture(texture: BaseTexture): boolean;
  17195. /**
  17196. * Makes a duplicate of the material, and gives it a new name
  17197. * @param name defines the new name for the duplicated material
  17198. * @returns the cloned material
  17199. */
  17200. clone(name: string): ShaderMaterial;
  17201. /**
  17202. * Disposes the material
  17203. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17204. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17205. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17206. */
  17207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17208. /**
  17209. * Serializes this material in a JSON representation
  17210. * @returns the serialized material object
  17211. */
  17212. serialize(): any;
  17213. /**
  17214. * Creates a shader material from parsed shader material data
  17215. * @param source defines the JSON represnetation of the material
  17216. * @param scene defines the hosting scene
  17217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17218. * @returns a new material
  17219. */
  17220. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17221. /**
  17222. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17223. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17224. * @param url defines the url to load from
  17225. * @param scene defines the hosting scene
  17226. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17227. * @returns a promise that will resolve to the new ShaderMaterial
  17228. */
  17229. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17230. /**
  17231. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17232. * @param snippetId defines the snippet to load
  17233. * @param scene defines the hosting scene
  17234. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17235. * @returns a promise that will resolve to the new ShaderMaterial
  17236. */
  17237. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17238. }
  17239. }
  17240. declare module "babylonjs/Shaders/color.fragment" {
  17241. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17242. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17243. /** @hidden */
  17244. export var colorPixelShader: {
  17245. name: string;
  17246. shader: string;
  17247. };
  17248. }
  17249. declare module "babylonjs/Shaders/color.vertex" {
  17250. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17251. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17252. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17253. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17254. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17255. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17256. /** @hidden */
  17257. export var colorVertexShader: {
  17258. name: string;
  17259. shader: string;
  17260. };
  17261. }
  17262. declare module "babylonjs/Meshes/linesMesh" {
  17263. import { Nullable } from "babylonjs/types";
  17264. import { Scene } from "babylonjs/scene";
  17265. import { Color3 } from "babylonjs/Maths/math.color";
  17266. import { Node } from "babylonjs/node";
  17267. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17268. import { Mesh } from "babylonjs/Meshes/mesh";
  17269. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17270. import { Effect } from "babylonjs/Materials/effect";
  17271. import { Material } from "babylonjs/Materials/material";
  17272. import "babylonjs/Shaders/color.fragment";
  17273. import "babylonjs/Shaders/color.vertex";
  17274. /**
  17275. * Line mesh
  17276. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17277. */
  17278. export class LinesMesh extends Mesh {
  17279. /**
  17280. * If vertex color should be applied to the mesh
  17281. */
  17282. readonly useVertexColor?: boolean | undefined;
  17283. /**
  17284. * If vertex alpha should be applied to the mesh
  17285. */
  17286. readonly useVertexAlpha?: boolean | undefined;
  17287. /**
  17288. * Color of the line (Default: White)
  17289. */
  17290. color: Color3;
  17291. /**
  17292. * Alpha of the line (Default: 1)
  17293. */
  17294. alpha: number;
  17295. /**
  17296. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17297. * This margin is expressed in world space coordinates, so its value may vary.
  17298. * Default value is 0.1
  17299. */
  17300. intersectionThreshold: number;
  17301. private _colorShader;
  17302. private color4;
  17303. /**
  17304. * Creates a new LinesMesh
  17305. * @param name defines the name
  17306. * @param scene defines the hosting scene
  17307. * @param parent defines the parent mesh if any
  17308. * @param source defines the optional source LinesMesh used to clone data from
  17309. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17310. * When false, achieved by calling a clone(), also passing False.
  17311. * This will make creation of children, recursive.
  17312. * @param useVertexColor defines if this LinesMesh supports vertex color
  17313. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17314. */
  17315. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17316. /**
  17317. * If vertex color should be applied to the mesh
  17318. */
  17319. useVertexColor?: boolean | undefined,
  17320. /**
  17321. * If vertex alpha should be applied to the mesh
  17322. */
  17323. useVertexAlpha?: boolean | undefined);
  17324. private _addClipPlaneDefine;
  17325. private _removeClipPlaneDefine;
  17326. isReady(): boolean;
  17327. /**
  17328. * Returns the string "LineMesh"
  17329. */
  17330. getClassName(): string;
  17331. /**
  17332. * @hidden
  17333. */
  17334. get material(): Material;
  17335. /**
  17336. * @hidden
  17337. */
  17338. set material(value: Material);
  17339. /**
  17340. * @hidden
  17341. */
  17342. get checkCollisions(): boolean;
  17343. /** @hidden */
  17344. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17345. /** @hidden */
  17346. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17347. /**
  17348. * Disposes of the line mesh
  17349. * @param doNotRecurse If children should be disposed
  17350. */
  17351. dispose(doNotRecurse?: boolean): void;
  17352. /**
  17353. * Returns a new LineMesh object cloned from the current one.
  17354. */
  17355. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17356. /**
  17357. * Creates a new InstancedLinesMesh object from the mesh model.
  17358. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17359. * @param name defines the name of the new instance
  17360. * @returns a new InstancedLinesMesh
  17361. */
  17362. createInstance(name: string): InstancedLinesMesh;
  17363. }
  17364. /**
  17365. * Creates an instance based on a source LinesMesh
  17366. */
  17367. export class InstancedLinesMesh extends InstancedMesh {
  17368. /**
  17369. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17370. * This margin is expressed in world space coordinates, so its value may vary.
  17371. * Initilized with the intersectionThreshold value of the source LinesMesh
  17372. */
  17373. intersectionThreshold: number;
  17374. constructor(name: string, source: LinesMesh);
  17375. /**
  17376. * Returns the string "InstancedLinesMesh".
  17377. */
  17378. getClassName(): string;
  17379. }
  17380. }
  17381. declare module "babylonjs/Shaders/line.fragment" {
  17382. /** @hidden */
  17383. export var linePixelShader: {
  17384. name: string;
  17385. shader: string;
  17386. };
  17387. }
  17388. declare module "babylonjs/Shaders/line.vertex" {
  17389. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17390. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17391. /** @hidden */
  17392. export var lineVertexShader: {
  17393. name: string;
  17394. shader: string;
  17395. };
  17396. }
  17397. declare module "babylonjs/Rendering/edgesRenderer" {
  17398. import { Nullable } from "babylonjs/types";
  17399. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17401. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17402. import { IDisposable } from "babylonjs/scene";
  17403. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17404. import "babylonjs/Shaders/line.fragment";
  17405. import "babylonjs/Shaders/line.vertex";
  17406. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17407. import { SmartArray } from "babylonjs/Misc/smartArray";
  17408. module "babylonjs/scene" {
  17409. interface Scene {
  17410. /** @hidden */
  17411. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17412. }
  17413. }
  17414. module "babylonjs/Meshes/abstractMesh" {
  17415. interface AbstractMesh {
  17416. /**
  17417. * Gets the edgesRenderer associated with the mesh
  17418. */
  17419. edgesRenderer: Nullable<EdgesRenderer>;
  17420. }
  17421. }
  17422. module "babylonjs/Meshes/linesMesh" {
  17423. interface LinesMesh {
  17424. /**
  17425. * Enables the edge rendering mode on the mesh.
  17426. * This mode makes the mesh edges visible
  17427. * @param epsilon defines the maximal distance between two angles to detect a face
  17428. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17429. * @returns the currentAbstractMesh
  17430. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17431. */
  17432. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17433. }
  17434. }
  17435. module "babylonjs/Meshes/linesMesh" {
  17436. interface InstancedLinesMesh {
  17437. /**
  17438. * Enables the edge rendering mode on the mesh.
  17439. * This mode makes the mesh edges visible
  17440. * @param epsilon defines the maximal distance between two angles to detect a face
  17441. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17442. * @returns the current InstancedLinesMesh
  17443. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17444. */
  17445. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17446. }
  17447. }
  17448. /**
  17449. * Defines the minimum contract an Edges renderer should follow.
  17450. */
  17451. export interface IEdgesRenderer extends IDisposable {
  17452. /**
  17453. * Gets or sets a boolean indicating if the edgesRenderer is active
  17454. */
  17455. isEnabled: boolean;
  17456. /**
  17457. * Renders the edges of the attached mesh,
  17458. */
  17459. render(): void;
  17460. /**
  17461. * Checks wether or not the edges renderer is ready to render.
  17462. * @return true if ready, otherwise false.
  17463. */
  17464. isReady(): boolean;
  17465. /**
  17466. * List of instances to render in case the source mesh has instances
  17467. */
  17468. customInstances: SmartArray<Matrix>;
  17469. }
  17470. /**
  17471. * Defines the additional options of the edges renderer
  17472. */
  17473. export interface IEdgesRendererOptions {
  17474. /**
  17475. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17476. * If not defined, the default value is true
  17477. */
  17478. useAlternateEdgeFinder?: boolean;
  17479. /**
  17480. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17481. * If not defined, the default value is true.
  17482. * 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)
  17483. * This option is used only if useAlternateEdgeFinder = true
  17484. */
  17485. useFastVertexMerger?: boolean;
  17486. /**
  17487. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17488. * The default value is 1e-6
  17489. * This option is used only if useAlternateEdgeFinder = true
  17490. */
  17491. epsilonVertexMerge?: number;
  17492. /**
  17493. * 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
  17494. * 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.
  17495. * This option is used only if useAlternateEdgeFinder = true
  17496. */
  17497. applyTessellation?: boolean;
  17498. /**
  17499. * 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
  17500. * The default value is 1e-6
  17501. * This option is used only if useAlternateEdgeFinder = true
  17502. */
  17503. epsilonVertexAligned?: number;
  17504. }
  17505. /**
  17506. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17507. */
  17508. export class EdgesRenderer implements IEdgesRenderer {
  17509. /**
  17510. * Define the size of the edges with an orthographic camera
  17511. */
  17512. edgesWidthScalerForOrthographic: number;
  17513. /**
  17514. * Define the size of the edges with a perspective camera
  17515. */
  17516. edgesWidthScalerForPerspective: number;
  17517. protected _source: AbstractMesh;
  17518. protected _linesPositions: number[];
  17519. protected _linesNormals: number[];
  17520. protected _linesIndices: number[];
  17521. protected _epsilon: number;
  17522. protected _indicesCount: number;
  17523. protected _lineShader: ShaderMaterial;
  17524. protected _ib: DataBuffer;
  17525. protected _buffers: {
  17526. [key: string]: Nullable<VertexBuffer>;
  17527. };
  17528. protected _buffersForInstances: {
  17529. [key: string]: Nullable<VertexBuffer>;
  17530. };
  17531. protected _checkVerticesInsteadOfIndices: boolean;
  17532. protected _options: Nullable<IEdgesRendererOptions>;
  17533. private _meshRebuildObserver;
  17534. private _meshDisposeObserver;
  17535. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17536. isEnabled: boolean;
  17537. /**
  17538. * List of instances to render in case the source mesh has instances
  17539. */
  17540. customInstances: SmartArray<Matrix>;
  17541. private static GetShader;
  17542. /**
  17543. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17544. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17545. * @param source Mesh used to create edges
  17546. * @param epsilon sum of angles in adjacency to check for edge
  17547. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17548. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17549. * @param options The options to apply when generating the edges
  17550. */
  17551. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17552. protected _prepareRessources(): void;
  17553. /** @hidden */
  17554. _rebuild(): void;
  17555. /**
  17556. * Releases the required resources for the edges renderer
  17557. */
  17558. dispose(): void;
  17559. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17560. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17561. /**
  17562. * Checks if the pair of p0 and p1 is en edge
  17563. * @param faceIndex
  17564. * @param edge
  17565. * @param faceNormals
  17566. * @param p0
  17567. * @param p1
  17568. * @private
  17569. */
  17570. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17571. /**
  17572. * push line into the position, normal and index buffer
  17573. * @protected
  17574. */
  17575. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17576. /**
  17577. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17578. */
  17579. private _tessellateTriangle;
  17580. private _generateEdgesLinesAlternate;
  17581. /**
  17582. * Generates lines edges from adjacencjes
  17583. * @private
  17584. */
  17585. _generateEdgesLines(): void;
  17586. /**
  17587. * Checks wether or not the edges renderer is ready to render.
  17588. * @return true if ready, otherwise false.
  17589. */
  17590. isReady(): boolean;
  17591. /**
  17592. * Renders the edges of the attached mesh,
  17593. */
  17594. render(): void;
  17595. }
  17596. /**
  17597. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17598. */
  17599. export class LineEdgesRenderer extends EdgesRenderer {
  17600. /**
  17601. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17602. * @param source LineMesh used to generate edges
  17603. * @param epsilon not important (specified angle for edge detection)
  17604. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17605. */
  17606. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17607. /**
  17608. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17609. */
  17610. _generateEdgesLines(): void;
  17611. }
  17612. }
  17613. declare module "babylonjs/Rendering/renderingGroup" {
  17614. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17617. import { Nullable } from "babylonjs/types";
  17618. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17619. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17620. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17621. import { Material } from "babylonjs/Materials/material";
  17622. import { Scene } from "babylonjs/scene";
  17623. /**
  17624. * This represents the object necessary to create a rendering group.
  17625. * This is exclusively used and created by the rendering manager.
  17626. * To modify the behavior, you use the available helpers in your scene or meshes.
  17627. * @hidden
  17628. */
  17629. export class RenderingGroup {
  17630. index: number;
  17631. private static _zeroVector;
  17632. private _scene;
  17633. private _opaqueSubMeshes;
  17634. private _transparentSubMeshes;
  17635. private _alphaTestSubMeshes;
  17636. private _depthOnlySubMeshes;
  17637. private _particleSystems;
  17638. private _spriteManagers;
  17639. private _opaqueSortCompareFn;
  17640. private _alphaTestSortCompareFn;
  17641. private _transparentSortCompareFn;
  17642. private _renderOpaque;
  17643. private _renderAlphaTest;
  17644. private _renderTransparent;
  17645. /** @hidden */
  17646. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17647. onBeforeTransparentRendering: () => void;
  17648. /**
  17649. * Set the opaque sort comparison function.
  17650. * If null the sub meshes will be render in the order they were created
  17651. */
  17652. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17653. /**
  17654. * Set the alpha test sort comparison function.
  17655. * If null the sub meshes will be render in the order they were created
  17656. */
  17657. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17658. /**
  17659. * Set the transparent sort comparison function.
  17660. * If null the sub meshes will be render in the order they were created
  17661. */
  17662. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17663. /**
  17664. * Creates a new rendering group.
  17665. * @param index The rendering group index
  17666. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17667. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17668. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17669. */
  17670. 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>);
  17671. /**
  17672. * Render all the sub meshes contained in the group.
  17673. * @param customRenderFunction Used to override the default render behaviour of the group.
  17674. * @returns true if rendered some submeshes.
  17675. */
  17676. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17677. /**
  17678. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17679. * @param subMeshes The submeshes to render
  17680. */
  17681. private renderOpaqueSorted;
  17682. /**
  17683. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17684. * @param subMeshes The submeshes to render
  17685. */
  17686. private renderAlphaTestSorted;
  17687. /**
  17688. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17689. * @param subMeshes The submeshes to render
  17690. */
  17691. private renderTransparentSorted;
  17692. /**
  17693. * Renders the submeshes in a specified order.
  17694. * @param subMeshes The submeshes to sort before render
  17695. * @param sortCompareFn The comparison function use to sort
  17696. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17697. * @param transparent Specifies to activate blending if true
  17698. */
  17699. private static renderSorted;
  17700. /**
  17701. * Renders the submeshes in the order they were dispatched (no sort applied).
  17702. * @param subMeshes The submeshes to render
  17703. */
  17704. private static renderUnsorted;
  17705. /**
  17706. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17707. * are rendered back to front if in the same alpha index.
  17708. *
  17709. * @param a The first submesh
  17710. * @param b The second submesh
  17711. * @returns The result of the comparison
  17712. */
  17713. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17714. /**
  17715. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17716. * are rendered back to front.
  17717. *
  17718. * @param a The first submesh
  17719. * @param b The second submesh
  17720. * @returns The result of the comparison
  17721. */
  17722. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17723. /**
  17724. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17725. * are rendered front to back (prevent overdraw).
  17726. *
  17727. * @param a The first submesh
  17728. * @param b The second submesh
  17729. * @returns The result of the comparison
  17730. */
  17731. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17732. /**
  17733. * Resets the different lists of submeshes to prepare a new frame.
  17734. */
  17735. prepare(): void;
  17736. dispose(): void;
  17737. /**
  17738. * Inserts the submesh in its correct queue depending on its material.
  17739. * @param subMesh The submesh to dispatch
  17740. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17741. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17742. */
  17743. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17744. dispatchSprites(spriteManager: ISpriteManager): void;
  17745. dispatchParticles(particleSystem: IParticleSystem): void;
  17746. private _renderParticles;
  17747. private _renderSprites;
  17748. }
  17749. }
  17750. declare module "babylonjs/Rendering/renderingManager" {
  17751. import { Nullable } from "babylonjs/types";
  17752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17753. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17754. import { SmartArray } from "babylonjs/Misc/smartArray";
  17755. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17756. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17757. import { Material } from "babylonjs/Materials/material";
  17758. import { Scene } from "babylonjs/scene";
  17759. import { Camera } from "babylonjs/Cameras/camera";
  17760. /**
  17761. * Interface describing the different options available in the rendering manager
  17762. * regarding Auto Clear between groups.
  17763. */
  17764. export interface IRenderingManagerAutoClearSetup {
  17765. /**
  17766. * Defines whether or not autoclear is enable.
  17767. */
  17768. autoClear: boolean;
  17769. /**
  17770. * Defines whether or not to autoclear the depth buffer.
  17771. */
  17772. depth: boolean;
  17773. /**
  17774. * Defines whether or not to autoclear the stencil buffer.
  17775. */
  17776. stencil: boolean;
  17777. }
  17778. /**
  17779. * This class is used by the onRenderingGroupObservable
  17780. */
  17781. export class RenderingGroupInfo {
  17782. /**
  17783. * The Scene that being rendered
  17784. */
  17785. scene: Scene;
  17786. /**
  17787. * The camera currently used for the rendering pass
  17788. */
  17789. camera: Nullable<Camera>;
  17790. /**
  17791. * The ID of the renderingGroup being processed
  17792. */
  17793. renderingGroupId: number;
  17794. }
  17795. /**
  17796. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17797. * It is enable to manage the different groups as well as the different necessary sort functions.
  17798. * This should not be used directly aside of the few static configurations
  17799. */
  17800. export class RenderingManager {
  17801. /**
  17802. * The max id used for rendering groups (not included)
  17803. */
  17804. static MAX_RENDERINGGROUPS: number;
  17805. /**
  17806. * The min id used for rendering groups (included)
  17807. */
  17808. static MIN_RENDERINGGROUPS: number;
  17809. /**
  17810. * Used to globally prevent autoclearing scenes.
  17811. */
  17812. static AUTOCLEAR: boolean;
  17813. /**
  17814. * @hidden
  17815. */
  17816. _useSceneAutoClearSetup: boolean;
  17817. private _scene;
  17818. private _renderingGroups;
  17819. private _depthStencilBufferAlreadyCleaned;
  17820. private _autoClearDepthStencil;
  17821. private _customOpaqueSortCompareFn;
  17822. private _customAlphaTestSortCompareFn;
  17823. private _customTransparentSortCompareFn;
  17824. private _renderingGroupInfo;
  17825. /**
  17826. * Instantiates a new rendering group for a particular scene
  17827. * @param scene Defines the scene the groups belongs to
  17828. */
  17829. constructor(scene: Scene);
  17830. private _clearDepthStencilBuffer;
  17831. /**
  17832. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17833. * @hidden
  17834. */
  17835. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17836. /**
  17837. * Resets the different information of the group to prepare a new frame
  17838. * @hidden
  17839. */
  17840. reset(): void;
  17841. /**
  17842. * Dispose and release the group and its associated resources.
  17843. * @hidden
  17844. */
  17845. dispose(): void;
  17846. /**
  17847. * Clear the info related to rendering groups preventing retention points during dispose.
  17848. */
  17849. freeRenderingGroups(): void;
  17850. private _prepareRenderingGroup;
  17851. /**
  17852. * Add a sprite manager to the rendering manager in order to render it this frame.
  17853. * @param spriteManager Define the sprite manager to render
  17854. */
  17855. dispatchSprites(spriteManager: ISpriteManager): void;
  17856. /**
  17857. * Add a particle system to the rendering manager in order to render it this frame.
  17858. * @param particleSystem Define the particle system to render
  17859. */
  17860. dispatchParticles(particleSystem: IParticleSystem): void;
  17861. /**
  17862. * Add a submesh to the manager in order to render it this frame
  17863. * @param subMesh The submesh to dispatch
  17864. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17865. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17866. */
  17867. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17868. /**
  17869. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17870. * This allowed control for front to back rendering or reversly depending of the special needs.
  17871. *
  17872. * @param renderingGroupId The rendering group id corresponding to its index
  17873. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17874. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17875. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17876. */
  17877. 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;
  17878. /**
  17879. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17880. *
  17881. * @param renderingGroupId The rendering group id corresponding to its index
  17882. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17883. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17884. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17885. */
  17886. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17887. /**
  17888. * Gets the current auto clear configuration for one rendering group of the rendering
  17889. * manager.
  17890. * @param index the rendering group index to get the information for
  17891. * @returns The auto clear setup for the requested rendering group
  17892. */
  17893. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17894. }
  17895. }
  17896. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17897. import { SmartArray } from "babylonjs/Misc/smartArray";
  17898. import { Nullable } from "babylonjs/types";
  17899. import { Scene } from "babylonjs/scene";
  17900. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17901. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17903. import { Mesh } from "babylonjs/Meshes/mesh";
  17904. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17905. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17906. import { Effect } from "babylonjs/Materials/effect";
  17907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17908. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17909. import "babylonjs/Shaders/shadowMap.fragment";
  17910. import "babylonjs/Shaders/shadowMap.vertex";
  17911. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17912. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17913. import { Observable } from "babylonjs/Misc/observable";
  17914. /**
  17915. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17916. */
  17917. export interface ICustomShaderOptions {
  17918. /**
  17919. * Gets or sets the custom shader name to use
  17920. */
  17921. shaderName: string;
  17922. /**
  17923. * The list of attribute names used in the shader
  17924. */
  17925. attributes?: string[];
  17926. /**
  17927. * The list of unifrom names used in the shader
  17928. */
  17929. uniforms?: string[];
  17930. /**
  17931. * The list of sampler names used in the shader
  17932. */
  17933. samplers?: string[];
  17934. /**
  17935. * The list of defines used in the shader
  17936. */
  17937. defines?: string[];
  17938. }
  17939. /**
  17940. * Interface to implement to create a shadow generator compatible with BJS.
  17941. */
  17942. export interface IShadowGenerator {
  17943. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17944. id: string;
  17945. /**
  17946. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17947. * @returns The render target texture if present otherwise, null
  17948. */
  17949. getShadowMap(): Nullable<RenderTargetTexture>;
  17950. /**
  17951. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17952. * @param subMesh The submesh we want to render in the shadow map
  17953. * @param useInstances Defines wether will draw in the map using instances
  17954. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17955. * @returns true if ready otherwise, false
  17956. */
  17957. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17958. /**
  17959. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17960. * @param defines Defines of the material we want to update
  17961. * @param lightIndex Index of the light in the enabled light list of the material
  17962. */
  17963. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17964. /**
  17965. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17966. * defined in the generator but impacting the effect).
  17967. * It implies the unifroms available on the materials are the standard BJS ones.
  17968. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17969. * @param effect The effect we are binfing the information for
  17970. */
  17971. bindShadowLight(lightIndex: string, effect: Effect): void;
  17972. /**
  17973. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17974. * (eq to shadow prjection matrix * light transform matrix)
  17975. * @returns The transform matrix used to create the shadow map
  17976. */
  17977. getTransformMatrix(): Matrix;
  17978. /**
  17979. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17980. * Cube and 2D textures for instance.
  17981. */
  17982. recreateShadowMap(): void;
  17983. /**
  17984. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17985. * @param onCompiled Callback triggered at the and of the effects compilation
  17986. * @param options Sets of optional options forcing the compilation with different modes
  17987. */
  17988. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17989. useInstances: boolean;
  17990. }>): void;
  17991. /**
  17992. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17993. * @param options Sets of optional options forcing the compilation with different modes
  17994. * @returns A promise that resolves when the compilation completes
  17995. */
  17996. forceCompilationAsync(options?: Partial<{
  17997. useInstances: boolean;
  17998. }>): Promise<void>;
  17999. /**
  18000. * Serializes the shadow generator setup to a json object.
  18001. * @returns The serialized JSON object
  18002. */
  18003. serialize(): any;
  18004. /**
  18005. * Disposes the Shadow map and related Textures and effects.
  18006. */
  18007. dispose(): void;
  18008. }
  18009. /**
  18010. * Default implementation IShadowGenerator.
  18011. * This is the main object responsible of generating shadows in the framework.
  18012. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18013. */
  18014. export class ShadowGenerator implements IShadowGenerator {
  18015. /**
  18016. * Name of the shadow generator class
  18017. */
  18018. static CLASSNAME: string;
  18019. /**
  18020. * Shadow generator mode None: no filtering applied.
  18021. */
  18022. static readonly FILTER_NONE: number;
  18023. /**
  18024. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18025. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18026. */
  18027. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18028. /**
  18029. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18030. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18031. */
  18032. static readonly FILTER_POISSONSAMPLING: number;
  18033. /**
  18034. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18035. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18036. */
  18037. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18038. /**
  18039. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18040. * edge artifacts on steep falloff.
  18041. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18042. */
  18043. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18044. /**
  18045. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18046. * edge artifacts on steep falloff.
  18047. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18048. */
  18049. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18050. /**
  18051. * Shadow generator mode PCF: Percentage Closer Filtering
  18052. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18053. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18054. */
  18055. static readonly FILTER_PCF: number;
  18056. /**
  18057. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18058. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18059. * Contact Hardening
  18060. */
  18061. static readonly FILTER_PCSS: number;
  18062. /**
  18063. * Reserved for PCF and PCSS
  18064. * Highest Quality.
  18065. *
  18066. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18067. *
  18068. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18069. */
  18070. static readonly QUALITY_HIGH: number;
  18071. /**
  18072. * Reserved for PCF and PCSS
  18073. * Good tradeoff for quality/perf cross devices
  18074. *
  18075. * Execute PCF on a 3*3 kernel.
  18076. *
  18077. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18078. */
  18079. static readonly QUALITY_MEDIUM: number;
  18080. /**
  18081. * Reserved for PCF and PCSS
  18082. * The lowest quality but the fastest.
  18083. *
  18084. * Execute PCF on a 1*1 kernel.
  18085. *
  18086. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18087. */
  18088. static readonly QUALITY_LOW: number;
  18089. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18090. id: string;
  18091. /** Gets or sets the custom shader name to use */
  18092. customShaderOptions: ICustomShaderOptions;
  18093. /**
  18094. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18095. */
  18096. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18097. /**
  18098. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18099. */
  18100. onAfterShadowMapRenderObservable: Observable<Effect>;
  18101. /**
  18102. * Observable triggered before a mesh is rendered in the shadow map.
  18103. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18104. */
  18105. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18106. /**
  18107. * Observable triggered after a mesh is rendered in the shadow map.
  18108. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18109. */
  18110. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18111. protected _bias: number;
  18112. /**
  18113. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18114. */
  18115. get bias(): number;
  18116. /**
  18117. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18118. */
  18119. set bias(bias: number);
  18120. protected _normalBias: number;
  18121. /**
  18122. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18123. */
  18124. get normalBias(): number;
  18125. /**
  18126. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18127. */
  18128. set normalBias(normalBias: number);
  18129. protected _blurBoxOffset: number;
  18130. /**
  18131. * Gets the blur box offset: offset applied during the blur pass.
  18132. * Only useful if useKernelBlur = false
  18133. */
  18134. get blurBoxOffset(): number;
  18135. /**
  18136. * Sets the blur box offset: offset applied during the blur pass.
  18137. * Only useful if useKernelBlur = false
  18138. */
  18139. set blurBoxOffset(value: number);
  18140. protected _blurScale: number;
  18141. /**
  18142. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18143. * 2 means half of the size.
  18144. */
  18145. get blurScale(): number;
  18146. /**
  18147. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18148. * 2 means half of the size.
  18149. */
  18150. set blurScale(value: number);
  18151. protected _blurKernel: number;
  18152. /**
  18153. * Gets the blur kernel: kernel size of the blur pass.
  18154. * Only useful if useKernelBlur = true
  18155. */
  18156. get blurKernel(): number;
  18157. /**
  18158. * Sets the blur kernel: kernel size of the blur pass.
  18159. * Only useful if useKernelBlur = true
  18160. */
  18161. set blurKernel(value: number);
  18162. protected _useKernelBlur: boolean;
  18163. /**
  18164. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18165. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18166. */
  18167. get useKernelBlur(): boolean;
  18168. /**
  18169. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18170. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18171. */
  18172. set useKernelBlur(value: boolean);
  18173. protected _depthScale: number;
  18174. /**
  18175. * Gets the depth scale used in ESM mode.
  18176. */
  18177. get depthScale(): number;
  18178. /**
  18179. * Sets the depth scale used in ESM mode.
  18180. * This can override the scale stored on the light.
  18181. */
  18182. set depthScale(value: number);
  18183. protected _validateFilter(filter: number): number;
  18184. protected _filter: number;
  18185. /**
  18186. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18187. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18188. */
  18189. get filter(): number;
  18190. /**
  18191. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18192. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18193. */
  18194. set filter(value: number);
  18195. /**
  18196. * Gets if the current filter is set to Poisson Sampling.
  18197. */
  18198. get usePoissonSampling(): boolean;
  18199. /**
  18200. * Sets the current filter to Poisson Sampling.
  18201. */
  18202. set usePoissonSampling(value: boolean);
  18203. /**
  18204. * Gets if the current filter is set to ESM.
  18205. */
  18206. get useExponentialShadowMap(): boolean;
  18207. /**
  18208. * Sets the current filter is to ESM.
  18209. */
  18210. set useExponentialShadowMap(value: boolean);
  18211. /**
  18212. * Gets if the current filter is set to filtered ESM.
  18213. */
  18214. get useBlurExponentialShadowMap(): boolean;
  18215. /**
  18216. * Gets if the current filter is set to filtered ESM.
  18217. */
  18218. set useBlurExponentialShadowMap(value: boolean);
  18219. /**
  18220. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18221. * exponential to prevent steep falloff artifacts).
  18222. */
  18223. get useCloseExponentialShadowMap(): boolean;
  18224. /**
  18225. * Sets the current filter to "close ESM" (using the inverse of the
  18226. * exponential to prevent steep falloff artifacts).
  18227. */
  18228. set useCloseExponentialShadowMap(value: boolean);
  18229. /**
  18230. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18231. * exponential to prevent steep falloff artifacts).
  18232. */
  18233. get useBlurCloseExponentialShadowMap(): boolean;
  18234. /**
  18235. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18236. * exponential to prevent steep falloff artifacts).
  18237. */
  18238. set useBlurCloseExponentialShadowMap(value: boolean);
  18239. /**
  18240. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18241. */
  18242. get usePercentageCloserFiltering(): boolean;
  18243. /**
  18244. * Sets the current filter to "PCF" (percentage closer filtering).
  18245. */
  18246. set usePercentageCloserFiltering(value: boolean);
  18247. protected _filteringQuality: number;
  18248. /**
  18249. * Gets the PCF or PCSS Quality.
  18250. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18251. */
  18252. get filteringQuality(): number;
  18253. /**
  18254. * Sets the PCF or PCSS Quality.
  18255. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18256. */
  18257. set filteringQuality(filteringQuality: number);
  18258. /**
  18259. * Gets if the current filter is set to "PCSS" (contact hardening).
  18260. */
  18261. get useContactHardeningShadow(): boolean;
  18262. /**
  18263. * Sets the current filter to "PCSS" (contact hardening).
  18264. */
  18265. set useContactHardeningShadow(value: boolean);
  18266. protected _contactHardeningLightSizeUVRatio: number;
  18267. /**
  18268. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18269. * Using a ratio helps keeping shape stability independently of the map size.
  18270. *
  18271. * It does not account for the light projection as it was having too much
  18272. * instability during the light setup or during light position changes.
  18273. *
  18274. * Only valid if useContactHardeningShadow is true.
  18275. */
  18276. get contactHardeningLightSizeUVRatio(): number;
  18277. /**
  18278. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18279. * Using a ratio helps keeping shape stability independently of the map size.
  18280. *
  18281. * It does not account for the light projection as it was having too much
  18282. * instability during the light setup or during light position changes.
  18283. *
  18284. * Only valid if useContactHardeningShadow is true.
  18285. */
  18286. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18287. protected _darkness: number;
  18288. /** Gets or sets the actual darkness of a shadow */
  18289. get darkness(): number;
  18290. set darkness(value: number);
  18291. /**
  18292. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18293. * 0 means strongest and 1 would means no shadow.
  18294. * @returns the darkness.
  18295. */
  18296. getDarkness(): number;
  18297. /**
  18298. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18299. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18300. * @returns the shadow generator allowing fluent coding.
  18301. */
  18302. setDarkness(darkness: number): ShadowGenerator;
  18303. protected _transparencyShadow: boolean;
  18304. /** Gets or sets the ability to have transparent shadow */
  18305. get transparencyShadow(): boolean;
  18306. set transparencyShadow(value: boolean);
  18307. /**
  18308. * Sets the ability to have transparent shadow (boolean).
  18309. * @param transparent True if transparent else False
  18310. * @returns the shadow generator allowing fluent coding
  18311. */
  18312. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18313. /**
  18314. * Enables or disables shadows with varying strength based on the transparency
  18315. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18316. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18317. * mesh.visibility * alphaTexture.a
  18318. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18319. */
  18320. enableSoftTransparentShadow: boolean;
  18321. protected _shadowMap: Nullable<RenderTargetTexture>;
  18322. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18323. /**
  18324. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18325. * @returns The render target texture if present otherwise, null
  18326. */
  18327. getShadowMap(): Nullable<RenderTargetTexture>;
  18328. /**
  18329. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18330. * @returns The render target texture if the shadow map is present otherwise, null
  18331. */
  18332. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18333. /**
  18334. * Gets the class name of that object
  18335. * @returns "ShadowGenerator"
  18336. */
  18337. getClassName(): string;
  18338. /**
  18339. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18340. * @param mesh Mesh to add
  18341. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18342. * @returns the Shadow Generator itself
  18343. */
  18344. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18345. /**
  18346. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18347. * @param mesh Mesh to remove
  18348. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18349. * @returns the Shadow Generator itself
  18350. */
  18351. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18352. /**
  18353. * Controls the extent to which the shadows fade out at the edge of the frustum
  18354. */
  18355. frustumEdgeFalloff: number;
  18356. protected _light: IShadowLight;
  18357. /**
  18358. * Returns the associated light object.
  18359. * @returns the light generating the shadow
  18360. */
  18361. getLight(): IShadowLight;
  18362. /**
  18363. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18364. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18365. * It might on the other hand introduce peter panning.
  18366. */
  18367. forceBackFacesOnly: boolean;
  18368. protected _scene: Scene;
  18369. protected _lightDirection: Vector3;
  18370. protected _effect: Effect;
  18371. protected _viewMatrix: Matrix;
  18372. protected _projectionMatrix: Matrix;
  18373. protected _transformMatrix: Matrix;
  18374. protected _cachedPosition: Vector3;
  18375. protected _cachedDirection: Vector3;
  18376. protected _cachedDefines: string;
  18377. protected _currentRenderID: number;
  18378. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18379. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18380. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18381. protected _blurPostProcesses: PostProcess[];
  18382. protected _mapSize: number;
  18383. protected _currentFaceIndex: number;
  18384. protected _currentFaceIndexCache: number;
  18385. protected _textureType: number;
  18386. protected _defaultTextureMatrix: Matrix;
  18387. protected _storedUniqueId: Nullable<number>;
  18388. /** @hidden */
  18389. static _SceneComponentInitialization: (scene: Scene) => void;
  18390. /**
  18391. * Creates a ShadowGenerator object.
  18392. * A ShadowGenerator is the required tool to use the shadows.
  18393. * Each light casting shadows needs to use its own ShadowGenerator.
  18394. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18395. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18396. * @param light The light object generating the shadows.
  18397. * @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.
  18398. */
  18399. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18400. protected _initializeGenerator(): void;
  18401. protected _createTargetRenderTexture(): void;
  18402. protected _initializeShadowMap(): void;
  18403. protected _initializeBlurRTTAndPostProcesses(): void;
  18404. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18405. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18406. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18407. protected _applyFilterValues(): void;
  18408. /**
  18409. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18410. * @param onCompiled Callback triggered at the and of the effects compilation
  18411. * @param options Sets of optional options forcing the compilation with different modes
  18412. */
  18413. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18414. useInstances: boolean;
  18415. }>): void;
  18416. /**
  18417. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18418. * @param options Sets of optional options forcing the compilation with different modes
  18419. * @returns A promise that resolves when the compilation completes
  18420. */
  18421. forceCompilationAsync(options?: Partial<{
  18422. useInstances: boolean;
  18423. }>): Promise<void>;
  18424. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18425. private _prepareShadowDefines;
  18426. /**
  18427. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18428. * @param subMesh The submesh we want to render in the shadow map
  18429. * @param useInstances Defines wether will draw in the map using instances
  18430. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18431. * @returns true if ready otherwise, false
  18432. */
  18433. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18434. /**
  18435. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18436. * @param defines Defines of the material we want to update
  18437. * @param lightIndex Index of the light in the enabled light list of the material
  18438. */
  18439. prepareDefines(defines: any, lightIndex: number): void;
  18440. /**
  18441. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18442. * defined in the generator but impacting the effect).
  18443. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18444. * @param effect The effect we are binfing the information for
  18445. */
  18446. bindShadowLight(lightIndex: string, effect: Effect): void;
  18447. /**
  18448. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18449. * (eq to shadow prjection matrix * light transform matrix)
  18450. * @returns The transform matrix used to create the shadow map
  18451. */
  18452. getTransformMatrix(): Matrix;
  18453. /**
  18454. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18455. * Cube and 2D textures for instance.
  18456. */
  18457. recreateShadowMap(): void;
  18458. protected _disposeBlurPostProcesses(): void;
  18459. protected _disposeRTTandPostProcesses(): void;
  18460. /**
  18461. * Disposes the ShadowGenerator.
  18462. * Returns nothing.
  18463. */
  18464. dispose(): void;
  18465. /**
  18466. * Serializes the shadow generator setup to a json object.
  18467. * @returns The serialized JSON object
  18468. */
  18469. serialize(): any;
  18470. /**
  18471. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18472. * @param parsedShadowGenerator The JSON object to parse
  18473. * @param scene The scene to create the shadow map for
  18474. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18475. * @returns The parsed shadow generator
  18476. */
  18477. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18478. }
  18479. }
  18480. declare module "babylonjs/Lights/light" {
  18481. import { Nullable } from "babylonjs/types";
  18482. import { Scene } from "babylonjs/scene";
  18483. import { Vector3 } from "babylonjs/Maths/math.vector";
  18484. import { Color3 } from "babylonjs/Maths/math.color";
  18485. import { Node } from "babylonjs/node";
  18486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18487. import { Effect } from "babylonjs/Materials/effect";
  18488. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18489. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18490. /**
  18491. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18492. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18493. * 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.
  18494. */
  18495. export abstract class Light extends Node {
  18496. /**
  18497. * Falloff Default: light is falling off following the material specification:
  18498. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18499. */
  18500. static readonly FALLOFF_DEFAULT: number;
  18501. /**
  18502. * Falloff Physical: light is falling off following the inverse squared distance law.
  18503. */
  18504. static readonly FALLOFF_PHYSICAL: number;
  18505. /**
  18506. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18507. * to enhance interoperability with other engines.
  18508. */
  18509. static readonly FALLOFF_GLTF: number;
  18510. /**
  18511. * Falloff Standard: light is falling off like in the standard material
  18512. * to enhance interoperability with other materials.
  18513. */
  18514. static readonly FALLOFF_STANDARD: number;
  18515. /**
  18516. * If every light affecting the material is in this lightmapMode,
  18517. * material.lightmapTexture adds or multiplies
  18518. * (depends on material.useLightmapAsShadowmap)
  18519. * after every other light calculations.
  18520. */
  18521. static readonly LIGHTMAP_DEFAULT: number;
  18522. /**
  18523. * material.lightmapTexture as only diffuse lighting from this light
  18524. * adds only specular lighting from this light
  18525. * adds dynamic shadows
  18526. */
  18527. static readonly LIGHTMAP_SPECULAR: number;
  18528. /**
  18529. * material.lightmapTexture as only lighting
  18530. * no light calculation from this light
  18531. * only adds dynamic shadows from this light
  18532. */
  18533. static readonly LIGHTMAP_SHADOWSONLY: number;
  18534. /**
  18535. * Each light type uses the default quantity according to its type:
  18536. * point/spot lights use luminous intensity
  18537. * directional lights use illuminance
  18538. */
  18539. static readonly INTENSITYMODE_AUTOMATIC: number;
  18540. /**
  18541. * lumen (lm)
  18542. */
  18543. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18544. /**
  18545. * candela (lm/sr)
  18546. */
  18547. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18548. /**
  18549. * lux (lm/m^2)
  18550. */
  18551. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18552. /**
  18553. * nit (cd/m^2)
  18554. */
  18555. static readonly INTENSITYMODE_LUMINANCE: number;
  18556. /**
  18557. * Light type const id of the point light.
  18558. */
  18559. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18560. /**
  18561. * Light type const id of the directional light.
  18562. */
  18563. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18564. /**
  18565. * Light type const id of the spot light.
  18566. */
  18567. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18568. /**
  18569. * Light type const id of the hemispheric light.
  18570. */
  18571. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18572. /**
  18573. * Diffuse gives the basic color to an object.
  18574. */
  18575. diffuse: Color3;
  18576. /**
  18577. * Specular produces a highlight color on an object.
  18578. * Note: This is note affecting PBR materials.
  18579. */
  18580. specular: Color3;
  18581. /**
  18582. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18583. * falling off base on range or angle.
  18584. * This can be set to any values in Light.FALLOFF_x.
  18585. *
  18586. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18587. * other types of materials.
  18588. */
  18589. falloffType: number;
  18590. /**
  18591. * Strength of the light.
  18592. * Note: By default it is define in the framework own unit.
  18593. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18594. */
  18595. intensity: number;
  18596. private _range;
  18597. protected _inverseSquaredRange: number;
  18598. /**
  18599. * Defines how far from the source the light is impacting in scene units.
  18600. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18601. */
  18602. get range(): number;
  18603. /**
  18604. * Defines how far from the source the light is impacting in scene units.
  18605. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18606. */
  18607. set range(value: number);
  18608. /**
  18609. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18610. * of light.
  18611. */
  18612. private _photometricScale;
  18613. private _intensityMode;
  18614. /**
  18615. * Gets the photometric scale used to interpret the intensity.
  18616. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18617. */
  18618. get intensityMode(): number;
  18619. /**
  18620. * Sets the photometric scale used to interpret the intensity.
  18621. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18622. */
  18623. set intensityMode(value: number);
  18624. private _radius;
  18625. /**
  18626. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18627. */
  18628. get radius(): number;
  18629. /**
  18630. * sets the light radius used by PBR Materials to simulate soft area lights.
  18631. */
  18632. set radius(value: number);
  18633. private _renderPriority;
  18634. /**
  18635. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18636. * exceeding the number allowed of the materials.
  18637. */
  18638. renderPriority: number;
  18639. private _shadowEnabled;
  18640. /**
  18641. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18642. * the current shadow generator.
  18643. */
  18644. get shadowEnabled(): boolean;
  18645. /**
  18646. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18647. * the current shadow generator.
  18648. */
  18649. set shadowEnabled(value: boolean);
  18650. private _includedOnlyMeshes;
  18651. /**
  18652. * Gets the only meshes impacted by this light.
  18653. */
  18654. get includedOnlyMeshes(): AbstractMesh[];
  18655. /**
  18656. * Sets the only meshes impacted by this light.
  18657. */
  18658. set includedOnlyMeshes(value: AbstractMesh[]);
  18659. private _excludedMeshes;
  18660. /**
  18661. * Gets the meshes not impacted by this light.
  18662. */
  18663. get excludedMeshes(): AbstractMesh[];
  18664. /**
  18665. * Sets the meshes not impacted by this light.
  18666. */
  18667. set excludedMeshes(value: AbstractMesh[]);
  18668. private _excludeWithLayerMask;
  18669. /**
  18670. * Gets the layer id use to find what meshes are not impacted by the light.
  18671. * Inactive if 0
  18672. */
  18673. get excludeWithLayerMask(): number;
  18674. /**
  18675. * Sets the layer id use to find what meshes are not impacted by the light.
  18676. * Inactive if 0
  18677. */
  18678. set excludeWithLayerMask(value: number);
  18679. private _includeOnlyWithLayerMask;
  18680. /**
  18681. * Gets the layer id use to find what meshes are impacted by the light.
  18682. * Inactive if 0
  18683. */
  18684. get includeOnlyWithLayerMask(): number;
  18685. /**
  18686. * Sets the layer id use to find what meshes are impacted by the light.
  18687. * Inactive if 0
  18688. */
  18689. set includeOnlyWithLayerMask(value: number);
  18690. private _lightmapMode;
  18691. /**
  18692. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18693. */
  18694. get lightmapMode(): number;
  18695. /**
  18696. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18697. */
  18698. set lightmapMode(value: number);
  18699. /**
  18700. * Shadow generator associted to the light.
  18701. * @hidden Internal use only.
  18702. */
  18703. _shadowGenerator: Nullable<IShadowGenerator>;
  18704. /**
  18705. * @hidden Internal use only.
  18706. */
  18707. _excludedMeshesIds: string[];
  18708. /**
  18709. * @hidden Internal use only.
  18710. */
  18711. _includedOnlyMeshesIds: string[];
  18712. /**
  18713. * The current light unifom buffer.
  18714. * @hidden Internal use only.
  18715. */
  18716. _uniformBuffer: UniformBuffer;
  18717. /** @hidden */
  18718. _renderId: number;
  18719. /**
  18720. * Creates a Light object in the scene.
  18721. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18722. * @param name The firendly name of the light
  18723. * @param scene The scene the light belongs too
  18724. */
  18725. constructor(name: string, scene: Scene);
  18726. protected abstract _buildUniformLayout(): void;
  18727. /**
  18728. * Sets the passed Effect "effect" with the Light information.
  18729. * @param effect The effect to update
  18730. * @param lightIndex The index of the light in the effect to update
  18731. * @returns The light
  18732. */
  18733. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18734. /**
  18735. * Sets the passed Effect "effect" with the Light textures.
  18736. * @param effect The effect to update
  18737. * @param lightIndex The index of the light in the effect to update
  18738. * @returns The light
  18739. */
  18740. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18741. /**
  18742. * Binds the lights information from the scene to the effect for the given mesh.
  18743. * @param lightIndex Light index
  18744. * @param scene The scene where the light belongs to
  18745. * @param effect The effect we are binding the data to
  18746. * @param useSpecular Defines if specular is supported
  18747. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18748. */
  18749. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18750. /**
  18751. * Sets the passed Effect "effect" with the Light information.
  18752. * @param effect The effect to update
  18753. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18754. * @returns The light
  18755. */
  18756. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18757. /**
  18758. * Returns the string "Light".
  18759. * @returns the class name
  18760. */
  18761. getClassName(): string;
  18762. /** @hidden */
  18763. readonly _isLight: boolean;
  18764. /**
  18765. * Converts the light information to a readable string for debug purpose.
  18766. * @param fullDetails Supports for multiple levels of logging within scene loading
  18767. * @returns the human readable light info
  18768. */
  18769. toString(fullDetails?: boolean): string;
  18770. /** @hidden */
  18771. protected _syncParentEnabledState(): void;
  18772. /**
  18773. * Set the enabled state of this node.
  18774. * @param value - the new enabled state
  18775. */
  18776. setEnabled(value: boolean): void;
  18777. /**
  18778. * Returns the Light associated shadow generator if any.
  18779. * @return the associated shadow generator.
  18780. */
  18781. getShadowGenerator(): Nullable<IShadowGenerator>;
  18782. /**
  18783. * Returns a Vector3, the absolute light position in the World.
  18784. * @returns the world space position of the light
  18785. */
  18786. getAbsolutePosition(): Vector3;
  18787. /**
  18788. * Specifies if the light will affect the passed mesh.
  18789. * @param mesh The mesh to test against the light
  18790. * @return true the mesh is affected otherwise, false.
  18791. */
  18792. canAffectMesh(mesh: AbstractMesh): boolean;
  18793. /**
  18794. * Sort function to order lights for rendering.
  18795. * @param a First Light object to compare to second.
  18796. * @param b Second Light object to compare first.
  18797. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18798. */
  18799. static CompareLightsPriority(a: Light, b: Light): number;
  18800. /**
  18801. * Releases resources associated with this node.
  18802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18804. */
  18805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18806. /**
  18807. * Returns the light type ID (integer).
  18808. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18809. */
  18810. getTypeID(): number;
  18811. /**
  18812. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18813. * @returns the scaled intensity in intensity mode unit
  18814. */
  18815. getScaledIntensity(): number;
  18816. /**
  18817. * Returns a new Light object, named "name", from the current one.
  18818. * @param name The name of the cloned light
  18819. * @param newParent The parent of this light, if it has one
  18820. * @returns the new created light
  18821. */
  18822. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18823. /**
  18824. * Serializes the current light into a Serialization object.
  18825. * @returns the serialized object.
  18826. */
  18827. serialize(): any;
  18828. /**
  18829. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18830. * This new light is named "name" and added to the passed scene.
  18831. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18832. * @param name The friendly name of the light
  18833. * @param scene The scene the new light will belong to
  18834. * @returns the constructor function
  18835. */
  18836. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18837. /**
  18838. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18839. * @param parsedLight The JSON representation of the light
  18840. * @param scene The scene to create the parsed light in
  18841. * @returns the created light after parsing
  18842. */
  18843. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18844. private _hookArrayForExcluded;
  18845. private _hookArrayForIncludedOnly;
  18846. private _resyncMeshes;
  18847. /**
  18848. * Forces the meshes to update their light related information in their rendering used effects
  18849. * @hidden Internal Use Only
  18850. */
  18851. _markMeshesAsLightDirty(): void;
  18852. /**
  18853. * Recomputes the cached photometric scale if needed.
  18854. */
  18855. private _computePhotometricScale;
  18856. /**
  18857. * Returns the Photometric Scale according to the light type and intensity mode.
  18858. */
  18859. private _getPhotometricScale;
  18860. /**
  18861. * Reorder the light in the scene according to their defined priority.
  18862. * @hidden Internal Use Only
  18863. */
  18864. _reorderLightsInScene(): void;
  18865. /**
  18866. * Prepares the list of defines specific to the light type.
  18867. * @param defines the list of defines
  18868. * @param lightIndex defines the index of the light for the effect
  18869. */
  18870. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18871. }
  18872. }
  18873. declare module "babylonjs/Cameras/targetCamera" {
  18874. import { Nullable } from "babylonjs/types";
  18875. import { Camera } from "babylonjs/Cameras/camera";
  18876. import { Scene } from "babylonjs/scene";
  18877. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18878. /**
  18879. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18880. * This is the base of the follow, arc rotate cameras and Free camera
  18881. * @see https://doc.babylonjs.com/features/cameras
  18882. */
  18883. export class TargetCamera extends Camera {
  18884. private static _RigCamTransformMatrix;
  18885. private static _TargetTransformMatrix;
  18886. private static _TargetFocalPoint;
  18887. private _tmpUpVector;
  18888. private _tmpTargetVector;
  18889. /**
  18890. * Define the current direction the camera is moving to
  18891. */
  18892. cameraDirection: Vector3;
  18893. /**
  18894. * Define the current rotation the camera is rotating to
  18895. */
  18896. cameraRotation: Vector2;
  18897. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18898. ignoreParentScaling: boolean;
  18899. /**
  18900. * When set, the up vector of the camera will be updated by the rotation of the camera
  18901. */
  18902. updateUpVectorFromRotation: boolean;
  18903. private _tmpQuaternion;
  18904. /**
  18905. * Define the current rotation of the camera
  18906. */
  18907. rotation: Vector3;
  18908. /**
  18909. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18910. */
  18911. rotationQuaternion: Quaternion;
  18912. /**
  18913. * Define the current speed of the camera
  18914. */
  18915. speed: number;
  18916. /**
  18917. * Add constraint to the camera to prevent it to move freely in all directions and
  18918. * around all axis.
  18919. */
  18920. noRotationConstraint: boolean;
  18921. /**
  18922. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18923. * panning
  18924. */
  18925. invertRotation: boolean;
  18926. /**
  18927. * Speed multiplier for inverse camera panning
  18928. */
  18929. inverseRotationSpeed: number;
  18930. /**
  18931. * Define the current target of the camera as an object or a position.
  18932. */
  18933. lockedTarget: any;
  18934. /** @hidden */
  18935. _currentTarget: Vector3;
  18936. /** @hidden */
  18937. _initialFocalDistance: number;
  18938. /** @hidden */
  18939. _viewMatrix: Matrix;
  18940. /** @hidden */
  18941. _camMatrix: Matrix;
  18942. /** @hidden */
  18943. _cameraTransformMatrix: Matrix;
  18944. /** @hidden */
  18945. _cameraRotationMatrix: Matrix;
  18946. /** @hidden */
  18947. _referencePoint: Vector3;
  18948. /** @hidden */
  18949. _transformedReferencePoint: Vector3;
  18950. /** @hidden */
  18951. _reset: () => void;
  18952. private _defaultUp;
  18953. /**
  18954. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18955. * This is the base of the follow, arc rotate cameras and Free camera
  18956. * @see https://doc.babylonjs.com/features/cameras
  18957. * @param name Defines the name of the camera in the scene
  18958. * @param position Defines the start position of the camera in the scene
  18959. * @param scene Defines the scene the camera belongs to
  18960. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18961. */
  18962. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18963. /**
  18964. * Gets the position in front of the camera at a given distance.
  18965. * @param distance The distance from the camera we want the position to be
  18966. * @returns the position
  18967. */
  18968. getFrontPosition(distance: number): Vector3;
  18969. /** @hidden */
  18970. _getLockedTargetPosition(): Nullable<Vector3>;
  18971. private _storedPosition;
  18972. private _storedRotation;
  18973. private _storedRotationQuaternion;
  18974. /**
  18975. * Store current camera state of the camera (fov, position, rotation, etc..)
  18976. * @returns the camera
  18977. */
  18978. storeState(): Camera;
  18979. /**
  18980. * Restored camera state. You must call storeState() first
  18981. * @returns whether it was successful or not
  18982. * @hidden
  18983. */
  18984. _restoreStateValues(): boolean;
  18985. /** @hidden */
  18986. _initCache(): void;
  18987. /** @hidden */
  18988. _updateCache(ignoreParentClass?: boolean): void;
  18989. /** @hidden */
  18990. _isSynchronizedViewMatrix(): boolean;
  18991. /** @hidden */
  18992. _computeLocalCameraSpeed(): number;
  18993. /**
  18994. * Defines the target the camera should look at.
  18995. * @param target Defines the new target as a Vector or a mesh
  18996. */
  18997. setTarget(target: Vector3): void;
  18998. /**
  18999. * Defines the target point of the camera.
  19000. * The camera looks towards it form the radius distance.
  19001. */
  19002. get target(): Vector3;
  19003. set target(value: Vector3);
  19004. /**
  19005. * Return the current target position of the camera. This value is expressed in local space.
  19006. * @returns the target position
  19007. */
  19008. getTarget(): Vector3;
  19009. /** @hidden */
  19010. _decideIfNeedsToMove(): boolean;
  19011. /** @hidden */
  19012. _updatePosition(): void;
  19013. /** @hidden */
  19014. _checkInputs(): void;
  19015. protected _updateCameraRotationMatrix(): void;
  19016. /**
  19017. * 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)
  19018. * @returns the current camera
  19019. */
  19020. private _rotateUpVectorWithCameraRotationMatrix;
  19021. private _cachedRotationZ;
  19022. private _cachedQuaternionRotationZ;
  19023. /** @hidden */
  19024. _getViewMatrix(): Matrix;
  19025. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19026. /**
  19027. * @hidden
  19028. */
  19029. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19030. /**
  19031. * @hidden
  19032. */
  19033. _updateRigCameras(): void;
  19034. private _getRigCamPositionAndTarget;
  19035. /**
  19036. * Gets the current object class name.
  19037. * @return the class name
  19038. */
  19039. getClassName(): string;
  19040. }
  19041. }
  19042. declare module "babylonjs/Events/keyboardEvents" {
  19043. /**
  19044. * Gather the list of keyboard event types as constants.
  19045. */
  19046. export class KeyboardEventTypes {
  19047. /**
  19048. * The keydown event is fired when a key becomes active (pressed).
  19049. */
  19050. static readonly KEYDOWN: number;
  19051. /**
  19052. * The keyup event is fired when a key has been released.
  19053. */
  19054. static readonly KEYUP: number;
  19055. }
  19056. /**
  19057. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19058. */
  19059. export class KeyboardInfo {
  19060. /**
  19061. * Defines the type of event (KeyboardEventTypes)
  19062. */
  19063. type: number;
  19064. /**
  19065. * Defines the related dom event
  19066. */
  19067. event: KeyboardEvent;
  19068. /**
  19069. * Instantiates a new keyboard info.
  19070. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19071. * @param type Defines the type of event (KeyboardEventTypes)
  19072. * @param event Defines the related dom event
  19073. */
  19074. constructor(
  19075. /**
  19076. * Defines the type of event (KeyboardEventTypes)
  19077. */
  19078. type: number,
  19079. /**
  19080. * Defines the related dom event
  19081. */
  19082. event: KeyboardEvent);
  19083. }
  19084. /**
  19085. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19086. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19087. */
  19088. export class KeyboardInfoPre extends KeyboardInfo {
  19089. /**
  19090. * Defines the type of event (KeyboardEventTypes)
  19091. */
  19092. type: number;
  19093. /**
  19094. * Defines the related dom event
  19095. */
  19096. event: KeyboardEvent;
  19097. /**
  19098. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19099. */
  19100. skipOnPointerObservable: boolean;
  19101. /**
  19102. * Instantiates a new keyboard pre info.
  19103. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19104. * @param type Defines the type of event (KeyboardEventTypes)
  19105. * @param event Defines the related dom event
  19106. */
  19107. constructor(
  19108. /**
  19109. * Defines the type of event (KeyboardEventTypes)
  19110. */
  19111. type: number,
  19112. /**
  19113. * Defines the related dom event
  19114. */
  19115. event: KeyboardEvent);
  19116. }
  19117. }
  19118. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19119. import { Nullable } from "babylonjs/types";
  19120. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19121. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19122. /**
  19123. * Manage the keyboard inputs to control the movement of a free camera.
  19124. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19125. */
  19126. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19127. /**
  19128. * Defines the camera the input is attached to.
  19129. */
  19130. camera: FreeCamera;
  19131. /**
  19132. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19133. */
  19134. keysUp: number[];
  19135. /**
  19136. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19137. */
  19138. keysUpward: number[];
  19139. /**
  19140. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19141. */
  19142. keysDown: number[];
  19143. /**
  19144. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19145. */
  19146. keysDownward: number[];
  19147. /**
  19148. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19149. */
  19150. keysLeft: number[];
  19151. /**
  19152. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19153. */
  19154. keysRight: number[];
  19155. private _keys;
  19156. private _onCanvasBlurObserver;
  19157. private _onKeyboardObserver;
  19158. private _engine;
  19159. private _scene;
  19160. /**
  19161. * Attach the input controls to a specific dom element to get the input from.
  19162. * @param element Defines the element the controls should be listened from
  19163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19164. */
  19165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19166. /**
  19167. * Detach the current controls from the specified dom element.
  19168. * @param element Defines the element to stop listening the inputs from
  19169. */
  19170. detachControl(element: Nullable<HTMLElement>): void;
  19171. /**
  19172. * Update the current camera state depending on the inputs that have been used this frame.
  19173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19174. */
  19175. checkInputs(): void;
  19176. /**
  19177. * Gets the class name of the current intput.
  19178. * @returns the class name
  19179. */
  19180. getClassName(): string;
  19181. /** @hidden */
  19182. _onLostFocus(): void;
  19183. /**
  19184. * Get the friendly name associated with the input class.
  19185. * @returns the input friendly name
  19186. */
  19187. getSimpleName(): string;
  19188. }
  19189. }
  19190. declare module "babylonjs/Events/pointerEvents" {
  19191. import { Nullable } from "babylonjs/types";
  19192. import { Vector2 } from "babylonjs/Maths/math.vector";
  19193. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19194. import { Ray } from "babylonjs/Culling/ray";
  19195. /**
  19196. * Gather the list of pointer event types as constants.
  19197. */
  19198. export class PointerEventTypes {
  19199. /**
  19200. * 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.
  19201. */
  19202. static readonly POINTERDOWN: number;
  19203. /**
  19204. * The pointerup event is fired when a pointer is no longer active.
  19205. */
  19206. static readonly POINTERUP: number;
  19207. /**
  19208. * The pointermove event is fired when a pointer changes coordinates.
  19209. */
  19210. static readonly POINTERMOVE: number;
  19211. /**
  19212. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19213. */
  19214. static readonly POINTERWHEEL: number;
  19215. /**
  19216. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19217. */
  19218. static readonly POINTERPICK: number;
  19219. /**
  19220. * The pointertap event is fired when a the object has been touched and released without drag.
  19221. */
  19222. static readonly POINTERTAP: number;
  19223. /**
  19224. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19225. */
  19226. static readonly POINTERDOUBLETAP: number;
  19227. }
  19228. /**
  19229. * Base class of pointer info types.
  19230. */
  19231. export class PointerInfoBase {
  19232. /**
  19233. * Defines the type of event (PointerEventTypes)
  19234. */
  19235. type: number;
  19236. /**
  19237. * Defines the related dom event
  19238. */
  19239. event: PointerEvent | MouseWheelEvent;
  19240. /**
  19241. * Instantiates the base class of pointers info.
  19242. * @param type Defines the type of event (PointerEventTypes)
  19243. * @param event Defines the related dom event
  19244. */
  19245. constructor(
  19246. /**
  19247. * Defines the type of event (PointerEventTypes)
  19248. */
  19249. type: number,
  19250. /**
  19251. * Defines the related dom event
  19252. */
  19253. event: PointerEvent | MouseWheelEvent);
  19254. }
  19255. /**
  19256. * This class is used to store pointer related info for the onPrePointerObservable event.
  19257. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19258. */
  19259. export class PointerInfoPre extends PointerInfoBase {
  19260. /**
  19261. * Ray from a pointer if availible (eg. 6dof controller)
  19262. */
  19263. ray: Nullable<Ray>;
  19264. /**
  19265. * Defines the local position of the pointer on the canvas.
  19266. */
  19267. localPosition: Vector2;
  19268. /**
  19269. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19270. */
  19271. skipOnPointerObservable: boolean;
  19272. /**
  19273. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19274. * @param type Defines the type of event (PointerEventTypes)
  19275. * @param event Defines the related dom event
  19276. * @param localX Defines the local x coordinates of the pointer when the event occured
  19277. * @param localY Defines the local y coordinates of the pointer when the event occured
  19278. */
  19279. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19280. }
  19281. /**
  19282. * This type contains all the data related to a pointer event in Babylon.js.
  19283. * 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.
  19284. */
  19285. export class PointerInfo extends PointerInfoBase {
  19286. /**
  19287. * Defines the picking info associated to the info (if any)\
  19288. */
  19289. pickInfo: Nullable<PickingInfo>;
  19290. /**
  19291. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19292. * @param type Defines the type of event (PointerEventTypes)
  19293. * @param event Defines the related dom event
  19294. * @param pickInfo Defines the picking info associated to the info (if any)\
  19295. */
  19296. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19297. /**
  19298. * Defines the picking info associated to the info (if any)\
  19299. */
  19300. pickInfo: Nullable<PickingInfo>);
  19301. }
  19302. /**
  19303. * Data relating to a touch event on the screen.
  19304. */
  19305. export interface PointerTouch {
  19306. /**
  19307. * X coordinate of touch.
  19308. */
  19309. x: number;
  19310. /**
  19311. * Y coordinate of touch.
  19312. */
  19313. y: number;
  19314. /**
  19315. * Id of touch. Unique for each finger.
  19316. */
  19317. pointerId: number;
  19318. /**
  19319. * Event type passed from DOM.
  19320. */
  19321. type: any;
  19322. }
  19323. }
  19324. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19325. import { Observable } from "babylonjs/Misc/observable";
  19326. import { Nullable } from "babylonjs/types";
  19327. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19328. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19329. /**
  19330. * Manage the mouse inputs to control the movement of a free camera.
  19331. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19332. */
  19333. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19334. /**
  19335. * Define if touch is enabled in the mouse input
  19336. */
  19337. touchEnabled: boolean;
  19338. /**
  19339. * Defines the camera the input is attached to.
  19340. */
  19341. camera: FreeCamera;
  19342. /**
  19343. * Defines the buttons associated with the input to handle camera move.
  19344. */
  19345. buttons: number[];
  19346. /**
  19347. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19348. */
  19349. angularSensibility: number;
  19350. private _pointerInput;
  19351. private _onMouseMove;
  19352. private _observer;
  19353. private previousPosition;
  19354. /**
  19355. * Observable for when a pointer move event occurs containing the move offset
  19356. */
  19357. onPointerMovedObservable: Observable<{
  19358. offsetX: number;
  19359. offsetY: number;
  19360. }>;
  19361. /**
  19362. * @hidden
  19363. * If the camera should be rotated automatically based on pointer movement
  19364. */
  19365. _allowCameraRotation: boolean;
  19366. /**
  19367. * Manage the mouse inputs to control the movement of a free camera.
  19368. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19369. * @param touchEnabled Defines if touch is enabled or not
  19370. */
  19371. constructor(
  19372. /**
  19373. * Define if touch is enabled in the mouse input
  19374. */
  19375. touchEnabled?: boolean);
  19376. /**
  19377. * Attach the input controls to a specific dom element to get the input from.
  19378. * @param element Defines the element the controls should be listened from
  19379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19380. */
  19381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19382. /**
  19383. * Called on JS contextmenu event.
  19384. * Override this method to provide functionality.
  19385. */
  19386. protected onContextMenu(evt: PointerEvent): void;
  19387. /**
  19388. * Detach the current controls from the specified dom element.
  19389. * @param element Defines the element to stop listening the inputs from
  19390. */
  19391. detachControl(element: Nullable<HTMLElement>): void;
  19392. /**
  19393. * Gets the class name of the current intput.
  19394. * @returns the class name
  19395. */
  19396. getClassName(): string;
  19397. /**
  19398. * Get the friendly name associated with the input class.
  19399. * @returns the input friendly name
  19400. */
  19401. getSimpleName(): string;
  19402. }
  19403. }
  19404. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19405. import { Nullable } from "babylonjs/types";
  19406. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19407. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19408. /**
  19409. * Manage the touch inputs to control the movement of a free camera.
  19410. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19411. */
  19412. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19413. /**
  19414. * Define if mouse events can be treated as touch events
  19415. */
  19416. allowMouse: boolean;
  19417. /**
  19418. * Defines the camera the input is attached to.
  19419. */
  19420. camera: FreeCamera;
  19421. /**
  19422. * Defines the touch sensibility for rotation.
  19423. * The higher the faster.
  19424. */
  19425. touchAngularSensibility: number;
  19426. /**
  19427. * Defines the touch sensibility for move.
  19428. * The higher the faster.
  19429. */
  19430. touchMoveSensibility: number;
  19431. private _offsetX;
  19432. private _offsetY;
  19433. private _pointerPressed;
  19434. private _pointerInput;
  19435. private _observer;
  19436. private _onLostFocus;
  19437. /**
  19438. * Manage the touch inputs to control the movement of a free camera.
  19439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19440. * @param allowMouse Defines if mouse events can be treated as touch events
  19441. */
  19442. constructor(
  19443. /**
  19444. * Define if mouse events can be treated as touch events
  19445. */
  19446. allowMouse?: boolean);
  19447. /**
  19448. * Attach the input controls to a specific dom element to get the input from.
  19449. * @param element Defines the element the controls should be listened from
  19450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19451. */
  19452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19453. /**
  19454. * Detach the current controls from the specified dom element.
  19455. * @param element Defines the element to stop listening the inputs from
  19456. */
  19457. detachControl(element: Nullable<HTMLElement>): void;
  19458. /**
  19459. * Update the current camera state depending on the inputs that have been used this frame.
  19460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19461. */
  19462. checkInputs(): void;
  19463. /**
  19464. * Gets the class name of the current intput.
  19465. * @returns the class name
  19466. */
  19467. getClassName(): string;
  19468. /**
  19469. * Get the friendly name associated with the input class.
  19470. * @returns the input friendly name
  19471. */
  19472. getSimpleName(): string;
  19473. }
  19474. }
  19475. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19476. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19477. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19478. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19479. import { Nullable } from "babylonjs/types";
  19480. /**
  19481. * Default Inputs manager for the FreeCamera.
  19482. * It groups all the default supported inputs for ease of use.
  19483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19484. */
  19485. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19486. /**
  19487. * @hidden
  19488. */
  19489. _mouseInput: Nullable<FreeCameraMouseInput>;
  19490. /**
  19491. * Instantiates a new FreeCameraInputsManager.
  19492. * @param camera Defines the camera the inputs belong to
  19493. */
  19494. constructor(camera: FreeCamera);
  19495. /**
  19496. * Add keyboard input support to the input manager.
  19497. * @returns the current input manager
  19498. */
  19499. addKeyboard(): FreeCameraInputsManager;
  19500. /**
  19501. * Add mouse input support to the input manager.
  19502. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19503. * @returns the current input manager
  19504. */
  19505. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19506. /**
  19507. * Removes the mouse input support from the manager
  19508. * @returns the current input manager
  19509. */
  19510. removeMouse(): FreeCameraInputsManager;
  19511. /**
  19512. * Add touch input support to the input manager.
  19513. * @returns the current input manager
  19514. */
  19515. addTouch(): FreeCameraInputsManager;
  19516. /**
  19517. * Remove all attached input methods from a camera
  19518. */
  19519. clear(): void;
  19520. }
  19521. }
  19522. declare module "babylonjs/Cameras/freeCamera" {
  19523. import { Vector3 } from "babylonjs/Maths/math.vector";
  19524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19525. import { Scene } from "babylonjs/scene";
  19526. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19527. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19528. /**
  19529. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19530. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19531. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19532. */
  19533. export class FreeCamera extends TargetCamera {
  19534. /**
  19535. * Define the collision ellipsoid of the camera.
  19536. * This is helpful to simulate a camera body like the player body around the camera
  19537. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19538. */
  19539. ellipsoid: Vector3;
  19540. /**
  19541. * Define an offset for the position of the ellipsoid around the camera.
  19542. * This can be helpful to determine the center of the body near the gravity center of the body
  19543. * instead of its head.
  19544. */
  19545. ellipsoidOffset: Vector3;
  19546. /**
  19547. * Enable or disable collisions of the camera with the rest of the scene objects.
  19548. */
  19549. checkCollisions: boolean;
  19550. /**
  19551. * Enable or disable gravity on the camera.
  19552. */
  19553. applyGravity: boolean;
  19554. /**
  19555. * Define the input manager associated to the camera.
  19556. */
  19557. inputs: FreeCameraInputsManager;
  19558. /**
  19559. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19560. * Higher values reduce sensitivity.
  19561. */
  19562. get angularSensibility(): number;
  19563. /**
  19564. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19565. * Higher values reduce sensitivity.
  19566. */
  19567. set angularSensibility(value: number);
  19568. /**
  19569. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19570. */
  19571. get keysUp(): number[];
  19572. set keysUp(value: number[]);
  19573. /**
  19574. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19575. */
  19576. get keysUpward(): number[];
  19577. set keysUpward(value: number[]);
  19578. /**
  19579. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19580. */
  19581. get keysDown(): number[];
  19582. set keysDown(value: number[]);
  19583. /**
  19584. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19585. */
  19586. get keysDownward(): number[];
  19587. set keysDownward(value: number[]);
  19588. /**
  19589. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19590. */
  19591. get keysLeft(): number[];
  19592. set keysLeft(value: number[]);
  19593. /**
  19594. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19595. */
  19596. get keysRight(): number[];
  19597. set keysRight(value: number[]);
  19598. /**
  19599. * Event raised when the camera collide with a mesh in the scene.
  19600. */
  19601. onCollide: (collidedMesh: AbstractMesh) => void;
  19602. private _collider;
  19603. private _needMoveForGravity;
  19604. private _oldPosition;
  19605. private _diffPosition;
  19606. private _newPosition;
  19607. /** @hidden */
  19608. _localDirection: Vector3;
  19609. /** @hidden */
  19610. _transformedDirection: Vector3;
  19611. /**
  19612. * Instantiates a Free Camera.
  19613. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19614. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19615. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19616. * @param name Define the name of the camera in the scene
  19617. * @param position Define the start position of the camera in the scene
  19618. * @param scene Define the scene the camera belongs to
  19619. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19620. */
  19621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19622. /**
  19623. * Attached controls to the current camera.
  19624. * @param element Defines the element the controls should be listened from
  19625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19626. */
  19627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19628. /**
  19629. * Detach the current controls from the camera.
  19630. * The camera will stop reacting to inputs.
  19631. * @param element Defines the element to stop listening the inputs from
  19632. */
  19633. detachControl(element: HTMLElement): void;
  19634. private _collisionMask;
  19635. /**
  19636. * Define a collision mask to limit the list of object the camera can collide with
  19637. */
  19638. get collisionMask(): number;
  19639. set collisionMask(mask: number);
  19640. /** @hidden */
  19641. _collideWithWorld(displacement: Vector3): void;
  19642. private _onCollisionPositionChange;
  19643. /** @hidden */
  19644. _checkInputs(): void;
  19645. /** @hidden */
  19646. _decideIfNeedsToMove(): boolean;
  19647. /** @hidden */
  19648. _updatePosition(): void;
  19649. /**
  19650. * Destroy the camera and release the current resources hold by it.
  19651. */
  19652. dispose(): void;
  19653. /**
  19654. * Gets the current object class name.
  19655. * @return the class name
  19656. */
  19657. getClassName(): string;
  19658. }
  19659. }
  19660. declare module "babylonjs/Gamepads/gamepad" {
  19661. import { Observable } from "babylonjs/Misc/observable";
  19662. /**
  19663. * Represents a gamepad control stick position
  19664. */
  19665. export class StickValues {
  19666. /**
  19667. * The x component of the control stick
  19668. */
  19669. x: number;
  19670. /**
  19671. * The y component of the control stick
  19672. */
  19673. y: number;
  19674. /**
  19675. * Initializes the gamepad x and y control stick values
  19676. * @param x The x component of the gamepad control stick value
  19677. * @param y The y component of the gamepad control stick value
  19678. */
  19679. constructor(
  19680. /**
  19681. * The x component of the control stick
  19682. */
  19683. x: number,
  19684. /**
  19685. * The y component of the control stick
  19686. */
  19687. y: number);
  19688. }
  19689. /**
  19690. * An interface which manages callbacks for gamepad button changes
  19691. */
  19692. export interface GamepadButtonChanges {
  19693. /**
  19694. * Called when a gamepad has been changed
  19695. */
  19696. changed: boolean;
  19697. /**
  19698. * Called when a gamepad press event has been triggered
  19699. */
  19700. pressChanged: boolean;
  19701. /**
  19702. * Called when a touch event has been triggered
  19703. */
  19704. touchChanged: boolean;
  19705. /**
  19706. * Called when a value has changed
  19707. */
  19708. valueChanged: boolean;
  19709. }
  19710. /**
  19711. * Represents a gamepad
  19712. */
  19713. export class Gamepad {
  19714. /**
  19715. * The id of the gamepad
  19716. */
  19717. id: string;
  19718. /**
  19719. * The index of the gamepad
  19720. */
  19721. index: number;
  19722. /**
  19723. * The browser gamepad
  19724. */
  19725. browserGamepad: any;
  19726. /**
  19727. * Specifies what type of gamepad this represents
  19728. */
  19729. type: number;
  19730. private _leftStick;
  19731. private _rightStick;
  19732. /** @hidden */
  19733. _isConnected: boolean;
  19734. private _leftStickAxisX;
  19735. private _leftStickAxisY;
  19736. private _rightStickAxisX;
  19737. private _rightStickAxisY;
  19738. /**
  19739. * Triggered when the left control stick has been changed
  19740. */
  19741. private _onleftstickchanged;
  19742. /**
  19743. * Triggered when the right control stick has been changed
  19744. */
  19745. private _onrightstickchanged;
  19746. /**
  19747. * Represents a gamepad controller
  19748. */
  19749. static GAMEPAD: number;
  19750. /**
  19751. * Represents a generic controller
  19752. */
  19753. static GENERIC: number;
  19754. /**
  19755. * Represents an XBox controller
  19756. */
  19757. static XBOX: number;
  19758. /**
  19759. * Represents a pose-enabled controller
  19760. */
  19761. static POSE_ENABLED: number;
  19762. /**
  19763. * Represents an Dual Shock controller
  19764. */
  19765. static DUALSHOCK: number;
  19766. /**
  19767. * Specifies whether the left control stick should be Y-inverted
  19768. */
  19769. protected _invertLeftStickY: boolean;
  19770. /**
  19771. * Specifies if the gamepad has been connected
  19772. */
  19773. get isConnected(): boolean;
  19774. /**
  19775. * Initializes the gamepad
  19776. * @param id The id of the gamepad
  19777. * @param index The index of the gamepad
  19778. * @param browserGamepad The browser gamepad
  19779. * @param leftStickX The x component of the left joystick
  19780. * @param leftStickY The y component of the left joystick
  19781. * @param rightStickX The x component of the right joystick
  19782. * @param rightStickY The y component of the right joystick
  19783. */
  19784. constructor(
  19785. /**
  19786. * The id of the gamepad
  19787. */
  19788. id: string,
  19789. /**
  19790. * The index of the gamepad
  19791. */
  19792. index: number,
  19793. /**
  19794. * The browser gamepad
  19795. */
  19796. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19797. /**
  19798. * Callback triggered when the left joystick has changed
  19799. * @param callback
  19800. */
  19801. onleftstickchanged(callback: (values: StickValues) => void): void;
  19802. /**
  19803. * Callback triggered when the right joystick has changed
  19804. * @param callback
  19805. */
  19806. onrightstickchanged(callback: (values: StickValues) => void): void;
  19807. /**
  19808. * Gets the left joystick
  19809. */
  19810. get leftStick(): StickValues;
  19811. /**
  19812. * Sets the left joystick values
  19813. */
  19814. set leftStick(newValues: StickValues);
  19815. /**
  19816. * Gets the right joystick
  19817. */
  19818. get rightStick(): StickValues;
  19819. /**
  19820. * Sets the right joystick value
  19821. */
  19822. set rightStick(newValues: StickValues);
  19823. /**
  19824. * Updates the gamepad joystick positions
  19825. */
  19826. update(): void;
  19827. /**
  19828. * Disposes the gamepad
  19829. */
  19830. dispose(): void;
  19831. }
  19832. /**
  19833. * Represents a generic gamepad
  19834. */
  19835. export class GenericPad extends Gamepad {
  19836. private _buttons;
  19837. private _onbuttondown;
  19838. private _onbuttonup;
  19839. /**
  19840. * Observable triggered when a button has been pressed
  19841. */
  19842. onButtonDownObservable: Observable<number>;
  19843. /**
  19844. * Observable triggered when a button has been released
  19845. */
  19846. onButtonUpObservable: Observable<number>;
  19847. /**
  19848. * Callback triggered when a button has been pressed
  19849. * @param callback Called when a button has been pressed
  19850. */
  19851. onbuttondown(callback: (buttonPressed: number) => void): void;
  19852. /**
  19853. * Callback triggered when a button has been released
  19854. * @param callback Called when a button has been released
  19855. */
  19856. onbuttonup(callback: (buttonReleased: number) => void): void;
  19857. /**
  19858. * Initializes the generic gamepad
  19859. * @param id The id of the generic gamepad
  19860. * @param index The index of the generic gamepad
  19861. * @param browserGamepad The browser gamepad
  19862. */
  19863. constructor(id: string, index: number, browserGamepad: any);
  19864. private _setButtonValue;
  19865. /**
  19866. * Updates the generic gamepad
  19867. */
  19868. update(): void;
  19869. /**
  19870. * Disposes the generic gamepad
  19871. */
  19872. dispose(): void;
  19873. }
  19874. }
  19875. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19876. import { Observable } from "babylonjs/Misc/observable";
  19877. import { Nullable } from "babylonjs/types";
  19878. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19879. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19881. import { Ray } from "babylonjs/Culling/ray";
  19882. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19883. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19884. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19885. /**
  19886. * Defines the types of pose enabled controllers that are supported
  19887. */
  19888. export enum PoseEnabledControllerType {
  19889. /**
  19890. * HTC Vive
  19891. */
  19892. VIVE = 0,
  19893. /**
  19894. * Oculus Rift
  19895. */
  19896. OCULUS = 1,
  19897. /**
  19898. * Windows mixed reality
  19899. */
  19900. WINDOWS = 2,
  19901. /**
  19902. * Samsung gear VR
  19903. */
  19904. GEAR_VR = 3,
  19905. /**
  19906. * Google Daydream
  19907. */
  19908. DAYDREAM = 4,
  19909. /**
  19910. * Generic
  19911. */
  19912. GENERIC = 5
  19913. }
  19914. /**
  19915. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19916. */
  19917. export interface MutableGamepadButton {
  19918. /**
  19919. * Value of the button/trigger
  19920. */
  19921. value: number;
  19922. /**
  19923. * If the button/trigger is currently touched
  19924. */
  19925. touched: boolean;
  19926. /**
  19927. * If the button/trigger is currently pressed
  19928. */
  19929. pressed: boolean;
  19930. }
  19931. /**
  19932. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19933. * @hidden
  19934. */
  19935. export interface ExtendedGamepadButton extends GamepadButton {
  19936. /**
  19937. * If the button/trigger is currently pressed
  19938. */
  19939. readonly pressed: boolean;
  19940. /**
  19941. * If the button/trigger is currently touched
  19942. */
  19943. readonly touched: boolean;
  19944. /**
  19945. * Value of the button/trigger
  19946. */
  19947. readonly value: number;
  19948. }
  19949. /** @hidden */
  19950. export interface _GamePadFactory {
  19951. /**
  19952. * Returns whether or not the current gamepad can be created for this type of controller.
  19953. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19954. * @returns true if it can be created, otherwise false
  19955. */
  19956. canCreate(gamepadInfo: any): boolean;
  19957. /**
  19958. * Creates a new instance of the Gamepad.
  19959. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19960. * @returns the new gamepad instance
  19961. */
  19962. create(gamepadInfo: any): Gamepad;
  19963. }
  19964. /**
  19965. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19966. */
  19967. export class PoseEnabledControllerHelper {
  19968. /** @hidden */
  19969. static _ControllerFactories: _GamePadFactory[];
  19970. /** @hidden */
  19971. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19972. /**
  19973. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19974. * @param vrGamepad the gamepad to initialized
  19975. * @returns a vr controller of the type the gamepad identified as
  19976. */
  19977. static InitiateController(vrGamepad: any): Gamepad;
  19978. }
  19979. /**
  19980. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19981. */
  19982. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19983. /**
  19984. * If the controller is used in a webXR session
  19985. */
  19986. isXR: boolean;
  19987. private _deviceRoomPosition;
  19988. private _deviceRoomRotationQuaternion;
  19989. /**
  19990. * The device position in babylon space
  19991. */
  19992. devicePosition: Vector3;
  19993. /**
  19994. * The device rotation in babylon space
  19995. */
  19996. deviceRotationQuaternion: Quaternion;
  19997. /**
  19998. * The scale factor of the device in babylon space
  19999. */
  20000. deviceScaleFactor: number;
  20001. /**
  20002. * (Likely devicePosition should be used instead) The device position in its room space
  20003. */
  20004. position: Vector3;
  20005. /**
  20006. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20007. */
  20008. rotationQuaternion: Quaternion;
  20009. /**
  20010. * The type of controller (Eg. Windows mixed reality)
  20011. */
  20012. controllerType: PoseEnabledControllerType;
  20013. protected _calculatedPosition: Vector3;
  20014. private _calculatedRotation;
  20015. /**
  20016. * The raw pose from the device
  20017. */
  20018. rawPose: DevicePose;
  20019. private _trackPosition;
  20020. private _maxRotationDistFromHeadset;
  20021. private _draggedRoomRotation;
  20022. /**
  20023. * @hidden
  20024. */
  20025. _disableTrackPosition(fixedPosition: Vector3): void;
  20026. /**
  20027. * Internal, the mesh attached to the controller
  20028. * @hidden
  20029. */
  20030. _mesh: Nullable<AbstractMesh>;
  20031. private _poseControlledCamera;
  20032. private _leftHandSystemQuaternion;
  20033. /**
  20034. * Internal, matrix used to convert room space to babylon space
  20035. * @hidden
  20036. */
  20037. _deviceToWorld: Matrix;
  20038. /**
  20039. * Node to be used when casting a ray from the controller
  20040. * @hidden
  20041. */
  20042. _pointingPoseNode: Nullable<TransformNode>;
  20043. /**
  20044. * Name of the child mesh that can be used to cast a ray from the controller
  20045. */
  20046. static readonly POINTING_POSE: string;
  20047. /**
  20048. * Creates a new PoseEnabledController from a gamepad
  20049. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20050. */
  20051. constructor(browserGamepad: any);
  20052. private _workingMatrix;
  20053. /**
  20054. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20055. */
  20056. update(): void;
  20057. /**
  20058. * Updates only the pose device and mesh without doing any button event checking
  20059. */
  20060. protected _updatePoseAndMesh(): void;
  20061. /**
  20062. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20063. * @param poseData raw pose fromthe device
  20064. */
  20065. updateFromDevice(poseData: DevicePose): void;
  20066. /**
  20067. * @hidden
  20068. */
  20069. _meshAttachedObservable: Observable<AbstractMesh>;
  20070. /**
  20071. * Attaches a mesh to the controller
  20072. * @param mesh the mesh to be attached
  20073. */
  20074. attachToMesh(mesh: AbstractMesh): void;
  20075. /**
  20076. * Attaches the controllers mesh to a camera
  20077. * @param camera the camera the mesh should be attached to
  20078. */
  20079. attachToPoseControlledCamera(camera: TargetCamera): void;
  20080. /**
  20081. * Disposes of the controller
  20082. */
  20083. dispose(): void;
  20084. /**
  20085. * The mesh that is attached to the controller
  20086. */
  20087. get mesh(): Nullable<AbstractMesh>;
  20088. /**
  20089. * Gets the ray of the controller in the direction the controller is pointing
  20090. * @param length the length the resulting ray should be
  20091. * @returns a ray in the direction the controller is pointing
  20092. */
  20093. getForwardRay(length?: number): Ray;
  20094. }
  20095. }
  20096. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20097. import { Observable } from "babylonjs/Misc/observable";
  20098. import { Scene } from "babylonjs/scene";
  20099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20100. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20101. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20102. import { Nullable } from "babylonjs/types";
  20103. /**
  20104. * Defines the WebVRController object that represents controllers tracked in 3D space
  20105. */
  20106. export abstract class WebVRController extends PoseEnabledController {
  20107. /**
  20108. * Internal, the default controller model for the controller
  20109. */
  20110. protected _defaultModel: Nullable<AbstractMesh>;
  20111. /**
  20112. * Fired when the trigger state has changed
  20113. */
  20114. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20115. /**
  20116. * Fired when the main button state has changed
  20117. */
  20118. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20119. /**
  20120. * Fired when the secondary button state has changed
  20121. */
  20122. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20123. /**
  20124. * Fired when the pad state has changed
  20125. */
  20126. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20127. /**
  20128. * Fired when controllers stick values have changed
  20129. */
  20130. onPadValuesChangedObservable: Observable<StickValues>;
  20131. /**
  20132. * Array of button availible on the controller
  20133. */
  20134. protected _buttons: Array<MutableGamepadButton>;
  20135. private _onButtonStateChange;
  20136. /**
  20137. * Fired when a controller button's state has changed
  20138. * @param callback the callback containing the button that was modified
  20139. */
  20140. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20141. /**
  20142. * X and Y axis corresponding to the controllers joystick
  20143. */
  20144. pad: StickValues;
  20145. /**
  20146. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20147. */
  20148. hand: string;
  20149. /**
  20150. * The default controller model for the controller
  20151. */
  20152. get defaultModel(): Nullable<AbstractMesh>;
  20153. /**
  20154. * Creates a new WebVRController from a gamepad
  20155. * @param vrGamepad the gamepad that the WebVRController should be created from
  20156. */
  20157. constructor(vrGamepad: any);
  20158. /**
  20159. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20160. */
  20161. update(): void;
  20162. /**
  20163. * Function to be called when a button is modified
  20164. */
  20165. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20166. /**
  20167. * Loads a mesh and attaches it to the controller
  20168. * @param scene the scene the mesh should be added to
  20169. * @param meshLoaded callback for when the mesh has been loaded
  20170. */
  20171. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20172. private _setButtonValue;
  20173. private _changes;
  20174. private _checkChanges;
  20175. /**
  20176. * Disposes of th webVRCOntroller
  20177. */
  20178. dispose(): void;
  20179. }
  20180. }
  20181. declare module "babylonjs/Lights/hemisphericLight" {
  20182. import { Nullable } from "babylonjs/types";
  20183. import { Scene } from "babylonjs/scene";
  20184. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20185. import { Color3 } from "babylonjs/Maths/math.color";
  20186. import { Effect } from "babylonjs/Materials/effect";
  20187. import { Light } from "babylonjs/Lights/light";
  20188. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20189. /**
  20190. * The HemisphericLight simulates the ambient environment light,
  20191. * so the passed direction is the light reflection direction, not the incoming direction.
  20192. */
  20193. export class HemisphericLight extends Light {
  20194. /**
  20195. * The groundColor is the light in the opposite direction to the one specified during creation.
  20196. * 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.
  20197. */
  20198. groundColor: Color3;
  20199. /**
  20200. * The light reflection direction, not the incoming direction.
  20201. */
  20202. direction: Vector3;
  20203. /**
  20204. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20205. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20206. * The HemisphericLight can't cast shadows.
  20207. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20208. * @param name The friendly name of the light
  20209. * @param direction The direction of the light reflection
  20210. * @param scene The scene the light belongs to
  20211. */
  20212. constructor(name: string, direction: Vector3, scene: Scene);
  20213. protected _buildUniformLayout(): void;
  20214. /**
  20215. * Returns the string "HemisphericLight".
  20216. * @return The class name
  20217. */
  20218. getClassName(): string;
  20219. /**
  20220. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20221. * Returns the updated direction.
  20222. * @param target The target the direction should point to
  20223. * @return The computed direction
  20224. */
  20225. setDirectionToTarget(target: Vector3): Vector3;
  20226. /**
  20227. * Returns the shadow generator associated to the light.
  20228. * @returns Always null for hemispheric lights because it does not support shadows.
  20229. */
  20230. getShadowGenerator(): Nullable<IShadowGenerator>;
  20231. /**
  20232. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20233. * @param effect The effect to update
  20234. * @param lightIndex The index of the light in the effect to update
  20235. * @returns The hemispheric light
  20236. */
  20237. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20238. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20239. /**
  20240. * Computes the world matrix of the node
  20241. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20242. * @param useWasUpdatedFlag defines a reserved property
  20243. * @returns the world matrix
  20244. */
  20245. computeWorldMatrix(): Matrix;
  20246. /**
  20247. * Returns the integer 3.
  20248. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20249. */
  20250. getTypeID(): number;
  20251. /**
  20252. * Prepares the list of defines specific to the light type.
  20253. * @param defines the list of defines
  20254. * @param lightIndex defines the index of the light for the effect
  20255. */
  20256. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20257. }
  20258. }
  20259. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20260. /** @hidden */
  20261. export var vrMultiviewToSingleviewPixelShader: {
  20262. name: string;
  20263. shader: string;
  20264. };
  20265. }
  20266. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20267. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20268. import { Scene } from "babylonjs/scene";
  20269. /**
  20270. * Renders to multiple views with a single draw call
  20271. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20272. */
  20273. export class MultiviewRenderTarget extends RenderTargetTexture {
  20274. /**
  20275. * Creates a multiview render target
  20276. * @param scene scene used with the render target
  20277. * @param size the size of the render target (used for each view)
  20278. */
  20279. constructor(scene: Scene, size?: number | {
  20280. width: number;
  20281. height: number;
  20282. } | {
  20283. ratio: number;
  20284. });
  20285. /**
  20286. * @hidden
  20287. * @param faceIndex the face index, if its a cube texture
  20288. */
  20289. _bindFrameBuffer(faceIndex?: number): void;
  20290. /**
  20291. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20292. * @returns the view count
  20293. */
  20294. getViewCount(): number;
  20295. }
  20296. }
  20297. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20298. import { Camera } from "babylonjs/Cameras/camera";
  20299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20300. import { Nullable } from "babylonjs/types";
  20301. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20302. import { Matrix } from "babylonjs/Maths/math.vector";
  20303. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20304. module "babylonjs/Engines/engine" {
  20305. interface Engine {
  20306. /**
  20307. * Creates a new multiview render target
  20308. * @param width defines the width of the texture
  20309. * @param height defines the height of the texture
  20310. * @returns the created multiview texture
  20311. */
  20312. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20313. /**
  20314. * Binds a multiview framebuffer to be drawn to
  20315. * @param multiviewTexture texture to bind
  20316. */
  20317. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20318. }
  20319. }
  20320. module "babylonjs/Cameras/camera" {
  20321. interface Camera {
  20322. /**
  20323. * @hidden
  20324. * 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)
  20325. */
  20326. _useMultiviewToSingleView: boolean;
  20327. /**
  20328. * @hidden
  20329. * 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)
  20330. */
  20331. _multiviewTexture: Nullable<RenderTargetTexture>;
  20332. /**
  20333. * @hidden
  20334. * ensures the multiview texture of the camera exists and has the specified width/height
  20335. * @param width height to set on the multiview texture
  20336. * @param height width to set on the multiview texture
  20337. */
  20338. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20339. }
  20340. }
  20341. module "babylonjs/scene" {
  20342. interface Scene {
  20343. /** @hidden */
  20344. _transformMatrixR: Matrix;
  20345. /** @hidden */
  20346. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20347. /** @hidden */
  20348. _createMultiviewUbo(): void;
  20349. /** @hidden */
  20350. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20351. /** @hidden */
  20352. _renderMultiviewToSingleView(camera: Camera): void;
  20353. }
  20354. }
  20355. }
  20356. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20357. import { Camera } from "babylonjs/Cameras/camera";
  20358. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20359. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20360. import "babylonjs/Engines/Extensions/engine.multiview";
  20361. /**
  20362. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20363. * This will not be used for webXR as it supports displaying texture arrays directly
  20364. */
  20365. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20366. /**
  20367. * Gets a string identifying the name of the class
  20368. * @returns "VRMultiviewToSingleviewPostProcess" string
  20369. */
  20370. getClassName(): string;
  20371. /**
  20372. * Initializes a VRMultiviewToSingleview
  20373. * @param name name of the post process
  20374. * @param camera camera to be applied to
  20375. * @param scaleFactor scaling factor to the size of the output texture
  20376. */
  20377. constructor(name: string, camera: Camera, scaleFactor: number);
  20378. }
  20379. }
  20380. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20381. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20382. import { Nullable } from "babylonjs/types";
  20383. import { Size } from "babylonjs/Maths/math.size";
  20384. import { Observable } from "babylonjs/Misc/observable";
  20385. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20386. /**
  20387. * Interface used to define additional presentation attributes
  20388. */
  20389. export interface IVRPresentationAttributes {
  20390. /**
  20391. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20392. */
  20393. highRefreshRate: boolean;
  20394. /**
  20395. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20396. */
  20397. foveationLevel: number;
  20398. }
  20399. module "babylonjs/Engines/engine" {
  20400. interface Engine {
  20401. /** @hidden */
  20402. _vrDisplay: any;
  20403. /** @hidden */
  20404. _vrSupported: boolean;
  20405. /** @hidden */
  20406. _oldSize: Size;
  20407. /** @hidden */
  20408. _oldHardwareScaleFactor: number;
  20409. /** @hidden */
  20410. _vrExclusivePointerMode: boolean;
  20411. /** @hidden */
  20412. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20413. /** @hidden */
  20414. _onVRDisplayPointerRestricted: () => void;
  20415. /** @hidden */
  20416. _onVRDisplayPointerUnrestricted: () => void;
  20417. /** @hidden */
  20418. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20419. /** @hidden */
  20420. _onVrDisplayDisconnect: Nullable<() => void>;
  20421. /** @hidden */
  20422. _onVrDisplayPresentChange: Nullable<() => void>;
  20423. /**
  20424. * Observable signaled when VR display mode changes
  20425. */
  20426. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20427. /**
  20428. * Observable signaled when VR request present is complete
  20429. */
  20430. onVRRequestPresentComplete: Observable<boolean>;
  20431. /**
  20432. * Observable signaled when VR request present starts
  20433. */
  20434. onVRRequestPresentStart: Observable<Engine>;
  20435. /**
  20436. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20437. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20438. */
  20439. isInVRExclusivePointerMode: boolean;
  20440. /**
  20441. * Gets a boolean indicating if a webVR device was detected
  20442. * @returns true if a webVR device was detected
  20443. */
  20444. isVRDevicePresent(): boolean;
  20445. /**
  20446. * Gets the current webVR device
  20447. * @returns the current webVR device (or null)
  20448. */
  20449. getVRDevice(): any;
  20450. /**
  20451. * Initializes a webVR display and starts listening to display change events
  20452. * The onVRDisplayChangedObservable will be notified upon these changes
  20453. * @returns A promise containing a VRDisplay and if vr is supported
  20454. */
  20455. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20456. /** @hidden */
  20457. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20458. /**
  20459. * Gets or sets the presentation attributes used to configure VR rendering
  20460. */
  20461. vrPresentationAttributes?: IVRPresentationAttributes;
  20462. /**
  20463. * Call this function to switch to webVR mode
  20464. * Will do nothing if webVR is not supported or if there is no webVR device
  20465. * @param options the webvr options provided to the camera. mainly used for multiview
  20466. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20467. */
  20468. enableVR(options: WebVROptions): void;
  20469. /** @hidden */
  20470. _onVRFullScreenTriggered(): void;
  20471. }
  20472. }
  20473. }
  20474. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20475. import { Nullable } from "babylonjs/types";
  20476. import { Observable } from "babylonjs/Misc/observable";
  20477. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20478. import { Scene } from "babylonjs/scene";
  20479. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20480. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20481. import { Node } from "babylonjs/node";
  20482. import { Ray } from "babylonjs/Culling/ray";
  20483. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20484. import "babylonjs/Engines/Extensions/engine.webVR";
  20485. /**
  20486. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20487. * IMPORTANT!! The data is right-hand data.
  20488. * @export
  20489. * @interface DevicePose
  20490. */
  20491. export interface DevicePose {
  20492. /**
  20493. * The position of the device, values in array are [x,y,z].
  20494. */
  20495. readonly position: Nullable<Float32Array>;
  20496. /**
  20497. * The linearVelocity of the device, values in array are [x,y,z].
  20498. */
  20499. readonly linearVelocity: Nullable<Float32Array>;
  20500. /**
  20501. * The linearAcceleration of the device, values in array are [x,y,z].
  20502. */
  20503. readonly linearAcceleration: Nullable<Float32Array>;
  20504. /**
  20505. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20506. */
  20507. readonly orientation: Nullable<Float32Array>;
  20508. /**
  20509. * The angularVelocity of the device, values in array are [x,y,z].
  20510. */
  20511. readonly angularVelocity: Nullable<Float32Array>;
  20512. /**
  20513. * The angularAcceleration of the device, values in array are [x,y,z].
  20514. */
  20515. readonly angularAcceleration: Nullable<Float32Array>;
  20516. }
  20517. /**
  20518. * Interface representing a pose controlled object in Babylon.
  20519. * A pose controlled object has both regular pose values as well as pose values
  20520. * from an external device such as a VR head mounted display
  20521. */
  20522. export interface PoseControlled {
  20523. /**
  20524. * The position of the object in babylon space.
  20525. */
  20526. position: Vector3;
  20527. /**
  20528. * The rotation quaternion of the object in babylon space.
  20529. */
  20530. rotationQuaternion: Quaternion;
  20531. /**
  20532. * The position of the device in babylon space.
  20533. */
  20534. devicePosition?: Vector3;
  20535. /**
  20536. * The rotation quaternion of the device in babylon space.
  20537. */
  20538. deviceRotationQuaternion: Quaternion;
  20539. /**
  20540. * The raw pose coming from the device.
  20541. */
  20542. rawPose: Nullable<DevicePose>;
  20543. /**
  20544. * The scale of the device to be used when translating from device space to babylon space.
  20545. */
  20546. deviceScaleFactor: number;
  20547. /**
  20548. * Updates the poseControlled values based on the input device pose.
  20549. * @param poseData the pose data to update the object with
  20550. */
  20551. updateFromDevice(poseData: DevicePose): void;
  20552. }
  20553. /**
  20554. * Set of options to customize the webVRCamera
  20555. */
  20556. export interface WebVROptions {
  20557. /**
  20558. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20559. */
  20560. trackPosition?: boolean;
  20561. /**
  20562. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20563. */
  20564. positionScale?: number;
  20565. /**
  20566. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20567. */
  20568. displayName?: string;
  20569. /**
  20570. * Should the native controller meshes be initialized. (default: true)
  20571. */
  20572. controllerMeshes?: boolean;
  20573. /**
  20574. * Creating a default HemiLight only on controllers. (default: true)
  20575. */
  20576. defaultLightingOnControllers?: boolean;
  20577. /**
  20578. * If you don't want to use the default VR button of the helper. (default: false)
  20579. */
  20580. useCustomVRButton?: boolean;
  20581. /**
  20582. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20583. */
  20584. customVRButton?: HTMLButtonElement;
  20585. /**
  20586. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20587. */
  20588. rayLength?: number;
  20589. /**
  20590. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20591. */
  20592. defaultHeight?: number;
  20593. /**
  20594. * If multiview should be used if availible (default: false)
  20595. */
  20596. useMultiview?: boolean;
  20597. }
  20598. /**
  20599. * This represents a WebVR camera.
  20600. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20601. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20602. */
  20603. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20604. private webVROptions;
  20605. /**
  20606. * @hidden
  20607. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20608. */
  20609. _vrDevice: any;
  20610. /**
  20611. * The rawPose of the vrDevice.
  20612. */
  20613. rawPose: Nullable<DevicePose>;
  20614. private _onVREnabled;
  20615. private _specsVersion;
  20616. private _attached;
  20617. private _frameData;
  20618. protected _descendants: Array<Node>;
  20619. private _deviceRoomPosition;
  20620. /** @hidden */
  20621. _deviceRoomRotationQuaternion: Quaternion;
  20622. private _standingMatrix;
  20623. /**
  20624. * Represents device position in babylon space.
  20625. */
  20626. devicePosition: Vector3;
  20627. /**
  20628. * Represents device rotation in babylon space.
  20629. */
  20630. deviceRotationQuaternion: Quaternion;
  20631. /**
  20632. * The scale of the device to be used when translating from device space to babylon space.
  20633. */
  20634. deviceScaleFactor: number;
  20635. private _deviceToWorld;
  20636. private _worldToDevice;
  20637. /**
  20638. * References to the webVR controllers for the vrDevice.
  20639. */
  20640. controllers: Array<WebVRController>;
  20641. /**
  20642. * Emits an event when a controller is attached.
  20643. */
  20644. onControllersAttachedObservable: Observable<WebVRController[]>;
  20645. /**
  20646. * Emits an event when a controller's mesh has been loaded;
  20647. */
  20648. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20649. /**
  20650. * Emits an event when the HMD's pose has been updated.
  20651. */
  20652. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20653. private _poseSet;
  20654. /**
  20655. * If the rig cameras be used as parent instead of this camera.
  20656. */
  20657. rigParenting: boolean;
  20658. private _lightOnControllers;
  20659. private _defaultHeight?;
  20660. /**
  20661. * Instantiates a WebVRFreeCamera.
  20662. * @param name The name of the WebVRFreeCamera
  20663. * @param position The starting anchor position for the camera
  20664. * @param scene The scene the camera belongs to
  20665. * @param webVROptions a set of customizable options for the webVRCamera
  20666. */
  20667. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20668. /**
  20669. * Gets the device distance from the ground in meters.
  20670. * @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.
  20671. */
  20672. deviceDistanceToRoomGround(): number;
  20673. /**
  20674. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20675. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20676. */
  20677. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20678. /**
  20679. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20680. * @returns A promise with a boolean set to if the standing matrix is supported.
  20681. */
  20682. useStandingMatrixAsync(): Promise<boolean>;
  20683. /**
  20684. * Disposes the camera
  20685. */
  20686. dispose(): void;
  20687. /**
  20688. * Gets a vrController by name.
  20689. * @param name The name of the controller to retreive
  20690. * @returns the controller matching the name specified or null if not found
  20691. */
  20692. getControllerByName(name: string): Nullable<WebVRController>;
  20693. private _leftController;
  20694. /**
  20695. * The controller corresponding to the users left hand.
  20696. */
  20697. get leftController(): Nullable<WebVRController>;
  20698. private _rightController;
  20699. /**
  20700. * The controller corresponding to the users right hand.
  20701. */
  20702. get rightController(): Nullable<WebVRController>;
  20703. /**
  20704. * Casts a ray forward from the vrCamera's gaze.
  20705. * @param length Length of the ray (default: 100)
  20706. * @returns the ray corresponding to the gaze
  20707. */
  20708. getForwardRay(length?: number): Ray;
  20709. /**
  20710. * @hidden
  20711. * Updates the camera based on device's frame data
  20712. */
  20713. _checkInputs(): void;
  20714. /**
  20715. * Updates the poseControlled values based on the input device pose.
  20716. * @param poseData Pose coming from the device
  20717. */
  20718. updateFromDevice(poseData: DevicePose): void;
  20719. private _htmlElementAttached;
  20720. private _detachIfAttached;
  20721. /**
  20722. * WebVR's attach control will start broadcasting frames to the device.
  20723. * Note that in certain browsers (chrome for example) this function must be called
  20724. * within a user-interaction callback. Example:
  20725. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20726. *
  20727. * @param element html element to attach the vrDevice to
  20728. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20729. */
  20730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20731. /**
  20732. * Detaches the camera from the html element and disables VR
  20733. *
  20734. * @param element html element to detach from
  20735. */
  20736. detachControl(element: HTMLElement): void;
  20737. /**
  20738. * @returns the name of this class
  20739. */
  20740. getClassName(): string;
  20741. /**
  20742. * Calls resetPose on the vrDisplay
  20743. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20744. */
  20745. resetToCurrentRotation(): void;
  20746. /**
  20747. * @hidden
  20748. * Updates the rig cameras (left and right eye)
  20749. */
  20750. _updateRigCameras(): void;
  20751. private _workingVector;
  20752. private _oneVector;
  20753. private _workingMatrix;
  20754. private updateCacheCalled;
  20755. private _correctPositionIfNotTrackPosition;
  20756. /**
  20757. * @hidden
  20758. * Updates the cached values of the camera
  20759. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20760. */
  20761. _updateCache(ignoreParentClass?: boolean): void;
  20762. /**
  20763. * @hidden
  20764. * Get current device position in babylon world
  20765. */
  20766. _computeDevicePosition(): void;
  20767. /**
  20768. * Updates the current device position and rotation in the babylon world
  20769. */
  20770. update(): void;
  20771. /**
  20772. * @hidden
  20773. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20774. * @returns an identity matrix
  20775. */
  20776. _getViewMatrix(): Matrix;
  20777. private _tmpMatrix;
  20778. /**
  20779. * This function is called by the two RIG cameras.
  20780. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20781. * @hidden
  20782. */
  20783. _getWebVRViewMatrix(): Matrix;
  20784. /** @hidden */
  20785. _getWebVRProjectionMatrix(): Matrix;
  20786. private _onGamepadConnectedObserver;
  20787. private _onGamepadDisconnectedObserver;
  20788. private _updateCacheWhenTrackingDisabledObserver;
  20789. /**
  20790. * Initializes the controllers and their meshes
  20791. */
  20792. initControllers(): void;
  20793. }
  20794. }
  20795. declare module "babylonjs/Materials/materialHelper" {
  20796. import { Nullable } from "babylonjs/types";
  20797. import { Scene } from "babylonjs/scene";
  20798. import { Engine } from "babylonjs/Engines/engine";
  20799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20800. import { Light } from "babylonjs/Lights/light";
  20801. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20802. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20803. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20804. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20805. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20806. /**
  20807. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20808. *
  20809. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20810. *
  20811. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20812. */
  20813. export class MaterialHelper {
  20814. /**
  20815. * Bind the current view position to an effect.
  20816. * @param effect The effect to be bound
  20817. * @param scene The scene the eyes position is used from
  20818. * @param variableName name of the shader variable that will hold the eye position
  20819. */
  20820. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20821. /**
  20822. * Helps preparing the defines values about the UVs in used in the effect.
  20823. * UVs are shared as much as we can accross channels in the shaders.
  20824. * @param texture The texture we are preparing the UVs for
  20825. * @param defines The defines to update
  20826. * @param key The channel key "diffuse", "specular"... used in the shader
  20827. */
  20828. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20829. /**
  20830. * Binds a texture matrix value to its corrsponding uniform
  20831. * @param texture The texture to bind the matrix for
  20832. * @param uniformBuffer The uniform buffer receivin the data
  20833. * @param key The channel key "diffuse", "specular"... used in the shader
  20834. */
  20835. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20836. /**
  20837. * Gets the current status of the fog (should it be enabled?)
  20838. * @param mesh defines the mesh to evaluate for fog support
  20839. * @param scene defines the hosting scene
  20840. * @returns true if fog must be enabled
  20841. */
  20842. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20843. /**
  20844. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20845. * @param mesh defines the current mesh
  20846. * @param scene defines the current scene
  20847. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20848. * @param pointsCloud defines if point cloud rendering has to be turned on
  20849. * @param fogEnabled defines if fog has to be turned on
  20850. * @param alphaTest defines if alpha testing has to be turned on
  20851. * @param defines defines the current list of defines
  20852. */
  20853. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20854. /**
  20855. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20856. * @param scene defines the current scene
  20857. * @param engine defines the current engine
  20858. * @param defines specifies the list of active defines
  20859. * @param useInstances defines if instances have to be turned on
  20860. * @param useClipPlane defines if clip plane have to be turned on
  20861. * @param useInstances defines if instances have to be turned on
  20862. * @param useThinInstances defines if thin instances have to be turned on
  20863. */
  20864. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20865. /**
  20866. * Prepares the defines for bones
  20867. * @param mesh The mesh containing the geometry data we will draw
  20868. * @param defines The defines to update
  20869. */
  20870. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20871. /**
  20872. * Prepares the defines for morph targets
  20873. * @param mesh The mesh containing the geometry data we will draw
  20874. * @param defines The defines to update
  20875. */
  20876. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20877. /**
  20878. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20879. * @param mesh The mesh containing the geometry data we will draw
  20880. * @param defines The defines to update
  20881. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20882. * @param useBones Precise whether bones should be used or not (override mesh info)
  20883. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20884. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20885. * @returns false if defines are considered not dirty and have not been checked
  20886. */
  20887. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20888. /**
  20889. * Prepares the defines related to multiview
  20890. * @param scene The scene we are intending to draw
  20891. * @param defines The defines to update
  20892. */
  20893. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20894. /**
  20895. * Prepares the defines related to the prepass
  20896. * @param scene The scene we are intending to draw
  20897. * @param defines The defines to update
  20898. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20899. */
  20900. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20901. /**
  20902. * Prepares the defines related to the light information passed in parameter
  20903. * @param scene The scene we are intending to draw
  20904. * @param mesh The mesh the effect is compiling for
  20905. * @param light The light the effect is compiling for
  20906. * @param lightIndex The index of the light
  20907. * @param defines The defines to update
  20908. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20909. * @param state Defines the current state regarding what is needed (normals, etc...)
  20910. */
  20911. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20912. needNormals: boolean;
  20913. needRebuild: boolean;
  20914. shadowEnabled: boolean;
  20915. specularEnabled: boolean;
  20916. lightmapMode: boolean;
  20917. }): void;
  20918. /**
  20919. * Prepares the defines related to the light information passed in parameter
  20920. * @param scene The scene we are intending to draw
  20921. * @param mesh The mesh the effect is compiling for
  20922. * @param defines The defines to update
  20923. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20924. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20925. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20926. * @returns true if normals will be required for the rest of the effect
  20927. */
  20928. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20929. /**
  20930. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20931. * @param lightIndex defines the light index
  20932. * @param uniformsList The uniform list
  20933. * @param samplersList The sampler list
  20934. * @param projectedLightTexture defines if projected texture must be used
  20935. * @param uniformBuffersList defines an optional list of uniform buffers
  20936. */
  20937. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20938. /**
  20939. * Prepares the uniforms and samplers list to be used in the effect
  20940. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20941. * @param samplersList The sampler list
  20942. * @param defines The defines helping in the list generation
  20943. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20944. */
  20945. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20946. /**
  20947. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20948. * @param defines The defines to update while falling back
  20949. * @param fallbacks The authorized effect fallbacks
  20950. * @param maxSimultaneousLights The maximum number of lights allowed
  20951. * @param rank the current rank of the Effect
  20952. * @returns The newly affected rank
  20953. */
  20954. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20955. private static _TmpMorphInfluencers;
  20956. /**
  20957. * Prepares the list of attributes required for morph targets according to the effect defines.
  20958. * @param attribs The current list of supported attribs
  20959. * @param mesh The mesh to prepare the morph targets attributes for
  20960. * @param influencers The number of influencers
  20961. */
  20962. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20963. /**
  20964. * Prepares the list of attributes required for morph targets according to the effect defines.
  20965. * @param attribs The current list of supported attribs
  20966. * @param mesh The mesh to prepare the morph targets attributes for
  20967. * @param defines The current Defines of the effect
  20968. */
  20969. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20970. /**
  20971. * Prepares the list of attributes required for bones according to the effect defines.
  20972. * @param attribs The current list of supported attribs
  20973. * @param mesh The mesh to prepare the bones attributes for
  20974. * @param defines The current Defines of the effect
  20975. * @param fallbacks The current efffect fallback strategy
  20976. */
  20977. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20978. /**
  20979. * Check and prepare the list of attributes required for instances according to the effect defines.
  20980. * @param attribs The current list of supported attribs
  20981. * @param defines The current MaterialDefines of the effect
  20982. */
  20983. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20984. /**
  20985. * Add the list of attributes required for instances to the attribs array.
  20986. * @param attribs The current list of supported attribs
  20987. */
  20988. static PushAttributesForInstances(attribs: string[]): void;
  20989. /**
  20990. * Binds the light information to the effect.
  20991. * @param light The light containing the generator
  20992. * @param effect The effect we are binding the data to
  20993. * @param lightIndex The light index in the effect used to render
  20994. */
  20995. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20996. /**
  20997. * Binds the lights information from the scene to the effect for the given mesh.
  20998. * @param light Light to bind
  20999. * @param lightIndex Light index
  21000. * @param scene The scene where the light belongs to
  21001. * @param effect The effect we are binding the data to
  21002. * @param useSpecular Defines if specular is supported
  21003. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21004. */
  21005. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21006. /**
  21007. * Binds the lights information from the scene to the effect for the given mesh.
  21008. * @param scene The scene the lights belongs to
  21009. * @param mesh The mesh we are binding the information to render
  21010. * @param effect The effect we are binding the data to
  21011. * @param defines The generated defines for the effect
  21012. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21013. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21014. */
  21015. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21016. private static _tempFogColor;
  21017. /**
  21018. * Binds the fog information from the scene to the effect for the given mesh.
  21019. * @param scene The scene the lights belongs to
  21020. * @param mesh The mesh we are binding the information to render
  21021. * @param effect The effect we are binding the data to
  21022. * @param linearSpace Defines if the fog effect is applied in linear space
  21023. */
  21024. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21025. /**
  21026. * Binds the bones information from the mesh to the effect.
  21027. * @param mesh The mesh we are binding the information to render
  21028. * @param effect The effect we are binding the data to
  21029. */
  21030. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21031. /**
  21032. * Binds the morph targets information from the mesh to the effect.
  21033. * @param abstractMesh The mesh we are binding the information to render
  21034. * @param effect The effect we are binding the data to
  21035. */
  21036. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21037. /**
  21038. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21039. * @param defines The generated defines used in the effect
  21040. * @param effect The effect we are binding the data to
  21041. * @param scene The scene we are willing to render with logarithmic scale for
  21042. */
  21043. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21044. /**
  21045. * Binds the clip plane information from the scene to the effect.
  21046. * @param scene The scene the clip plane information are extracted from
  21047. * @param effect The effect we are binding the data to
  21048. */
  21049. static BindClipPlane(effect: Effect, scene: Scene): void;
  21050. }
  21051. }
  21052. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21054. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21055. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21056. import { Nullable } from "babylonjs/types";
  21057. import { Effect } from "babylonjs/Materials/effect";
  21058. import { Matrix } from "babylonjs/Maths/math.vector";
  21059. import { Scene } from "babylonjs/scene";
  21060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21062. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21063. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21064. import { Observable } from "babylonjs/Misc/observable";
  21065. /**
  21066. * Block used to expose an input value
  21067. */
  21068. export class InputBlock extends NodeMaterialBlock {
  21069. private _mode;
  21070. private _associatedVariableName;
  21071. private _storedValue;
  21072. private _valueCallback;
  21073. private _type;
  21074. private _animationType;
  21075. /** Gets or set a value used to limit the range of float values */
  21076. min: number;
  21077. /** Gets or set a value used to limit the range of float values */
  21078. max: number;
  21079. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21080. isBoolean: boolean;
  21081. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21082. matrixMode: number;
  21083. /** @hidden */
  21084. _systemValue: Nullable<NodeMaterialSystemValues>;
  21085. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21086. visibleInInspector: boolean;
  21087. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21088. isConstant: boolean;
  21089. /** Gets or sets the group to use to display this block in the Inspector */
  21090. groupInInspector: string;
  21091. /** Gets an observable raised when the value is changed */
  21092. onValueChangedObservable: Observable<InputBlock>;
  21093. /**
  21094. * Gets or sets the connection point type (default is float)
  21095. */
  21096. get type(): NodeMaterialBlockConnectionPointTypes;
  21097. /**
  21098. * Creates a new InputBlock
  21099. * @param name defines the block name
  21100. * @param target defines the target of that block (Vertex by default)
  21101. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21102. */
  21103. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21104. /**
  21105. * Validates if a name is a reserve word.
  21106. * @param newName the new name to be given to the node.
  21107. * @returns false if the name is a reserve word, else true.
  21108. */
  21109. validateBlockName(newName: string): boolean;
  21110. /**
  21111. * Gets the output component
  21112. */
  21113. get output(): NodeMaterialConnectionPoint;
  21114. /**
  21115. * Set the source of this connection point to a vertex attribute
  21116. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21117. * @returns the current connection point
  21118. */
  21119. setAsAttribute(attributeName?: string): InputBlock;
  21120. /**
  21121. * Set the source of this connection point to a system value
  21122. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21123. * @returns the current connection point
  21124. */
  21125. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21126. /**
  21127. * Gets or sets the value of that point.
  21128. * Please note that this value will be ignored if valueCallback is defined
  21129. */
  21130. get value(): any;
  21131. set value(value: any);
  21132. /**
  21133. * Gets or sets a callback used to get the value of that point.
  21134. * Please note that setting this value will force the connection point to ignore the value property
  21135. */
  21136. get valueCallback(): () => any;
  21137. set valueCallback(value: () => any);
  21138. /**
  21139. * Gets or sets the associated variable name in the shader
  21140. */
  21141. get associatedVariableName(): string;
  21142. set associatedVariableName(value: string);
  21143. /** Gets or sets the type of animation applied to the input */
  21144. get animationType(): AnimatedInputBlockTypes;
  21145. set animationType(value: AnimatedInputBlockTypes);
  21146. /**
  21147. * Gets a boolean indicating that this connection point not defined yet
  21148. */
  21149. get isUndefined(): boolean;
  21150. /**
  21151. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21152. * In this case the connection point name must be the name of the uniform to use.
  21153. * Can only be set on inputs
  21154. */
  21155. get isUniform(): boolean;
  21156. set isUniform(value: boolean);
  21157. /**
  21158. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21159. * In this case the connection point name must be the name of the attribute to use
  21160. * Can only be set on inputs
  21161. */
  21162. get isAttribute(): boolean;
  21163. set isAttribute(value: boolean);
  21164. /**
  21165. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21166. * Can only be set on exit points
  21167. */
  21168. get isVarying(): boolean;
  21169. set isVarying(value: boolean);
  21170. /**
  21171. * Gets a boolean indicating that the current connection point is a system value
  21172. */
  21173. get isSystemValue(): boolean;
  21174. /**
  21175. * Gets or sets the current well known value or null if not defined as a system value
  21176. */
  21177. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21178. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21179. /**
  21180. * Gets the current class name
  21181. * @returns the class name
  21182. */
  21183. getClassName(): string;
  21184. /**
  21185. * Animate the input if animationType !== None
  21186. * @param scene defines the rendering scene
  21187. */
  21188. animate(scene: Scene): void;
  21189. private _emitDefine;
  21190. initialize(state: NodeMaterialBuildState): void;
  21191. /**
  21192. * Set the input block to its default value (based on its type)
  21193. */
  21194. setDefaultValue(): void;
  21195. private _emitConstant;
  21196. /** @hidden */
  21197. get _noContextSwitch(): boolean;
  21198. private _emit;
  21199. /** @hidden */
  21200. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21201. /** @hidden */
  21202. _transmit(effect: Effect, scene: Scene): void;
  21203. protected _buildBlock(state: NodeMaterialBuildState): void;
  21204. protected _dumpPropertiesCode(): string;
  21205. dispose(): void;
  21206. serialize(): any;
  21207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21208. }
  21209. }
  21210. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21211. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21212. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21213. import { Nullable } from "babylonjs/types";
  21214. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21215. import { Observable } from "babylonjs/Misc/observable";
  21216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21217. /**
  21218. * Enum used to define the compatibility state between two connection points
  21219. */
  21220. export enum NodeMaterialConnectionPointCompatibilityStates {
  21221. /** Points are compatibles */
  21222. Compatible = 0,
  21223. /** Points are incompatible because of their types */
  21224. TypeIncompatible = 1,
  21225. /** Points are incompatible because of their targets (vertex vs fragment) */
  21226. TargetIncompatible = 2
  21227. }
  21228. /**
  21229. * Defines the direction of a connection point
  21230. */
  21231. export enum NodeMaterialConnectionPointDirection {
  21232. /** Input */
  21233. Input = 0,
  21234. /** Output */
  21235. Output = 1
  21236. }
  21237. /**
  21238. * Defines a connection point for a block
  21239. */
  21240. export class NodeMaterialConnectionPoint {
  21241. /** @hidden */
  21242. _ownerBlock: NodeMaterialBlock;
  21243. /** @hidden */
  21244. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21245. private _endpoints;
  21246. private _associatedVariableName;
  21247. private _direction;
  21248. /** @hidden */
  21249. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21250. /** @hidden */
  21251. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21252. private _type;
  21253. /** @hidden */
  21254. _enforceAssociatedVariableName: boolean;
  21255. /** Gets the direction of the point */
  21256. get direction(): NodeMaterialConnectionPointDirection;
  21257. /** Indicates that this connection point needs dual validation before being connected to another point */
  21258. needDualDirectionValidation: boolean;
  21259. /**
  21260. * Gets or sets the additional types supported by this connection point
  21261. */
  21262. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21263. /**
  21264. * Gets or sets the additional types excluded by this connection point
  21265. */
  21266. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21267. /**
  21268. * Observable triggered when this point is connected
  21269. */
  21270. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21271. /**
  21272. * Gets or sets the associated variable name in the shader
  21273. */
  21274. get associatedVariableName(): string;
  21275. set associatedVariableName(value: string);
  21276. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21277. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21278. /**
  21279. * Gets or sets the connection point type (default is float)
  21280. */
  21281. get type(): NodeMaterialBlockConnectionPointTypes;
  21282. set type(value: NodeMaterialBlockConnectionPointTypes);
  21283. /**
  21284. * Gets or sets the connection point name
  21285. */
  21286. name: string;
  21287. /**
  21288. * Gets or sets the connection point name
  21289. */
  21290. displayName: string;
  21291. /**
  21292. * Gets or sets a boolean indicating that this connection point can be omitted
  21293. */
  21294. isOptional: boolean;
  21295. /**
  21296. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21297. */
  21298. isExposedOnFrame: boolean;
  21299. /**
  21300. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21301. */
  21302. define: string;
  21303. /** @hidden */
  21304. _prioritizeVertex: boolean;
  21305. private _target;
  21306. /** Gets or sets the target of that connection point */
  21307. get target(): NodeMaterialBlockTargets;
  21308. set target(value: NodeMaterialBlockTargets);
  21309. /**
  21310. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21311. */
  21312. get isConnected(): boolean;
  21313. /**
  21314. * Gets a boolean indicating that the current point is connected to an input block
  21315. */
  21316. get isConnectedToInputBlock(): boolean;
  21317. /**
  21318. * Gets a the connected input block (if any)
  21319. */
  21320. get connectInputBlock(): Nullable<InputBlock>;
  21321. /** Get the other side of the connection (if any) */
  21322. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21323. /** Get the block that owns this connection point */
  21324. get ownerBlock(): NodeMaterialBlock;
  21325. /** Get the block connected on the other side of this connection (if any) */
  21326. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21327. /** Get the block connected on the endpoints of this connection (if any) */
  21328. get connectedBlocks(): Array<NodeMaterialBlock>;
  21329. /** Gets the list of connected endpoints */
  21330. get endpoints(): NodeMaterialConnectionPoint[];
  21331. /** Gets a boolean indicating if that output point is connected to at least one input */
  21332. get hasEndpoints(): boolean;
  21333. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21334. get isConnectedInVertexShader(): boolean;
  21335. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21336. get isConnectedInFragmentShader(): boolean;
  21337. /**
  21338. * Creates a block suitable to be used as an input for this input point.
  21339. * If null is returned, a block based on the point type will be created.
  21340. * @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
  21341. */
  21342. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21343. /**
  21344. * Creates a new connection point
  21345. * @param name defines the connection point name
  21346. * @param ownerBlock defines the block hosting this connection point
  21347. * @param direction defines the direction of the connection point
  21348. */
  21349. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21350. /**
  21351. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21352. * @returns the class name
  21353. */
  21354. getClassName(): string;
  21355. /**
  21356. * Gets a boolean indicating if the current point can be connected to another point
  21357. * @param connectionPoint defines the other connection point
  21358. * @returns a boolean
  21359. */
  21360. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21361. /**
  21362. * Gets a number indicating if the current point can be connected to another point
  21363. * @param connectionPoint defines the other connection point
  21364. * @returns a number defining the compatibility state
  21365. */
  21366. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21367. /**
  21368. * Connect this point to another connection point
  21369. * @param connectionPoint defines the other connection point
  21370. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21371. * @returns the current connection point
  21372. */
  21373. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21374. /**
  21375. * Disconnect this point from one of his endpoint
  21376. * @param endpoint defines the other connection point
  21377. * @returns the current connection point
  21378. */
  21379. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21380. /**
  21381. * Serializes this point in a JSON representation
  21382. * @param isInput defines if the connection point is an input (default is true)
  21383. * @returns the serialized point object
  21384. */
  21385. serialize(isInput?: boolean): any;
  21386. /**
  21387. * Release resources
  21388. */
  21389. dispose(): void;
  21390. }
  21391. }
  21392. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21393. /**
  21394. * Enum used to define the material modes
  21395. */
  21396. export enum NodeMaterialModes {
  21397. /** Regular material */
  21398. Material = 0,
  21399. /** For post process */
  21400. PostProcess = 1,
  21401. /** For particle system */
  21402. Particle = 2
  21403. }
  21404. }
  21405. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21406. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21407. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21408. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21411. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21412. import { Effect } from "babylonjs/Materials/effect";
  21413. import { Mesh } from "babylonjs/Meshes/mesh";
  21414. import { Nullable } from "babylonjs/types";
  21415. import { Texture } from "babylonjs/Materials/Textures/texture";
  21416. import { Scene } from "babylonjs/scene";
  21417. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21418. /**
  21419. * Block used to read a texture from a sampler
  21420. */
  21421. export class TextureBlock extends NodeMaterialBlock {
  21422. private _defineName;
  21423. private _linearDefineName;
  21424. private _gammaDefineName;
  21425. private _tempTextureRead;
  21426. private _samplerName;
  21427. private _transformedUVName;
  21428. private _textureTransformName;
  21429. private _textureInfoName;
  21430. private _mainUVName;
  21431. private _mainUVDefineName;
  21432. private _fragmentOnly;
  21433. /**
  21434. * Gets or sets the texture associated with the node
  21435. */
  21436. texture: Nullable<Texture>;
  21437. /**
  21438. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21439. */
  21440. convertToGammaSpace: boolean;
  21441. /**
  21442. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21443. */
  21444. convertToLinearSpace: boolean;
  21445. /**
  21446. * Create a new TextureBlock
  21447. * @param name defines the block name
  21448. */
  21449. constructor(name: string, fragmentOnly?: boolean);
  21450. /**
  21451. * Gets the current class name
  21452. * @returns the class name
  21453. */
  21454. getClassName(): string;
  21455. /**
  21456. * Gets the uv input component
  21457. */
  21458. get uv(): NodeMaterialConnectionPoint;
  21459. /**
  21460. * Gets the rgba output component
  21461. */
  21462. get rgba(): NodeMaterialConnectionPoint;
  21463. /**
  21464. * Gets the rgb output component
  21465. */
  21466. get rgb(): NodeMaterialConnectionPoint;
  21467. /**
  21468. * Gets the r output component
  21469. */
  21470. get r(): NodeMaterialConnectionPoint;
  21471. /**
  21472. * Gets the g output component
  21473. */
  21474. get g(): NodeMaterialConnectionPoint;
  21475. /**
  21476. * Gets the b output component
  21477. */
  21478. get b(): NodeMaterialConnectionPoint;
  21479. /**
  21480. * Gets the a output component
  21481. */
  21482. get a(): NodeMaterialConnectionPoint;
  21483. get target(): NodeMaterialBlockTargets;
  21484. autoConfigure(material: NodeMaterial): void;
  21485. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21486. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21487. isReady(): boolean;
  21488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21489. private get _isMixed();
  21490. private _injectVertexCode;
  21491. private _writeTextureRead;
  21492. private _writeOutput;
  21493. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21494. protected _dumpPropertiesCode(): string;
  21495. serialize(): any;
  21496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21497. }
  21498. }
  21499. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21500. /** @hidden */
  21501. export var reflectionFunction: {
  21502. name: string;
  21503. shader: string;
  21504. };
  21505. }
  21506. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21512. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21513. import { Effect } from "babylonjs/Materials/effect";
  21514. import { Mesh } from "babylonjs/Meshes/mesh";
  21515. import { Nullable } from "babylonjs/types";
  21516. import { Scene } from "babylonjs/scene";
  21517. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21518. /**
  21519. * Base block used to read a reflection texture from a sampler
  21520. */
  21521. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21522. /** @hidden */
  21523. _define3DName: string;
  21524. /** @hidden */
  21525. _defineCubicName: string;
  21526. /** @hidden */
  21527. _defineExplicitName: string;
  21528. /** @hidden */
  21529. _defineProjectionName: string;
  21530. /** @hidden */
  21531. _defineLocalCubicName: string;
  21532. /** @hidden */
  21533. _defineSphericalName: string;
  21534. /** @hidden */
  21535. _definePlanarName: string;
  21536. /** @hidden */
  21537. _defineEquirectangularName: string;
  21538. /** @hidden */
  21539. _defineMirroredEquirectangularFixedName: string;
  21540. /** @hidden */
  21541. _defineEquirectangularFixedName: string;
  21542. /** @hidden */
  21543. _defineSkyboxName: string;
  21544. /** @hidden */
  21545. _defineOppositeZ: string;
  21546. /** @hidden */
  21547. _cubeSamplerName: string;
  21548. /** @hidden */
  21549. _2DSamplerName: string;
  21550. protected _positionUVWName: string;
  21551. protected _directionWName: string;
  21552. protected _reflectionVectorName: string;
  21553. /** @hidden */
  21554. _reflectionCoordsName: string;
  21555. /** @hidden */
  21556. _reflectionMatrixName: string;
  21557. protected _reflectionColorName: string;
  21558. /**
  21559. * Gets or sets the texture associated with the node
  21560. */
  21561. texture: Nullable<BaseTexture>;
  21562. /**
  21563. * Create a new ReflectionTextureBaseBlock
  21564. * @param name defines the block name
  21565. */
  21566. constructor(name: string);
  21567. /**
  21568. * Gets the current class name
  21569. * @returns the class name
  21570. */
  21571. getClassName(): string;
  21572. /**
  21573. * Gets the world position input component
  21574. */
  21575. abstract get position(): NodeMaterialConnectionPoint;
  21576. /**
  21577. * Gets the world position input component
  21578. */
  21579. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21580. /**
  21581. * Gets the world normal input component
  21582. */
  21583. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21584. /**
  21585. * Gets the world input component
  21586. */
  21587. abstract get world(): NodeMaterialConnectionPoint;
  21588. /**
  21589. * Gets the camera (or eye) position component
  21590. */
  21591. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21592. /**
  21593. * Gets the view input component
  21594. */
  21595. abstract get view(): NodeMaterialConnectionPoint;
  21596. protected _getTexture(): Nullable<BaseTexture>;
  21597. autoConfigure(material: NodeMaterial): void;
  21598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21599. isReady(): boolean;
  21600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21601. /**
  21602. * Gets the code to inject in the vertex shader
  21603. * @param state current state of the node material building
  21604. * @returns the shader code
  21605. */
  21606. handleVertexSide(state: NodeMaterialBuildState): string;
  21607. /**
  21608. * Handles the inits for the fragment code path
  21609. * @param state node material build state
  21610. */
  21611. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21612. /**
  21613. * Generates the reflection coords code for the fragment code path
  21614. * @param worldNormalVarName name of the world normal variable
  21615. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21616. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21617. * @returns the shader code
  21618. */
  21619. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21620. /**
  21621. * Generates the reflection color code for the fragment code path
  21622. * @param lodVarName name of the lod variable
  21623. * @param swizzleLookupTexture swizzle to use for the final color variable
  21624. * @returns the shader code
  21625. */
  21626. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21627. /**
  21628. * Generates the code corresponding to the connected output points
  21629. * @param state node material build state
  21630. * @param varName name of the variable to output
  21631. * @returns the shader code
  21632. */
  21633. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21634. protected _buildBlock(state: NodeMaterialBuildState): this;
  21635. protected _dumpPropertiesCode(): string;
  21636. serialize(): any;
  21637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21638. }
  21639. }
  21640. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21642. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21643. import { Nullable } from "babylonjs/types";
  21644. /**
  21645. * Defines a connection point to be used for points with a custom object type
  21646. */
  21647. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21648. private _blockType;
  21649. private _blockName;
  21650. private _nameForCheking?;
  21651. /**
  21652. * Creates a new connection point
  21653. * @param name defines the connection point name
  21654. * @param ownerBlock defines the block hosting this connection point
  21655. * @param direction defines the direction of the connection point
  21656. */
  21657. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21658. /**
  21659. * Gets a number indicating if the current point can be connected to another point
  21660. * @param connectionPoint defines the other connection point
  21661. * @returns a number defining the compatibility state
  21662. */
  21663. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21664. /**
  21665. * Creates a block suitable to be used as an input for this input point.
  21666. * If null is returned, a block based on the point type will be created.
  21667. * @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
  21668. */
  21669. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21670. }
  21671. }
  21672. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21673. /**
  21674. * Enum defining the type of properties that can be edited in the property pages in the NME
  21675. */
  21676. export enum PropertyTypeForEdition {
  21677. /** property is a boolean */
  21678. Boolean = 0,
  21679. /** property is a float */
  21680. Float = 1,
  21681. /** property is a Vector2 */
  21682. Vector2 = 2,
  21683. /** property is a list of values */
  21684. List = 3
  21685. }
  21686. /**
  21687. * Interface that defines an option in a variable of type list
  21688. */
  21689. export interface IEditablePropertyListOption {
  21690. /** label of the option */
  21691. "label": string;
  21692. /** value of the option */
  21693. "value": number;
  21694. }
  21695. /**
  21696. * Interface that defines the options available for an editable property
  21697. */
  21698. export interface IEditablePropertyOption {
  21699. /** min value */
  21700. "min"?: number;
  21701. /** max value */
  21702. "max"?: number;
  21703. /** notifiers: indicates which actions to take when the property is changed */
  21704. "notifiers"?: {
  21705. /** the material should be rebuilt */
  21706. "rebuild"?: boolean;
  21707. /** the preview should be updated */
  21708. "update"?: boolean;
  21709. };
  21710. /** list of the options for a variable of type list */
  21711. "options"?: IEditablePropertyListOption[];
  21712. }
  21713. /**
  21714. * Interface that describes an editable property
  21715. */
  21716. export interface IPropertyDescriptionForEdition {
  21717. /** name of the property */
  21718. "propertyName": string;
  21719. /** display name of the property */
  21720. "displayName": string;
  21721. /** type of the property */
  21722. "type": PropertyTypeForEdition;
  21723. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21724. "groupName": string;
  21725. /** options for the property */
  21726. "options": IEditablePropertyOption;
  21727. }
  21728. /**
  21729. * Decorator that flags a property in a node material block as being editable
  21730. */
  21731. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21732. }
  21733. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21734. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21735. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21736. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21738. import { Nullable } from "babylonjs/types";
  21739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21740. import { Mesh } from "babylonjs/Meshes/mesh";
  21741. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21742. import { Effect } from "babylonjs/Materials/effect";
  21743. import { Scene } from "babylonjs/scene";
  21744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21745. /**
  21746. * Block used to implement the refraction part of the sub surface module of the PBR material
  21747. */
  21748. export class RefractionBlock extends NodeMaterialBlock {
  21749. /** @hidden */
  21750. _define3DName: string;
  21751. /** @hidden */
  21752. _refractionMatrixName: string;
  21753. /** @hidden */
  21754. _defineLODRefractionAlpha: string;
  21755. /** @hidden */
  21756. _defineLinearSpecularRefraction: string;
  21757. /** @hidden */
  21758. _defineOppositeZ: string;
  21759. /** @hidden */
  21760. _cubeSamplerName: string;
  21761. /** @hidden */
  21762. _2DSamplerName: string;
  21763. /** @hidden */
  21764. _vRefractionMicrosurfaceInfosName: string;
  21765. /** @hidden */
  21766. _vRefractionInfosName: string;
  21767. private _scene;
  21768. /**
  21769. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21770. * Materials half opaque for instance using refraction could benefit from this control.
  21771. */
  21772. linkRefractionWithTransparency: boolean;
  21773. /**
  21774. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21775. */
  21776. invertRefractionY: boolean;
  21777. /**
  21778. * Gets or sets the texture associated with the node
  21779. */
  21780. texture: Nullable<BaseTexture>;
  21781. /**
  21782. * Create a new RefractionBlock
  21783. * @param name defines the block name
  21784. */
  21785. constructor(name: string);
  21786. /**
  21787. * Gets the current class name
  21788. * @returns the class name
  21789. */
  21790. getClassName(): string;
  21791. /**
  21792. * Gets the intensity input component
  21793. */
  21794. get intensity(): NodeMaterialConnectionPoint;
  21795. /**
  21796. * Gets the index of refraction input component
  21797. */
  21798. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21799. /**
  21800. * Gets the tint at distance input component
  21801. */
  21802. get tintAtDistance(): NodeMaterialConnectionPoint;
  21803. /**
  21804. * Gets the view input component
  21805. */
  21806. get view(): NodeMaterialConnectionPoint;
  21807. /**
  21808. * Gets the refraction object output component
  21809. */
  21810. get refraction(): NodeMaterialConnectionPoint;
  21811. /**
  21812. * Returns true if the block has a texture
  21813. */
  21814. get hasTexture(): boolean;
  21815. protected _getTexture(): Nullable<BaseTexture>;
  21816. autoConfigure(material: NodeMaterial): void;
  21817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21818. isReady(): boolean;
  21819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21820. /**
  21821. * Gets the main code of the block (fragment side)
  21822. * @param state current state of the node material building
  21823. * @returns the shader code
  21824. */
  21825. getCode(state: NodeMaterialBuildState): string;
  21826. protected _buildBlock(state: NodeMaterialBuildState): this;
  21827. protected _dumpPropertiesCode(): string;
  21828. serialize(): any;
  21829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21830. }
  21831. }
  21832. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21835. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21838. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21840. import { Nullable } from "babylonjs/types";
  21841. import { Scene } from "babylonjs/scene";
  21842. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21843. /**
  21844. * Base block used as input for post process
  21845. */
  21846. export class CurrentScreenBlock extends NodeMaterialBlock {
  21847. private _samplerName;
  21848. private _linearDefineName;
  21849. private _gammaDefineName;
  21850. private _mainUVName;
  21851. private _tempTextureRead;
  21852. /**
  21853. * Gets or sets the texture associated with the node
  21854. */
  21855. texture: Nullable<BaseTexture>;
  21856. /**
  21857. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21858. */
  21859. convertToGammaSpace: boolean;
  21860. /**
  21861. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21862. */
  21863. convertToLinearSpace: boolean;
  21864. /**
  21865. * Create a new CurrentScreenBlock
  21866. * @param name defines the block name
  21867. */
  21868. constructor(name: string);
  21869. /**
  21870. * Gets the current class name
  21871. * @returns the class name
  21872. */
  21873. getClassName(): string;
  21874. /**
  21875. * Gets the uv input component
  21876. */
  21877. get uv(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the rgba output component
  21880. */
  21881. get rgba(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the rgb output component
  21884. */
  21885. get rgb(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Gets the r output component
  21888. */
  21889. get r(): NodeMaterialConnectionPoint;
  21890. /**
  21891. * Gets the g output component
  21892. */
  21893. get g(): NodeMaterialConnectionPoint;
  21894. /**
  21895. * Gets the b output component
  21896. */
  21897. get b(): NodeMaterialConnectionPoint;
  21898. /**
  21899. * Gets the a output component
  21900. */
  21901. get a(): NodeMaterialConnectionPoint;
  21902. /**
  21903. * Initialize the block and prepare the context for build
  21904. * @param state defines the state that will be used for the build
  21905. */
  21906. initialize(state: NodeMaterialBuildState): void;
  21907. get target(): NodeMaterialBlockTargets;
  21908. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21909. isReady(): boolean;
  21910. private _injectVertexCode;
  21911. private _writeTextureRead;
  21912. private _writeOutput;
  21913. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21914. serialize(): any;
  21915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21916. }
  21917. }
  21918. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21923. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21925. import { Nullable } from "babylonjs/types";
  21926. import { Scene } from "babylonjs/scene";
  21927. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21928. /**
  21929. * Base block used for the particle texture
  21930. */
  21931. export class ParticleTextureBlock extends NodeMaterialBlock {
  21932. private _samplerName;
  21933. private _linearDefineName;
  21934. private _gammaDefineName;
  21935. private _tempTextureRead;
  21936. /**
  21937. * Gets or sets the texture associated with the node
  21938. */
  21939. texture: Nullable<BaseTexture>;
  21940. /**
  21941. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21942. */
  21943. convertToGammaSpace: boolean;
  21944. /**
  21945. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21946. */
  21947. convertToLinearSpace: boolean;
  21948. /**
  21949. * Create a new ParticleTextureBlock
  21950. * @param name defines the block name
  21951. */
  21952. constructor(name: string);
  21953. /**
  21954. * Gets the current class name
  21955. * @returns the class name
  21956. */
  21957. getClassName(): string;
  21958. /**
  21959. * Gets the uv input component
  21960. */
  21961. get uv(): NodeMaterialConnectionPoint;
  21962. /**
  21963. * Gets the rgba output component
  21964. */
  21965. get rgba(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the rgb output component
  21968. */
  21969. get rgb(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the r output component
  21972. */
  21973. get r(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the g output component
  21976. */
  21977. get g(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Gets the b output component
  21980. */
  21981. get b(): NodeMaterialConnectionPoint;
  21982. /**
  21983. * Gets the a output component
  21984. */
  21985. get a(): NodeMaterialConnectionPoint;
  21986. /**
  21987. * Initialize the block and prepare the context for build
  21988. * @param state defines the state that will be used for the build
  21989. */
  21990. initialize(state: NodeMaterialBuildState): void;
  21991. autoConfigure(material: NodeMaterial): void;
  21992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21993. isReady(): boolean;
  21994. private _writeOutput;
  21995. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21996. serialize(): any;
  21997. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21998. }
  21999. }
  22000. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22003. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22004. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22005. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22006. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22007. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22008. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22009. import { Scene } from "babylonjs/scene";
  22010. /**
  22011. * Class used to store shared data between 2 NodeMaterialBuildState
  22012. */
  22013. export class NodeMaterialBuildStateSharedData {
  22014. /**
  22015. * Gets the list of emitted varyings
  22016. */
  22017. temps: string[];
  22018. /**
  22019. * Gets the list of emitted varyings
  22020. */
  22021. varyings: string[];
  22022. /**
  22023. * Gets the varying declaration string
  22024. */
  22025. varyingDeclaration: string;
  22026. /**
  22027. * Input blocks
  22028. */
  22029. inputBlocks: InputBlock[];
  22030. /**
  22031. * Input blocks
  22032. */
  22033. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22034. /**
  22035. * Bindable blocks (Blocks that need to set data to the effect)
  22036. */
  22037. bindableBlocks: NodeMaterialBlock[];
  22038. /**
  22039. * List of blocks that can provide a compilation fallback
  22040. */
  22041. blocksWithFallbacks: NodeMaterialBlock[];
  22042. /**
  22043. * List of blocks that can provide a define update
  22044. */
  22045. blocksWithDefines: NodeMaterialBlock[];
  22046. /**
  22047. * List of blocks that can provide a repeatable content
  22048. */
  22049. repeatableContentBlocks: NodeMaterialBlock[];
  22050. /**
  22051. * List of blocks that can provide a dynamic list of uniforms
  22052. */
  22053. dynamicUniformBlocks: NodeMaterialBlock[];
  22054. /**
  22055. * List of blocks that can block the isReady function for the material
  22056. */
  22057. blockingBlocks: NodeMaterialBlock[];
  22058. /**
  22059. * Gets the list of animated inputs
  22060. */
  22061. animatedInputs: InputBlock[];
  22062. /**
  22063. * Build Id used to avoid multiple recompilations
  22064. */
  22065. buildId: number;
  22066. /** List of emitted variables */
  22067. variableNames: {
  22068. [key: string]: number;
  22069. };
  22070. /** List of emitted defines */
  22071. defineNames: {
  22072. [key: string]: number;
  22073. };
  22074. /** Should emit comments? */
  22075. emitComments: boolean;
  22076. /** Emit build activity */
  22077. verbose: boolean;
  22078. /** Gets or sets the hosting scene */
  22079. scene: Scene;
  22080. /**
  22081. * Gets the compilation hints emitted at compilation time
  22082. */
  22083. hints: {
  22084. needWorldViewMatrix: boolean;
  22085. needWorldViewProjectionMatrix: boolean;
  22086. needAlphaBlending: boolean;
  22087. needAlphaTesting: boolean;
  22088. };
  22089. /**
  22090. * List of compilation checks
  22091. */
  22092. checks: {
  22093. emitVertex: boolean;
  22094. emitFragment: boolean;
  22095. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22096. };
  22097. /**
  22098. * Is vertex program allowed to be empty?
  22099. */
  22100. allowEmptyVertexProgram: boolean;
  22101. /** Creates a new shared data */
  22102. constructor();
  22103. /**
  22104. * Emits console errors and exceptions if there is a failing check
  22105. */
  22106. emitErrors(): void;
  22107. }
  22108. }
  22109. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22110. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22111. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22112. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22113. /**
  22114. * Class used to store node based material build state
  22115. */
  22116. export class NodeMaterialBuildState {
  22117. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22118. supportUniformBuffers: boolean;
  22119. /**
  22120. * Gets the list of emitted attributes
  22121. */
  22122. attributes: string[];
  22123. /**
  22124. * Gets the list of emitted uniforms
  22125. */
  22126. uniforms: string[];
  22127. /**
  22128. * Gets the list of emitted constants
  22129. */
  22130. constants: string[];
  22131. /**
  22132. * Gets the list of emitted samplers
  22133. */
  22134. samplers: string[];
  22135. /**
  22136. * Gets the list of emitted functions
  22137. */
  22138. functions: {
  22139. [key: string]: string;
  22140. };
  22141. /**
  22142. * Gets the list of emitted extensions
  22143. */
  22144. extensions: {
  22145. [key: string]: string;
  22146. };
  22147. /**
  22148. * Gets the target of the compilation state
  22149. */
  22150. target: NodeMaterialBlockTargets;
  22151. /**
  22152. * Gets the list of emitted counters
  22153. */
  22154. counters: {
  22155. [key: string]: number;
  22156. };
  22157. /**
  22158. * Shared data between multiple NodeMaterialBuildState instances
  22159. */
  22160. sharedData: NodeMaterialBuildStateSharedData;
  22161. /** @hidden */
  22162. _vertexState: NodeMaterialBuildState;
  22163. /** @hidden */
  22164. _attributeDeclaration: string;
  22165. /** @hidden */
  22166. _uniformDeclaration: string;
  22167. /** @hidden */
  22168. _constantDeclaration: string;
  22169. /** @hidden */
  22170. _samplerDeclaration: string;
  22171. /** @hidden */
  22172. _varyingTransfer: string;
  22173. /** @hidden */
  22174. _injectAtEnd: string;
  22175. private _repeatableContentAnchorIndex;
  22176. /** @hidden */
  22177. _builtCompilationString: string;
  22178. /**
  22179. * Gets the emitted compilation strings
  22180. */
  22181. compilationString: string;
  22182. /**
  22183. * Finalize the compilation strings
  22184. * @param state defines the current compilation state
  22185. */
  22186. finalize(state: NodeMaterialBuildState): void;
  22187. /** @hidden */
  22188. get _repeatableContentAnchor(): string;
  22189. /** @hidden */
  22190. _getFreeVariableName(prefix: string): string;
  22191. /** @hidden */
  22192. _getFreeDefineName(prefix: string): string;
  22193. /** @hidden */
  22194. _excludeVariableName(name: string): void;
  22195. /** @hidden */
  22196. _emit2DSampler(name: string): void;
  22197. /** @hidden */
  22198. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22199. /** @hidden */
  22200. _emitExtension(name: string, extension: string, define?: string): void;
  22201. /** @hidden */
  22202. _emitFunction(name: string, code: string, comments: string): void;
  22203. /** @hidden */
  22204. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22205. replaceStrings?: {
  22206. search: RegExp;
  22207. replace: string;
  22208. }[];
  22209. repeatKey?: string;
  22210. }): string;
  22211. /** @hidden */
  22212. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22213. repeatKey?: string;
  22214. removeAttributes?: boolean;
  22215. removeUniforms?: boolean;
  22216. removeVaryings?: boolean;
  22217. removeIfDef?: boolean;
  22218. replaceStrings?: {
  22219. search: RegExp;
  22220. replace: string;
  22221. }[];
  22222. }, storeKey?: string): void;
  22223. /** @hidden */
  22224. _registerTempVariable(name: string): boolean;
  22225. /** @hidden */
  22226. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22227. /** @hidden */
  22228. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22229. /** @hidden */
  22230. _emitFloat(value: number): string;
  22231. }
  22232. }
  22233. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22234. /**
  22235. * Helper class used to generate session unique ID
  22236. */
  22237. export class UniqueIdGenerator {
  22238. private static _UniqueIdCounter;
  22239. /**
  22240. * Gets an unique (relatively to the current scene) Id
  22241. */
  22242. static get UniqueId(): number;
  22243. }
  22244. }
  22245. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22246. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22248. import { Nullable } from "babylonjs/types";
  22249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22250. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22251. import { Effect } from "babylonjs/Materials/effect";
  22252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22253. import { Mesh } from "babylonjs/Meshes/mesh";
  22254. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22255. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22256. import { Scene } from "babylonjs/scene";
  22257. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22258. /**
  22259. * Defines a block that can be used inside a node based material
  22260. */
  22261. export class NodeMaterialBlock {
  22262. private _buildId;
  22263. private _buildTarget;
  22264. private _target;
  22265. private _isFinalMerger;
  22266. private _isInput;
  22267. private _name;
  22268. protected _isUnique: boolean;
  22269. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22270. inputsAreExclusive: boolean;
  22271. /** @hidden */
  22272. _codeVariableName: string;
  22273. /** @hidden */
  22274. _inputs: NodeMaterialConnectionPoint[];
  22275. /** @hidden */
  22276. _outputs: NodeMaterialConnectionPoint[];
  22277. /** @hidden */
  22278. _preparationId: number;
  22279. /**
  22280. * Gets the name of the block
  22281. */
  22282. get name(): string;
  22283. /**
  22284. * Sets the name of the block. Will check if the name is valid.
  22285. */
  22286. set name(newName: string);
  22287. /**
  22288. * Gets or sets the unique id of the node
  22289. */
  22290. uniqueId: number;
  22291. /**
  22292. * Gets or sets the comments associated with this block
  22293. */
  22294. comments: string;
  22295. /**
  22296. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22297. */
  22298. get isUnique(): boolean;
  22299. /**
  22300. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22301. */
  22302. get isFinalMerger(): boolean;
  22303. /**
  22304. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22305. */
  22306. get isInput(): boolean;
  22307. /**
  22308. * Gets or sets the build Id
  22309. */
  22310. get buildId(): number;
  22311. set buildId(value: number);
  22312. /**
  22313. * Gets or sets the target of the block
  22314. */
  22315. get target(): NodeMaterialBlockTargets;
  22316. set target(value: NodeMaterialBlockTargets);
  22317. /**
  22318. * Gets the list of input points
  22319. */
  22320. get inputs(): NodeMaterialConnectionPoint[];
  22321. /** Gets the list of output points */
  22322. get outputs(): NodeMaterialConnectionPoint[];
  22323. /**
  22324. * Find an input by its name
  22325. * @param name defines the name of the input to look for
  22326. * @returns the input or null if not found
  22327. */
  22328. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22329. /**
  22330. * Find an output by its name
  22331. * @param name defines the name of the outputto look for
  22332. * @returns the output or null if not found
  22333. */
  22334. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22335. /**
  22336. * Creates a new NodeMaterialBlock
  22337. * @param name defines the block name
  22338. * @param target defines the target of that block (Vertex by default)
  22339. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22340. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22341. */
  22342. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22343. /**
  22344. * Initialize the block and prepare the context for build
  22345. * @param state defines the state that will be used for the build
  22346. */
  22347. initialize(state: NodeMaterialBuildState): void;
  22348. /**
  22349. * Bind data to effect. Will only be called for blocks with isBindable === true
  22350. * @param effect defines the effect to bind data to
  22351. * @param nodeMaterial defines the hosting NodeMaterial
  22352. * @param mesh defines the mesh that will be rendered
  22353. * @param subMesh defines the submesh that will be rendered
  22354. */
  22355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22356. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22357. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22358. protected _writeFloat(value: number): string;
  22359. /**
  22360. * Gets the current class name e.g. "NodeMaterialBlock"
  22361. * @returns the class name
  22362. */
  22363. getClassName(): string;
  22364. /**
  22365. * Register a new input. Must be called inside a block constructor
  22366. * @param name defines the connection point name
  22367. * @param type defines the connection point type
  22368. * @param isOptional defines a boolean indicating that this input can be omitted
  22369. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22370. * @param point an already created connection point. If not provided, create a new one
  22371. * @returns the current block
  22372. */
  22373. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22374. /**
  22375. * Register a new output. Must be called inside a block constructor
  22376. * @param name defines the connection point name
  22377. * @param type defines the connection point type
  22378. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22379. * @param point an already created connection point. If not provided, create a new one
  22380. * @returns the current block
  22381. */
  22382. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22383. /**
  22384. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22385. * @param forOutput defines an optional connection point to check compatibility with
  22386. * @returns the first available input or null
  22387. */
  22388. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22389. /**
  22390. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22391. * @param forBlock defines an optional block to check compatibility with
  22392. * @returns the first available input or null
  22393. */
  22394. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22395. /**
  22396. * Gets the sibling of the given output
  22397. * @param current defines the current output
  22398. * @returns the next output in the list or null
  22399. */
  22400. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22401. /**
  22402. * Connect current block with another block
  22403. * @param other defines the block to connect with
  22404. * @param options define the various options to help pick the right connections
  22405. * @returns the current block
  22406. */
  22407. connectTo(other: NodeMaterialBlock, options?: {
  22408. input?: string;
  22409. output?: string;
  22410. outputSwizzle?: string;
  22411. }): this | undefined;
  22412. protected _buildBlock(state: NodeMaterialBuildState): void;
  22413. /**
  22414. * Add uniforms, samplers and uniform buffers at compilation time
  22415. * @param state defines the state to update
  22416. * @param nodeMaterial defines the node material requesting the update
  22417. * @param defines defines the material defines to update
  22418. * @param uniformBuffers defines the list of uniform buffer names
  22419. */
  22420. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22421. /**
  22422. * Add potential fallbacks if shader compilation fails
  22423. * @param mesh defines the mesh to be rendered
  22424. * @param fallbacks defines the current prioritized list of fallbacks
  22425. */
  22426. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22427. /**
  22428. * Initialize defines for shader compilation
  22429. * @param mesh defines the mesh to be rendered
  22430. * @param nodeMaterial defines the node material requesting the update
  22431. * @param defines defines the material defines to update
  22432. * @param useInstances specifies that instances should be used
  22433. */
  22434. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22435. /**
  22436. * Update defines for shader compilation
  22437. * @param mesh defines the mesh to be rendered
  22438. * @param nodeMaterial defines the node material requesting the update
  22439. * @param defines defines the material defines to update
  22440. * @param useInstances specifies that instances should be used
  22441. * @param subMesh defines which submesh to render
  22442. */
  22443. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22444. /**
  22445. * Lets the block try to connect some inputs automatically
  22446. * @param material defines the hosting NodeMaterial
  22447. */
  22448. autoConfigure(material: NodeMaterial): void;
  22449. /**
  22450. * Function called when a block is declared as repeatable content generator
  22451. * @param vertexShaderState defines the current compilation state for the vertex shader
  22452. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22453. * @param mesh defines the mesh to be rendered
  22454. * @param defines defines the material defines to update
  22455. */
  22456. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22457. /**
  22458. * Checks if the block is ready
  22459. * @param mesh defines the mesh to be rendered
  22460. * @param nodeMaterial defines the node material requesting the update
  22461. * @param defines defines the material defines to update
  22462. * @param useInstances specifies that instances should be used
  22463. * @returns true if the block is ready
  22464. */
  22465. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22466. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22467. private _processBuild;
  22468. /**
  22469. * Validates the new name for the block node.
  22470. * @param newName the new name to be given to the node.
  22471. * @returns false if the name is a reserve word, else true.
  22472. */
  22473. validateBlockName(newName: string): boolean;
  22474. /**
  22475. * Compile the current node and generate the shader code
  22476. * @param state defines the current compilation state (uniforms, samplers, current string)
  22477. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22478. * @returns true if already built
  22479. */
  22480. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22481. protected _inputRename(name: string): string;
  22482. protected _outputRename(name: string): string;
  22483. protected _dumpPropertiesCode(): string;
  22484. /** @hidden */
  22485. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22486. /** @hidden */
  22487. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22488. /**
  22489. * Clone the current block to a new identical block
  22490. * @param scene defines the hosting scene
  22491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22492. * @returns a copy of the current block
  22493. */
  22494. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22495. /**
  22496. * Serializes this block in a JSON representation
  22497. * @returns the serialized block object
  22498. */
  22499. serialize(): any;
  22500. /** @hidden */
  22501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22502. private _deserializePortDisplayNamesAndExposedOnFrame;
  22503. /**
  22504. * Release resources
  22505. */
  22506. dispose(): void;
  22507. }
  22508. }
  22509. declare module "babylonjs/Materials/pushMaterial" {
  22510. import { Nullable } from "babylonjs/types";
  22511. import { Scene } from "babylonjs/scene";
  22512. import { Matrix } from "babylonjs/Maths/math.vector";
  22513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22514. import { Mesh } from "babylonjs/Meshes/mesh";
  22515. import { Material } from "babylonjs/Materials/material";
  22516. import { Effect } from "babylonjs/Materials/effect";
  22517. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22518. /**
  22519. * Base class of materials working in push mode in babylon JS
  22520. * @hidden
  22521. */
  22522. export class PushMaterial extends Material {
  22523. protected _activeEffect: Effect;
  22524. protected _normalMatrix: Matrix;
  22525. constructor(name: string, scene: Scene);
  22526. getEffect(): Effect;
  22527. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22528. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22529. /**
  22530. * Binds the given world matrix to the active effect
  22531. *
  22532. * @param world the matrix to bind
  22533. */
  22534. bindOnlyWorldMatrix(world: Matrix): void;
  22535. /**
  22536. * Binds the given normal matrix to the active effect
  22537. *
  22538. * @param normalMatrix the matrix to bind
  22539. */
  22540. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22541. bind(world: Matrix, mesh?: Mesh): void;
  22542. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22543. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22544. }
  22545. }
  22546. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22548. /**
  22549. * Root class for all node material optimizers
  22550. */
  22551. export class NodeMaterialOptimizer {
  22552. /**
  22553. * Function used to optimize a NodeMaterial graph
  22554. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22555. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22556. */
  22557. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22558. }
  22559. }
  22560. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22564. import { Scene } from "babylonjs/scene";
  22565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22566. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22567. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22568. /**
  22569. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22570. */
  22571. export class TransformBlock extends NodeMaterialBlock {
  22572. /**
  22573. * Defines the value to use to complement W value to transform it to a Vector4
  22574. */
  22575. complementW: number;
  22576. /**
  22577. * Defines the value to use to complement z value to transform it to a Vector4
  22578. */
  22579. complementZ: number;
  22580. /**
  22581. * Creates a new TransformBlock
  22582. * @param name defines the block name
  22583. */
  22584. constructor(name: string);
  22585. /**
  22586. * Gets the current class name
  22587. * @returns the class name
  22588. */
  22589. getClassName(): string;
  22590. /**
  22591. * Gets the vector input
  22592. */
  22593. get vector(): NodeMaterialConnectionPoint;
  22594. /**
  22595. * Gets the output component
  22596. */
  22597. get output(): NodeMaterialConnectionPoint;
  22598. /**
  22599. * Gets the xyz output component
  22600. */
  22601. get xyz(): NodeMaterialConnectionPoint;
  22602. /**
  22603. * Gets the matrix transform input
  22604. */
  22605. get transform(): NodeMaterialConnectionPoint;
  22606. protected _buildBlock(state: NodeMaterialBuildState): this;
  22607. /**
  22608. * Update defines for shader compilation
  22609. * @param mesh defines the mesh to be rendered
  22610. * @param nodeMaterial defines the node material requesting the update
  22611. * @param defines defines the material defines to update
  22612. * @param useInstances specifies that instances should be used
  22613. * @param subMesh defines which submesh to render
  22614. */
  22615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22616. serialize(): any;
  22617. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22618. protected _dumpPropertiesCode(): string;
  22619. }
  22620. }
  22621. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22625. /**
  22626. * Block used to output the vertex position
  22627. */
  22628. export class VertexOutputBlock extends NodeMaterialBlock {
  22629. /**
  22630. * Creates a new VertexOutputBlock
  22631. * @param name defines the block name
  22632. */
  22633. constructor(name: string);
  22634. /**
  22635. * Gets the current class name
  22636. * @returns the class name
  22637. */
  22638. getClassName(): string;
  22639. /**
  22640. * Gets the vector input component
  22641. */
  22642. get vector(): NodeMaterialConnectionPoint;
  22643. protected _buildBlock(state: NodeMaterialBuildState): this;
  22644. }
  22645. }
  22646. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22650. /**
  22651. * Block used to output the final color
  22652. */
  22653. export class FragmentOutputBlock extends NodeMaterialBlock {
  22654. /**
  22655. * Create a new FragmentOutputBlock
  22656. * @param name defines the block name
  22657. */
  22658. constructor(name: string);
  22659. /**
  22660. * Gets the current class name
  22661. * @returns the class name
  22662. */
  22663. getClassName(): string;
  22664. /**
  22665. * Gets the rgba input component
  22666. */
  22667. get rgba(): NodeMaterialConnectionPoint;
  22668. /**
  22669. * Gets the rgb input component
  22670. */
  22671. get rgb(): NodeMaterialConnectionPoint;
  22672. /**
  22673. * Gets the a input component
  22674. */
  22675. get a(): NodeMaterialConnectionPoint;
  22676. protected _buildBlock(state: NodeMaterialBuildState): this;
  22677. }
  22678. }
  22679. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22683. /**
  22684. * Block used for the particle ramp gradient section
  22685. */
  22686. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22687. /**
  22688. * Create a new ParticleRampGradientBlock
  22689. * @param name defines the block name
  22690. */
  22691. constructor(name: string);
  22692. /**
  22693. * Gets the current class name
  22694. * @returns the class name
  22695. */
  22696. getClassName(): string;
  22697. /**
  22698. * Gets the color input component
  22699. */
  22700. get color(): NodeMaterialConnectionPoint;
  22701. /**
  22702. * Gets the rampColor output component
  22703. */
  22704. get rampColor(): NodeMaterialConnectionPoint;
  22705. /**
  22706. * Initialize the block and prepare the context for build
  22707. * @param state defines the state that will be used for the build
  22708. */
  22709. initialize(state: NodeMaterialBuildState): void;
  22710. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22711. }
  22712. }
  22713. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22717. /**
  22718. * Block used for the particle blend multiply section
  22719. */
  22720. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22721. /**
  22722. * Create a new ParticleBlendMultiplyBlock
  22723. * @param name defines the block name
  22724. */
  22725. constructor(name: string);
  22726. /**
  22727. * Gets the current class name
  22728. * @returns the class name
  22729. */
  22730. getClassName(): string;
  22731. /**
  22732. * Gets the color input component
  22733. */
  22734. get color(): NodeMaterialConnectionPoint;
  22735. /**
  22736. * Gets the alphaTexture input component
  22737. */
  22738. get alphaTexture(): NodeMaterialConnectionPoint;
  22739. /**
  22740. * Gets the alphaColor input component
  22741. */
  22742. get alphaColor(): NodeMaterialConnectionPoint;
  22743. /**
  22744. * Gets the blendColor output component
  22745. */
  22746. get blendColor(): NodeMaterialConnectionPoint;
  22747. /**
  22748. * Initialize the block and prepare the context for build
  22749. * @param state defines the state that will be used for the build
  22750. */
  22751. initialize(state: NodeMaterialBuildState): void;
  22752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22753. }
  22754. }
  22755. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22759. /**
  22760. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22761. */
  22762. export class VectorMergerBlock extends NodeMaterialBlock {
  22763. /**
  22764. * Create a new VectorMergerBlock
  22765. * @param name defines the block name
  22766. */
  22767. constructor(name: string);
  22768. /**
  22769. * Gets the current class name
  22770. * @returns the class name
  22771. */
  22772. getClassName(): string;
  22773. /**
  22774. * Gets the xyz component (input)
  22775. */
  22776. get xyzIn(): NodeMaterialConnectionPoint;
  22777. /**
  22778. * Gets the xy component (input)
  22779. */
  22780. get xyIn(): NodeMaterialConnectionPoint;
  22781. /**
  22782. * Gets the x component (input)
  22783. */
  22784. get x(): NodeMaterialConnectionPoint;
  22785. /**
  22786. * Gets the y component (input)
  22787. */
  22788. get y(): NodeMaterialConnectionPoint;
  22789. /**
  22790. * Gets the z component (input)
  22791. */
  22792. get z(): NodeMaterialConnectionPoint;
  22793. /**
  22794. * Gets the w component (input)
  22795. */
  22796. get w(): NodeMaterialConnectionPoint;
  22797. /**
  22798. * Gets the xyzw component (output)
  22799. */
  22800. get xyzw(): NodeMaterialConnectionPoint;
  22801. /**
  22802. * Gets the xyz component (output)
  22803. */
  22804. get xyzOut(): NodeMaterialConnectionPoint;
  22805. /**
  22806. * Gets the xy component (output)
  22807. */
  22808. get xyOut(): NodeMaterialConnectionPoint;
  22809. /**
  22810. * Gets the xy component (output)
  22811. * @deprecated Please use xyOut instead.
  22812. */
  22813. get xy(): NodeMaterialConnectionPoint;
  22814. /**
  22815. * Gets the xyz component (output)
  22816. * @deprecated Please use xyzOut instead.
  22817. */
  22818. get xyz(): NodeMaterialConnectionPoint;
  22819. protected _buildBlock(state: NodeMaterialBuildState): this;
  22820. }
  22821. }
  22822. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22826. import { Vector2 } from "babylonjs/Maths/math.vector";
  22827. import { Scene } from "babylonjs/scene";
  22828. /**
  22829. * Block used to remap a float from a range to a new one
  22830. */
  22831. export class RemapBlock extends NodeMaterialBlock {
  22832. /**
  22833. * Gets or sets the source range
  22834. */
  22835. sourceRange: Vector2;
  22836. /**
  22837. * Gets or sets the target range
  22838. */
  22839. targetRange: Vector2;
  22840. /**
  22841. * Creates a new RemapBlock
  22842. * @param name defines the block name
  22843. */
  22844. constructor(name: string);
  22845. /**
  22846. * Gets the current class name
  22847. * @returns the class name
  22848. */
  22849. getClassName(): string;
  22850. /**
  22851. * Gets the input component
  22852. */
  22853. get input(): NodeMaterialConnectionPoint;
  22854. /**
  22855. * Gets the source min input component
  22856. */
  22857. get sourceMin(): NodeMaterialConnectionPoint;
  22858. /**
  22859. * Gets the source max input component
  22860. */
  22861. get sourceMax(): NodeMaterialConnectionPoint;
  22862. /**
  22863. * Gets the target min input component
  22864. */
  22865. get targetMin(): NodeMaterialConnectionPoint;
  22866. /**
  22867. * Gets the target max input component
  22868. */
  22869. get targetMax(): NodeMaterialConnectionPoint;
  22870. /**
  22871. * Gets the output component
  22872. */
  22873. get output(): NodeMaterialConnectionPoint;
  22874. protected _buildBlock(state: NodeMaterialBuildState): this;
  22875. protected _dumpPropertiesCode(): string;
  22876. serialize(): any;
  22877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22878. }
  22879. }
  22880. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22884. /**
  22885. * Block used to multiply 2 values
  22886. */
  22887. export class MultiplyBlock extends NodeMaterialBlock {
  22888. /**
  22889. * Creates a new MultiplyBlock
  22890. * @param name defines the block name
  22891. */
  22892. constructor(name: string);
  22893. /**
  22894. * Gets the current class name
  22895. * @returns the class name
  22896. */
  22897. getClassName(): string;
  22898. /**
  22899. * Gets the left operand input component
  22900. */
  22901. get left(): NodeMaterialConnectionPoint;
  22902. /**
  22903. * Gets the right operand input component
  22904. */
  22905. get right(): NodeMaterialConnectionPoint;
  22906. /**
  22907. * Gets the output component
  22908. */
  22909. get output(): NodeMaterialConnectionPoint;
  22910. protected _buildBlock(state: NodeMaterialBuildState): this;
  22911. }
  22912. }
  22913. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22917. /**
  22918. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22919. */
  22920. export class ColorSplitterBlock extends NodeMaterialBlock {
  22921. /**
  22922. * Create a new ColorSplitterBlock
  22923. * @param name defines the block name
  22924. */
  22925. constructor(name: string);
  22926. /**
  22927. * Gets the current class name
  22928. * @returns the class name
  22929. */
  22930. getClassName(): string;
  22931. /**
  22932. * Gets the rgba component (input)
  22933. */
  22934. get rgba(): NodeMaterialConnectionPoint;
  22935. /**
  22936. * Gets the rgb component (input)
  22937. */
  22938. get rgbIn(): NodeMaterialConnectionPoint;
  22939. /**
  22940. * Gets the rgb component (output)
  22941. */
  22942. get rgbOut(): NodeMaterialConnectionPoint;
  22943. /**
  22944. * Gets the r component (output)
  22945. */
  22946. get r(): NodeMaterialConnectionPoint;
  22947. /**
  22948. * Gets the g component (output)
  22949. */
  22950. get g(): NodeMaterialConnectionPoint;
  22951. /**
  22952. * Gets the b component (output)
  22953. */
  22954. get b(): NodeMaterialConnectionPoint;
  22955. /**
  22956. * Gets the a component (output)
  22957. */
  22958. get a(): NodeMaterialConnectionPoint;
  22959. protected _inputRename(name: string): string;
  22960. protected _outputRename(name: string): string;
  22961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22962. }
  22963. }
  22964. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22966. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22967. import { Scene } from "babylonjs/scene";
  22968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22969. import { Matrix } from "babylonjs/Maths/math.vector";
  22970. import { Mesh } from "babylonjs/Meshes/mesh";
  22971. import { Engine } from "babylonjs/Engines/engine";
  22972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22973. import { Observable } from "babylonjs/Misc/observable";
  22974. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22975. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22976. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22977. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22978. import { Nullable } from "babylonjs/types";
  22979. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22980. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22981. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22982. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22983. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22984. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22985. import { Effect } from "babylonjs/Materials/effect";
  22986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22987. import { Camera } from "babylonjs/Cameras/camera";
  22988. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22989. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22990. /**
  22991. * Interface used to configure the node material editor
  22992. */
  22993. export interface INodeMaterialEditorOptions {
  22994. /** Define the URl to load node editor script */
  22995. editorURL?: string;
  22996. }
  22997. /** @hidden */
  22998. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22999. NORMAL: boolean;
  23000. TANGENT: boolean;
  23001. UV1: boolean;
  23002. /** BONES */
  23003. NUM_BONE_INFLUENCERS: number;
  23004. BonesPerMesh: number;
  23005. BONETEXTURE: boolean;
  23006. /** MORPH TARGETS */
  23007. MORPHTARGETS: boolean;
  23008. MORPHTARGETS_NORMAL: boolean;
  23009. MORPHTARGETS_TANGENT: boolean;
  23010. MORPHTARGETS_UV: boolean;
  23011. NUM_MORPH_INFLUENCERS: number;
  23012. /** IMAGE PROCESSING */
  23013. IMAGEPROCESSING: boolean;
  23014. VIGNETTE: boolean;
  23015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23016. VIGNETTEBLENDMODEOPAQUE: boolean;
  23017. TONEMAPPING: boolean;
  23018. TONEMAPPING_ACES: boolean;
  23019. CONTRAST: boolean;
  23020. EXPOSURE: boolean;
  23021. COLORCURVES: boolean;
  23022. COLORGRADING: boolean;
  23023. COLORGRADING3D: boolean;
  23024. SAMPLER3DGREENDEPTH: boolean;
  23025. SAMPLER3DBGRMAP: boolean;
  23026. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23027. /** MISC. */
  23028. BUMPDIRECTUV: number;
  23029. constructor();
  23030. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23031. }
  23032. /**
  23033. * Class used to configure NodeMaterial
  23034. */
  23035. export interface INodeMaterialOptions {
  23036. /**
  23037. * Defines if blocks should emit comments
  23038. */
  23039. emitComments: boolean;
  23040. }
  23041. /**
  23042. * Class used to create a node based material built by assembling shader blocks
  23043. */
  23044. export class NodeMaterial extends PushMaterial {
  23045. private static _BuildIdGenerator;
  23046. private _options;
  23047. private _vertexCompilationState;
  23048. private _fragmentCompilationState;
  23049. private _sharedData;
  23050. private _buildId;
  23051. private _buildWasSuccessful;
  23052. private _cachedWorldViewMatrix;
  23053. private _cachedWorldViewProjectionMatrix;
  23054. private _optimizers;
  23055. private _animationFrame;
  23056. /** Define the Url to load node editor script */
  23057. static EditorURL: string;
  23058. /** Define the Url to load snippets */
  23059. static SnippetUrl: string;
  23060. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23061. static IgnoreTexturesAtLoadTime: boolean;
  23062. private BJSNODEMATERIALEDITOR;
  23063. /** Get the inspector from bundle or global */
  23064. private _getGlobalNodeMaterialEditor;
  23065. /**
  23066. * Snippet ID if the material was created from the snippet server
  23067. */
  23068. snippetId: string;
  23069. /**
  23070. * Gets or sets data used by visual editor
  23071. * @see https://nme.babylonjs.com
  23072. */
  23073. editorData: any;
  23074. /**
  23075. * 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)
  23076. */
  23077. ignoreAlpha: boolean;
  23078. /**
  23079. * Defines the maximum number of lights that can be used in the material
  23080. */
  23081. maxSimultaneousLights: number;
  23082. /**
  23083. * Observable raised when the material is built
  23084. */
  23085. onBuildObservable: Observable<NodeMaterial>;
  23086. /**
  23087. * Gets or sets the root nodes of the material vertex shader
  23088. */
  23089. _vertexOutputNodes: NodeMaterialBlock[];
  23090. /**
  23091. * Gets or sets the root nodes of the material fragment (pixel) shader
  23092. */
  23093. _fragmentOutputNodes: NodeMaterialBlock[];
  23094. /** Gets or sets options to control the node material overall behavior */
  23095. get options(): INodeMaterialOptions;
  23096. set options(options: INodeMaterialOptions);
  23097. /**
  23098. * Default configuration related to image processing available in the standard Material.
  23099. */
  23100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23101. /**
  23102. * Gets the image processing configuration used either in this material.
  23103. */
  23104. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23105. /**
  23106. * Sets the Default image processing configuration used either in the this material.
  23107. *
  23108. * If sets to null, the scene one is in use.
  23109. */
  23110. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23111. /**
  23112. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23113. */
  23114. attachedBlocks: NodeMaterialBlock[];
  23115. /**
  23116. * Specifies the mode of the node material
  23117. * @hidden
  23118. */
  23119. _mode: NodeMaterialModes;
  23120. /**
  23121. * Gets the mode property
  23122. */
  23123. get mode(): NodeMaterialModes;
  23124. /**
  23125. * Create a new node based material
  23126. * @param name defines the material name
  23127. * @param scene defines the hosting scene
  23128. * @param options defines creation option
  23129. */
  23130. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23131. /**
  23132. * Gets the current class name of the material e.g. "NodeMaterial"
  23133. * @returns the class name
  23134. */
  23135. getClassName(): string;
  23136. /**
  23137. * Keep track of the image processing observer to allow dispose and replace.
  23138. */
  23139. private _imageProcessingObserver;
  23140. /**
  23141. * Attaches a new image processing configuration to the Standard Material.
  23142. * @param configuration
  23143. */
  23144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23145. /**
  23146. * Get a block by its name
  23147. * @param name defines the name of the block to retrieve
  23148. * @returns the required block or null if not found
  23149. */
  23150. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23151. /**
  23152. * Get a block by its name
  23153. * @param predicate defines the predicate used to find the good candidate
  23154. * @returns the required block or null if not found
  23155. */
  23156. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23157. /**
  23158. * Get an input block by its name
  23159. * @param predicate defines the predicate used to find the good candidate
  23160. * @returns the required input block or null if not found
  23161. */
  23162. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23163. /**
  23164. * Gets the list of input blocks attached to this material
  23165. * @returns an array of InputBlocks
  23166. */
  23167. getInputBlocks(): InputBlock[];
  23168. /**
  23169. * Adds a new optimizer to the list of optimizers
  23170. * @param optimizer defines the optimizers to add
  23171. * @returns the current material
  23172. */
  23173. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23174. /**
  23175. * Remove an optimizer from the list of optimizers
  23176. * @param optimizer defines the optimizers to remove
  23177. * @returns the current material
  23178. */
  23179. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23180. /**
  23181. * Add a new block to the list of output nodes
  23182. * @param node defines the node to add
  23183. * @returns the current material
  23184. */
  23185. addOutputNode(node: NodeMaterialBlock): this;
  23186. /**
  23187. * Remove a block from the list of root nodes
  23188. * @param node defines the node to remove
  23189. * @returns the current material
  23190. */
  23191. removeOutputNode(node: NodeMaterialBlock): this;
  23192. private _addVertexOutputNode;
  23193. private _removeVertexOutputNode;
  23194. private _addFragmentOutputNode;
  23195. private _removeFragmentOutputNode;
  23196. /**
  23197. * Specifies if the material will require alpha blending
  23198. * @returns a boolean specifying if alpha blending is needed
  23199. */
  23200. needAlphaBlending(): boolean;
  23201. /**
  23202. * Specifies if this material should be rendered in alpha test mode
  23203. * @returns a boolean specifying if an alpha test is needed.
  23204. */
  23205. needAlphaTesting(): boolean;
  23206. private _initializeBlock;
  23207. private _resetDualBlocks;
  23208. /**
  23209. * Remove a block from the current node material
  23210. * @param block defines the block to remove
  23211. */
  23212. removeBlock(block: NodeMaterialBlock): void;
  23213. /**
  23214. * Build the material and generates the inner effect
  23215. * @param verbose defines if the build should log activity
  23216. */
  23217. build(verbose?: boolean): void;
  23218. /**
  23219. * Runs an otpimization phase to try to improve the shader code
  23220. */
  23221. optimize(): void;
  23222. private _prepareDefinesForAttributes;
  23223. /**
  23224. * Create a post process from the material
  23225. * @param camera The camera to apply the render pass to.
  23226. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23228. * @param engine The engine which the post process will be applied. (default: current engine)
  23229. * @param reusable If the post process can be reused on the same frame. (default: false)
  23230. * @param textureType Type of textures used when performing the post process. (default: 0)
  23231. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23232. * @returns the post process created
  23233. */
  23234. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23235. /**
  23236. * Create the post process effect from the material
  23237. * @param postProcess The post process to create the effect for
  23238. */
  23239. createEffectForPostProcess(postProcess: PostProcess): void;
  23240. private _createEffectOrPostProcess;
  23241. private _createEffectForParticles;
  23242. /**
  23243. * Create the effect to be used as the custom effect for a particle system
  23244. * @param particleSystem Particle system to create the effect for
  23245. * @param onCompiled defines a function to call when the effect creation is successful
  23246. * @param onError defines a function to call when the effect creation has failed
  23247. */
  23248. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23249. private _processDefines;
  23250. /**
  23251. * Get if the submesh is ready to be used and all its information available.
  23252. * Child classes can use it to update shaders
  23253. * @param mesh defines the mesh to check
  23254. * @param subMesh defines which submesh to check
  23255. * @param useInstances specifies that instances should be used
  23256. * @returns a boolean indicating that the submesh is ready or not
  23257. */
  23258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23259. /**
  23260. * Get a string representing the shaders built by the current node graph
  23261. */
  23262. get compiledShaders(): string;
  23263. /**
  23264. * Binds the world matrix to the material
  23265. * @param world defines the world transformation matrix
  23266. */
  23267. bindOnlyWorldMatrix(world: Matrix): void;
  23268. /**
  23269. * Binds the submesh to this material by preparing the effect and shader to draw
  23270. * @param world defines the world transformation matrix
  23271. * @param mesh defines the mesh containing the submesh
  23272. * @param subMesh defines the submesh to bind the material to
  23273. */
  23274. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23275. /**
  23276. * Gets the active textures from the material
  23277. * @returns an array of textures
  23278. */
  23279. getActiveTextures(): BaseTexture[];
  23280. /**
  23281. * Gets the list of texture blocks
  23282. * @returns an array of texture blocks
  23283. */
  23284. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23285. /**
  23286. * Specifies if the material uses a texture
  23287. * @param texture defines the texture to check against the material
  23288. * @returns a boolean specifying if the material uses the texture
  23289. */
  23290. hasTexture(texture: BaseTexture): boolean;
  23291. /**
  23292. * Disposes the material
  23293. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23294. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23295. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23296. */
  23297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23298. /** Creates the node editor window. */
  23299. private _createNodeEditor;
  23300. /**
  23301. * Launch the node material editor
  23302. * @param config Define the configuration of the editor
  23303. * @return a promise fulfilled when the node editor is visible
  23304. */
  23305. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23306. /**
  23307. * Clear the current material
  23308. */
  23309. clear(): void;
  23310. /**
  23311. * Clear the current material and set it to a default state
  23312. */
  23313. setToDefault(): void;
  23314. /**
  23315. * Clear the current material and set it to a default state for post process
  23316. */
  23317. setToDefaultPostProcess(): void;
  23318. /**
  23319. * Clear the current material and set it to a default state for particle
  23320. */
  23321. setToDefaultParticle(): void;
  23322. /**
  23323. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23324. * @param url defines the url to load from
  23325. * @returns a promise that will fullfil when the material is fully loaded
  23326. */
  23327. loadAsync(url: string): Promise<void>;
  23328. private _gatherBlocks;
  23329. /**
  23330. * Generate a string containing the code declaration required to create an equivalent of this material
  23331. * @returns a string
  23332. */
  23333. generateCode(): string;
  23334. /**
  23335. * Serializes this material in a JSON representation
  23336. * @returns the serialized material object
  23337. */
  23338. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23339. private _restoreConnections;
  23340. /**
  23341. * Clear the current graph and load a new one from a serialization object
  23342. * @param source defines the JSON representation of the material
  23343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23344. * @param merge defines whether or not the source must be merged or replace the current content
  23345. */
  23346. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23347. /**
  23348. * Makes a duplicate of the current material.
  23349. * @param name - name to use for the new material.
  23350. */
  23351. clone(name: string): NodeMaterial;
  23352. /**
  23353. * Creates a node material from parsed material data
  23354. * @param source defines the JSON representation of the material
  23355. * @param scene defines the hosting scene
  23356. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23357. * @returns a new node material
  23358. */
  23359. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23360. /**
  23361. * Creates a node material from a snippet saved in a remote file
  23362. * @param name defines the name of the material to create
  23363. * @param url defines the url to load from
  23364. * @param scene defines the hosting scene
  23365. * @returns a promise that will resolve to the new node material
  23366. */
  23367. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23368. /**
  23369. * Creates a node material from a snippet saved by the node material editor
  23370. * @param snippetId defines the snippet to load
  23371. * @param scene defines the hosting scene
  23372. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23373. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23374. * @returns a promise that will resolve to the new node material
  23375. */
  23376. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23377. /**
  23378. * Creates a new node material set to default basic configuration
  23379. * @param name defines the name of the material
  23380. * @param scene defines the hosting scene
  23381. * @returns a new NodeMaterial
  23382. */
  23383. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23384. }
  23385. }
  23386. declare module "babylonjs/PostProcesses/postProcess" {
  23387. import { Nullable } from "babylonjs/types";
  23388. import { SmartArray } from "babylonjs/Misc/smartArray";
  23389. import { Observable } from "babylonjs/Misc/observable";
  23390. import { Vector2 } from "babylonjs/Maths/math.vector";
  23391. import { Camera } from "babylonjs/Cameras/camera";
  23392. import { Effect } from "babylonjs/Materials/effect";
  23393. import "babylonjs/Shaders/postprocess.vertex";
  23394. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23395. import { Engine } from "babylonjs/Engines/engine";
  23396. import { Color4 } from "babylonjs/Maths/math.color";
  23397. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23398. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23399. import { Scene } from "babylonjs/scene";
  23400. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23401. /**
  23402. * Size options for a post process
  23403. */
  23404. export type PostProcessOptions = {
  23405. width: number;
  23406. height: number;
  23407. };
  23408. /**
  23409. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23410. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23411. */
  23412. export class PostProcess {
  23413. /**
  23414. * Gets or sets the unique id of the post process
  23415. */
  23416. uniqueId: number;
  23417. /** Name of the PostProcess. */
  23418. name: string;
  23419. /**
  23420. * Width of the texture to apply the post process on
  23421. */
  23422. width: number;
  23423. /**
  23424. * Height of the texture to apply the post process on
  23425. */
  23426. height: number;
  23427. /**
  23428. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23429. */
  23430. nodeMaterialSource: Nullable<NodeMaterial>;
  23431. /**
  23432. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23433. * @hidden
  23434. */
  23435. _outputTexture: Nullable<InternalTexture>;
  23436. /**
  23437. * Sampling mode used by the shader
  23438. * See https://doc.babylonjs.com/classes/3.1/texture
  23439. */
  23440. renderTargetSamplingMode: number;
  23441. /**
  23442. * Clear color to use when screen clearing
  23443. */
  23444. clearColor: Color4;
  23445. /**
  23446. * If the buffer needs to be cleared before applying the post process. (default: true)
  23447. * Should be set to false if shader will overwrite all previous pixels.
  23448. */
  23449. autoClear: boolean;
  23450. /**
  23451. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23452. */
  23453. alphaMode: number;
  23454. /**
  23455. * Sets the setAlphaBlendConstants of the babylon engine
  23456. */
  23457. alphaConstants: Color4;
  23458. /**
  23459. * Animations to be used for the post processing
  23460. */
  23461. animations: import("babylonjs/Animations/animation").Animation[];
  23462. /**
  23463. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23464. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23465. */
  23466. enablePixelPerfectMode: boolean;
  23467. /**
  23468. * Force the postprocess to be applied without taking in account viewport
  23469. */
  23470. forceFullscreenViewport: boolean;
  23471. /**
  23472. * List of inspectable custom properties (used by the Inspector)
  23473. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23474. */
  23475. inspectableCustomProperties: IInspectable[];
  23476. /**
  23477. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23478. *
  23479. * | Value | Type | Description |
  23480. * | ----- | ----------------------------------- | ----------- |
  23481. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23482. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23483. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23484. *
  23485. */
  23486. scaleMode: number;
  23487. /**
  23488. * Force textures to be a power of two (default: false)
  23489. */
  23490. alwaysForcePOT: boolean;
  23491. private _samples;
  23492. /**
  23493. * Number of sample textures (default: 1)
  23494. */
  23495. get samples(): number;
  23496. set samples(n: number);
  23497. /**
  23498. * Modify the scale of the post process to be the same as the viewport (default: false)
  23499. */
  23500. adaptScaleToCurrentViewport: boolean;
  23501. private _camera;
  23502. protected _scene: Scene;
  23503. private _engine;
  23504. private _options;
  23505. private _reusable;
  23506. private _textureType;
  23507. private _textureFormat;
  23508. /**
  23509. * Smart array of input and output textures for the post process.
  23510. * @hidden
  23511. */
  23512. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23513. /**
  23514. * The index in _textures that corresponds to the output texture.
  23515. * @hidden
  23516. */
  23517. _currentRenderTextureInd: number;
  23518. private _effect;
  23519. private _samplers;
  23520. private _fragmentUrl;
  23521. private _vertexUrl;
  23522. private _parameters;
  23523. private _scaleRatio;
  23524. protected _indexParameters: any;
  23525. private _shareOutputWithPostProcess;
  23526. private _texelSize;
  23527. private _forcedOutputTexture;
  23528. /**
  23529. * Returns the fragment url or shader name used in the post process.
  23530. * @returns the fragment url or name in the shader store.
  23531. */
  23532. getEffectName(): string;
  23533. /**
  23534. * An event triggered when the postprocess is activated.
  23535. */
  23536. onActivateObservable: Observable<Camera>;
  23537. private _onActivateObserver;
  23538. /**
  23539. * A function that is added to the onActivateObservable
  23540. */
  23541. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23542. /**
  23543. * An event triggered when the postprocess changes its size.
  23544. */
  23545. onSizeChangedObservable: Observable<PostProcess>;
  23546. private _onSizeChangedObserver;
  23547. /**
  23548. * A function that is added to the onSizeChangedObservable
  23549. */
  23550. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23551. /**
  23552. * An event triggered when the postprocess applies its effect.
  23553. */
  23554. onApplyObservable: Observable<Effect>;
  23555. private _onApplyObserver;
  23556. /**
  23557. * A function that is added to the onApplyObservable
  23558. */
  23559. set onApply(callback: (effect: Effect) => void);
  23560. /**
  23561. * An event triggered before rendering the postprocess
  23562. */
  23563. onBeforeRenderObservable: Observable<Effect>;
  23564. private _onBeforeRenderObserver;
  23565. /**
  23566. * A function that is added to the onBeforeRenderObservable
  23567. */
  23568. set onBeforeRender(callback: (effect: Effect) => void);
  23569. /**
  23570. * An event triggered after rendering the postprocess
  23571. */
  23572. onAfterRenderObservable: Observable<Effect>;
  23573. private _onAfterRenderObserver;
  23574. /**
  23575. * A function that is added to the onAfterRenderObservable
  23576. */
  23577. set onAfterRender(callback: (efect: Effect) => void);
  23578. /**
  23579. * 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
  23580. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23581. */
  23582. get inputTexture(): InternalTexture;
  23583. set inputTexture(value: InternalTexture);
  23584. /**
  23585. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23586. * the only way to unset it is to use this function to restore its internal state
  23587. */
  23588. restoreDefaultInputTexture(): void;
  23589. /**
  23590. * Gets the camera which post process is applied to.
  23591. * @returns The camera the post process is applied to.
  23592. */
  23593. getCamera(): Camera;
  23594. /**
  23595. * Gets the texel size of the postprocess.
  23596. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23597. */
  23598. get texelSize(): Vector2;
  23599. /**
  23600. * Creates a new instance PostProcess
  23601. * @param name The name of the PostProcess.
  23602. * @param fragmentUrl The url of the fragment shader to be used.
  23603. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23604. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23605. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23606. * @param camera The camera to apply the render pass to.
  23607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23608. * @param engine The engine which the post process will be applied. (default: current engine)
  23609. * @param reusable If the post process can be reused on the same frame. (default: false)
  23610. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23611. * @param textureType Type of textures used when performing the post process. (default: 0)
  23612. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23613. * @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
  23614. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23615. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23616. */
  23617. 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);
  23618. /**
  23619. * Gets a string identifying the name of the class
  23620. * @returns "PostProcess" string
  23621. */
  23622. getClassName(): string;
  23623. /**
  23624. * Gets the engine which this post process belongs to.
  23625. * @returns The engine the post process was enabled with.
  23626. */
  23627. getEngine(): Engine;
  23628. /**
  23629. * The effect that is created when initializing the post process.
  23630. * @returns The created effect corresponding the the postprocess.
  23631. */
  23632. getEffect(): Effect;
  23633. /**
  23634. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23635. * @param postProcess The post process to share the output with.
  23636. * @returns This post process.
  23637. */
  23638. shareOutputWith(postProcess: PostProcess): PostProcess;
  23639. /**
  23640. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23641. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23642. */
  23643. useOwnOutput(): void;
  23644. /**
  23645. * Updates the effect with the current post process compile time values and recompiles the shader.
  23646. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23647. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23648. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23649. * @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
  23650. * @param onCompiled Called when the shader has been compiled.
  23651. * @param onError Called if there is an error when compiling a shader.
  23652. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23653. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23654. */
  23655. 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;
  23656. /**
  23657. * The post process is reusable if it can be used multiple times within one frame.
  23658. * @returns If the post process is reusable
  23659. */
  23660. isReusable(): boolean;
  23661. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23662. markTextureDirty(): void;
  23663. /**
  23664. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23665. * 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.
  23666. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23667. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23668. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23669. * @returns The target texture that was bound to be written to.
  23670. */
  23671. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23672. /**
  23673. * If the post process is supported.
  23674. */
  23675. get isSupported(): boolean;
  23676. /**
  23677. * The aspect ratio of the output texture.
  23678. */
  23679. get aspectRatio(): number;
  23680. /**
  23681. * Get a value indicating if the post-process is ready to be used
  23682. * @returns true if the post-process is ready (shader is compiled)
  23683. */
  23684. isReady(): boolean;
  23685. /**
  23686. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23687. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23688. */
  23689. apply(): Nullable<Effect>;
  23690. private _disposeTextures;
  23691. /**
  23692. * Disposes the post process.
  23693. * @param camera The camera to dispose the post process on.
  23694. */
  23695. dispose(camera?: Camera): void;
  23696. /**
  23697. * Serializes the particle system to a JSON object
  23698. * @returns the JSON object
  23699. */
  23700. serialize(): any;
  23701. /**
  23702. * Creates a material from parsed material data
  23703. * @param parsedPostProcess defines parsed post process data
  23704. * @param scene defines the hosting scene
  23705. * @param rootUrl defines the root URL to use to load textures
  23706. * @returns a new post process
  23707. */
  23708. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23709. }
  23710. }
  23711. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23712. /** @hidden */
  23713. export var kernelBlurVaryingDeclaration: {
  23714. name: string;
  23715. shader: string;
  23716. };
  23717. }
  23718. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23719. /** @hidden */
  23720. export var kernelBlurFragment: {
  23721. name: string;
  23722. shader: string;
  23723. };
  23724. }
  23725. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23726. /** @hidden */
  23727. export var kernelBlurFragment2: {
  23728. name: string;
  23729. shader: string;
  23730. };
  23731. }
  23732. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23733. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23734. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23735. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23736. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23737. /** @hidden */
  23738. export var kernelBlurPixelShader: {
  23739. name: string;
  23740. shader: string;
  23741. };
  23742. }
  23743. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23744. /** @hidden */
  23745. export var kernelBlurVertex: {
  23746. name: string;
  23747. shader: string;
  23748. };
  23749. }
  23750. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23751. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23752. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23753. /** @hidden */
  23754. export var kernelBlurVertexShader: {
  23755. name: string;
  23756. shader: string;
  23757. };
  23758. }
  23759. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23760. import { Vector2 } from "babylonjs/Maths/math.vector";
  23761. import { Nullable } from "babylonjs/types";
  23762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23763. import { Camera } from "babylonjs/Cameras/camera";
  23764. import { Effect } from "babylonjs/Materials/effect";
  23765. import { Engine } from "babylonjs/Engines/engine";
  23766. import "babylonjs/Shaders/kernelBlur.fragment";
  23767. import "babylonjs/Shaders/kernelBlur.vertex";
  23768. import { Scene } from "babylonjs/scene";
  23769. /**
  23770. * The Blur Post Process which blurs an image based on a kernel and direction.
  23771. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23772. */
  23773. export class BlurPostProcess extends PostProcess {
  23774. private blockCompilation;
  23775. protected _kernel: number;
  23776. protected _idealKernel: number;
  23777. protected _packedFloat: boolean;
  23778. private _staticDefines;
  23779. /** The direction in which to blur the image. */
  23780. direction: Vector2;
  23781. /**
  23782. * Sets the length in pixels of the blur sample region
  23783. */
  23784. set kernel(v: number);
  23785. /**
  23786. * Gets the length in pixels of the blur sample region
  23787. */
  23788. get kernel(): number;
  23789. /**
  23790. * Sets wether or not the blur needs to unpack/repack floats
  23791. */
  23792. set packedFloat(v: boolean);
  23793. /**
  23794. * Gets wether or not the blur is unpacking/repacking floats
  23795. */
  23796. get packedFloat(): boolean;
  23797. /**
  23798. * Gets a string identifying the name of the class
  23799. * @returns "BlurPostProcess" string
  23800. */
  23801. getClassName(): string;
  23802. /**
  23803. * Creates a new instance BlurPostProcess
  23804. * @param name The name of the effect.
  23805. * @param direction The direction in which to blur the image.
  23806. * @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.
  23807. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23808. * @param camera The camera to apply the render pass to.
  23809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23810. * @param engine The engine which the post process will be applied. (default: current engine)
  23811. * @param reusable If the post process can be reused on the same frame. (default: false)
  23812. * @param textureType Type of textures used when performing the post process. (default: 0)
  23813. * @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)
  23814. */
  23815. 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);
  23816. /**
  23817. * Updates the effect with the current post process compile time values and recompiles the shader.
  23818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23821. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23822. * @param onCompiled Called when the shader has been compiled.
  23823. * @param onError Called if there is an error when compiling a shader.
  23824. */
  23825. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23826. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23827. /**
  23828. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23829. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23830. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23831. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23832. * The gaps between physical kernels are compensated for in the weighting of the samples
  23833. * @param idealKernel Ideal blur kernel.
  23834. * @return Nearest best kernel.
  23835. */
  23836. protected _nearestBestKernel(idealKernel: number): number;
  23837. /**
  23838. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23839. * @param x The point on the Gaussian distribution to sample.
  23840. * @return the value of the Gaussian function at x.
  23841. */
  23842. protected _gaussianWeight(x: number): number;
  23843. /**
  23844. * Generates a string that can be used as a floating point number in GLSL.
  23845. * @param x Value to print.
  23846. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23847. * @return GLSL float string.
  23848. */
  23849. protected _glslFloat(x: number, decimalFigures?: number): string;
  23850. /** @hidden */
  23851. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23852. }
  23853. }
  23854. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23855. import { Scene } from "babylonjs/scene";
  23856. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23857. import { Plane } from "babylonjs/Maths/math.plane";
  23858. /**
  23859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23861. * You can then easily use it as a reflectionTexture on a flat surface.
  23862. * In case the surface is not a plane, please consider relying on reflection probes.
  23863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23864. */
  23865. export class MirrorTexture extends RenderTargetTexture {
  23866. private scene;
  23867. /**
  23868. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23869. * 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.
  23870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23871. */
  23872. mirrorPlane: Plane;
  23873. /**
  23874. * Define the blur ratio used to blur the reflection if needed.
  23875. */
  23876. set blurRatio(value: number);
  23877. get blurRatio(): number;
  23878. /**
  23879. * Define the adaptive blur kernel used to blur the reflection if needed.
  23880. * This will autocompute the closest best match for the `blurKernel`
  23881. */
  23882. set adaptiveBlurKernel(value: number);
  23883. /**
  23884. * Define the blur kernel used to blur the reflection if needed.
  23885. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23886. */
  23887. set blurKernel(value: number);
  23888. /**
  23889. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23890. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23891. */
  23892. set blurKernelX(value: number);
  23893. get blurKernelX(): number;
  23894. /**
  23895. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23896. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23897. */
  23898. set blurKernelY(value: number);
  23899. get blurKernelY(): number;
  23900. private _autoComputeBlurKernel;
  23901. protected _onRatioRescale(): void;
  23902. private _updateGammaSpace;
  23903. private _imageProcessingConfigChangeObserver;
  23904. private _transformMatrix;
  23905. private _mirrorMatrix;
  23906. private _savedViewMatrix;
  23907. private _blurX;
  23908. private _blurY;
  23909. private _adaptiveBlurKernel;
  23910. private _blurKernelX;
  23911. private _blurKernelY;
  23912. private _blurRatio;
  23913. /**
  23914. * Instantiates a Mirror Texture.
  23915. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23916. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23917. * You can then easily use it as a reflectionTexture on a flat surface.
  23918. * In case the surface is not a plane, please consider relying on reflection probes.
  23919. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23920. * @param name
  23921. * @param size
  23922. * @param scene
  23923. * @param generateMipMaps
  23924. * @param type
  23925. * @param samplingMode
  23926. * @param generateDepthBuffer
  23927. */
  23928. constructor(name: string, size: number | {
  23929. width: number;
  23930. height: number;
  23931. } | {
  23932. ratio: number;
  23933. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23934. private _preparePostProcesses;
  23935. /**
  23936. * Clone the mirror texture.
  23937. * @returns the cloned texture
  23938. */
  23939. clone(): MirrorTexture;
  23940. /**
  23941. * Serialize the texture to a JSON representation you could use in Parse later on
  23942. * @returns the serialized JSON representation
  23943. */
  23944. serialize(): any;
  23945. /**
  23946. * Dispose the texture and release its associated resources.
  23947. */
  23948. dispose(): void;
  23949. }
  23950. }
  23951. declare module "babylonjs/Materials/Textures/texture" {
  23952. import { Observable } from "babylonjs/Misc/observable";
  23953. import { Nullable } from "babylonjs/types";
  23954. import { Matrix } from "babylonjs/Maths/math.vector";
  23955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23956. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23957. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23958. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23959. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23961. import { Scene } from "babylonjs/scene";
  23962. /**
  23963. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23964. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23965. */
  23966. export class Texture extends BaseTexture {
  23967. /**
  23968. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23969. */
  23970. static SerializeBuffers: boolean;
  23971. /** @hidden */
  23972. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23973. /** @hidden */
  23974. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23975. /** @hidden */
  23976. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23977. /** nearest is mag = nearest and min = nearest and mip = linear */
  23978. static readonly NEAREST_SAMPLINGMODE: number;
  23979. /** nearest is mag = nearest and min = nearest and mip = linear */
  23980. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23981. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23982. static readonly BILINEAR_SAMPLINGMODE: number;
  23983. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23984. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23985. /** Trilinear is mag = linear and min = linear and mip = linear */
  23986. static readonly TRILINEAR_SAMPLINGMODE: number;
  23987. /** Trilinear is mag = linear and min = linear and mip = linear */
  23988. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23989. /** mag = nearest and min = nearest and mip = nearest */
  23990. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23991. /** mag = nearest and min = linear and mip = nearest */
  23992. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23993. /** mag = nearest and min = linear and mip = linear */
  23994. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23995. /** mag = nearest and min = linear and mip = none */
  23996. static readonly NEAREST_LINEAR: number;
  23997. /** mag = nearest and min = nearest and mip = none */
  23998. static readonly NEAREST_NEAREST: number;
  23999. /** mag = linear and min = nearest and mip = nearest */
  24000. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24001. /** mag = linear and min = nearest and mip = linear */
  24002. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24003. /** mag = linear and min = linear and mip = none */
  24004. static readonly LINEAR_LINEAR: number;
  24005. /** mag = linear and min = nearest and mip = none */
  24006. static readonly LINEAR_NEAREST: number;
  24007. /** Explicit coordinates mode */
  24008. static readonly EXPLICIT_MODE: number;
  24009. /** Spherical coordinates mode */
  24010. static readonly SPHERICAL_MODE: number;
  24011. /** Planar coordinates mode */
  24012. static readonly PLANAR_MODE: number;
  24013. /** Cubic coordinates mode */
  24014. static readonly CUBIC_MODE: number;
  24015. /** Projection coordinates mode */
  24016. static readonly PROJECTION_MODE: number;
  24017. /** Inverse Cubic coordinates mode */
  24018. static readonly SKYBOX_MODE: number;
  24019. /** Inverse Cubic coordinates mode */
  24020. static readonly INVCUBIC_MODE: number;
  24021. /** Equirectangular coordinates mode */
  24022. static readonly EQUIRECTANGULAR_MODE: number;
  24023. /** Equirectangular Fixed coordinates mode */
  24024. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24025. /** Equirectangular Fixed Mirrored coordinates mode */
  24026. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24027. /** Texture is not repeating outside of 0..1 UVs */
  24028. static readonly CLAMP_ADDRESSMODE: number;
  24029. /** Texture is repeating outside of 0..1 UVs */
  24030. static readonly WRAP_ADDRESSMODE: number;
  24031. /** Texture is repeating and mirrored */
  24032. static readonly MIRROR_ADDRESSMODE: number;
  24033. /**
  24034. * 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
  24035. */
  24036. static UseSerializedUrlIfAny: boolean;
  24037. /**
  24038. * Define the url of the texture.
  24039. */
  24040. url: Nullable<string>;
  24041. /**
  24042. * Define an offset on the texture to offset the u coordinates of the UVs
  24043. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24044. */
  24045. uOffset: number;
  24046. /**
  24047. * Define an offset on the texture to offset the v coordinates of the UVs
  24048. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24049. */
  24050. vOffset: number;
  24051. /**
  24052. * Define an offset on the texture to scale the u coordinates of the UVs
  24053. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24054. */
  24055. uScale: number;
  24056. /**
  24057. * Define an offset on the texture to scale the v coordinates of the UVs
  24058. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24059. */
  24060. vScale: number;
  24061. /**
  24062. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24063. * @see https://doc.babylonjs.com/how_to/more_materials
  24064. */
  24065. uAng: number;
  24066. /**
  24067. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24068. * @see https://doc.babylonjs.com/how_to/more_materials
  24069. */
  24070. vAng: number;
  24071. /**
  24072. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24073. * @see https://doc.babylonjs.com/how_to/more_materials
  24074. */
  24075. wAng: number;
  24076. /**
  24077. * Defines the center of rotation (U)
  24078. */
  24079. uRotationCenter: number;
  24080. /**
  24081. * Defines the center of rotation (V)
  24082. */
  24083. vRotationCenter: number;
  24084. /**
  24085. * Defines the center of rotation (W)
  24086. */
  24087. wRotationCenter: number;
  24088. /**
  24089. * Are mip maps generated for this texture or not.
  24090. */
  24091. get noMipmap(): boolean;
  24092. /**
  24093. * List of inspectable custom properties (used by the Inspector)
  24094. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24095. */
  24096. inspectableCustomProperties: Nullable<IInspectable[]>;
  24097. private _noMipmap;
  24098. /** @hidden */
  24099. _invertY: boolean;
  24100. private _rowGenerationMatrix;
  24101. private _cachedTextureMatrix;
  24102. private _projectionModeMatrix;
  24103. private _t0;
  24104. private _t1;
  24105. private _t2;
  24106. private _cachedUOffset;
  24107. private _cachedVOffset;
  24108. private _cachedUScale;
  24109. private _cachedVScale;
  24110. private _cachedUAng;
  24111. private _cachedVAng;
  24112. private _cachedWAng;
  24113. private _cachedProjectionMatrixId;
  24114. private _cachedCoordinatesMode;
  24115. /** @hidden */
  24116. protected _initialSamplingMode: number;
  24117. /** @hidden */
  24118. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24119. private _deleteBuffer;
  24120. protected _format: Nullable<number>;
  24121. private _delayedOnLoad;
  24122. private _delayedOnError;
  24123. private _mimeType?;
  24124. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24125. get mimeType(): string | undefined;
  24126. /**
  24127. * Observable triggered once the texture has been loaded.
  24128. */
  24129. onLoadObservable: Observable<Texture>;
  24130. protected _isBlocking: boolean;
  24131. /**
  24132. * Is the texture preventing material to render while loading.
  24133. * If false, a default texture will be used instead of the loading one during the preparation step.
  24134. */
  24135. set isBlocking(value: boolean);
  24136. get isBlocking(): boolean;
  24137. /**
  24138. * Get the current sampling mode associated with the texture.
  24139. */
  24140. get samplingMode(): number;
  24141. /**
  24142. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24143. */
  24144. get invertY(): boolean;
  24145. /**
  24146. * Instantiates a new texture.
  24147. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24148. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24149. * @param url defines the url of the picture to load as a texture
  24150. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24151. * @param noMipmap defines if the texture will require mip maps or not
  24152. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24153. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24154. * @param onLoad defines a callback triggered when the texture has been loaded
  24155. * @param onError defines a callback triggered when an error occurred during the loading session
  24156. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24157. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24158. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24159. * @param mimeType defines an optional mime type information
  24160. */
  24161. 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);
  24162. /**
  24163. * Update the url (and optional buffer) of this texture if url was null during construction.
  24164. * @param url the url of the texture
  24165. * @param buffer the buffer of the texture (defaults to null)
  24166. * @param onLoad callback called when the texture is loaded (defaults to null)
  24167. */
  24168. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24169. /**
  24170. * Finish the loading sequence of a texture flagged as delayed load.
  24171. * @hidden
  24172. */
  24173. delayLoad(): void;
  24174. private _prepareRowForTextureGeneration;
  24175. /**
  24176. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24177. * @returns the transform matrix of the texture.
  24178. */
  24179. getTextureMatrix(uBase?: number): Matrix;
  24180. /**
  24181. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24182. * @returns The reflection texture transform
  24183. */
  24184. getReflectionTextureMatrix(): Matrix;
  24185. /**
  24186. * Clones the texture.
  24187. * @returns the cloned texture
  24188. */
  24189. clone(): Texture;
  24190. /**
  24191. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24192. * @returns The JSON representation of the texture
  24193. */
  24194. serialize(): any;
  24195. /**
  24196. * Get the current class name of the texture useful for serialization or dynamic coding.
  24197. * @returns "Texture"
  24198. */
  24199. getClassName(): string;
  24200. /**
  24201. * Dispose the texture and release its associated resources.
  24202. */
  24203. dispose(): void;
  24204. /**
  24205. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24206. * @param parsedTexture Define the JSON representation of the texture
  24207. * @param scene Define the scene the parsed texture should be instantiated in
  24208. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24209. * @returns The parsed texture if successful
  24210. */
  24211. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24212. /**
  24213. * Creates a texture from its base 64 representation.
  24214. * @param data Define the base64 payload without the data: prefix
  24215. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24216. * @param scene Define the scene the texture should belong to
  24217. * @param noMipmap Forces the texture to not create mip map information if true
  24218. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24219. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24220. * @param onLoad define a callback triggered when the texture has been loaded
  24221. * @param onError define a callback triggered when an error occurred during the loading session
  24222. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24223. * @returns the created texture
  24224. */
  24225. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24226. /**
  24227. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24228. * @param data Define the base64 payload without the data: prefix
  24229. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24230. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24231. * @param scene Define the scene the texture should belong to
  24232. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24233. * @param noMipmap Forces the texture to not create mip map information if true
  24234. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24235. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24236. * @param onLoad define a callback triggered when the texture has been loaded
  24237. * @param onError define a callback triggered when an error occurred during the loading session
  24238. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24239. * @returns the created texture
  24240. */
  24241. 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;
  24242. }
  24243. }
  24244. declare module "babylonjs/PostProcesses/postProcessManager" {
  24245. import { Nullable } from "babylonjs/types";
  24246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24248. import { Scene } from "babylonjs/scene";
  24249. /**
  24250. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24251. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24252. */
  24253. export class PostProcessManager {
  24254. private _scene;
  24255. private _indexBuffer;
  24256. private _vertexBuffers;
  24257. /**
  24258. * Creates a new instance PostProcess
  24259. * @param scene The scene that the post process is associated with.
  24260. */
  24261. constructor(scene: Scene);
  24262. private _prepareBuffers;
  24263. private _buildIndexBuffer;
  24264. /**
  24265. * Rebuilds the vertex buffers of the manager.
  24266. * @hidden
  24267. */
  24268. _rebuild(): void;
  24269. /**
  24270. * Prepares a frame to be run through a post process.
  24271. * @param sourceTexture The input texture to the post procesess. (default: null)
  24272. * @param postProcesses An array of post processes to be run. (default: null)
  24273. * @returns True if the post processes were able to be run.
  24274. * @hidden
  24275. */
  24276. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24277. /**
  24278. * Manually render a set of post processes to a texture.
  24279. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24280. * @param postProcesses An array of post processes to be run.
  24281. * @param targetTexture The target texture to render to.
  24282. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24283. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24284. * @param lodLevel defines which lod of the texture to render to
  24285. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24286. */
  24287. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24288. /**
  24289. * Finalize the result of the output of the postprocesses.
  24290. * @param doNotPresent If true the result will not be displayed to the screen.
  24291. * @param targetTexture The target texture to render to.
  24292. * @param faceIndex The index of the face to bind the target texture to.
  24293. * @param postProcesses The array of post processes to render.
  24294. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24295. * @hidden
  24296. */
  24297. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24298. /**
  24299. * Disposes of the post process manager.
  24300. */
  24301. dispose(): void;
  24302. }
  24303. }
  24304. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24305. import { Observable } from "babylonjs/Misc/observable";
  24306. import { SmartArray } from "babylonjs/Misc/smartArray";
  24307. import { Nullable, Immutable } from "babylonjs/types";
  24308. import { Camera } from "babylonjs/Cameras/camera";
  24309. import { Scene } from "babylonjs/scene";
  24310. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24311. import { Color4 } from "babylonjs/Maths/math.color";
  24312. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24314. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24316. import { Texture } from "babylonjs/Materials/Textures/texture";
  24317. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24318. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24319. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24320. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24321. import { Engine } from "babylonjs/Engines/engine";
  24322. /**
  24323. * This Helps creating a texture that will be created from a camera in your scene.
  24324. * It is basically a dynamic texture that could be used to create special effects for instance.
  24325. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24326. */
  24327. export class RenderTargetTexture extends Texture {
  24328. /**
  24329. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24330. */
  24331. static readonly REFRESHRATE_RENDER_ONCE: number;
  24332. /**
  24333. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24334. */
  24335. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24336. /**
  24337. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24338. * the central point of your effect and can save a lot of performances.
  24339. */
  24340. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24341. /**
  24342. * Use this predicate to dynamically define the list of mesh you want to render.
  24343. * If set, the renderList property will be overwritten.
  24344. */
  24345. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24346. private _renderList;
  24347. /**
  24348. * Use this list to define the list of mesh you want to render.
  24349. */
  24350. get renderList(): Nullable<Array<AbstractMesh>>;
  24351. set renderList(value: Nullable<Array<AbstractMesh>>);
  24352. /**
  24353. * Use this function to overload the renderList array at rendering time.
  24354. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24355. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24356. * the cube (if the RTT is a cube, else layerOrFace=0).
  24357. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24358. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24359. * hold dummy elements!
  24360. */
  24361. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24362. private _hookArray;
  24363. /**
  24364. * Define if particles should be rendered in your texture.
  24365. */
  24366. renderParticles: boolean;
  24367. /**
  24368. * Define if sprites should be rendered in your texture.
  24369. */
  24370. renderSprites: boolean;
  24371. /**
  24372. * Define the camera used to render the texture.
  24373. */
  24374. activeCamera: Nullable<Camera>;
  24375. /**
  24376. * Override the mesh isReady function with your own one.
  24377. */
  24378. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24379. /**
  24380. * Override the render function of the texture with your own one.
  24381. */
  24382. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24383. /**
  24384. * Define if camera post processes should be use while rendering the texture.
  24385. */
  24386. useCameraPostProcesses: boolean;
  24387. /**
  24388. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24389. */
  24390. ignoreCameraViewport: boolean;
  24391. private _postProcessManager;
  24392. private _postProcesses;
  24393. private _resizeObserver;
  24394. /**
  24395. * An event triggered when the texture is unbind.
  24396. */
  24397. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24398. /**
  24399. * An event triggered when the texture is unbind.
  24400. */
  24401. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24402. private _onAfterUnbindObserver;
  24403. /**
  24404. * Set a after unbind callback in the texture.
  24405. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24406. */
  24407. set onAfterUnbind(callback: () => void);
  24408. /**
  24409. * An event triggered before rendering the texture
  24410. */
  24411. onBeforeRenderObservable: Observable<number>;
  24412. private _onBeforeRenderObserver;
  24413. /**
  24414. * Set a before render callback in the texture.
  24415. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24416. */
  24417. set onBeforeRender(callback: (faceIndex: number) => void);
  24418. /**
  24419. * An event triggered after rendering the texture
  24420. */
  24421. onAfterRenderObservable: Observable<number>;
  24422. private _onAfterRenderObserver;
  24423. /**
  24424. * Set a after render callback in the texture.
  24425. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24426. */
  24427. set onAfterRender(callback: (faceIndex: number) => void);
  24428. /**
  24429. * An event triggered after the texture clear
  24430. */
  24431. onClearObservable: Observable<Engine>;
  24432. private _onClearObserver;
  24433. /**
  24434. * Set a clear callback in the texture.
  24435. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24436. */
  24437. set onClear(callback: (Engine: Engine) => void);
  24438. /**
  24439. * An event triggered when the texture is resized.
  24440. */
  24441. onResizeObservable: Observable<RenderTargetTexture>;
  24442. /**
  24443. * Define the clear color of the Render Target if it should be different from the scene.
  24444. */
  24445. clearColor: Color4;
  24446. protected _size: number | {
  24447. width: number;
  24448. height: number;
  24449. layers?: number;
  24450. };
  24451. protected _initialSizeParameter: number | {
  24452. width: number;
  24453. height: number;
  24454. } | {
  24455. ratio: number;
  24456. };
  24457. protected _sizeRatio: Nullable<number>;
  24458. /** @hidden */
  24459. _generateMipMaps: boolean;
  24460. protected _renderingManager: RenderingManager;
  24461. /** @hidden */
  24462. _waitingRenderList?: string[];
  24463. protected _doNotChangeAspectRatio: boolean;
  24464. protected _currentRefreshId: number;
  24465. protected _refreshRate: number;
  24466. protected _textureMatrix: Matrix;
  24467. protected _samples: number;
  24468. protected _renderTargetOptions: RenderTargetCreationOptions;
  24469. /**
  24470. * Gets render target creation options that were used.
  24471. */
  24472. get renderTargetOptions(): RenderTargetCreationOptions;
  24473. protected _onRatioRescale(): void;
  24474. /**
  24475. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24476. * It must define where the camera used to render the texture is set
  24477. */
  24478. boundingBoxPosition: Vector3;
  24479. private _boundingBoxSize;
  24480. /**
  24481. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24482. * When defined, the cubemap will switch to local mode
  24483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24484. * @example https://www.babylonjs-playground.com/#RNASML
  24485. */
  24486. set boundingBoxSize(value: Vector3);
  24487. get boundingBoxSize(): Vector3;
  24488. /**
  24489. * In case the RTT has been created with a depth texture, get the associated
  24490. * depth texture.
  24491. * Otherwise, return null.
  24492. */
  24493. get depthStencilTexture(): Nullable<InternalTexture>;
  24494. /**
  24495. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24496. * or used a shadow, depth texture...
  24497. * @param name The friendly name of the texture
  24498. * @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)
  24499. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24500. * @param generateMipMaps True if mip maps need to be generated after render.
  24501. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24502. * @param type The type of the buffer in the RTT (int, half float, float...)
  24503. * @param isCube True if a cube texture needs to be created
  24504. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24505. * @param generateDepthBuffer True to generate a depth buffer
  24506. * @param generateStencilBuffer True to generate a stencil buffer
  24507. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24508. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24509. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24510. */
  24511. constructor(name: string, size: number | {
  24512. width: number;
  24513. height: number;
  24514. layers?: number;
  24515. } | {
  24516. ratio: number;
  24517. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24518. /**
  24519. * Creates a depth stencil texture.
  24520. * This is only available in WebGL 2 or with the depth texture extension available.
  24521. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24522. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24523. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24524. */
  24525. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24526. private _processSizeParameter;
  24527. /**
  24528. * Define the number of samples to use in case of MSAA.
  24529. * It defaults to one meaning no MSAA has been enabled.
  24530. */
  24531. get samples(): number;
  24532. set samples(value: number);
  24533. /**
  24534. * Resets the refresh counter of the texture and start bak from scratch.
  24535. * Could be useful to regenerate the texture if it is setup to render only once.
  24536. */
  24537. resetRefreshCounter(): void;
  24538. /**
  24539. * Define the refresh rate of the texture or the rendering frequency.
  24540. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24541. */
  24542. get refreshRate(): number;
  24543. set refreshRate(value: number);
  24544. /**
  24545. * Adds a post process to the render target rendering passes.
  24546. * @param postProcess define the post process to add
  24547. */
  24548. addPostProcess(postProcess: PostProcess): void;
  24549. /**
  24550. * Clear all the post processes attached to the render target
  24551. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24552. */
  24553. clearPostProcesses(dispose?: boolean): void;
  24554. /**
  24555. * Remove one of the post process from the list of attached post processes to the texture
  24556. * @param postProcess define the post process to remove from the list
  24557. */
  24558. removePostProcess(postProcess: PostProcess): void;
  24559. /** @hidden */
  24560. _shouldRender(): boolean;
  24561. /**
  24562. * Gets the actual render size of the texture.
  24563. * @returns the width of the render size
  24564. */
  24565. getRenderSize(): number;
  24566. /**
  24567. * Gets the actual render width of the texture.
  24568. * @returns the width of the render size
  24569. */
  24570. getRenderWidth(): number;
  24571. /**
  24572. * Gets the actual render height of the texture.
  24573. * @returns the height of the render size
  24574. */
  24575. getRenderHeight(): number;
  24576. /**
  24577. * Gets the actual number of layers of the texture.
  24578. * @returns the number of layers
  24579. */
  24580. getRenderLayers(): number;
  24581. /**
  24582. * Get if the texture can be rescaled or not.
  24583. */
  24584. get canRescale(): boolean;
  24585. /**
  24586. * Resize the texture using a ratio.
  24587. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24588. */
  24589. scale(ratio: number): void;
  24590. /**
  24591. * Get the texture reflection matrix used to rotate/transform the reflection.
  24592. * @returns the reflection matrix
  24593. */
  24594. getReflectionTextureMatrix(): Matrix;
  24595. /**
  24596. * Resize the texture to a new desired size.
  24597. * Be carrefull as it will recreate all the data in the new texture.
  24598. * @param size Define the new size. It can be:
  24599. * - a number for squared texture,
  24600. * - an object containing { width: number, height: number }
  24601. * - or an object containing a ratio { ratio: number }
  24602. */
  24603. resize(size: number | {
  24604. width: number;
  24605. height: number;
  24606. } | {
  24607. ratio: number;
  24608. }): void;
  24609. private _defaultRenderListPrepared;
  24610. /**
  24611. * Renders all the objects from the render list into the texture.
  24612. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24613. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24614. */
  24615. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24616. private _bestReflectionRenderTargetDimension;
  24617. private _prepareRenderingManager;
  24618. /**
  24619. * @hidden
  24620. * @param faceIndex face index to bind to if this is a cubetexture
  24621. * @param layer defines the index of the texture to bind in the array
  24622. */
  24623. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24624. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24625. private renderToTarget;
  24626. /**
  24627. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24628. * This allowed control for front to back rendering or reversly depending of the special needs.
  24629. *
  24630. * @param renderingGroupId The rendering group id corresponding to its index
  24631. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24632. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24633. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24634. */
  24635. 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;
  24636. /**
  24637. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24638. *
  24639. * @param renderingGroupId The rendering group id corresponding to its index
  24640. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24641. */
  24642. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24643. /**
  24644. * Clones the texture.
  24645. * @returns the cloned texture
  24646. */
  24647. clone(): RenderTargetTexture;
  24648. /**
  24649. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24650. * @returns The JSON representation of the texture
  24651. */
  24652. serialize(): any;
  24653. /**
  24654. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24655. */
  24656. disposeFramebufferObjects(): void;
  24657. /**
  24658. * Dispose the texture and release its associated resources.
  24659. */
  24660. dispose(): void;
  24661. /** @hidden */
  24662. _rebuild(): void;
  24663. /**
  24664. * Clear the info related to rendering groups preventing retention point in material dispose.
  24665. */
  24666. freeRenderingGroups(): void;
  24667. /**
  24668. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24669. * @returns the view count
  24670. */
  24671. getViewCount(): number;
  24672. }
  24673. }
  24674. declare module "babylonjs/Misc/guid" {
  24675. /**
  24676. * Class used to manipulate GUIDs
  24677. */
  24678. export class GUID {
  24679. /**
  24680. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24681. * Be aware Math.random() could cause collisions, but:
  24682. * "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"
  24683. * @returns a pseudo random id
  24684. */
  24685. static RandomId(): string;
  24686. }
  24687. }
  24688. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24689. import { Nullable } from "babylonjs/types";
  24690. import { Scene } from "babylonjs/scene";
  24691. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24692. import { Material } from "babylonjs/Materials/material";
  24693. import { Effect } from "babylonjs/Materials/effect";
  24694. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24695. /**
  24696. * Options to be used when creating a shadow depth material
  24697. */
  24698. export interface IIOptionShadowDepthMaterial {
  24699. /** Variables in the vertex shader code that need to have their names remapped.
  24700. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24701. * "var_name" should be either: worldPos or vNormalW
  24702. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24703. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24704. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24705. */
  24706. remappedVariables?: string[];
  24707. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24708. standalone?: boolean;
  24709. }
  24710. /**
  24711. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24712. */
  24713. export class ShadowDepthWrapper {
  24714. private _scene;
  24715. private _options?;
  24716. private _baseMaterial;
  24717. private _onEffectCreatedObserver;
  24718. private _subMeshToEffect;
  24719. private _subMeshToDepthEffect;
  24720. private _meshes;
  24721. /** @hidden */
  24722. _matriceNames: any;
  24723. /** Gets the standalone status of the wrapper */
  24724. get standalone(): boolean;
  24725. /** Gets the base material the wrapper is built upon */
  24726. get baseMaterial(): Material;
  24727. /**
  24728. * Instantiate a new shadow depth wrapper.
  24729. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24730. * generate the shadow depth map. For more information, please refer to the documentation:
  24731. * https://doc.babylonjs.com/babylon101/shadows
  24732. * @param baseMaterial Material to wrap
  24733. * @param scene Define the scene the material belongs to
  24734. * @param options Options used to create the wrapper
  24735. */
  24736. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24737. /**
  24738. * Gets the effect to use to generate the depth map
  24739. * @param subMesh subMesh to get the effect for
  24740. * @param shadowGenerator shadow generator to get the effect for
  24741. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24742. */
  24743. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24744. /**
  24745. * Specifies that the submesh is ready to be used for depth rendering
  24746. * @param subMesh submesh to check
  24747. * @param defines the list of defines to take into account when checking the effect
  24748. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24749. * @param useInstances specifies that instances should be used
  24750. * @returns a boolean indicating that the submesh is ready or not
  24751. */
  24752. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24753. /**
  24754. * Disposes the resources
  24755. */
  24756. dispose(): void;
  24757. private _makeEffect;
  24758. }
  24759. }
  24760. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24762. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24763. import { Nullable } from "babylonjs/types";
  24764. module "babylonjs/Engines/thinEngine" {
  24765. interface ThinEngine {
  24766. /**
  24767. * Unbind a list of render target textures from the webGL context
  24768. * This is used only when drawBuffer extension or webGL2 are active
  24769. * @param textures defines the render target textures to unbind
  24770. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24771. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24772. */
  24773. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24774. /**
  24775. * Create a multi render target texture
  24776. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24777. * @param size defines the size of the texture
  24778. * @param options defines the creation options
  24779. * @returns the cube texture as an InternalTexture
  24780. */
  24781. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24782. /**
  24783. * Update the sample count for a given multiple render target texture
  24784. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24785. * @param textures defines the textures to update
  24786. * @param samples defines the sample count to set
  24787. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24788. */
  24789. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24790. /**
  24791. * Select a subsets of attachments to draw to.
  24792. * @param attachments gl attachments
  24793. */
  24794. bindAttachments(attachments: number[]): void;
  24795. }
  24796. }
  24797. }
  24798. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24799. import { Scene } from "babylonjs/scene";
  24800. import { Engine } from "babylonjs/Engines/engine";
  24801. import { Texture } from "babylonjs/Materials/Textures/texture";
  24802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24803. import "babylonjs/Engines/Extensions/engine.multiRender";
  24804. /**
  24805. * Creation options of the multi render target texture.
  24806. */
  24807. export interface IMultiRenderTargetOptions {
  24808. /**
  24809. * Define if the texture needs to create mip maps after render.
  24810. */
  24811. generateMipMaps?: boolean;
  24812. /**
  24813. * Define the types of all the draw buffers we want to create
  24814. */
  24815. types?: number[];
  24816. /**
  24817. * Define the sampling modes of all the draw buffers we want to create
  24818. */
  24819. samplingModes?: number[];
  24820. /**
  24821. * Define if a depth buffer is required
  24822. */
  24823. generateDepthBuffer?: boolean;
  24824. /**
  24825. * Define if a stencil buffer is required
  24826. */
  24827. generateStencilBuffer?: boolean;
  24828. /**
  24829. * Define if a depth texture is required instead of a depth buffer
  24830. */
  24831. generateDepthTexture?: boolean;
  24832. /**
  24833. * Define the number of desired draw buffers
  24834. */
  24835. textureCount?: number;
  24836. /**
  24837. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24838. */
  24839. doNotChangeAspectRatio?: boolean;
  24840. /**
  24841. * Define the default type of the buffers we are creating
  24842. */
  24843. defaultType?: number;
  24844. }
  24845. /**
  24846. * A multi render target, like a render target provides the ability to render to a texture.
  24847. * Unlike the render target, it can render to several draw buffers in one draw.
  24848. * This is specially interesting in deferred rendering or for any effects requiring more than
  24849. * just one color from a single pass.
  24850. */
  24851. export class MultiRenderTarget extends RenderTargetTexture {
  24852. private _internalTextures;
  24853. private _textures;
  24854. private _multiRenderTargetOptions;
  24855. private _count;
  24856. /**
  24857. * Get if draw buffers are currently supported by the used hardware and browser.
  24858. */
  24859. get isSupported(): boolean;
  24860. /**
  24861. * Get the list of textures generated by the multi render target.
  24862. */
  24863. get textures(): Texture[];
  24864. /**
  24865. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24866. */
  24867. get count(): number;
  24868. /**
  24869. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24870. */
  24871. get depthTexture(): Texture;
  24872. /**
  24873. * Set the wrapping mode on U of all the textures we are rendering to.
  24874. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24875. */
  24876. set wrapU(wrap: number);
  24877. /**
  24878. * Set the wrapping mode on V of all the textures we are rendering to.
  24879. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24880. */
  24881. set wrapV(wrap: number);
  24882. /**
  24883. * Instantiate a new multi render target texture.
  24884. * A multi render target, like a render target provides the ability to render to a texture.
  24885. * Unlike the render target, it can render to several draw buffers in one draw.
  24886. * This is specially interesting in deferred rendering or for any effects requiring more than
  24887. * just one color from a single pass.
  24888. * @param name Define the name of the texture
  24889. * @param size Define the size of the buffers to render to
  24890. * @param count Define the number of target we are rendering into
  24891. * @param scene Define the scene the texture belongs to
  24892. * @param options Define the options used to create the multi render target
  24893. */
  24894. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24895. /** @hidden */
  24896. _rebuild(): void;
  24897. private _createInternalTextures;
  24898. private _createTextures;
  24899. /**
  24900. * Define the number of samples used if MSAA is enabled.
  24901. */
  24902. get samples(): number;
  24903. set samples(value: number);
  24904. /**
  24905. * Resize all the textures in the multi render target.
  24906. * Be carrefull as it will recreate all the data in the new texture.
  24907. * @param size Define the new size
  24908. */
  24909. resize(size: any): void;
  24910. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24911. /**
  24912. * Dispose the render targets and their associated resources
  24913. */
  24914. dispose(): void;
  24915. /**
  24916. * Release all the underlying texture used as draw buffers.
  24917. */
  24918. releaseInternalTextures(): void;
  24919. }
  24920. }
  24921. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24922. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24923. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24924. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24925. /** @hidden */
  24926. export var imageProcessingPixelShader: {
  24927. name: string;
  24928. shader: string;
  24929. };
  24930. }
  24931. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24932. import { Nullable } from "babylonjs/types";
  24933. import { Color4 } from "babylonjs/Maths/math.color";
  24934. import { Camera } from "babylonjs/Cameras/camera";
  24935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24936. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24937. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24939. import { Engine } from "babylonjs/Engines/engine";
  24940. import "babylonjs/Shaders/imageProcessing.fragment";
  24941. import "babylonjs/Shaders/postprocess.vertex";
  24942. /**
  24943. * ImageProcessingPostProcess
  24944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24945. */
  24946. export class ImageProcessingPostProcess extends PostProcess {
  24947. /**
  24948. * Default configuration related to image processing available in the PBR Material.
  24949. */
  24950. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24951. /**
  24952. * Gets the image processing configuration used either in this material.
  24953. */
  24954. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24955. /**
  24956. * Sets the Default image processing configuration used either in the this material.
  24957. *
  24958. * If sets to null, the scene one is in use.
  24959. */
  24960. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24961. /**
  24962. * Keep track of the image processing observer to allow dispose and replace.
  24963. */
  24964. private _imageProcessingObserver;
  24965. /**
  24966. * Attaches a new image processing configuration to the PBR Material.
  24967. * @param configuration
  24968. */
  24969. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24970. /**
  24971. * If the post process is supported.
  24972. */
  24973. get isSupported(): boolean;
  24974. /**
  24975. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24976. */
  24977. get colorCurves(): Nullable<ColorCurves>;
  24978. /**
  24979. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24980. */
  24981. set colorCurves(value: Nullable<ColorCurves>);
  24982. /**
  24983. * Gets wether the color curves effect is enabled.
  24984. */
  24985. get colorCurvesEnabled(): boolean;
  24986. /**
  24987. * Sets wether the color curves effect is enabled.
  24988. */
  24989. set colorCurvesEnabled(value: boolean);
  24990. /**
  24991. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24992. */
  24993. get colorGradingTexture(): Nullable<BaseTexture>;
  24994. /**
  24995. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24996. */
  24997. set colorGradingTexture(value: Nullable<BaseTexture>);
  24998. /**
  24999. * Gets wether the color grading effect is enabled.
  25000. */
  25001. get colorGradingEnabled(): boolean;
  25002. /**
  25003. * Gets wether the color grading effect is enabled.
  25004. */
  25005. set colorGradingEnabled(value: boolean);
  25006. /**
  25007. * Gets exposure used in the effect.
  25008. */
  25009. get exposure(): number;
  25010. /**
  25011. * Sets exposure used in the effect.
  25012. */
  25013. set exposure(value: number);
  25014. /**
  25015. * Gets wether tonemapping is enabled or not.
  25016. */
  25017. get toneMappingEnabled(): boolean;
  25018. /**
  25019. * Sets wether tonemapping is enabled or not
  25020. */
  25021. set toneMappingEnabled(value: boolean);
  25022. /**
  25023. * Gets the type of tone mapping effect.
  25024. */
  25025. get toneMappingType(): number;
  25026. /**
  25027. * Sets the type of tone mapping effect.
  25028. */
  25029. set toneMappingType(value: number);
  25030. /**
  25031. * Gets contrast used in the effect.
  25032. */
  25033. get contrast(): number;
  25034. /**
  25035. * Sets contrast used in the effect.
  25036. */
  25037. set contrast(value: number);
  25038. /**
  25039. * Gets Vignette stretch size.
  25040. */
  25041. get vignetteStretch(): number;
  25042. /**
  25043. * Sets Vignette stretch size.
  25044. */
  25045. set vignetteStretch(value: number);
  25046. /**
  25047. * Gets Vignette centre X Offset.
  25048. */
  25049. get vignetteCentreX(): number;
  25050. /**
  25051. * Sets Vignette centre X Offset.
  25052. */
  25053. set vignetteCentreX(value: number);
  25054. /**
  25055. * Gets Vignette centre Y Offset.
  25056. */
  25057. get vignetteCentreY(): number;
  25058. /**
  25059. * Sets Vignette centre Y Offset.
  25060. */
  25061. set vignetteCentreY(value: number);
  25062. /**
  25063. * Gets Vignette weight or intensity of the vignette effect.
  25064. */
  25065. get vignetteWeight(): number;
  25066. /**
  25067. * Sets Vignette weight or intensity of the vignette effect.
  25068. */
  25069. set vignetteWeight(value: number);
  25070. /**
  25071. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25072. * if vignetteEnabled is set to true.
  25073. */
  25074. get vignetteColor(): Color4;
  25075. /**
  25076. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25077. * if vignetteEnabled is set to true.
  25078. */
  25079. set vignetteColor(value: Color4);
  25080. /**
  25081. * Gets Camera field of view used by the Vignette effect.
  25082. */
  25083. get vignetteCameraFov(): number;
  25084. /**
  25085. * Sets Camera field of view used by the Vignette effect.
  25086. */
  25087. set vignetteCameraFov(value: number);
  25088. /**
  25089. * Gets the vignette blend mode allowing different kind of effect.
  25090. */
  25091. get vignetteBlendMode(): number;
  25092. /**
  25093. * Sets the vignette blend mode allowing different kind of effect.
  25094. */
  25095. set vignetteBlendMode(value: number);
  25096. /**
  25097. * Gets wether the vignette effect is enabled.
  25098. */
  25099. get vignetteEnabled(): boolean;
  25100. /**
  25101. * Sets wether the vignette effect is enabled.
  25102. */
  25103. set vignetteEnabled(value: boolean);
  25104. private _fromLinearSpace;
  25105. /**
  25106. * Gets wether the input of the processing is in Gamma or Linear Space.
  25107. */
  25108. get fromLinearSpace(): boolean;
  25109. /**
  25110. * Sets wether the input of the processing is in Gamma or Linear Space.
  25111. */
  25112. set fromLinearSpace(value: boolean);
  25113. /**
  25114. * Defines cache preventing GC.
  25115. */
  25116. private _defines;
  25117. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25118. /**
  25119. * "ImageProcessingPostProcess"
  25120. * @returns "ImageProcessingPostProcess"
  25121. */
  25122. getClassName(): string;
  25123. /**
  25124. * @hidden
  25125. */
  25126. _updateParameters(): void;
  25127. dispose(camera?: Camera): void;
  25128. }
  25129. }
  25130. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25131. /** @hidden */
  25132. export var fibonacci: {
  25133. name: string;
  25134. shader: string;
  25135. };
  25136. }
  25137. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25138. /** @hidden */
  25139. export var subSurfaceScatteringFunctions: {
  25140. name: string;
  25141. shader: string;
  25142. };
  25143. }
  25144. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25145. /** @hidden */
  25146. export var diffusionProfile: {
  25147. name: string;
  25148. shader: string;
  25149. };
  25150. }
  25151. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25152. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25154. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25155. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25156. /** @hidden */
  25157. export var subSurfaceScatteringPixelShader: {
  25158. name: string;
  25159. shader: string;
  25160. };
  25161. }
  25162. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25163. import { Nullable } from "babylonjs/types";
  25164. import { Camera } from "babylonjs/Cameras/camera";
  25165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25166. import { Engine } from "babylonjs/Engines/engine";
  25167. import { Scene } from "babylonjs/scene";
  25168. import "babylonjs/Shaders/imageProcessing.fragment";
  25169. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25170. import "babylonjs/Shaders/postprocess.vertex";
  25171. /**
  25172. * Sub surface scattering post process
  25173. */
  25174. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25175. /**
  25176. * Gets a string identifying the name of the class
  25177. * @returns "SubSurfaceScatteringPostProcess" string
  25178. */
  25179. getClassName(): string;
  25180. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25181. }
  25182. }
  25183. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25184. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25185. /**
  25186. * Interface for defining prepass effects in the prepass post-process pipeline
  25187. */
  25188. export interface PrePassEffectConfiguration {
  25189. /**
  25190. * Post process to attach for this effect
  25191. */
  25192. postProcess: PostProcess;
  25193. /**
  25194. * Is the effect enabled
  25195. */
  25196. enabled: boolean;
  25197. /**
  25198. * Disposes the effect configuration
  25199. */
  25200. dispose(): void;
  25201. /**
  25202. * Disposes the effect configuration
  25203. */
  25204. createPostProcess: () => PostProcess;
  25205. }
  25206. }
  25207. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25208. import { Scene } from "babylonjs/scene";
  25209. import { Color3 } from "babylonjs/Maths/math.color";
  25210. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25211. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25212. /**
  25213. * Contains all parameters needed for the prepass to perform
  25214. * screen space subsurface scattering
  25215. */
  25216. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25217. private _ssDiffusionS;
  25218. private _ssFilterRadii;
  25219. private _ssDiffusionD;
  25220. /**
  25221. * Post process to attach for screen space subsurface scattering
  25222. */
  25223. postProcess: SubSurfaceScatteringPostProcess;
  25224. /**
  25225. * Diffusion profile color for subsurface scattering
  25226. */
  25227. get ssDiffusionS(): number[];
  25228. /**
  25229. * Diffusion profile max color channel value for subsurface scattering
  25230. */
  25231. get ssDiffusionD(): number[];
  25232. /**
  25233. * Diffusion profile filter radius for subsurface scattering
  25234. */
  25235. get ssFilterRadii(): number[];
  25236. /**
  25237. * Is subsurface enabled
  25238. */
  25239. enabled: boolean;
  25240. /**
  25241. * Diffusion profile colors for subsurface scattering
  25242. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25243. * See ...
  25244. * Note that you can only store up to 5 of them
  25245. */
  25246. ssDiffusionProfileColors: Color3[];
  25247. /**
  25248. * Defines the ratio real world => scene units.
  25249. * Used for subsurface scattering
  25250. */
  25251. metersPerUnit: number;
  25252. private _scene;
  25253. /**
  25254. * Builds a subsurface configuration object
  25255. * @param scene The scene
  25256. */
  25257. constructor(scene: Scene);
  25258. /**
  25259. * Adds a new diffusion profile.
  25260. * Useful for more realistic subsurface scattering on diverse materials.
  25261. * @param color The color of the diffusion profile. Should be the average color of the material.
  25262. * @return The index of the diffusion profile for the material subsurface configuration
  25263. */
  25264. addDiffusionProfile(color: Color3): number;
  25265. /**
  25266. * Creates the sss post process
  25267. * @return The created post process
  25268. */
  25269. createPostProcess(): SubSurfaceScatteringPostProcess;
  25270. /**
  25271. * Deletes all diffusion profiles.
  25272. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25273. */
  25274. clearAllDiffusionProfiles(): void;
  25275. /**
  25276. * Disposes this object
  25277. */
  25278. dispose(): void;
  25279. /**
  25280. * @hidden
  25281. * https://zero-radiance.github.io/post/sampling-diffusion/
  25282. *
  25283. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25284. * ------------------------------------------------------------------------------------
  25285. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25286. * PDF[r, phi, s] = r * R[r, phi, s]
  25287. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25288. * ------------------------------------------------------------------------------------
  25289. * We importance sample the color channel with the widest scattering distance.
  25290. */
  25291. getDiffusionProfileParameters(color: Color3): number;
  25292. /**
  25293. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25294. * 'u' is the random number (the value of the CDF): [0, 1).
  25295. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25296. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25297. */
  25298. private _sampleBurleyDiffusionProfile;
  25299. }
  25300. }
  25301. declare module "babylonjs/Rendering/prePassRenderer" {
  25302. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25303. import { Scene } from "babylonjs/scene";
  25304. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25305. import { Effect } from "babylonjs/Materials/effect";
  25306. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25307. /**
  25308. * Renders a pre pass of the scene
  25309. * This means every mesh in the scene will be rendered to a render target texture
  25310. * And then this texture will be composited to the rendering canvas with post processes
  25311. * It is necessary for effects like subsurface scattering or deferred shading
  25312. */
  25313. export class PrePassRenderer {
  25314. /** @hidden */
  25315. static _SceneComponentInitialization: (scene: Scene) => void;
  25316. private _scene;
  25317. private _engine;
  25318. private _isDirty;
  25319. /**
  25320. * Number of textures in the multi render target texture where the scene is directly rendered
  25321. */
  25322. readonly mrtCount: number;
  25323. /**
  25324. * The render target where the scene is directly rendered
  25325. */
  25326. prePassRT: MultiRenderTarget;
  25327. private _mrtTypes;
  25328. private _multiRenderAttachments;
  25329. private _defaultAttachments;
  25330. private _clearAttachments;
  25331. private _postProcesses;
  25332. private readonly _clearColor;
  25333. /**
  25334. * Image processing post process for composition
  25335. */
  25336. imageProcessingPostProcess: ImageProcessingPostProcess;
  25337. /**
  25338. * Configuration for sub surface scattering post process
  25339. */
  25340. subSurfaceConfiguration: SubSurfaceConfiguration;
  25341. /**
  25342. * Should materials render their geometry on the MRT
  25343. */
  25344. materialsShouldRenderGeometry: boolean;
  25345. /**
  25346. * Should materials render the irradiance information on the MRT
  25347. */
  25348. materialsShouldRenderIrradiance: boolean;
  25349. private _enabled;
  25350. /**
  25351. * Indicates if the prepass is enabled
  25352. */
  25353. get enabled(): boolean;
  25354. /**
  25355. * How many samples are used for MSAA of the scene render target
  25356. */
  25357. get samples(): number;
  25358. set samples(n: number);
  25359. /**
  25360. * Instanciates a prepass renderer
  25361. * @param scene The scene
  25362. */
  25363. constructor(scene: Scene);
  25364. private _initializeAttachments;
  25365. private _createCompositionEffect;
  25366. /**
  25367. * Indicates if rendering a prepass is supported
  25368. */
  25369. get isSupported(): boolean;
  25370. /**
  25371. * Sets the proper output textures to draw in the engine.
  25372. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25373. */
  25374. bindAttachmentsForEffect(effect: Effect): void;
  25375. /**
  25376. * @hidden
  25377. */
  25378. _beforeCameraDraw(): void;
  25379. /**
  25380. * @hidden
  25381. */
  25382. _afterCameraDraw(): void;
  25383. private _checkRTSize;
  25384. private _bindFrameBuffer;
  25385. /**
  25386. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25387. */
  25388. clear(): void;
  25389. private _setState;
  25390. private _enable;
  25391. private _disable;
  25392. private _resetPostProcessChain;
  25393. private _bindPostProcessChain;
  25394. /**
  25395. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25396. */
  25397. markAsDirty(): void;
  25398. private _update;
  25399. /**
  25400. * Disposes the prepass renderer.
  25401. */
  25402. dispose(): void;
  25403. }
  25404. }
  25405. declare module "babylonjs/Materials/material" {
  25406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25407. import { SmartArray } from "babylonjs/Misc/smartArray";
  25408. import { Observable } from "babylonjs/Misc/observable";
  25409. import { Nullable } from "babylonjs/types";
  25410. import { Scene } from "babylonjs/scene";
  25411. import { Matrix } from "babylonjs/Maths/math.vector";
  25412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25414. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25415. import { Effect } from "babylonjs/Materials/effect";
  25416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25418. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25419. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25420. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25421. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25422. import { Mesh } from "babylonjs/Meshes/mesh";
  25423. import { Animation } from "babylonjs/Animations/animation";
  25424. /**
  25425. * Options for compiling materials.
  25426. */
  25427. export interface IMaterialCompilationOptions {
  25428. /**
  25429. * Defines whether clip planes are enabled.
  25430. */
  25431. clipPlane: boolean;
  25432. /**
  25433. * Defines whether instances are enabled.
  25434. */
  25435. useInstances: boolean;
  25436. }
  25437. /**
  25438. * Options passed when calling customShaderNameResolve
  25439. */
  25440. export interface ICustomShaderNameResolveOptions {
  25441. /**
  25442. * 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
  25443. */
  25444. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25445. }
  25446. /**
  25447. * Base class for the main features of a material in Babylon.js
  25448. */
  25449. export class Material implements IAnimatable {
  25450. /**
  25451. * Returns the triangle fill mode
  25452. */
  25453. static readonly TriangleFillMode: number;
  25454. /**
  25455. * Returns the wireframe mode
  25456. */
  25457. static readonly WireFrameFillMode: number;
  25458. /**
  25459. * Returns the point fill mode
  25460. */
  25461. static readonly PointFillMode: number;
  25462. /**
  25463. * Returns the point list draw mode
  25464. */
  25465. static readonly PointListDrawMode: number;
  25466. /**
  25467. * Returns the line list draw mode
  25468. */
  25469. static readonly LineListDrawMode: number;
  25470. /**
  25471. * Returns the line loop draw mode
  25472. */
  25473. static readonly LineLoopDrawMode: number;
  25474. /**
  25475. * Returns the line strip draw mode
  25476. */
  25477. static readonly LineStripDrawMode: number;
  25478. /**
  25479. * Returns the triangle strip draw mode
  25480. */
  25481. static readonly TriangleStripDrawMode: number;
  25482. /**
  25483. * Returns the triangle fan draw mode
  25484. */
  25485. static readonly TriangleFanDrawMode: number;
  25486. /**
  25487. * Stores the clock-wise side orientation
  25488. */
  25489. static readonly ClockWiseSideOrientation: number;
  25490. /**
  25491. * Stores the counter clock-wise side orientation
  25492. */
  25493. static readonly CounterClockWiseSideOrientation: number;
  25494. /**
  25495. * The dirty texture flag value
  25496. */
  25497. static readonly TextureDirtyFlag: number;
  25498. /**
  25499. * The dirty light flag value
  25500. */
  25501. static readonly LightDirtyFlag: number;
  25502. /**
  25503. * The dirty fresnel flag value
  25504. */
  25505. static readonly FresnelDirtyFlag: number;
  25506. /**
  25507. * The dirty attribute flag value
  25508. */
  25509. static readonly AttributesDirtyFlag: number;
  25510. /**
  25511. * The dirty misc flag value
  25512. */
  25513. static readonly MiscDirtyFlag: number;
  25514. /**
  25515. * The all dirty flag value
  25516. */
  25517. static readonly AllDirtyFlag: number;
  25518. /**
  25519. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25520. */
  25521. static readonly MATERIAL_OPAQUE: number;
  25522. /**
  25523. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25524. */
  25525. static readonly MATERIAL_ALPHATEST: number;
  25526. /**
  25527. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25528. */
  25529. static readonly MATERIAL_ALPHABLEND: number;
  25530. /**
  25531. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25532. * They are also discarded below the alpha cutoff threshold to improve performances.
  25533. */
  25534. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25535. /**
  25536. * The Whiteout method is used to blend normals.
  25537. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25538. */
  25539. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25540. /**
  25541. * The Reoriented Normal Mapping method is used to blend normals.
  25542. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25543. */
  25544. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25545. /**
  25546. * Custom callback helping to override the default shader used in the material.
  25547. */
  25548. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25549. /**
  25550. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25551. */
  25552. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25553. /**
  25554. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25555. * This means that the material can keep using a previous shader while a new one is being compiled.
  25556. * This is mostly used when shader parallel compilation is supported (true by default)
  25557. */
  25558. allowShaderHotSwapping: boolean;
  25559. /**
  25560. * The ID of the material
  25561. */
  25562. id: string;
  25563. /**
  25564. * Gets or sets the unique id of the material
  25565. */
  25566. uniqueId: number;
  25567. /**
  25568. * The name of the material
  25569. */
  25570. name: string;
  25571. /**
  25572. * Gets or sets user defined metadata
  25573. */
  25574. metadata: any;
  25575. /**
  25576. * For internal use only. Please do not use.
  25577. */
  25578. reservedDataStore: any;
  25579. /**
  25580. * Specifies if the ready state should be checked on each call
  25581. */
  25582. checkReadyOnEveryCall: boolean;
  25583. /**
  25584. * Specifies if the ready state should be checked once
  25585. */
  25586. checkReadyOnlyOnce: boolean;
  25587. /**
  25588. * The state of the material
  25589. */
  25590. state: string;
  25591. /**
  25592. * If the material can be rendered to several textures with MRT extension
  25593. */
  25594. get canRenderToMRT(): boolean;
  25595. /**
  25596. * The alpha value of the material
  25597. */
  25598. protected _alpha: number;
  25599. /**
  25600. * List of inspectable custom properties (used by the Inspector)
  25601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25602. */
  25603. inspectableCustomProperties: IInspectable[];
  25604. /**
  25605. * Sets the alpha value of the material
  25606. */
  25607. set alpha(value: number);
  25608. /**
  25609. * Gets the alpha value of the material
  25610. */
  25611. get alpha(): number;
  25612. /**
  25613. * Specifies if back face culling is enabled
  25614. */
  25615. protected _backFaceCulling: boolean;
  25616. /**
  25617. * Sets the back-face culling state
  25618. */
  25619. set backFaceCulling(value: boolean);
  25620. /**
  25621. * Gets the back-face culling state
  25622. */
  25623. get backFaceCulling(): boolean;
  25624. /**
  25625. * Stores the value for side orientation
  25626. */
  25627. sideOrientation: number;
  25628. /**
  25629. * Callback triggered when the material is compiled
  25630. */
  25631. onCompiled: Nullable<(effect: Effect) => void>;
  25632. /**
  25633. * Callback triggered when an error occurs
  25634. */
  25635. onError: Nullable<(effect: Effect, errors: string) => void>;
  25636. /**
  25637. * Callback triggered to get the render target textures
  25638. */
  25639. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25640. /**
  25641. * Gets a boolean indicating that current material needs to register RTT
  25642. */
  25643. get hasRenderTargetTextures(): boolean;
  25644. /**
  25645. * Specifies if the material should be serialized
  25646. */
  25647. doNotSerialize: boolean;
  25648. /**
  25649. * @hidden
  25650. */
  25651. _storeEffectOnSubMeshes: boolean;
  25652. /**
  25653. * Stores the animations for the material
  25654. */
  25655. animations: Nullable<Array<Animation>>;
  25656. /**
  25657. * An event triggered when the material is disposed
  25658. */
  25659. onDisposeObservable: Observable<Material>;
  25660. /**
  25661. * An observer which watches for dispose events
  25662. */
  25663. private _onDisposeObserver;
  25664. private _onUnBindObservable;
  25665. /**
  25666. * Called during a dispose event
  25667. */
  25668. set onDispose(callback: () => void);
  25669. private _onBindObservable;
  25670. /**
  25671. * An event triggered when the material is bound
  25672. */
  25673. get onBindObservable(): Observable<AbstractMesh>;
  25674. /**
  25675. * An observer which watches for bind events
  25676. */
  25677. private _onBindObserver;
  25678. /**
  25679. * Called during a bind event
  25680. */
  25681. set onBind(callback: (Mesh: AbstractMesh) => void);
  25682. /**
  25683. * An event triggered when the material is unbound
  25684. */
  25685. get onUnBindObservable(): Observable<Material>;
  25686. protected _onEffectCreatedObservable: Nullable<Observable<{
  25687. effect: Effect;
  25688. subMesh: Nullable<SubMesh>;
  25689. }>>;
  25690. /**
  25691. * An event triggered when the effect is (re)created
  25692. */
  25693. get onEffectCreatedObservable(): Observable<{
  25694. effect: Effect;
  25695. subMesh: Nullable<SubMesh>;
  25696. }>;
  25697. /**
  25698. * Stores the value of the alpha mode
  25699. */
  25700. private _alphaMode;
  25701. /**
  25702. * Sets the value of the alpha mode.
  25703. *
  25704. * | Value | Type | Description |
  25705. * | --- | --- | --- |
  25706. * | 0 | ALPHA_DISABLE | |
  25707. * | 1 | ALPHA_ADD | |
  25708. * | 2 | ALPHA_COMBINE | |
  25709. * | 3 | ALPHA_SUBTRACT | |
  25710. * | 4 | ALPHA_MULTIPLY | |
  25711. * | 5 | ALPHA_MAXIMIZED | |
  25712. * | 6 | ALPHA_ONEONE | |
  25713. * | 7 | ALPHA_PREMULTIPLIED | |
  25714. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25715. * | 9 | ALPHA_INTERPOLATE | |
  25716. * | 10 | ALPHA_SCREENMODE | |
  25717. *
  25718. */
  25719. set alphaMode(value: number);
  25720. /**
  25721. * Gets the value of the alpha mode
  25722. */
  25723. get alphaMode(): number;
  25724. /**
  25725. * Stores the state of the need depth pre-pass value
  25726. */
  25727. private _needDepthPrePass;
  25728. /**
  25729. * Sets the need depth pre-pass value
  25730. */
  25731. set needDepthPrePass(value: boolean);
  25732. /**
  25733. * Gets the depth pre-pass value
  25734. */
  25735. get needDepthPrePass(): boolean;
  25736. /**
  25737. * Specifies if depth writing should be disabled
  25738. */
  25739. disableDepthWrite: boolean;
  25740. /**
  25741. * Specifies if color writing should be disabled
  25742. */
  25743. disableColorWrite: boolean;
  25744. /**
  25745. * Specifies if depth writing should be forced
  25746. */
  25747. forceDepthWrite: boolean;
  25748. /**
  25749. * Specifies the depth function that should be used. 0 means the default engine function
  25750. */
  25751. depthFunction: number;
  25752. /**
  25753. * Specifies if there should be a separate pass for culling
  25754. */
  25755. separateCullingPass: boolean;
  25756. /**
  25757. * Stores the state specifing if fog should be enabled
  25758. */
  25759. private _fogEnabled;
  25760. /**
  25761. * Sets the state for enabling fog
  25762. */
  25763. set fogEnabled(value: boolean);
  25764. /**
  25765. * Gets the value of the fog enabled state
  25766. */
  25767. get fogEnabled(): boolean;
  25768. /**
  25769. * Stores the size of points
  25770. */
  25771. pointSize: number;
  25772. /**
  25773. * Stores the z offset value
  25774. */
  25775. zOffset: number;
  25776. get wireframe(): boolean;
  25777. /**
  25778. * Sets the state of wireframe mode
  25779. */
  25780. set wireframe(value: boolean);
  25781. /**
  25782. * Gets the value specifying if point clouds are enabled
  25783. */
  25784. get pointsCloud(): boolean;
  25785. /**
  25786. * Sets the state of point cloud mode
  25787. */
  25788. set pointsCloud(value: boolean);
  25789. /**
  25790. * Gets the material fill mode
  25791. */
  25792. get fillMode(): number;
  25793. /**
  25794. * Sets the material fill mode
  25795. */
  25796. set fillMode(value: number);
  25797. /**
  25798. * @hidden
  25799. * Stores the effects for the material
  25800. */
  25801. _effect: Nullable<Effect>;
  25802. /**
  25803. * Specifies if uniform buffers should be used
  25804. */
  25805. private _useUBO;
  25806. /**
  25807. * Stores a reference to the scene
  25808. */
  25809. private _scene;
  25810. /**
  25811. * Stores the fill mode state
  25812. */
  25813. private _fillMode;
  25814. /**
  25815. * Specifies if the depth write state should be cached
  25816. */
  25817. private _cachedDepthWriteState;
  25818. /**
  25819. * Specifies if the color write state should be cached
  25820. */
  25821. private _cachedColorWriteState;
  25822. /**
  25823. * Specifies if the depth function state should be cached
  25824. */
  25825. private _cachedDepthFunctionState;
  25826. /**
  25827. * Stores the uniform buffer
  25828. */
  25829. protected _uniformBuffer: UniformBuffer;
  25830. /** @hidden */
  25831. _indexInSceneMaterialArray: number;
  25832. /** @hidden */
  25833. meshMap: Nullable<{
  25834. [id: string]: AbstractMesh | undefined;
  25835. }>;
  25836. /**
  25837. * Creates a material instance
  25838. * @param name defines the name of the material
  25839. * @param scene defines the scene to reference
  25840. * @param doNotAdd specifies if the material should be added to the scene
  25841. */
  25842. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25843. /**
  25844. * Returns a string representation of the current material
  25845. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25846. * @returns a string with material information
  25847. */
  25848. toString(fullDetails?: boolean): string;
  25849. /**
  25850. * Gets the class name of the material
  25851. * @returns a string with the class name of the material
  25852. */
  25853. getClassName(): string;
  25854. /**
  25855. * Specifies if updates for the material been locked
  25856. */
  25857. get isFrozen(): boolean;
  25858. /**
  25859. * Locks updates for the material
  25860. */
  25861. freeze(): void;
  25862. /**
  25863. * Unlocks updates for the material
  25864. */
  25865. unfreeze(): void;
  25866. /**
  25867. * Specifies if the material is ready to be used
  25868. * @param mesh defines the mesh to check
  25869. * @param useInstances specifies if instances should be used
  25870. * @returns a boolean indicating if the material is ready to be used
  25871. */
  25872. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25873. /**
  25874. * Specifies that the submesh is ready to be used
  25875. * @param mesh defines the mesh to check
  25876. * @param subMesh defines which submesh to check
  25877. * @param useInstances specifies that instances should be used
  25878. * @returns a boolean indicating that the submesh is ready or not
  25879. */
  25880. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25881. /**
  25882. * Returns the material effect
  25883. * @returns the effect associated with the material
  25884. */
  25885. getEffect(): Nullable<Effect>;
  25886. /**
  25887. * Returns the current scene
  25888. * @returns a Scene
  25889. */
  25890. getScene(): Scene;
  25891. /**
  25892. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25893. */
  25894. protected _forceAlphaTest: boolean;
  25895. /**
  25896. * The transparency mode of the material.
  25897. */
  25898. protected _transparencyMode: Nullable<number>;
  25899. /**
  25900. * Gets the current transparency mode.
  25901. */
  25902. get transparencyMode(): Nullable<number>;
  25903. /**
  25904. * Sets the transparency mode of the material.
  25905. *
  25906. * | Value | Type | Description |
  25907. * | ----- | ----------------------------------- | ----------- |
  25908. * | 0 | OPAQUE | |
  25909. * | 1 | ALPHATEST | |
  25910. * | 2 | ALPHABLEND | |
  25911. * | 3 | ALPHATESTANDBLEND | |
  25912. *
  25913. */
  25914. set transparencyMode(value: Nullable<number>);
  25915. /**
  25916. * Returns true if alpha blending should be disabled.
  25917. */
  25918. protected get _disableAlphaBlending(): boolean;
  25919. /**
  25920. * Specifies whether or not this material should be rendered in alpha blend mode.
  25921. * @returns a boolean specifying if alpha blending is needed
  25922. */
  25923. needAlphaBlending(): boolean;
  25924. /**
  25925. * Specifies if the mesh will require alpha blending
  25926. * @param mesh defines the mesh to check
  25927. * @returns a boolean specifying if alpha blending is needed for the mesh
  25928. */
  25929. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25930. /**
  25931. * Specifies whether or not this material should be rendered in alpha test mode.
  25932. * @returns a boolean specifying if an alpha test is needed.
  25933. */
  25934. needAlphaTesting(): boolean;
  25935. /**
  25936. * Specifies if material alpha testing should be turned on for the mesh
  25937. * @param mesh defines the mesh to check
  25938. */
  25939. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25940. /**
  25941. * Gets the texture used for the alpha test
  25942. * @returns the texture to use for alpha testing
  25943. */
  25944. getAlphaTestTexture(): Nullable<BaseTexture>;
  25945. /**
  25946. * Marks the material to indicate that it needs to be re-calculated
  25947. */
  25948. markDirty(): void;
  25949. /** @hidden */
  25950. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25951. /**
  25952. * Binds the material to the mesh
  25953. * @param world defines the world transformation matrix
  25954. * @param mesh defines the mesh to bind the material to
  25955. */
  25956. bind(world: Matrix, mesh?: Mesh): void;
  25957. /**
  25958. * Binds the submesh to the material
  25959. * @param world defines the world transformation matrix
  25960. * @param mesh defines the mesh containing the submesh
  25961. * @param subMesh defines the submesh to bind the material to
  25962. */
  25963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25964. /**
  25965. * Binds the world matrix to the material
  25966. * @param world defines the world transformation matrix
  25967. */
  25968. bindOnlyWorldMatrix(world: Matrix): void;
  25969. /**
  25970. * Binds the scene's uniform buffer to the effect.
  25971. * @param effect defines the effect to bind to the scene uniform buffer
  25972. * @param sceneUbo defines the uniform buffer storing scene data
  25973. */
  25974. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25975. /**
  25976. * Binds the view matrix to the effect
  25977. * @param effect defines the effect to bind the view matrix to
  25978. */
  25979. bindView(effect: Effect): void;
  25980. /**
  25981. * Binds the view projection matrix to the effect
  25982. * @param effect defines the effect to bind the view projection matrix to
  25983. */
  25984. bindViewProjection(effect: Effect): void;
  25985. /**
  25986. * Processes to execute after binding the material to a mesh
  25987. * @param mesh defines the rendered mesh
  25988. */
  25989. protected _afterBind(mesh?: Mesh): void;
  25990. /**
  25991. * Unbinds the material from the mesh
  25992. */
  25993. unbind(): void;
  25994. /**
  25995. * Gets the active textures from the material
  25996. * @returns an array of textures
  25997. */
  25998. getActiveTextures(): BaseTexture[];
  25999. /**
  26000. * Specifies if the material uses a texture
  26001. * @param texture defines the texture to check against the material
  26002. * @returns a boolean specifying if the material uses the texture
  26003. */
  26004. hasTexture(texture: BaseTexture): boolean;
  26005. /**
  26006. * Makes a duplicate of the material, and gives it a new name
  26007. * @param name defines the new name for the duplicated material
  26008. * @returns the cloned material
  26009. */
  26010. clone(name: string): Nullable<Material>;
  26011. /**
  26012. * Gets the meshes bound to the material
  26013. * @returns an array of meshes bound to the material
  26014. */
  26015. getBindedMeshes(): AbstractMesh[];
  26016. /**
  26017. * Force shader compilation
  26018. * @param mesh defines the mesh associated with this material
  26019. * @param onCompiled defines a function to execute once the material is compiled
  26020. * @param options defines the options to configure the compilation
  26021. * @param onError defines a function to execute if the material fails compiling
  26022. */
  26023. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26024. /**
  26025. * Force shader compilation
  26026. * @param mesh defines the mesh that will use this material
  26027. * @param options defines additional options for compiling the shaders
  26028. * @returns a promise that resolves when the compilation completes
  26029. */
  26030. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26031. private static readonly _AllDirtyCallBack;
  26032. private static readonly _ImageProcessingDirtyCallBack;
  26033. private static readonly _TextureDirtyCallBack;
  26034. private static readonly _FresnelDirtyCallBack;
  26035. private static readonly _MiscDirtyCallBack;
  26036. private static readonly _LightsDirtyCallBack;
  26037. private static readonly _AttributeDirtyCallBack;
  26038. private static _FresnelAndMiscDirtyCallBack;
  26039. private static _TextureAndMiscDirtyCallBack;
  26040. private static readonly _DirtyCallbackArray;
  26041. private static readonly _RunDirtyCallBacks;
  26042. /**
  26043. * Marks a define in the material to indicate that it needs to be re-computed
  26044. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26045. */
  26046. markAsDirty(flag: number): void;
  26047. /**
  26048. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26049. * @param func defines a function which checks material defines against the submeshes
  26050. */
  26051. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26052. /**
  26053. * Indicates that the scene should check if the rendering now needs a prepass
  26054. */
  26055. protected _markScenePrePassDirty(): void;
  26056. /**
  26057. * Indicates that we need to re-calculated for all submeshes
  26058. */
  26059. protected _markAllSubMeshesAsAllDirty(): void;
  26060. /**
  26061. * Indicates that image processing needs to be re-calculated for all submeshes
  26062. */
  26063. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26064. /**
  26065. * Indicates that textures need to be re-calculated for all submeshes
  26066. */
  26067. protected _markAllSubMeshesAsTexturesDirty(): void;
  26068. /**
  26069. * Indicates that fresnel needs to be re-calculated for all submeshes
  26070. */
  26071. protected _markAllSubMeshesAsFresnelDirty(): void;
  26072. /**
  26073. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26074. */
  26075. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26076. /**
  26077. * Indicates that lights need to be re-calculated for all submeshes
  26078. */
  26079. protected _markAllSubMeshesAsLightsDirty(): void;
  26080. /**
  26081. * Indicates that attributes need to be re-calculated for all submeshes
  26082. */
  26083. protected _markAllSubMeshesAsAttributesDirty(): void;
  26084. /**
  26085. * Indicates that misc needs to be re-calculated for all submeshes
  26086. */
  26087. protected _markAllSubMeshesAsMiscDirty(): void;
  26088. /**
  26089. * Indicates that textures and misc need to be re-calculated for all submeshes
  26090. */
  26091. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26092. /**
  26093. * Sets the required values to the prepass renderer.
  26094. * @param prePassRenderer defines the prepass renderer to setup.
  26095. * @returns true if the pre pass is needed.
  26096. */
  26097. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26098. /**
  26099. * Disposes the material
  26100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26103. */
  26104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26105. /** @hidden */
  26106. private releaseVertexArrayObject;
  26107. /**
  26108. * Serializes this material
  26109. * @returns the serialized material object
  26110. */
  26111. serialize(): any;
  26112. /**
  26113. * Creates a material from parsed material data
  26114. * @param parsedMaterial defines parsed material data
  26115. * @param scene defines the hosting scene
  26116. * @param rootUrl defines the root URL to use to load textures
  26117. * @returns a new material
  26118. */
  26119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26120. }
  26121. }
  26122. declare module "babylonjs/Materials/multiMaterial" {
  26123. import { Nullable } from "babylonjs/types";
  26124. import { Scene } from "babylonjs/scene";
  26125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26128. import { Material } from "babylonjs/Materials/material";
  26129. /**
  26130. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26131. * separate meshes. This can be use to improve performances.
  26132. * @see https://doc.babylonjs.com/how_to/multi_materials
  26133. */
  26134. export class MultiMaterial extends Material {
  26135. private _subMaterials;
  26136. /**
  26137. * Gets or Sets the list of Materials used within the multi material.
  26138. * They need to be ordered according to the submeshes order in the associated mesh
  26139. */
  26140. get subMaterials(): Nullable<Material>[];
  26141. set subMaterials(value: Nullable<Material>[]);
  26142. /**
  26143. * Function used to align with Node.getChildren()
  26144. * @returns the list of Materials used within the multi material
  26145. */
  26146. getChildren(): Nullable<Material>[];
  26147. /**
  26148. * Instantiates a new Multi Material
  26149. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26150. * separate meshes. This can be use to improve performances.
  26151. * @see https://doc.babylonjs.com/how_to/multi_materials
  26152. * @param name Define the name in the scene
  26153. * @param scene Define the scene the material belongs to
  26154. */
  26155. constructor(name: string, scene: Scene);
  26156. private _hookArray;
  26157. /**
  26158. * Get one of the submaterial by its index in the submaterials array
  26159. * @param index The index to look the sub material at
  26160. * @returns The Material if the index has been defined
  26161. */
  26162. getSubMaterial(index: number): Nullable<Material>;
  26163. /**
  26164. * Get the list of active textures for the whole sub materials list.
  26165. * @returns All the textures that will be used during the rendering
  26166. */
  26167. getActiveTextures(): BaseTexture[];
  26168. /**
  26169. * Gets the current class name of the material e.g. "MultiMaterial"
  26170. * Mainly use in serialization.
  26171. * @returns the class name
  26172. */
  26173. getClassName(): string;
  26174. /**
  26175. * Checks if the material is ready to render the requested sub mesh
  26176. * @param mesh Define the mesh the submesh belongs to
  26177. * @param subMesh Define the sub mesh to look readyness for
  26178. * @param useInstances Define whether or not the material is used with instances
  26179. * @returns true if ready, otherwise false
  26180. */
  26181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26182. /**
  26183. * Clones the current material and its related sub materials
  26184. * @param name Define the name of the newly cloned material
  26185. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26186. * @returns the cloned material
  26187. */
  26188. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26189. /**
  26190. * Serializes the materials into a JSON representation.
  26191. * @returns the JSON representation
  26192. */
  26193. serialize(): any;
  26194. /**
  26195. * Dispose the material and release its associated resources
  26196. * @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)
  26197. * @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)
  26198. * @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)
  26199. */
  26200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26201. /**
  26202. * Creates a MultiMaterial from parsed MultiMaterial data.
  26203. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26204. * @param scene defines the hosting scene
  26205. * @returns a new MultiMaterial
  26206. */
  26207. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26208. }
  26209. }
  26210. declare module "babylonjs/Meshes/subMesh" {
  26211. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26213. import { Engine } from "babylonjs/Engines/engine";
  26214. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26215. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26216. import { Effect } from "babylonjs/Materials/effect";
  26217. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26218. import { Plane } from "babylonjs/Maths/math.plane";
  26219. import { Collider } from "babylonjs/Collisions/collider";
  26220. import { Material } from "babylonjs/Materials/material";
  26221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26223. import { Mesh } from "babylonjs/Meshes/mesh";
  26224. import { Ray } from "babylonjs/Culling/ray";
  26225. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26226. /**
  26227. * Defines a subdivision inside a mesh
  26228. */
  26229. export class SubMesh implements ICullable {
  26230. /** the material index to use */
  26231. materialIndex: number;
  26232. /** vertex index start */
  26233. verticesStart: number;
  26234. /** vertices count */
  26235. verticesCount: number;
  26236. /** index start */
  26237. indexStart: number;
  26238. /** indices count */
  26239. indexCount: number;
  26240. /** @hidden */
  26241. _materialDefines: Nullable<MaterialDefines>;
  26242. /** @hidden */
  26243. _materialEffect: Nullable<Effect>;
  26244. /** @hidden */
  26245. _effectOverride: Nullable<Effect>;
  26246. /**
  26247. * Gets material defines used by the effect associated to the sub mesh
  26248. */
  26249. get materialDefines(): Nullable<MaterialDefines>;
  26250. /**
  26251. * Sets material defines used by the effect associated to the sub mesh
  26252. */
  26253. set materialDefines(defines: Nullable<MaterialDefines>);
  26254. /**
  26255. * Gets associated effect
  26256. */
  26257. get effect(): Nullable<Effect>;
  26258. /**
  26259. * Sets associated effect (effect used to render this submesh)
  26260. * @param effect defines the effect to associate with
  26261. * @param defines defines the set of defines used to compile this effect
  26262. */
  26263. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26264. /** @hidden */
  26265. _linesIndexCount: number;
  26266. private _mesh;
  26267. private _renderingMesh;
  26268. private _boundingInfo;
  26269. private _linesIndexBuffer;
  26270. /** @hidden */
  26271. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26272. /** @hidden */
  26273. _trianglePlanes: Plane[];
  26274. /** @hidden */
  26275. _lastColliderTransformMatrix: Nullable<Matrix>;
  26276. /** @hidden */
  26277. _renderId: number;
  26278. /** @hidden */
  26279. _alphaIndex: number;
  26280. /** @hidden */
  26281. _distanceToCamera: number;
  26282. /** @hidden */
  26283. _id: number;
  26284. private _currentMaterial;
  26285. /**
  26286. * Add a new submesh to a mesh
  26287. * @param materialIndex defines the material index to use
  26288. * @param verticesStart defines vertex index start
  26289. * @param verticesCount defines vertices count
  26290. * @param indexStart defines index start
  26291. * @param indexCount defines indices count
  26292. * @param mesh defines the parent mesh
  26293. * @param renderingMesh defines an optional rendering mesh
  26294. * @param createBoundingBox defines if bounding box should be created for this submesh
  26295. * @returns the new submesh
  26296. */
  26297. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26298. /**
  26299. * Creates a new submesh
  26300. * @param materialIndex defines the material index to use
  26301. * @param verticesStart defines vertex index start
  26302. * @param verticesCount defines vertices count
  26303. * @param indexStart defines index start
  26304. * @param indexCount defines indices count
  26305. * @param mesh defines the parent mesh
  26306. * @param renderingMesh defines an optional rendering mesh
  26307. * @param createBoundingBox defines if bounding box should be created for this submesh
  26308. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26309. */
  26310. constructor(
  26311. /** the material index to use */
  26312. materialIndex: number,
  26313. /** vertex index start */
  26314. verticesStart: number,
  26315. /** vertices count */
  26316. verticesCount: number,
  26317. /** index start */
  26318. indexStart: number,
  26319. /** indices count */
  26320. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26321. /**
  26322. * Returns true if this submesh covers the entire parent mesh
  26323. * @ignorenaming
  26324. */
  26325. get IsGlobal(): boolean;
  26326. /**
  26327. * Returns the submesh BoudingInfo object
  26328. * @returns current bounding info (or mesh's one if the submesh is global)
  26329. */
  26330. getBoundingInfo(): BoundingInfo;
  26331. /**
  26332. * Sets the submesh BoundingInfo
  26333. * @param boundingInfo defines the new bounding info to use
  26334. * @returns the SubMesh
  26335. */
  26336. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26337. /**
  26338. * Returns the mesh of the current submesh
  26339. * @return the parent mesh
  26340. */
  26341. getMesh(): AbstractMesh;
  26342. /**
  26343. * Returns the rendering mesh of the submesh
  26344. * @returns the rendering mesh (could be different from parent mesh)
  26345. */
  26346. getRenderingMesh(): Mesh;
  26347. /**
  26348. * Returns the replacement mesh of the submesh
  26349. * @returns the replacement mesh (could be different from parent mesh)
  26350. */
  26351. getReplacementMesh(): Nullable<AbstractMesh>;
  26352. /**
  26353. * Returns the effective mesh of the submesh
  26354. * @returns the effective mesh (could be different from parent mesh)
  26355. */
  26356. getEffectiveMesh(): AbstractMesh;
  26357. /**
  26358. * Returns the submesh material
  26359. * @returns null or the current material
  26360. */
  26361. getMaterial(): Nullable<Material>;
  26362. private _IsMultiMaterial;
  26363. /**
  26364. * Sets a new updated BoundingInfo object to the submesh
  26365. * @param data defines an optional position array to use to determine the bounding info
  26366. * @returns the SubMesh
  26367. */
  26368. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26369. /** @hidden */
  26370. _checkCollision(collider: Collider): boolean;
  26371. /**
  26372. * Updates the submesh BoundingInfo
  26373. * @param world defines the world matrix to use to update the bounding info
  26374. * @returns the submesh
  26375. */
  26376. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26377. /**
  26378. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26379. * @param frustumPlanes defines the frustum planes
  26380. * @returns true if the submesh is intersecting with the frustum
  26381. */
  26382. isInFrustum(frustumPlanes: Plane[]): boolean;
  26383. /**
  26384. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26385. * @param frustumPlanes defines the frustum planes
  26386. * @returns true if the submesh is inside the frustum
  26387. */
  26388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26389. /**
  26390. * Renders the submesh
  26391. * @param enableAlphaMode defines if alpha needs to be used
  26392. * @returns the submesh
  26393. */
  26394. render(enableAlphaMode: boolean): SubMesh;
  26395. /**
  26396. * @hidden
  26397. */
  26398. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26399. /**
  26400. * Checks if the submesh intersects with a ray
  26401. * @param ray defines the ray to test
  26402. * @returns true is the passed ray intersects the submesh bounding box
  26403. */
  26404. canIntersects(ray: Ray): boolean;
  26405. /**
  26406. * Intersects current submesh with a ray
  26407. * @param ray defines the ray to test
  26408. * @param positions defines mesh's positions array
  26409. * @param indices defines mesh's indices array
  26410. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26412. * @returns intersection info or null if no intersection
  26413. */
  26414. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26415. /** @hidden */
  26416. private _intersectLines;
  26417. /** @hidden */
  26418. private _intersectUnIndexedLines;
  26419. /** @hidden */
  26420. private _intersectTriangles;
  26421. /** @hidden */
  26422. private _intersectUnIndexedTriangles;
  26423. /** @hidden */
  26424. _rebuild(): void;
  26425. /**
  26426. * Creates a new submesh from the passed mesh
  26427. * @param newMesh defines the new hosting mesh
  26428. * @param newRenderingMesh defines an optional rendering mesh
  26429. * @returns the new submesh
  26430. */
  26431. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26432. /**
  26433. * Release associated resources
  26434. */
  26435. dispose(): void;
  26436. /**
  26437. * Gets the class name
  26438. * @returns the string "SubMesh".
  26439. */
  26440. getClassName(): string;
  26441. /**
  26442. * Creates a new submesh from indices data
  26443. * @param materialIndex the index of the main mesh material
  26444. * @param startIndex the index where to start the copy in the mesh indices array
  26445. * @param indexCount the number of indices to copy then from the startIndex
  26446. * @param mesh the main mesh to create the submesh from
  26447. * @param renderingMesh the optional rendering mesh
  26448. * @returns a new submesh
  26449. */
  26450. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26451. }
  26452. }
  26453. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26454. /**
  26455. * Class used to represent data loading progression
  26456. */
  26457. export class SceneLoaderFlags {
  26458. private static _ForceFullSceneLoadingForIncremental;
  26459. private static _ShowLoadingScreen;
  26460. private static _CleanBoneMatrixWeights;
  26461. private static _loggingLevel;
  26462. /**
  26463. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26464. */
  26465. static get ForceFullSceneLoadingForIncremental(): boolean;
  26466. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26467. /**
  26468. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26469. */
  26470. static get ShowLoadingScreen(): boolean;
  26471. static set ShowLoadingScreen(value: boolean);
  26472. /**
  26473. * Defines the current logging level (while loading the scene)
  26474. * @ignorenaming
  26475. */
  26476. static get loggingLevel(): number;
  26477. static set loggingLevel(value: number);
  26478. /**
  26479. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26480. */
  26481. static get CleanBoneMatrixWeights(): boolean;
  26482. static set CleanBoneMatrixWeights(value: boolean);
  26483. }
  26484. }
  26485. declare module "babylonjs/Meshes/geometry" {
  26486. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26487. import { Scene } from "babylonjs/scene";
  26488. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26489. import { Engine } from "babylonjs/Engines/engine";
  26490. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26491. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26492. import { Effect } from "babylonjs/Materials/effect";
  26493. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26495. import { Mesh } from "babylonjs/Meshes/mesh";
  26496. /**
  26497. * Class used to store geometry data (vertex buffers + index buffer)
  26498. */
  26499. export class Geometry implements IGetSetVerticesData {
  26500. /**
  26501. * Gets or sets the ID of the geometry
  26502. */
  26503. id: string;
  26504. /**
  26505. * Gets or sets the unique ID of the geometry
  26506. */
  26507. uniqueId: number;
  26508. /**
  26509. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26510. */
  26511. delayLoadState: number;
  26512. /**
  26513. * Gets the file containing the data to load when running in delay load state
  26514. */
  26515. delayLoadingFile: Nullable<string>;
  26516. /**
  26517. * Callback called when the geometry is updated
  26518. */
  26519. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26520. private _scene;
  26521. private _engine;
  26522. private _meshes;
  26523. private _totalVertices;
  26524. /** @hidden */
  26525. _indices: IndicesArray;
  26526. /** @hidden */
  26527. _vertexBuffers: {
  26528. [key: string]: VertexBuffer;
  26529. };
  26530. private _isDisposed;
  26531. private _extend;
  26532. private _boundingBias;
  26533. /** @hidden */
  26534. _delayInfo: Array<string>;
  26535. private _indexBuffer;
  26536. private _indexBufferIsUpdatable;
  26537. /** @hidden */
  26538. _boundingInfo: Nullable<BoundingInfo>;
  26539. /** @hidden */
  26540. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26541. /** @hidden */
  26542. _softwareSkinningFrameId: number;
  26543. private _vertexArrayObjects;
  26544. private _updatable;
  26545. /** @hidden */
  26546. _positions: Nullable<Vector3[]>;
  26547. /**
  26548. * 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
  26549. */
  26550. get boundingBias(): Vector2;
  26551. /**
  26552. * 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
  26553. */
  26554. set boundingBias(value: Vector2);
  26555. /**
  26556. * Static function used to attach a new empty geometry to a mesh
  26557. * @param mesh defines the mesh to attach the geometry to
  26558. * @returns the new Geometry
  26559. */
  26560. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26561. /** Get the list of meshes using this geometry */
  26562. get meshes(): Mesh[];
  26563. /**
  26564. * 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
  26565. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26566. */
  26567. useBoundingInfoFromGeometry: boolean;
  26568. /**
  26569. * Creates a new geometry
  26570. * @param id defines the unique ID
  26571. * @param scene defines the hosting scene
  26572. * @param vertexData defines the VertexData used to get geometry data
  26573. * @param updatable defines if geometry must be updatable (false by default)
  26574. * @param mesh defines the mesh that will be associated with the geometry
  26575. */
  26576. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26577. /**
  26578. * Gets the current extend of the geometry
  26579. */
  26580. get extend(): {
  26581. minimum: Vector3;
  26582. maximum: Vector3;
  26583. };
  26584. /**
  26585. * Gets the hosting scene
  26586. * @returns the hosting Scene
  26587. */
  26588. getScene(): Scene;
  26589. /**
  26590. * Gets the hosting engine
  26591. * @returns the hosting Engine
  26592. */
  26593. getEngine(): Engine;
  26594. /**
  26595. * Defines if the geometry is ready to use
  26596. * @returns true if the geometry is ready to be used
  26597. */
  26598. isReady(): boolean;
  26599. /**
  26600. * Gets a value indicating that the geometry should not be serialized
  26601. */
  26602. get doNotSerialize(): boolean;
  26603. /** @hidden */
  26604. _rebuild(): void;
  26605. /**
  26606. * Affects all geometry data in one call
  26607. * @param vertexData defines the geometry data
  26608. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26609. */
  26610. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26611. /**
  26612. * Set specific vertex data
  26613. * @param kind defines the data kind (Position, normal, etc...)
  26614. * @param data defines the vertex data to use
  26615. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26616. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26617. */
  26618. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26619. /**
  26620. * Removes a specific vertex data
  26621. * @param kind defines the data kind (Position, normal, etc...)
  26622. */
  26623. removeVerticesData(kind: string): void;
  26624. /**
  26625. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26626. * @param buffer defines the vertex buffer to use
  26627. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26628. */
  26629. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26630. /**
  26631. * Update a specific vertex buffer
  26632. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26633. * It will do nothing if the buffer is not updatable
  26634. * @param kind defines the data kind (Position, normal, etc...)
  26635. * @param data defines the data to use
  26636. * @param offset defines the offset in the target buffer where to store the data
  26637. * @param useBytes set to true if the offset is in bytes
  26638. */
  26639. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26640. /**
  26641. * Update a specific vertex buffer
  26642. * This function will create a new buffer if the current one is not updatable
  26643. * @param kind defines the data kind (Position, normal, etc...)
  26644. * @param data defines the data to use
  26645. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26646. */
  26647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26648. private _updateBoundingInfo;
  26649. /** @hidden */
  26650. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26651. /**
  26652. * Gets total number of vertices
  26653. * @returns the total number of vertices
  26654. */
  26655. getTotalVertices(): number;
  26656. /**
  26657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26658. * @param kind defines the data kind (Position, normal, etc...)
  26659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26661. * @returns a float array containing vertex data
  26662. */
  26663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26664. /**
  26665. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26666. * @param kind defines the data kind (Position, normal, etc...)
  26667. * @returns true if the vertex buffer with the specified kind is updatable
  26668. */
  26669. isVertexBufferUpdatable(kind: string): boolean;
  26670. /**
  26671. * Gets a specific vertex buffer
  26672. * @param kind defines the data kind (Position, normal, etc...)
  26673. * @returns a VertexBuffer
  26674. */
  26675. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26676. /**
  26677. * Returns all vertex buffers
  26678. * @return an object holding all vertex buffers indexed by kind
  26679. */
  26680. getVertexBuffers(): Nullable<{
  26681. [key: string]: VertexBuffer;
  26682. }>;
  26683. /**
  26684. * Gets a boolean indicating if specific vertex buffer is present
  26685. * @param kind defines the data kind (Position, normal, etc...)
  26686. * @returns true if data is present
  26687. */
  26688. isVerticesDataPresent(kind: string): boolean;
  26689. /**
  26690. * Gets a list of all attached data kinds (Position, normal, etc...)
  26691. * @returns a list of string containing all kinds
  26692. */
  26693. getVerticesDataKinds(): string[];
  26694. /**
  26695. * Update index buffer
  26696. * @param indices defines the indices to store in the index buffer
  26697. * @param offset defines the offset in the target buffer where to store the data
  26698. * @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)
  26699. */
  26700. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26701. /**
  26702. * Creates a new index buffer
  26703. * @param indices defines the indices to store in the index buffer
  26704. * @param totalVertices defines the total number of vertices (could be null)
  26705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26706. */
  26707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26708. /**
  26709. * Return the total number of indices
  26710. * @returns the total number of indices
  26711. */
  26712. getTotalIndices(): number;
  26713. /**
  26714. * Gets the index buffer array
  26715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26717. * @returns the index buffer array
  26718. */
  26719. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26720. /**
  26721. * Gets the index buffer
  26722. * @return the index buffer
  26723. */
  26724. getIndexBuffer(): Nullable<DataBuffer>;
  26725. /** @hidden */
  26726. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26727. /**
  26728. * Release the associated resources for a specific mesh
  26729. * @param mesh defines the source mesh
  26730. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26731. */
  26732. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26733. /**
  26734. * Apply current geometry to a given mesh
  26735. * @param mesh defines the mesh to apply geometry to
  26736. */
  26737. applyToMesh(mesh: Mesh): void;
  26738. private _updateExtend;
  26739. private _applyToMesh;
  26740. private notifyUpdate;
  26741. /**
  26742. * Load the geometry if it was flagged as delay loaded
  26743. * @param scene defines the hosting scene
  26744. * @param onLoaded defines a callback called when the geometry is loaded
  26745. */
  26746. load(scene: Scene, onLoaded?: () => void): void;
  26747. private _queueLoad;
  26748. /**
  26749. * Invert the geometry to move from a right handed system to a left handed one.
  26750. */
  26751. toLeftHanded(): void;
  26752. /** @hidden */
  26753. _resetPointsArrayCache(): void;
  26754. /** @hidden */
  26755. _generatePointsArray(): boolean;
  26756. /**
  26757. * Gets a value indicating if the geometry is disposed
  26758. * @returns true if the geometry was disposed
  26759. */
  26760. isDisposed(): boolean;
  26761. private _disposeVertexArrayObjects;
  26762. /**
  26763. * Free all associated resources
  26764. */
  26765. dispose(): void;
  26766. /**
  26767. * Clone the current geometry into a new geometry
  26768. * @param id defines the unique ID of the new geometry
  26769. * @returns a new geometry object
  26770. */
  26771. copy(id: string): Geometry;
  26772. /**
  26773. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26774. * @return a JSON representation of the current geometry data (without the vertices data)
  26775. */
  26776. serialize(): any;
  26777. private toNumberArray;
  26778. /**
  26779. * Serialize all vertices data into a JSON oject
  26780. * @returns a JSON representation of the current geometry data
  26781. */
  26782. serializeVerticeData(): any;
  26783. /**
  26784. * Extracts a clone of a mesh geometry
  26785. * @param mesh defines the source mesh
  26786. * @param id defines the unique ID of the new geometry object
  26787. * @returns the new geometry object
  26788. */
  26789. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26790. /**
  26791. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26793. * Be aware Math.random() could cause collisions, but:
  26794. * "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"
  26795. * @returns a string containing a new GUID
  26796. */
  26797. static RandomId(): string;
  26798. /** @hidden */
  26799. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26800. private static _CleanMatricesWeights;
  26801. /**
  26802. * Create a new geometry from persisted data (Using .babylon file format)
  26803. * @param parsedVertexData defines the persisted data
  26804. * @param scene defines the hosting scene
  26805. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26806. * @returns the new geometry object
  26807. */
  26808. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26809. }
  26810. }
  26811. declare module "babylonjs/Meshes/mesh.vertexData" {
  26812. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26813. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26814. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26815. import { Geometry } from "babylonjs/Meshes/geometry";
  26816. import { Mesh } from "babylonjs/Meshes/mesh";
  26817. /**
  26818. * Define an interface for all classes that will get and set the data on vertices
  26819. */
  26820. export interface IGetSetVerticesData {
  26821. /**
  26822. * Gets a boolean indicating if specific vertex data is present
  26823. * @param kind defines the vertex data kind to use
  26824. * @returns true is data kind is present
  26825. */
  26826. isVerticesDataPresent(kind: string): boolean;
  26827. /**
  26828. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26829. * @param kind defines the data kind (Position, normal, etc...)
  26830. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26831. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26832. * @returns a float array containing vertex data
  26833. */
  26834. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26835. /**
  26836. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26837. * @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.
  26838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26839. * @returns the indices array or an empty array if the mesh has no geometry
  26840. */
  26841. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26842. /**
  26843. * Set specific vertex data
  26844. * @param kind defines the data kind (Position, normal, etc...)
  26845. * @param data defines the vertex data to use
  26846. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26847. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26848. */
  26849. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26850. /**
  26851. * Update a specific associated vertex buffer
  26852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26853. * - VertexBuffer.PositionKind
  26854. * - VertexBuffer.UVKind
  26855. * - VertexBuffer.UV2Kind
  26856. * - VertexBuffer.UV3Kind
  26857. * - VertexBuffer.UV4Kind
  26858. * - VertexBuffer.UV5Kind
  26859. * - VertexBuffer.UV6Kind
  26860. * - VertexBuffer.ColorKind
  26861. * - VertexBuffer.MatricesIndicesKind
  26862. * - VertexBuffer.MatricesIndicesExtraKind
  26863. * - VertexBuffer.MatricesWeightsKind
  26864. * - VertexBuffer.MatricesWeightsExtraKind
  26865. * @param data defines the data source
  26866. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26867. * @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)
  26868. */
  26869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26870. /**
  26871. * Creates a new index buffer
  26872. * @param indices defines the indices to store in the index buffer
  26873. * @param totalVertices defines the total number of vertices (could be null)
  26874. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26875. */
  26876. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26877. }
  26878. /**
  26879. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26880. */
  26881. export class VertexData {
  26882. /**
  26883. * Mesh side orientation : usually the external or front surface
  26884. */
  26885. static readonly FRONTSIDE: number;
  26886. /**
  26887. * Mesh side orientation : usually the internal or back surface
  26888. */
  26889. static readonly BACKSIDE: number;
  26890. /**
  26891. * Mesh side orientation : both internal and external or front and back surfaces
  26892. */
  26893. static readonly DOUBLESIDE: number;
  26894. /**
  26895. * Mesh side orientation : by default, `FRONTSIDE`
  26896. */
  26897. static readonly DEFAULTSIDE: number;
  26898. /**
  26899. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26900. */
  26901. positions: Nullable<FloatArray>;
  26902. /**
  26903. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26904. */
  26905. normals: Nullable<FloatArray>;
  26906. /**
  26907. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26908. */
  26909. tangents: Nullable<FloatArray>;
  26910. /**
  26911. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26912. */
  26913. uvs: Nullable<FloatArray>;
  26914. /**
  26915. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26916. */
  26917. uvs2: Nullable<FloatArray>;
  26918. /**
  26919. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26920. */
  26921. uvs3: Nullable<FloatArray>;
  26922. /**
  26923. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26924. */
  26925. uvs4: Nullable<FloatArray>;
  26926. /**
  26927. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26928. */
  26929. uvs5: Nullable<FloatArray>;
  26930. /**
  26931. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26932. */
  26933. uvs6: Nullable<FloatArray>;
  26934. /**
  26935. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26936. */
  26937. colors: Nullable<FloatArray>;
  26938. /**
  26939. * 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).
  26940. */
  26941. matricesIndices: Nullable<FloatArray>;
  26942. /**
  26943. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26944. */
  26945. matricesWeights: Nullable<FloatArray>;
  26946. /**
  26947. * An array extending the number of possible indices
  26948. */
  26949. matricesIndicesExtra: Nullable<FloatArray>;
  26950. /**
  26951. * An array extending the number of possible weights when the number of indices is extended
  26952. */
  26953. matricesWeightsExtra: Nullable<FloatArray>;
  26954. /**
  26955. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26956. */
  26957. indices: Nullable<IndicesArray>;
  26958. /**
  26959. * Uses the passed data array to set the set the values for the specified kind of data
  26960. * @param data a linear array of floating numbers
  26961. * @param kind the type of data that is being set, eg positions, colors etc
  26962. */
  26963. set(data: FloatArray, kind: string): void;
  26964. /**
  26965. * Associates the vertexData to the passed Mesh.
  26966. * Sets it as updatable or not (default `false`)
  26967. * @param mesh the mesh the vertexData is applied to
  26968. * @param updatable when used and having the value true allows new data to update the vertexData
  26969. * @returns the VertexData
  26970. */
  26971. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26972. /**
  26973. * Associates the vertexData to the passed Geometry.
  26974. * Sets it as updatable or not (default `false`)
  26975. * @param geometry the geometry the vertexData is applied to
  26976. * @param updatable when used and having the value true allows new data to update the vertexData
  26977. * @returns VertexData
  26978. */
  26979. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26980. /**
  26981. * Updates the associated mesh
  26982. * @param mesh the mesh to be updated
  26983. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26984. * @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
  26985. * @returns VertexData
  26986. */
  26987. updateMesh(mesh: Mesh): VertexData;
  26988. /**
  26989. * Updates the associated geometry
  26990. * @param geometry the geometry to be updated
  26991. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26992. * @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
  26993. * @returns VertexData.
  26994. */
  26995. updateGeometry(geometry: Geometry): VertexData;
  26996. private _applyTo;
  26997. private _update;
  26998. /**
  26999. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27000. * @param matrix the transforming matrix
  27001. * @returns the VertexData
  27002. */
  27003. transform(matrix: Matrix): VertexData;
  27004. /**
  27005. * Merges the passed VertexData into the current one
  27006. * @param other the VertexData to be merged into the current one
  27007. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27008. * @returns the modified VertexData
  27009. */
  27010. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27011. private _mergeElement;
  27012. private _validate;
  27013. /**
  27014. * Serializes the VertexData
  27015. * @returns a serialized object
  27016. */
  27017. serialize(): any;
  27018. /**
  27019. * Extracts the vertexData from a mesh
  27020. * @param mesh the mesh from which to extract the VertexData
  27021. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27022. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27023. * @returns the object VertexData associated to the passed mesh
  27024. */
  27025. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27026. /**
  27027. * Extracts the vertexData from the geometry
  27028. * @param geometry the geometry from which to extract the VertexData
  27029. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27030. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27031. * @returns the object VertexData associated to the passed mesh
  27032. */
  27033. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27034. private static _ExtractFrom;
  27035. /**
  27036. * Creates the VertexData for a Ribbon
  27037. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27038. * * pathArray array of paths, each of which an array of successive Vector3
  27039. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27040. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27041. * * 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
  27042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27043. * * 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)
  27044. * * 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)
  27045. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27046. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27047. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27048. * @returns the VertexData of the ribbon
  27049. */
  27050. static CreateRibbon(options: {
  27051. pathArray: Vector3[][];
  27052. closeArray?: boolean;
  27053. closePath?: boolean;
  27054. offset?: number;
  27055. sideOrientation?: number;
  27056. frontUVs?: Vector4;
  27057. backUVs?: Vector4;
  27058. invertUV?: boolean;
  27059. uvs?: Vector2[];
  27060. colors?: Color4[];
  27061. }): VertexData;
  27062. /**
  27063. * Creates the VertexData for a box
  27064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27065. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27066. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27067. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27068. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27069. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27070. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27072. * * 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)
  27073. * * 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)
  27074. * @returns the VertexData of the box
  27075. */
  27076. static CreateBox(options: {
  27077. size?: number;
  27078. width?: number;
  27079. height?: number;
  27080. depth?: number;
  27081. faceUV?: Vector4[];
  27082. faceColors?: Color4[];
  27083. sideOrientation?: number;
  27084. frontUVs?: Vector4;
  27085. backUVs?: Vector4;
  27086. }): VertexData;
  27087. /**
  27088. * Creates the VertexData for a tiled box
  27089. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27090. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27091. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27092. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27094. * @returns the VertexData of the box
  27095. */
  27096. static CreateTiledBox(options: {
  27097. pattern?: number;
  27098. width?: number;
  27099. height?: number;
  27100. depth?: number;
  27101. tileSize?: number;
  27102. tileWidth?: number;
  27103. tileHeight?: number;
  27104. alignHorizontal?: number;
  27105. alignVertical?: number;
  27106. faceUV?: Vector4[];
  27107. faceColors?: Color4[];
  27108. sideOrientation?: number;
  27109. }): VertexData;
  27110. /**
  27111. * Creates the VertexData for a tiled plane
  27112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27113. * * pattern a limited pattern arrangement depending on the number
  27114. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27115. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27116. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27118. * * 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)
  27119. * * 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)
  27120. * @returns the VertexData of the tiled plane
  27121. */
  27122. static CreateTiledPlane(options: {
  27123. pattern?: number;
  27124. tileSize?: number;
  27125. tileWidth?: number;
  27126. tileHeight?: number;
  27127. size?: number;
  27128. width?: number;
  27129. height?: number;
  27130. alignHorizontal?: number;
  27131. alignVertical?: number;
  27132. sideOrientation?: number;
  27133. frontUVs?: Vector4;
  27134. backUVs?: Vector4;
  27135. }): VertexData;
  27136. /**
  27137. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27139. * * segments sets the number of horizontal strips optional, default 32
  27140. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27141. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27142. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27143. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27144. * * 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
  27145. * * 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
  27146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27147. * * 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)
  27148. * * 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)
  27149. * @returns the VertexData of the ellipsoid
  27150. */
  27151. static CreateSphere(options: {
  27152. segments?: number;
  27153. diameter?: number;
  27154. diameterX?: number;
  27155. diameterY?: number;
  27156. diameterZ?: number;
  27157. arc?: number;
  27158. slice?: number;
  27159. sideOrientation?: number;
  27160. frontUVs?: Vector4;
  27161. backUVs?: Vector4;
  27162. }): VertexData;
  27163. /**
  27164. * Creates the VertexData for a cylinder, cone or prism
  27165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27166. * * height sets the height (y direction) of the cylinder, optional, default 2
  27167. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27168. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27169. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27170. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27171. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27172. * * 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
  27173. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27174. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27175. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27176. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27178. * * 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)
  27179. * * 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)
  27180. * @returns the VertexData of the cylinder, cone or prism
  27181. */
  27182. static CreateCylinder(options: {
  27183. height?: number;
  27184. diameterTop?: number;
  27185. diameterBottom?: number;
  27186. diameter?: number;
  27187. tessellation?: number;
  27188. subdivisions?: number;
  27189. arc?: number;
  27190. faceColors?: Color4[];
  27191. faceUV?: Vector4[];
  27192. hasRings?: boolean;
  27193. enclose?: boolean;
  27194. sideOrientation?: number;
  27195. frontUVs?: Vector4;
  27196. backUVs?: Vector4;
  27197. }): VertexData;
  27198. /**
  27199. * Creates the VertexData for a torus
  27200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27201. * * diameter the diameter of the torus, optional default 1
  27202. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27205. * * 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)
  27206. * * 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)
  27207. * @returns the VertexData of the torus
  27208. */
  27209. static CreateTorus(options: {
  27210. diameter?: number;
  27211. thickness?: number;
  27212. tessellation?: number;
  27213. sideOrientation?: number;
  27214. frontUVs?: Vector4;
  27215. backUVs?: Vector4;
  27216. }): VertexData;
  27217. /**
  27218. * Creates the VertexData of the LineSystem
  27219. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27220. * - lines an array of lines, each line being an array of successive Vector3
  27221. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27222. * @returns the VertexData of the LineSystem
  27223. */
  27224. static CreateLineSystem(options: {
  27225. lines: Vector3[][];
  27226. colors?: Nullable<Color4[][]>;
  27227. }): VertexData;
  27228. /**
  27229. * Create the VertexData for a DashedLines
  27230. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27231. * - points an array successive Vector3
  27232. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27233. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27234. * - dashNb the intended total number of dashes, optional, default 200
  27235. * @returns the VertexData for the DashedLines
  27236. */
  27237. static CreateDashedLines(options: {
  27238. points: Vector3[];
  27239. dashSize?: number;
  27240. gapSize?: number;
  27241. dashNb?: number;
  27242. }): VertexData;
  27243. /**
  27244. * Creates the VertexData for a Ground
  27245. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27246. * - width the width (x direction) of the ground, optional, default 1
  27247. * - height the height (z direction) of the ground, optional, default 1
  27248. * - subdivisions the number of subdivisions per side, optional, default 1
  27249. * @returns the VertexData of the Ground
  27250. */
  27251. static CreateGround(options: {
  27252. width?: number;
  27253. height?: number;
  27254. subdivisions?: number;
  27255. subdivisionsX?: number;
  27256. subdivisionsY?: number;
  27257. }): VertexData;
  27258. /**
  27259. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27260. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27261. * * xmin the ground minimum X coordinate, optional, default -1
  27262. * * zmin the ground minimum Z coordinate, optional, default -1
  27263. * * xmax the ground maximum X coordinate, optional, default 1
  27264. * * zmax the ground maximum Z coordinate, optional, default 1
  27265. * * 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}
  27266. * * 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}
  27267. * @returns the VertexData of the TiledGround
  27268. */
  27269. static CreateTiledGround(options: {
  27270. xmin: number;
  27271. zmin: number;
  27272. xmax: number;
  27273. zmax: number;
  27274. subdivisions?: {
  27275. w: number;
  27276. h: number;
  27277. };
  27278. precision?: {
  27279. w: number;
  27280. h: number;
  27281. };
  27282. }): VertexData;
  27283. /**
  27284. * Creates the VertexData of the Ground designed from a heightmap
  27285. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27286. * * width the width (x direction) of the ground
  27287. * * height the height (z direction) of the ground
  27288. * * subdivisions the number of subdivisions per side
  27289. * * minHeight the minimum altitude on the ground, optional, default 0
  27290. * * maxHeight the maximum altitude on the ground, optional default 1
  27291. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27292. * * buffer the array holding the image color data
  27293. * * bufferWidth the width of image
  27294. * * bufferHeight the height of image
  27295. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27296. * @returns the VertexData of the Ground designed from a heightmap
  27297. */
  27298. static CreateGroundFromHeightMap(options: {
  27299. width: number;
  27300. height: number;
  27301. subdivisions: number;
  27302. minHeight: number;
  27303. maxHeight: number;
  27304. colorFilter: Color3;
  27305. buffer: Uint8Array;
  27306. bufferWidth: number;
  27307. bufferHeight: number;
  27308. alphaFilter: number;
  27309. }): VertexData;
  27310. /**
  27311. * Creates the VertexData for a Plane
  27312. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27313. * * size sets the width and height of the plane to the value of size, optional default 1
  27314. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27315. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27317. * * 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)
  27318. * * 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)
  27319. * @returns the VertexData of the box
  27320. */
  27321. static CreatePlane(options: {
  27322. size?: number;
  27323. width?: number;
  27324. height?: number;
  27325. sideOrientation?: number;
  27326. frontUVs?: Vector4;
  27327. backUVs?: Vector4;
  27328. }): VertexData;
  27329. /**
  27330. * Creates the VertexData of the Disc or regular Polygon
  27331. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27332. * * radius the radius of the disc, optional default 0.5
  27333. * * tessellation the number of polygon sides, optional, default 64
  27334. * * 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
  27335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27336. * * 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)
  27337. * * 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)
  27338. * @returns the VertexData of the box
  27339. */
  27340. static CreateDisc(options: {
  27341. radius?: number;
  27342. tessellation?: number;
  27343. arc?: number;
  27344. sideOrientation?: number;
  27345. frontUVs?: Vector4;
  27346. backUVs?: Vector4;
  27347. }): VertexData;
  27348. /**
  27349. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27350. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27351. * @param polygon a mesh built from polygonTriangulation.build()
  27352. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27353. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27354. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27355. * @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)
  27356. * @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)
  27357. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27358. * @returns the VertexData of the Polygon
  27359. */
  27360. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27361. /**
  27362. * Creates the VertexData of the IcoSphere
  27363. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27364. * * radius the radius of the IcoSphere, optional default 1
  27365. * * radiusX allows stretching in the x direction, optional, default radius
  27366. * * radiusY allows stretching in the y direction, optional, default radius
  27367. * * radiusZ allows stretching in the z direction, optional, default radius
  27368. * * flat when true creates a flat shaded mesh, optional, default true
  27369. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27371. * * 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)
  27372. * * 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)
  27373. * @returns the VertexData of the IcoSphere
  27374. */
  27375. static CreateIcoSphere(options: {
  27376. radius?: number;
  27377. radiusX?: number;
  27378. radiusY?: number;
  27379. radiusZ?: number;
  27380. flat?: boolean;
  27381. subdivisions?: number;
  27382. sideOrientation?: number;
  27383. frontUVs?: Vector4;
  27384. backUVs?: Vector4;
  27385. }): VertexData;
  27386. /**
  27387. * Creates the VertexData for a Polyhedron
  27388. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27389. * * type provided types are:
  27390. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27391. * * 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)
  27392. * * size the size of the IcoSphere, optional default 1
  27393. * * sizeX allows stretching in the x direction, optional, default size
  27394. * * sizeY allows stretching in the y direction, optional, default size
  27395. * * sizeZ allows stretching in the z direction, optional, default size
  27396. * * 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
  27397. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27398. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27399. * * flat when true creates a flat shaded mesh, optional, default true
  27400. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27402. * * 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)
  27403. * * 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)
  27404. * @returns the VertexData of the Polyhedron
  27405. */
  27406. static CreatePolyhedron(options: {
  27407. type?: number;
  27408. size?: number;
  27409. sizeX?: number;
  27410. sizeY?: number;
  27411. sizeZ?: number;
  27412. custom?: any;
  27413. faceUV?: Vector4[];
  27414. faceColors?: Color4[];
  27415. flat?: boolean;
  27416. sideOrientation?: number;
  27417. frontUVs?: Vector4;
  27418. backUVs?: Vector4;
  27419. }): VertexData;
  27420. /**
  27421. * Creates the VertexData for a TorusKnot
  27422. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27423. * * radius the radius of the torus knot, optional, default 2
  27424. * * tube the thickness of the tube, optional, default 0.5
  27425. * * radialSegments the number of sides on each tube segments, optional, default 32
  27426. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27427. * * p the number of windings around the z axis, optional, default 2
  27428. * * q the number of windings around the x axis, optional, default 3
  27429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27430. * * 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)
  27431. * * 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)
  27432. * @returns the VertexData of the Torus Knot
  27433. */
  27434. static CreateTorusKnot(options: {
  27435. radius?: number;
  27436. tube?: number;
  27437. radialSegments?: number;
  27438. tubularSegments?: number;
  27439. p?: number;
  27440. q?: number;
  27441. sideOrientation?: number;
  27442. frontUVs?: Vector4;
  27443. backUVs?: Vector4;
  27444. }): VertexData;
  27445. /**
  27446. * Compute normals for given positions and indices
  27447. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27448. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27449. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27450. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27451. * * facetNormals : optional array of facet normals (vector3)
  27452. * * facetPositions : optional array of facet positions (vector3)
  27453. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27454. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27455. * * bInfo : optional bounding info, required for facetPartitioning computation
  27456. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27457. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27458. * * useRightHandedSystem: optional boolean to for right handed system computation
  27459. * * depthSort : optional boolean to enable the facet depth sort computation
  27460. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27461. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27462. */
  27463. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27464. facetNormals?: any;
  27465. facetPositions?: any;
  27466. facetPartitioning?: any;
  27467. ratio?: number;
  27468. bInfo?: any;
  27469. bbSize?: Vector3;
  27470. subDiv?: any;
  27471. useRightHandedSystem?: boolean;
  27472. depthSort?: boolean;
  27473. distanceTo?: Vector3;
  27474. depthSortedFacets?: any;
  27475. }): void;
  27476. /** @hidden */
  27477. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27478. /**
  27479. * Applies VertexData created from the imported parameters to the geometry
  27480. * @param parsedVertexData the parsed data from an imported file
  27481. * @param geometry the geometry to apply the VertexData to
  27482. */
  27483. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27484. }
  27485. }
  27486. declare module "babylonjs/Morph/morphTarget" {
  27487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27488. import { Observable } from "babylonjs/Misc/observable";
  27489. import { Nullable, FloatArray } from "babylonjs/types";
  27490. import { Scene } from "babylonjs/scene";
  27491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27493. /**
  27494. * Defines a target to use with MorphTargetManager
  27495. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27496. */
  27497. export class MorphTarget implements IAnimatable {
  27498. /** defines the name of the target */
  27499. name: string;
  27500. /**
  27501. * Gets or sets the list of animations
  27502. */
  27503. animations: import("babylonjs/Animations/animation").Animation[];
  27504. private _scene;
  27505. private _positions;
  27506. private _normals;
  27507. private _tangents;
  27508. private _uvs;
  27509. private _influence;
  27510. private _uniqueId;
  27511. /**
  27512. * Observable raised when the influence changes
  27513. */
  27514. onInfluenceChanged: Observable<boolean>;
  27515. /** @hidden */
  27516. _onDataLayoutChanged: Observable<void>;
  27517. /**
  27518. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27519. */
  27520. get influence(): number;
  27521. set influence(influence: number);
  27522. /**
  27523. * Gets or sets the id of the morph Target
  27524. */
  27525. id: string;
  27526. private _animationPropertiesOverride;
  27527. /**
  27528. * Gets or sets the animation properties override
  27529. */
  27530. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27531. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27532. /**
  27533. * Creates a new MorphTarget
  27534. * @param name defines the name of the target
  27535. * @param influence defines the influence to use
  27536. * @param scene defines the scene the morphtarget belongs to
  27537. */
  27538. constructor(
  27539. /** defines the name of the target */
  27540. name: string, influence?: number, scene?: Nullable<Scene>);
  27541. /**
  27542. * Gets the unique ID of this manager
  27543. */
  27544. get uniqueId(): number;
  27545. /**
  27546. * Gets a boolean defining if the target contains position data
  27547. */
  27548. get hasPositions(): boolean;
  27549. /**
  27550. * Gets a boolean defining if the target contains normal data
  27551. */
  27552. get hasNormals(): boolean;
  27553. /**
  27554. * Gets a boolean defining if the target contains tangent data
  27555. */
  27556. get hasTangents(): boolean;
  27557. /**
  27558. * Gets a boolean defining if the target contains texture coordinates data
  27559. */
  27560. get hasUVs(): boolean;
  27561. /**
  27562. * Affects position data to this target
  27563. * @param data defines the position data to use
  27564. */
  27565. setPositions(data: Nullable<FloatArray>): void;
  27566. /**
  27567. * Gets the position data stored in this target
  27568. * @returns a FloatArray containing the position data (or null if not present)
  27569. */
  27570. getPositions(): Nullable<FloatArray>;
  27571. /**
  27572. * Affects normal data to this target
  27573. * @param data defines the normal data to use
  27574. */
  27575. setNormals(data: Nullable<FloatArray>): void;
  27576. /**
  27577. * Gets the normal data stored in this target
  27578. * @returns a FloatArray containing the normal data (or null if not present)
  27579. */
  27580. getNormals(): Nullable<FloatArray>;
  27581. /**
  27582. * Affects tangent data to this target
  27583. * @param data defines the tangent data to use
  27584. */
  27585. setTangents(data: Nullable<FloatArray>): void;
  27586. /**
  27587. * Gets the tangent data stored in this target
  27588. * @returns a FloatArray containing the tangent data (or null if not present)
  27589. */
  27590. getTangents(): Nullable<FloatArray>;
  27591. /**
  27592. * Affects texture coordinates data to this target
  27593. * @param data defines the texture coordinates data to use
  27594. */
  27595. setUVs(data: Nullable<FloatArray>): void;
  27596. /**
  27597. * Gets the texture coordinates data stored in this target
  27598. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27599. */
  27600. getUVs(): Nullable<FloatArray>;
  27601. /**
  27602. * Clone the current target
  27603. * @returns a new MorphTarget
  27604. */
  27605. clone(): MorphTarget;
  27606. /**
  27607. * Serializes the current target into a Serialization object
  27608. * @returns the serialized object
  27609. */
  27610. serialize(): any;
  27611. /**
  27612. * Returns the string "MorphTarget"
  27613. * @returns "MorphTarget"
  27614. */
  27615. getClassName(): string;
  27616. /**
  27617. * Creates a new target from serialized data
  27618. * @param serializationObject defines the serialized data to use
  27619. * @returns a new MorphTarget
  27620. */
  27621. static Parse(serializationObject: any): MorphTarget;
  27622. /**
  27623. * Creates a MorphTarget from mesh data
  27624. * @param mesh defines the source mesh
  27625. * @param name defines the name to use for the new target
  27626. * @param influence defines the influence to attach to the target
  27627. * @returns a new MorphTarget
  27628. */
  27629. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27630. }
  27631. }
  27632. declare module "babylonjs/Morph/morphTargetManager" {
  27633. import { Nullable } from "babylonjs/types";
  27634. import { Scene } from "babylonjs/scene";
  27635. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27636. /**
  27637. * This class is used to deform meshes using morphing between different targets
  27638. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27639. */
  27640. export class MorphTargetManager {
  27641. private _targets;
  27642. private _targetInfluenceChangedObservers;
  27643. private _targetDataLayoutChangedObservers;
  27644. private _activeTargets;
  27645. private _scene;
  27646. private _influences;
  27647. private _supportsNormals;
  27648. private _supportsTangents;
  27649. private _supportsUVs;
  27650. private _vertexCount;
  27651. private _uniqueId;
  27652. private _tempInfluences;
  27653. /**
  27654. * Gets or sets a boolean indicating if normals must be morphed
  27655. */
  27656. enableNormalMorphing: boolean;
  27657. /**
  27658. * Gets or sets a boolean indicating if tangents must be morphed
  27659. */
  27660. enableTangentMorphing: boolean;
  27661. /**
  27662. * Gets or sets a boolean indicating if UV must be morphed
  27663. */
  27664. enableUVMorphing: boolean;
  27665. /**
  27666. * Creates a new MorphTargetManager
  27667. * @param scene defines the current scene
  27668. */
  27669. constructor(scene?: Nullable<Scene>);
  27670. /**
  27671. * Gets the unique ID of this manager
  27672. */
  27673. get uniqueId(): number;
  27674. /**
  27675. * Gets the number of vertices handled by this manager
  27676. */
  27677. get vertexCount(): number;
  27678. /**
  27679. * Gets a boolean indicating if this manager supports morphing of normals
  27680. */
  27681. get supportsNormals(): boolean;
  27682. /**
  27683. * Gets a boolean indicating if this manager supports morphing of tangents
  27684. */
  27685. get supportsTangents(): boolean;
  27686. /**
  27687. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27688. */
  27689. get supportsUVs(): boolean;
  27690. /**
  27691. * Gets the number of targets stored in this manager
  27692. */
  27693. get numTargets(): number;
  27694. /**
  27695. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27696. */
  27697. get numInfluencers(): number;
  27698. /**
  27699. * Gets the list of influences (one per target)
  27700. */
  27701. get influences(): Float32Array;
  27702. /**
  27703. * Gets the active target at specified index. An active target is a target with an influence > 0
  27704. * @param index defines the index to check
  27705. * @returns the requested target
  27706. */
  27707. getActiveTarget(index: number): MorphTarget;
  27708. /**
  27709. * Gets the target at specified index
  27710. * @param index defines the index to check
  27711. * @returns the requested target
  27712. */
  27713. getTarget(index: number): MorphTarget;
  27714. /**
  27715. * Add a new target to this manager
  27716. * @param target defines the target to add
  27717. */
  27718. addTarget(target: MorphTarget): void;
  27719. /**
  27720. * Removes a target from the manager
  27721. * @param target defines the target to remove
  27722. */
  27723. removeTarget(target: MorphTarget): void;
  27724. /**
  27725. * Clone the current manager
  27726. * @returns a new MorphTargetManager
  27727. */
  27728. clone(): MorphTargetManager;
  27729. /**
  27730. * Serializes the current manager into a Serialization object
  27731. * @returns the serialized object
  27732. */
  27733. serialize(): any;
  27734. private _syncActiveTargets;
  27735. /**
  27736. * Syncrhonize the targets with all the meshes using this morph target manager
  27737. */
  27738. synchronize(): void;
  27739. /**
  27740. * Creates a new MorphTargetManager from serialized data
  27741. * @param serializationObject defines the serialized data
  27742. * @param scene defines the hosting scene
  27743. * @returns the new MorphTargetManager
  27744. */
  27745. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27746. }
  27747. }
  27748. declare module "babylonjs/Meshes/meshLODLevel" {
  27749. import { Mesh } from "babylonjs/Meshes/mesh";
  27750. import { Nullable } from "babylonjs/types";
  27751. /**
  27752. * Class used to represent a specific level of detail of a mesh
  27753. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27754. */
  27755. export class MeshLODLevel {
  27756. /** Defines the distance where this level should start being displayed */
  27757. distance: number;
  27758. /** Defines the mesh to use to render this level */
  27759. mesh: Nullable<Mesh>;
  27760. /**
  27761. * Creates a new LOD level
  27762. * @param distance defines the distance where this level should star being displayed
  27763. * @param mesh defines the mesh to use to render this level
  27764. */
  27765. constructor(
  27766. /** Defines the distance where this level should start being displayed */
  27767. distance: number,
  27768. /** Defines the mesh to use to render this level */
  27769. mesh: Nullable<Mesh>);
  27770. }
  27771. }
  27772. declare module "babylonjs/Misc/canvasGenerator" {
  27773. /**
  27774. * Helper class used to generate a canvas to manipulate images
  27775. */
  27776. export class CanvasGenerator {
  27777. /**
  27778. * Create a new canvas (or offscreen canvas depending on the context)
  27779. * @param width defines the expected width
  27780. * @param height defines the expected height
  27781. * @return a new canvas or offscreen canvas
  27782. */
  27783. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27784. }
  27785. }
  27786. declare module "babylonjs/Meshes/groundMesh" {
  27787. import { Scene } from "babylonjs/scene";
  27788. import { Vector3 } from "babylonjs/Maths/math.vector";
  27789. import { Mesh } from "babylonjs/Meshes/mesh";
  27790. /**
  27791. * Mesh representing the gorund
  27792. */
  27793. export class GroundMesh extends Mesh {
  27794. /** If octree should be generated */
  27795. generateOctree: boolean;
  27796. private _heightQuads;
  27797. /** @hidden */
  27798. _subdivisionsX: number;
  27799. /** @hidden */
  27800. _subdivisionsY: number;
  27801. /** @hidden */
  27802. _width: number;
  27803. /** @hidden */
  27804. _height: number;
  27805. /** @hidden */
  27806. _minX: number;
  27807. /** @hidden */
  27808. _maxX: number;
  27809. /** @hidden */
  27810. _minZ: number;
  27811. /** @hidden */
  27812. _maxZ: number;
  27813. constructor(name: string, scene: Scene);
  27814. /**
  27815. * "GroundMesh"
  27816. * @returns "GroundMesh"
  27817. */
  27818. getClassName(): string;
  27819. /**
  27820. * The minimum of x and y subdivisions
  27821. */
  27822. get subdivisions(): number;
  27823. /**
  27824. * X subdivisions
  27825. */
  27826. get subdivisionsX(): number;
  27827. /**
  27828. * Y subdivisions
  27829. */
  27830. get subdivisionsY(): number;
  27831. /**
  27832. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27833. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27834. * @param chunksCount the number of subdivisions for x and y
  27835. * @param octreeBlocksSize (Default: 32)
  27836. */
  27837. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27838. /**
  27839. * Returns a height (y) value in the Worl system :
  27840. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27841. * @param x x coordinate
  27842. * @param z z coordinate
  27843. * @returns the ground y position if (x, z) are outside the ground surface.
  27844. */
  27845. getHeightAtCoordinates(x: number, z: number): number;
  27846. /**
  27847. * Returns a normalized vector (Vector3) orthogonal to the ground
  27848. * at the ground coordinates (x, z) expressed in the World system.
  27849. * @param x x coordinate
  27850. * @param z z coordinate
  27851. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27852. */
  27853. getNormalAtCoordinates(x: number, z: number): Vector3;
  27854. /**
  27855. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27856. * at the ground coordinates (x, z) expressed in the World system.
  27857. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27858. * @param x x coordinate
  27859. * @param z z coordinate
  27860. * @param ref vector to store the result
  27861. * @returns the GroundMesh.
  27862. */
  27863. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27864. /**
  27865. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27866. * if the ground has been updated.
  27867. * This can be used in the render loop.
  27868. * @returns the GroundMesh.
  27869. */
  27870. updateCoordinateHeights(): GroundMesh;
  27871. private _getFacetAt;
  27872. private _initHeightQuads;
  27873. private _computeHeightQuads;
  27874. /**
  27875. * Serializes this ground mesh
  27876. * @param serializationObject object to write serialization to
  27877. */
  27878. serialize(serializationObject: any): void;
  27879. /**
  27880. * Parses a serialized ground mesh
  27881. * @param parsedMesh the serialized mesh
  27882. * @param scene the scene to create the ground mesh in
  27883. * @returns the created ground mesh
  27884. */
  27885. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27886. }
  27887. }
  27888. declare module "babylonjs/Physics/physicsJoint" {
  27889. import { Vector3 } from "babylonjs/Maths/math.vector";
  27890. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27891. /**
  27892. * Interface for Physics-Joint data
  27893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27894. */
  27895. export interface PhysicsJointData {
  27896. /**
  27897. * The main pivot of the joint
  27898. */
  27899. mainPivot?: Vector3;
  27900. /**
  27901. * The connected pivot of the joint
  27902. */
  27903. connectedPivot?: Vector3;
  27904. /**
  27905. * The main axis of the joint
  27906. */
  27907. mainAxis?: Vector3;
  27908. /**
  27909. * The connected axis of the joint
  27910. */
  27911. connectedAxis?: Vector3;
  27912. /**
  27913. * The collision of the joint
  27914. */
  27915. collision?: boolean;
  27916. /**
  27917. * Native Oimo/Cannon/Energy data
  27918. */
  27919. nativeParams?: any;
  27920. }
  27921. /**
  27922. * This is a holder class for the physics joint created by the physics plugin
  27923. * It holds a set of functions to control the underlying joint
  27924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27925. */
  27926. export class PhysicsJoint {
  27927. /**
  27928. * The type of the physics joint
  27929. */
  27930. type: number;
  27931. /**
  27932. * The data for the physics joint
  27933. */
  27934. jointData: PhysicsJointData;
  27935. private _physicsJoint;
  27936. protected _physicsPlugin: IPhysicsEnginePlugin;
  27937. /**
  27938. * Initializes the physics joint
  27939. * @param type The type of the physics joint
  27940. * @param jointData The data for the physics joint
  27941. */
  27942. constructor(
  27943. /**
  27944. * The type of the physics joint
  27945. */
  27946. type: number,
  27947. /**
  27948. * The data for the physics joint
  27949. */
  27950. jointData: PhysicsJointData);
  27951. /**
  27952. * Gets the physics joint
  27953. */
  27954. get physicsJoint(): any;
  27955. /**
  27956. * Sets the physics joint
  27957. */
  27958. set physicsJoint(newJoint: any);
  27959. /**
  27960. * Sets the physics plugin
  27961. */
  27962. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27963. /**
  27964. * Execute a function that is physics-plugin specific.
  27965. * @param {Function} func the function that will be executed.
  27966. * It accepts two parameters: the physics world and the physics joint
  27967. */
  27968. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27969. /**
  27970. * Distance-Joint type
  27971. */
  27972. static DistanceJoint: number;
  27973. /**
  27974. * Hinge-Joint type
  27975. */
  27976. static HingeJoint: number;
  27977. /**
  27978. * Ball-and-Socket joint type
  27979. */
  27980. static BallAndSocketJoint: number;
  27981. /**
  27982. * Wheel-Joint type
  27983. */
  27984. static WheelJoint: number;
  27985. /**
  27986. * Slider-Joint type
  27987. */
  27988. static SliderJoint: number;
  27989. /**
  27990. * Prismatic-Joint type
  27991. */
  27992. static PrismaticJoint: number;
  27993. /**
  27994. * Universal-Joint type
  27995. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27996. */
  27997. static UniversalJoint: number;
  27998. /**
  27999. * Hinge-Joint 2 type
  28000. */
  28001. static Hinge2Joint: number;
  28002. /**
  28003. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28004. */
  28005. static PointToPointJoint: number;
  28006. /**
  28007. * Spring-Joint type
  28008. */
  28009. static SpringJoint: number;
  28010. /**
  28011. * Lock-Joint type
  28012. */
  28013. static LockJoint: number;
  28014. }
  28015. /**
  28016. * A class representing a physics distance joint
  28017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28018. */
  28019. export class DistanceJoint extends PhysicsJoint {
  28020. /**
  28021. *
  28022. * @param jointData The data for the Distance-Joint
  28023. */
  28024. constructor(jointData: DistanceJointData);
  28025. /**
  28026. * Update the predefined distance.
  28027. * @param maxDistance The maximum preferred distance
  28028. * @param minDistance The minimum preferred distance
  28029. */
  28030. updateDistance(maxDistance: number, minDistance?: number): void;
  28031. }
  28032. /**
  28033. * Represents a Motor-Enabled Joint
  28034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28035. */
  28036. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28037. /**
  28038. * Initializes the Motor-Enabled Joint
  28039. * @param type The type of the joint
  28040. * @param jointData The physica joint data for the joint
  28041. */
  28042. constructor(type: number, jointData: PhysicsJointData);
  28043. /**
  28044. * Set the motor values.
  28045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28046. * @param force the force to apply
  28047. * @param maxForce max force for this motor.
  28048. */
  28049. setMotor(force?: number, maxForce?: number): void;
  28050. /**
  28051. * Set the motor's limits.
  28052. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28053. * @param upperLimit The upper limit of the motor
  28054. * @param lowerLimit The lower limit of the motor
  28055. */
  28056. setLimit(upperLimit: number, lowerLimit?: number): void;
  28057. }
  28058. /**
  28059. * This class represents a single physics Hinge-Joint
  28060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28061. */
  28062. export class HingeJoint extends MotorEnabledJoint {
  28063. /**
  28064. * Initializes the Hinge-Joint
  28065. * @param jointData The joint data for the Hinge-Joint
  28066. */
  28067. constructor(jointData: PhysicsJointData);
  28068. /**
  28069. * Set the motor values.
  28070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28071. * @param {number} force the force to apply
  28072. * @param {number} maxForce max force for this motor.
  28073. */
  28074. setMotor(force?: number, maxForce?: number): void;
  28075. /**
  28076. * Set the motor's limits.
  28077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28078. * @param upperLimit The upper limit of the motor
  28079. * @param lowerLimit The lower limit of the motor
  28080. */
  28081. setLimit(upperLimit: number, lowerLimit?: number): void;
  28082. }
  28083. /**
  28084. * This class represents a dual hinge physics joint (same as wheel joint)
  28085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28086. */
  28087. export class Hinge2Joint extends MotorEnabledJoint {
  28088. /**
  28089. * Initializes the Hinge2-Joint
  28090. * @param jointData The joint data for the Hinge2-Joint
  28091. */
  28092. constructor(jointData: PhysicsJointData);
  28093. /**
  28094. * Set the motor values.
  28095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28096. * @param {number} targetSpeed the speed the motor is to reach
  28097. * @param {number} maxForce max force for this motor.
  28098. * @param {motorIndex} the motor's index, 0 or 1.
  28099. */
  28100. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28101. /**
  28102. * Set the motor limits.
  28103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28104. * @param {number} upperLimit the upper limit
  28105. * @param {number} lowerLimit lower limit
  28106. * @param {motorIndex} the motor's index, 0 or 1.
  28107. */
  28108. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28109. }
  28110. /**
  28111. * Interface for a motor enabled joint
  28112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28113. */
  28114. export interface IMotorEnabledJoint {
  28115. /**
  28116. * Physics joint
  28117. */
  28118. physicsJoint: any;
  28119. /**
  28120. * Sets the motor of the motor-enabled joint
  28121. * @param force The force of the motor
  28122. * @param maxForce The maximum force of the motor
  28123. * @param motorIndex The index of the motor
  28124. */
  28125. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28126. /**
  28127. * Sets the limit of the motor
  28128. * @param upperLimit The upper limit of the motor
  28129. * @param lowerLimit The lower limit of the motor
  28130. * @param motorIndex The index of the motor
  28131. */
  28132. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28133. }
  28134. /**
  28135. * Joint data for a Distance-Joint
  28136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28137. */
  28138. export interface DistanceJointData extends PhysicsJointData {
  28139. /**
  28140. * Max distance the 2 joint objects can be apart
  28141. */
  28142. maxDistance: number;
  28143. }
  28144. /**
  28145. * Joint data from a spring joint
  28146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28147. */
  28148. export interface SpringJointData extends PhysicsJointData {
  28149. /**
  28150. * Length of the spring
  28151. */
  28152. length: number;
  28153. /**
  28154. * Stiffness of the spring
  28155. */
  28156. stiffness: number;
  28157. /**
  28158. * Damping of the spring
  28159. */
  28160. damping: number;
  28161. /** this callback will be called when applying the force to the impostors. */
  28162. forceApplicationCallback: () => void;
  28163. }
  28164. }
  28165. declare module "babylonjs/Physics/physicsRaycastResult" {
  28166. import { Vector3 } from "babylonjs/Maths/math.vector";
  28167. /**
  28168. * Holds the data for the raycast result
  28169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28170. */
  28171. export class PhysicsRaycastResult {
  28172. private _hasHit;
  28173. private _hitDistance;
  28174. private _hitNormalWorld;
  28175. private _hitPointWorld;
  28176. private _rayFromWorld;
  28177. private _rayToWorld;
  28178. /**
  28179. * Gets if there was a hit
  28180. */
  28181. get hasHit(): boolean;
  28182. /**
  28183. * Gets the distance from the hit
  28184. */
  28185. get hitDistance(): number;
  28186. /**
  28187. * Gets the hit normal/direction in the world
  28188. */
  28189. get hitNormalWorld(): Vector3;
  28190. /**
  28191. * Gets the hit point in the world
  28192. */
  28193. get hitPointWorld(): Vector3;
  28194. /**
  28195. * Gets the ray "start point" of the ray in the world
  28196. */
  28197. get rayFromWorld(): Vector3;
  28198. /**
  28199. * Gets the ray "end point" of the ray in the world
  28200. */
  28201. get rayToWorld(): Vector3;
  28202. /**
  28203. * Sets the hit data (normal & point in world space)
  28204. * @param hitNormalWorld defines the normal in world space
  28205. * @param hitPointWorld defines the point in world space
  28206. */
  28207. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28208. /**
  28209. * Sets the distance from the start point to the hit point
  28210. * @param distance
  28211. */
  28212. setHitDistance(distance: number): void;
  28213. /**
  28214. * Calculates the distance manually
  28215. */
  28216. calculateHitDistance(): void;
  28217. /**
  28218. * Resets all the values to default
  28219. * @param from The from point on world space
  28220. * @param to The to point on world space
  28221. */
  28222. reset(from?: Vector3, to?: Vector3): void;
  28223. }
  28224. /**
  28225. * Interface for the size containing width and height
  28226. */
  28227. interface IXYZ {
  28228. /**
  28229. * X
  28230. */
  28231. x: number;
  28232. /**
  28233. * Y
  28234. */
  28235. y: number;
  28236. /**
  28237. * Z
  28238. */
  28239. z: number;
  28240. }
  28241. }
  28242. declare module "babylonjs/Physics/IPhysicsEngine" {
  28243. import { Nullable } from "babylonjs/types";
  28244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28246. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28247. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28248. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28249. /**
  28250. * Interface used to describe a physics joint
  28251. */
  28252. export interface PhysicsImpostorJoint {
  28253. /** Defines the main impostor to which the joint is linked */
  28254. mainImpostor: PhysicsImpostor;
  28255. /** Defines the impostor that is connected to the main impostor using this joint */
  28256. connectedImpostor: PhysicsImpostor;
  28257. /** Defines the joint itself */
  28258. joint: PhysicsJoint;
  28259. }
  28260. /** @hidden */
  28261. export interface IPhysicsEnginePlugin {
  28262. world: any;
  28263. name: string;
  28264. setGravity(gravity: Vector3): void;
  28265. setTimeStep(timeStep: number): void;
  28266. getTimeStep(): number;
  28267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28271. removePhysicsBody(impostor: PhysicsImpostor): void;
  28272. generateJoint(joint: PhysicsImpostorJoint): void;
  28273. removeJoint(joint: PhysicsImpostorJoint): void;
  28274. isSupported(): boolean;
  28275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28282. getBodyMass(impostor: PhysicsImpostor): number;
  28283. getBodyFriction(impostor: PhysicsImpostor): number;
  28284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28285. getBodyRestitution(impostor: PhysicsImpostor): number;
  28286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28287. getBodyPressure?(impostor: PhysicsImpostor): number;
  28288. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28289. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28290. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28291. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28292. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28293. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28294. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28295. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28296. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28297. sleepBody(impostor: PhysicsImpostor): void;
  28298. wakeUpBody(impostor: PhysicsImpostor): void;
  28299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28300. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28301. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28303. getRadius(impostor: PhysicsImpostor): number;
  28304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28306. dispose(): void;
  28307. }
  28308. /**
  28309. * Interface used to define a physics engine
  28310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28311. */
  28312. export interface IPhysicsEngine {
  28313. /**
  28314. * Gets the gravity vector used by the simulation
  28315. */
  28316. gravity: Vector3;
  28317. /**
  28318. * Sets the gravity vector used by the simulation
  28319. * @param gravity defines the gravity vector to use
  28320. */
  28321. setGravity(gravity: Vector3): void;
  28322. /**
  28323. * Set the time step of the physics engine.
  28324. * Default is 1/60.
  28325. * To slow it down, enter 1/600 for example.
  28326. * To speed it up, 1/30
  28327. * @param newTimeStep the new timestep to apply to this world.
  28328. */
  28329. setTimeStep(newTimeStep: number): void;
  28330. /**
  28331. * Get the time step of the physics engine.
  28332. * @returns the current time step
  28333. */
  28334. getTimeStep(): number;
  28335. /**
  28336. * Set the sub time step of the physics engine.
  28337. * Default is 0 meaning there is no sub steps
  28338. * To increase physics resolution precision, set a small value (like 1 ms)
  28339. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28340. */
  28341. setSubTimeStep(subTimeStep: number): void;
  28342. /**
  28343. * Get the sub time step of the physics engine.
  28344. * @returns the current sub time step
  28345. */
  28346. getSubTimeStep(): number;
  28347. /**
  28348. * Release all resources
  28349. */
  28350. dispose(): void;
  28351. /**
  28352. * Gets the name of the current physics plugin
  28353. * @returns the name of the plugin
  28354. */
  28355. getPhysicsPluginName(): string;
  28356. /**
  28357. * Adding a new impostor for the impostor tracking.
  28358. * This will be done by the impostor itself.
  28359. * @param impostor the impostor to add
  28360. */
  28361. addImpostor(impostor: PhysicsImpostor): void;
  28362. /**
  28363. * Remove an impostor from the engine.
  28364. * This impostor and its mesh will not longer be updated by the physics engine.
  28365. * @param impostor the impostor to remove
  28366. */
  28367. removeImpostor(impostor: PhysicsImpostor): void;
  28368. /**
  28369. * Add a joint to the physics engine
  28370. * @param mainImpostor defines the main impostor to which the joint is added.
  28371. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28372. * @param joint defines the joint that will connect both impostors.
  28373. */
  28374. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28375. /**
  28376. * Removes a joint from the simulation
  28377. * @param mainImpostor defines the impostor used with the joint
  28378. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28379. * @param joint defines the joint to remove
  28380. */
  28381. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28382. /**
  28383. * Gets the current plugin used to run the simulation
  28384. * @returns current plugin
  28385. */
  28386. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28387. /**
  28388. * Gets the list of physic impostors
  28389. * @returns an array of PhysicsImpostor
  28390. */
  28391. getImpostors(): Array<PhysicsImpostor>;
  28392. /**
  28393. * Gets the impostor for a physics enabled object
  28394. * @param object defines the object impersonated by the impostor
  28395. * @returns the PhysicsImpostor or null if not found
  28396. */
  28397. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28398. /**
  28399. * Gets the impostor for a physics body object
  28400. * @param body defines physics body used by the impostor
  28401. * @returns the PhysicsImpostor or null if not found
  28402. */
  28403. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28404. /**
  28405. * Does a raycast in the physics world
  28406. * @param from when should the ray start?
  28407. * @param to when should the ray end?
  28408. * @returns PhysicsRaycastResult
  28409. */
  28410. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28411. /**
  28412. * Called by the scene. No need to call it.
  28413. * @param delta defines the timespam between frames
  28414. */
  28415. _step(delta: number): void;
  28416. }
  28417. }
  28418. declare module "babylonjs/Physics/physicsImpostor" {
  28419. import { Nullable, IndicesArray } from "babylonjs/types";
  28420. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28423. import { Scene } from "babylonjs/scene";
  28424. import { Bone } from "babylonjs/Bones/bone";
  28425. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28426. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28427. import { Space } from "babylonjs/Maths/math.axis";
  28428. /**
  28429. * The interface for the physics imposter parameters
  28430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28431. */
  28432. export interface PhysicsImpostorParameters {
  28433. /**
  28434. * The mass of the physics imposter
  28435. */
  28436. mass: number;
  28437. /**
  28438. * The friction of the physics imposter
  28439. */
  28440. friction?: number;
  28441. /**
  28442. * The coefficient of restitution of the physics imposter
  28443. */
  28444. restitution?: number;
  28445. /**
  28446. * The native options of the physics imposter
  28447. */
  28448. nativeOptions?: any;
  28449. /**
  28450. * Specifies if the parent should be ignored
  28451. */
  28452. ignoreParent?: boolean;
  28453. /**
  28454. * Specifies if bi-directional transformations should be disabled
  28455. */
  28456. disableBidirectionalTransformation?: boolean;
  28457. /**
  28458. * The pressure inside the physics imposter, soft object only
  28459. */
  28460. pressure?: number;
  28461. /**
  28462. * The stiffness the physics imposter, soft object only
  28463. */
  28464. stiffness?: number;
  28465. /**
  28466. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28467. */
  28468. velocityIterations?: number;
  28469. /**
  28470. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28471. */
  28472. positionIterations?: number;
  28473. /**
  28474. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28475. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28476. * Add to fix multiple points
  28477. */
  28478. fixedPoints?: number;
  28479. /**
  28480. * The collision margin around a soft object
  28481. */
  28482. margin?: number;
  28483. /**
  28484. * The collision margin around a soft object
  28485. */
  28486. damping?: number;
  28487. /**
  28488. * The path for a rope based on an extrusion
  28489. */
  28490. path?: any;
  28491. /**
  28492. * The shape of an extrusion used for a rope based on an extrusion
  28493. */
  28494. shape?: any;
  28495. }
  28496. /**
  28497. * Interface for a physics-enabled object
  28498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28499. */
  28500. export interface IPhysicsEnabledObject {
  28501. /**
  28502. * The position of the physics-enabled object
  28503. */
  28504. position: Vector3;
  28505. /**
  28506. * The rotation of the physics-enabled object
  28507. */
  28508. rotationQuaternion: Nullable<Quaternion>;
  28509. /**
  28510. * The scale of the physics-enabled object
  28511. */
  28512. scaling: Vector3;
  28513. /**
  28514. * The rotation of the physics-enabled object
  28515. */
  28516. rotation?: Vector3;
  28517. /**
  28518. * The parent of the physics-enabled object
  28519. */
  28520. parent?: any;
  28521. /**
  28522. * The bounding info of the physics-enabled object
  28523. * @returns The bounding info of the physics-enabled object
  28524. */
  28525. getBoundingInfo(): BoundingInfo;
  28526. /**
  28527. * Computes the world matrix
  28528. * @param force Specifies if the world matrix should be computed by force
  28529. * @returns A world matrix
  28530. */
  28531. computeWorldMatrix(force: boolean): Matrix;
  28532. /**
  28533. * Gets the world matrix
  28534. * @returns A world matrix
  28535. */
  28536. getWorldMatrix?(): Matrix;
  28537. /**
  28538. * Gets the child meshes
  28539. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28540. * @returns An array of abstract meshes
  28541. */
  28542. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28543. /**
  28544. * Gets the vertex data
  28545. * @param kind The type of vertex data
  28546. * @returns A nullable array of numbers, or a float32 array
  28547. */
  28548. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28549. /**
  28550. * Gets the indices from the mesh
  28551. * @returns A nullable array of index arrays
  28552. */
  28553. getIndices?(): Nullable<IndicesArray>;
  28554. /**
  28555. * Gets the scene from the mesh
  28556. * @returns the indices array or null
  28557. */
  28558. getScene?(): Scene;
  28559. /**
  28560. * Gets the absolute position from the mesh
  28561. * @returns the absolute position
  28562. */
  28563. getAbsolutePosition(): Vector3;
  28564. /**
  28565. * Gets the absolute pivot point from the mesh
  28566. * @returns the absolute pivot point
  28567. */
  28568. getAbsolutePivotPoint(): Vector3;
  28569. /**
  28570. * Rotates the mesh
  28571. * @param axis The axis of rotation
  28572. * @param amount The amount of rotation
  28573. * @param space The space of the rotation
  28574. * @returns The rotation transform node
  28575. */
  28576. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28577. /**
  28578. * Translates the mesh
  28579. * @param axis The axis of translation
  28580. * @param distance The distance of translation
  28581. * @param space The space of the translation
  28582. * @returns The transform node
  28583. */
  28584. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28585. /**
  28586. * Sets the absolute position of the mesh
  28587. * @param absolutePosition The absolute position of the mesh
  28588. * @returns The transform node
  28589. */
  28590. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28591. /**
  28592. * Gets the class name of the mesh
  28593. * @returns The class name
  28594. */
  28595. getClassName(): string;
  28596. }
  28597. /**
  28598. * Represents a physics imposter
  28599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28600. */
  28601. export class PhysicsImpostor {
  28602. /**
  28603. * The physics-enabled object used as the physics imposter
  28604. */
  28605. object: IPhysicsEnabledObject;
  28606. /**
  28607. * The type of the physics imposter
  28608. */
  28609. type: number;
  28610. private _options;
  28611. private _scene?;
  28612. /**
  28613. * The default object size of the imposter
  28614. */
  28615. static DEFAULT_OBJECT_SIZE: Vector3;
  28616. /**
  28617. * The identity quaternion of the imposter
  28618. */
  28619. static IDENTITY_QUATERNION: Quaternion;
  28620. /** @hidden */
  28621. _pluginData: any;
  28622. private _physicsEngine;
  28623. private _physicsBody;
  28624. private _bodyUpdateRequired;
  28625. private _onBeforePhysicsStepCallbacks;
  28626. private _onAfterPhysicsStepCallbacks;
  28627. /** @hidden */
  28628. _onPhysicsCollideCallbacks: Array<{
  28629. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28630. otherImpostors: Array<PhysicsImpostor>;
  28631. }>;
  28632. private _deltaPosition;
  28633. private _deltaRotation;
  28634. private _deltaRotationConjugated;
  28635. /** @hidden */
  28636. _isFromLine: boolean;
  28637. private _parent;
  28638. private _isDisposed;
  28639. private static _tmpVecs;
  28640. private static _tmpQuat;
  28641. /**
  28642. * Specifies if the physics imposter is disposed
  28643. */
  28644. get isDisposed(): boolean;
  28645. /**
  28646. * Gets the mass of the physics imposter
  28647. */
  28648. get mass(): number;
  28649. set mass(value: number);
  28650. /**
  28651. * Gets the coefficient of friction
  28652. */
  28653. get friction(): number;
  28654. /**
  28655. * Sets the coefficient of friction
  28656. */
  28657. set friction(value: number);
  28658. /**
  28659. * Gets the coefficient of restitution
  28660. */
  28661. get restitution(): number;
  28662. /**
  28663. * Sets the coefficient of restitution
  28664. */
  28665. set restitution(value: number);
  28666. /**
  28667. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28668. */
  28669. get pressure(): number;
  28670. /**
  28671. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28672. */
  28673. set pressure(value: number);
  28674. /**
  28675. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28676. */
  28677. get stiffness(): number;
  28678. /**
  28679. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28680. */
  28681. set stiffness(value: number);
  28682. /**
  28683. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28684. */
  28685. get velocityIterations(): number;
  28686. /**
  28687. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28688. */
  28689. set velocityIterations(value: number);
  28690. /**
  28691. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28692. */
  28693. get positionIterations(): number;
  28694. /**
  28695. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28696. */
  28697. set positionIterations(value: number);
  28698. /**
  28699. * The unique id of the physics imposter
  28700. * set by the physics engine when adding this impostor to the array
  28701. */
  28702. uniqueId: number;
  28703. /**
  28704. * @hidden
  28705. */
  28706. soft: boolean;
  28707. /**
  28708. * @hidden
  28709. */
  28710. segments: number;
  28711. private _joints;
  28712. /**
  28713. * Initializes the physics imposter
  28714. * @param object The physics-enabled object used as the physics imposter
  28715. * @param type The type of the physics imposter
  28716. * @param _options The options for the physics imposter
  28717. * @param _scene The Babylon scene
  28718. */
  28719. constructor(
  28720. /**
  28721. * The physics-enabled object used as the physics imposter
  28722. */
  28723. object: IPhysicsEnabledObject,
  28724. /**
  28725. * The type of the physics imposter
  28726. */
  28727. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28728. /**
  28729. * This function will completly initialize this impostor.
  28730. * It will create a new body - but only if this mesh has no parent.
  28731. * If it has, this impostor will not be used other than to define the impostor
  28732. * of the child mesh.
  28733. * @hidden
  28734. */
  28735. _init(): void;
  28736. private _getPhysicsParent;
  28737. /**
  28738. * Should a new body be generated.
  28739. * @returns boolean specifying if body initialization is required
  28740. */
  28741. isBodyInitRequired(): boolean;
  28742. /**
  28743. * Sets the updated scaling
  28744. * @param updated Specifies if the scaling is updated
  28745. */
  28746. setScalingUpdated(): void;
  28747. /**
  28748. * Force a regeneration of this or the parent's impostor's body.
  28749. * Use under cautious - This will remove all joints already implemented.
  28750. */
  28751. forceUpdate(): void;
  28752. /**
  28753. * Gets the body that holds this impostor. Either its own, or its parent.
  28754. */
  28755. get physicsBody(): any;
  28756. /**
  28757. * Get the parent of the physics imposter
  28758. * @returns Physics imposter or null
  28759. */
  28760. get parent(): Nullable<PhysicsImpostor>;
  28761. /**
  28762. * Sets the parent of the physics imposter
  28763. */
  28764. set parent(value: Nullable<PhysicsImpostor>);
  28765. /**
  28766. * Set the physics body. Used mainly by the physics engine/plugin
  28767. */
  28768. set physicsBody(physicsBody: any);
  28769. /**
  28770. * Resets the update flags
  28771. */
  28772. resetUpdateFlags(): void;
  28773. /**
  28774. * Gets the object extend size
  28775. * @returns the object extend size
  28776. */
  28777. getObjectExtendSize(): Vector3;
  28778. /**
  28779. * Gets the object center
  28780. * @returns The object center
  28781. */
  28782. getObjectCenter(): Vector3;
  28783. /**
  28784. * Get a specific parameter from the options parameters
  28785. * @param paramName The object parameter name
  28786. * @returns The object parameter
  28787. */
  28788. getParam(paramName: string): any;
  28789. /**
  28790. * Sets a specific parameter in the options given to the physics plugin
  28791. * @param paramName The parameter name
  28792. * @param value The value of the parameter
  28793. */
  28794. setParam(paramName: string, value: number): void;
  28795. /**
  28796. * Specifically change the body's mass option. Won't recreate the physics body object
  28797. * @param mass The mass of the physics imposter
  28798. */
  28799. setMass(mass: number): void;
  28800. /**
  28801. * Gets the linear velocity
  28802. * @returns linear velocity or null
  28803. */
  28804. getLinearVelocity(): Nullable<Vector3>;
  28805. /**
  28806. * Sets the linear velocity
  28807. * @param velocity linear velocity or null
  28808. */
  28809. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28810. /**
  28811. * Gets the angular velocity
  28812. * @returns angular velocity or null
  28813. */
  28814. getAngularVelocity(): Nullable<Vector3>;
  28815. /**
  28816. * Sets the angular velocity
  28817. * @param velocity The velocity or null
  28818. */
  28819. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28820. /**
  28821. * Execute a function with the physics plugin native code
  28822. * Provide a function the will have two variables - the world object and the physics body object
  28823. * @param func The function to execute with the physics plugin native code
  28824. */
  28825. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28826. /**
  28827. * Register a function that will be executed before the physics world is stepping forward
  28828. * @param func The function to execute before the physics world is stepped forward
  28829. */
  28830. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28831. /**
  28832. * Unregister a function that will be executed before the physics world is stepping forward
  28833. * @param func The function to execute before the physics world is stepped forward
  28834. */
  28835. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28836. /**
  28837. * Register a function that will be executed after the physics step
  28838. * @param func The function to execute after physics step
  28839. */
  28840. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28841. /**
  28842. * Unregisters a function that will be executed after the physics step
  28843. * @param func The function to execute after physics step
  28844. */
  28845. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28846. /**
  28847. * register a function that will be executed when this impostor collides against a different body
  28848. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28849. * @param func Callback that is executed on collision
  28850. */
  28851. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28852. /**
  28853. * Unregisters the physics imposter on contact
  28854. * @param collideAgainst The physics object to collide against
  28855. * @param func Callback to execute on collision
  28856. */
  28857. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28858. private _tmpQuat;
  28859. private _tmpQuat2;
  28860. /**
  28861. * Get the parent rotation
  28862. * @returns The parent rotation
  28863. */
  28864. getParentsRotation(): Quaternion;
  28865. /**
  28866. * this function is executed by the physics engine.
  28867. */
  28868. beforeStep: () => void;
  28869. /**
  28870. * this function is executed by the physics engine
  28871. */
  28872. afterStep: () => void;
  28873. /**
  28874. * Legacy collision detection event support
  28875. */
  28876. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28877. /**
  28878. * event and body object due to cannon's event-based architecture.
  28879. */
  28880. onCollide: (e: {
  28881. body: any;
  28882. }) => void;
  28883. /**
  28884. * Apply a force
  28885. * @param force The force to apply
  28886. * @param contactPoint The contact point for the force
  28887. * @returns The physics imposter
  28888. */
  28889. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28890. /**
  28891. * Apply an impulse
  28892. * @param force The impulse force
  28893. * @param contactPoint The contact point for the impulse force
  28894. * @returns The physics imposter
  28895. */
  28896. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28897. /**
  28898. * A help function to create a joint
  28899. * @param otherImpostor A physics imposter used to create a joint
  28900. * @param jointType The type of joint
  28901. * @param jointData The data for the joint
  28902. * @returns The physics imposter
  28903. */
  28904. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28905. /**
  28906. * Add a joint to this impostor with a different impostor
  28907. * @param otherImpostor A physics imposter used to add a joint
  28908. * @param joint The joint to add
  28909. * @returns The physics imposter
  28910. */
  28911. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28912. /**
  28913. * Add an anchor to a cloth impostor
  28914. * @param otherImpostor rigid impostor to anchor to
  28915. * @param width ratio across width from 0 to 1
  28916. * @param height ratio up height from 0 to 1
  28917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28918. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28919. * @returns impostor the soft imposter
  28920. */
  28921. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28922. /**
  28923. * Add a hook to a rope impostor
  28924. * @param otherImpostor rigid impostor to anchor to
  28925. * @param length ratio across rope from 0 to 1
  28926. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28928. * @returns impostor the rope imposter
  28929. */
  28930. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28931. /**
  28932. * Will keep this body still, in a sleep mode.
  28933. * @returns the physics imposter
  28934. */
  28935. sleep(): PhysicsImpostor;
  28936. /**
  28937. * Wake the body up.
  28938. * @returns The physics imposter
  28939. */
  28940. wakeUp(): PhysicsImpostor;
  28941. /**
  28942. * Clones the physics imposter
  28943. * @param newObject The physics imposter clones to this physics-enabled object
  28944. * @returns A nullable physics imposter
  28945. */
  28946. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28947. /**
  28948. * Disposes the physics imposter
  28949. */
  28950. dispose(): void;
  28951. /**
  28952. * Sets the delta position
  28953. * @param position The delta position amount
  28954. */
  28955. setDeltaPosition(position: Vector3): void;
  28956. /**
  28957. * Sets the delta rotation
  28958. * @param rotation The delta rotation amount
  28959. */
  28960. setDeltaRotation(rotation: Quaternion): void;
  28961. /**
  28962. * Gets the box size of the physics imposter and stores the result in the input parameter
  28963. * @param result Stores the box size
  28964. * @returns The physics imposter
  28965. */
  28966. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28967. /**
  28968. * Gets the radius of the physics imposter
  28969. * @returns Radius of the physics imposter
  28970. */
  28971. getRadius(): number;
  28972. /**
  28973. * Sync a bone with this impostor
  28974. * @param bone The bone to sync to the impostor.
  28975. * @param boneMesh The mesh that the bone is influencing.
  28976. * @param jointPivot The pivot of the joint / bone in local space.
  28977. * @param distToJoint Optional distance from the impostor to the joint.
  28978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28979. */
  28980. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28981. /**
  28982. * Sync impostor to a bone
  28983. * @param bone The bone that the impostor will be synced to.
  28984. * @param boneMesh The mesh that the bone is influencing.
  28985. * @param jointPivot The pivot of the joint / bone in local space.
  28986. * @param distToJoint Optional distance from the impostor to the joint.
  28987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28988. * @param boneAxis Optional vector3 axis the bone is aligned with
  28989. */
  28990. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28991. /**
  28992. * No-Imposter type
  28993. */
  28994. static NoImpostor: number;
  28995. /**
  28996. * Sphere-Imposter type
  28997. */
  28998. static SphereImpostor: number;
  28999. /**
  29000. * Box-Imposter type
  29001. */
  29002. static BoxImpostor: number;
  29003. /**
  29004. * Plane-Imposter type
  29005. */
  29006. static PlaneImpostor: number;
  29007. /**
  29008. * Mesh-imposter type
  29009. */
  29010. static MeshImpostor: number;
  29011. /**
  29012. * Capsule-Impostor type (Ammo.js plugin only)
  29013. */
  29014. static CapsuleImpostor: number;
  29015. /**
  29016. * Cylinder-Imposter type
  29017. */
  29018. static CylinderImpostor: number;
  29019. /**
  29020. * Particle-Imposter type
  29021. */
  29022. static ParticleImpostor: number;
  29023. /**
  29024. * Heightmap-Imposter type
  29025. */
  29026. static HeightmapImpostor: number;
  29027. /**
  29028. * ConvexHull-Impostor type (Ammo.js plugin only)
  29029. */
  29030. static ConvexHullImpostor: number;
  29031. /**
  29032. * Custom-Imposter type (Ammo.js plugin only)
  29033. */
  29034. static CustomImpostor: number;
  29035. /**
  29036. * Rope-Imposter type
  29037. */
  29038. static RopeImpostor: number;
  29039. /**
  29040. * Cloth-Imposter type
  29041. */
  29042. static ClothImpostor: number;
  29043. /**
  29044. * Softbody-Imposter type
  29045. */
  29046. static SoftbodyImpostor: number;
  29047. }
  29048. }
  29049. declare module "babylonjs/Meshes/mesh" {
  29050. import { Observable } from "babylonjs/Misc/observable";
  29051. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29052. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29053. import { Camera } from "babylonjs/Cameras/camera";
  29054. import { Scene } from "babylonjs/scene";
  29055. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29056. import { Color4 } from "babylonjs/Maths/math.color";
  29057. import { Engine } from "babylonjs/Engines/engine";
  29058. import { Node } from "babylonjs/node";
  29059. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29060. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29061. import { Buffer } from "babylonjs/Meshes/buffer";
  29062. import { Geometry } from "babylonjs/Meshes/geometry";
  29063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29065. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29066. import { Effect } from "babylonjs/Materials/effect";
  29067. import { Material } from "babylonjs/Materials/material";
  29068. import { Skeleton } from "babylonjs/Bones/skeleton";
  29069. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29070. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29071. import { Path3D } from "babylonjs/Maths/math.path";
  29072. import { Plane } from "babylonjs/Maths/math.plane";
  29073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29074. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29075. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29076. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29077. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29079. /**
  29080. * @hidden
  29081. **/
  29082. export class _CreationDataStorage {
  29083. closePath?: boolean;
  29084. closeArray?: boolean;
  29085. idx: number[];
  29086. dashSize: number;
  29087. gapSize: number;
  29088. path3D: Path3D;
  29089. pathArray: Vector3[][];
  29090. arc: number;
  29091. radius: number;
  29092. cap: number;
  29093. tessellation: number;
  29094. }
  29095. /**
  29096. * @hidden
  29097. **/
  29098. class _InstanceDataStorage {
  29099. visibleInstances: any;
  29100. batchCache: _InstancesBatch;
  29101. instancesBufferSize: number;
  29102. instancesBuffer: Nullable<Buffer>;
  29103. instancesData: Float32Array;
  29104. overridenInstanceCount: number;
  29105. isFrozen: boolean;
  29106. previousBatch: Nullable<_InstancesBatch>;
  29107. hardwareInstancedRendering: boolean;
  29108. sideOrientation: number;
  29109. manualUpdate: boolean;
  29110. }
  29111. /**
  29112. * @hidden
  29113. **/
  29114. export class _InstancesBatch {
  29115. mustReturn: boolean;
  29116. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29117. renderSelf: boolean[];
  29118. hardwareInstancedRendering: boolean[];
  29119. }
  29120. /**
  29121. * @hidden
  29122. **/
  29123. class _ThinInstanceDataStorage {
  29124. instancesCount: number;
  29125. matrixBuffer: Nullable<Buffer>;
  29126. matrixBufferSize: number;
  29127. matrixData: Nullable<Float32Array>;
  29128. boundingVectors: Array<Vector3>;
  29129. worldMatrices: Nullable<Matrix[]>;
  29130. }
  29131. /**
  29132. * Class used to represent renderable models
  29133. */
  29134. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29135. /**
  29136. * Mesh side orientation : usually the external or front surface
  29137. */
  29138. static readonly FRONTSIDE: number;
  29139. /**
  29140. * Mesh side orientation : usually the internal or back surface
  29141. */
  29142. static readonly BACKSIDE: number;
  29143. /**
  29144. * Mesh side orientation : both internal and external or front and back surfaces
  29145. */
  29146. static readonly DOUBLESIDE: number;
  29147. /**
  29148. * Mesh side orientation : by default, `FRONTSIDE`
  29149. */
  29150. static readonly DEFAULTSIDE: number;
  29151. /**
  29152. * Mesh cap setting : no cap
  29153. */
  29154. static readonly NO_CAP: number;
  29155. /**
  29156. * Mesh cap setting : one cap at the beginning of the mesh
  29157. */
  29158. static readonly CAP_START: number;
  29159. /**
  29160. * Mesh cap setting : one cap at the end of the mesh
  29161. */
  29162. static readonly CAP_END: number;
  29163. /**
  29164. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29165. */
  29166. static readonly CAP_ALL: number;
  29167. /**
  29168. * Mesh pattern setting : no flip or rotate
  29169. */
  29170. static readonly NO_FLIP: number;
  29171. /**
  29172. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29173. */
  29174. static readonly FLIP_TILE: number;
  29175. /**
  29176. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29177. */
  29178. static readonly ROTATE_TILE: number;
  29179. /**
  29180. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29181. */
  29182. static readonly FLIP_ROW: number;
  29183. /**
  29184. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29185. */
  29186. static readonly ROTATE_ROW: number;
  29187. /**
  29188. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29189. */
  29190. static readonly FLIP_N_ROTATE_TILE: number;
  29191. /**
  29192. * Mesh pattern setting : rotate pattern and rotate
  29193. */
  29194. static readonly FLIP_N_ROTATE_ROW: number;
  29195. /**
  29196. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29197. */
  29198. static readonly CENTER: number;
  29199. /**
  29200. * Mesh tile positioning : part tiles on left
  29201. */
  29202. static readonly LEFT: number;
  29203. /**
  29204. * Mesh tile positioning : part tiles on right
  29205. */
  29206. static readonly RIGHT: number;
  29207. /**
  29208. * Mesh tile positioning : part tiles on top
  29209. */
  29210. static readonly TOP: number;
  29211. /**
  29212. * Mesh tile positioning : part tiles on bottom
  29213. */
  29214. static readonly BOTTOM: number;
  29215. /**
  29216. * Gets the default side orientation.
  29217. * @param orientation the orientation to value to attempt to get
  29218. * @returns the default orientation
  29219. * @hidden
  29220. */
  29221. static _GetDefaultSideOrientation(orientation?: number): number;
  29222. private _internalMeshDataInfo;
  29223. get computeBonesUsingShaders(): boolean;
  29224. set computeBonesUsingShaders(value: boolean);
  29225. /**
  29226. * An event triggered before rendering the mesh
  29227. */
  29228. get onBeforeRenderObservable(): Observable<Mesh>;
  29229. /**
  29230. * An event triggered before binding the mesh
  29231. */
  29232. get onBeforeBindObservable(): Observable<Mesh>;
  29233. /**
  29234. * An event triggered after rendering the mesh
  29235. */
  29236. get onAfterRenderObservable(): Observable<Mesh>;
  29237. /**
  29238. * An event triggered before drawing the mesh
  29239. */
  29240. get onBeforeDrawObservable(): Observable<Mesh>;
  29241. private _onBeforeDrawObserver;
  29242. /**
  29243. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29244. */
  29245. set onBeforeDraw(callback: () => void);
  29246. get hasInstances(): boolean;
  29247. get hasThinInstances(): boolean;
  29248. /**
  29249. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29250. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29251. */
  29252. delayLoadState: number;
  29253. /**
  29254. * Gets the list of instances created from this mesh
  29255. * it is not supposed to be modified manually.
  29256. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29257. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29258. */
  29259. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29260. /**
  29261. * Gets the file containing delay loading data for this mesh
  29262. */
  29263. delayLoadingFile: string;
  29264. /** @hidden */
  29265. _binaryInfo: any;
  29266. /**
  29267. * User defined function used to change how LOD level selection is done
  29268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29269. */
  29270. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29271. /**
  29272. * Gets or sets the morph target manager
  29273. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29274. */
  29275. get morphTargetManager(): Nullable<MorphTargetManager>;
  29276. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29277. /** @hidden */
  29278. _creationDataStorage: Nullable<_CreationDataStorage>;
  29279. /** @hidden */
  29280. _geometry: Nullable<Geometry>;
  29281. /** @hidden */
  29282. _delayInfo: Array<string>;
  29283. /** @hidden */
  29284. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29285. /** @hidden */
  29286. _instanceDataStorage: _InstanceDataStorage;
  29287. /** @hidden */
  29288. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29289. private _effectiveMaterial;
  29290. /** @hidden */
  29291. _shouldGenerateFlatShading: boolean;
  29292. /** @hidden */
  29293. _originalBuilderSideOrientation: number;
  29294. /**
  29295. * Use this property to change the original side orientation defined at construction time
  29296. */
  29297. overrideMaterialSideOrientation: Nullable<number>;
  29298. /**
  29299. * Gets the source mesh (the one used to clone this one from)
  29300. */
  29301. get source(): Nullable<Mesh>;
  29302. /**
  29303. * Gets the list of clones of this mesh
  29304. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29305. * Note that useClonedMeshMap=true is the default setting
  29306. */
  29307. get cloneMeshMap(): Nullable<{
  29308. [id: string]: Mesh | undefined;
  29309. }>;
  29310. /**
  29311. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29312. */
  29313. get isUnIndexed(): boolean;
  29314. set isUnIndexed(value: boolean);
  29315. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29316. get worldMatrixInstancedBuffer(): Float32Array;
  29317. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29318. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29319. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29320. /**
  29321. * @constructor
  29322. * @param name The value used by scene.getMeshByName() to do a lookup.
  29323. * @param scene The scene to add this mesh to.
  29324. * @param parent The parent of this mesh, if it has one
  29325. * @param source An optional Mesh from which geometry is shared, cloned.
  29326. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29327. * When false, achieved by calling a clone(), also passing False.
  29328. * This will make creation of children, recursive.
  29329. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29330. */
  29331. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29332. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29333. doNotInstantiate: boolean;
  29334. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29335. /**
  29336. * Gets the class name
  29337. * @returns the string "Mesh".
  29338. */
  29339. getClassName(): string;
  29340. /** @hidden */
  29341. get _isMesh(): boolean;
  29342. /**
  29343. * Returns a description of this mesh
  29344. * @param fullDetails define if full details about this mesh must be used
  29345. * @returns a descriptive string representing this mesh
  29346. */
  29347. toString(fullDetails?: boolean): string;
  29348. /** @hidden */
  29349. _unBindEffect(): void;
  29350. /**
  29351. * Gets a boolean indicating if this mesh has LOD
  29352. */
  29353. get hasLODLevels(): boolean;
  29354. /**
  29355. * Gets the list of MeshLODLevel associated with the current mesh
  29356. * @returns an array of MeshLODLevel
  29357. */
  29358. getLODLevels(): MeshLODLevel[];
  29359. private _sortLODLevels;
  29360. /**
  29361. * Add a mesh as LOD level triggered at the given distance.
  29362. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29363. * @param distance The distance from the center of the object to show this level
  29364. * @param mesh The mesh to be added as LOD level (can be null)
  29365. * @return This mesh (for chaining)
  29366. */
  29367. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29368. /**
  29369. * Returns the LOD level mesh at the passed distance or null if not found.
  29370. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29371. * @param distance The distance from the center of the object to show this level
  29372. * @returns a Mesh or `null`
  29373. */
  29374. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29375. /**
  29376. * Remove a mesh from the LOD array
  29377. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29378. * @param mesh defines the mesh to be removed
  29379. * @return This mesh (for chaining)
  29380. */
  29381. removeLODLevel(mesh: Mesh): Mesh;
  29382. /**
  29383. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29384. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29385. * @param camera defines the camera to use to compute distance
  29386. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29387. * @return This mesh (for chaining)
  29388. */
  29389. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29390. /**
  29391. * Gets the mesh internal Geometry object
  29392. */
  29393. get geometry(): Nullable<Geometry>;
  29394. /**
  29395. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29396. * @returns the total number of vertices
  29397. */
  29398. getTotalVertices(): number;
  29399. /**
  29400. * Returns the content of an associated vertex buffer
  29401. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29402. * - VertexBuffer.PositionKind
  29403. * - VertexBuffer.UVKind
  29404. * - VertexBuffer.UV2Kind
  29405. * - VertexBuffer.UV3Kind
  29406. * - VertexBuffer.UV4Kind
  29407. * - VertexBuffer.UV5Kind
  29408. * - VertexBuffer.UV6Kind
  29409. * - VertexBuffer.ColorKind
  29410. * - VertexBuffer.MatricesIndicesKind
  29411. * - VertexBuffer.MatricesIndicesExtraKind
  29412. * - VertexBuffer.MatricesWeightsKind
  29413. * - VertexBuffer.MatricesWeightsExtraKind
  29414. * @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
  29415. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29416. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29417. */
  29418. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29419. /**
  29420. * Returns the mesh VertexBuffer object from the requested `kind`
  29421. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29422. * - VertexBuffer.PositionKind
  29423. * - VertexBuffer.NormalKind
  29424. * - VertexBuffer.UVKind
  29425. * - VertexBuffer.UV2Kind
  29426. * - VertexBuffer.UV3Kind
  29427. * - VertexBuffer.UV4Kind
  29428. * - VertexBuffer.UV5Kind
  29429. * - VertexBuffer.UV6Kind
  29430. * - VertexBuffer.ColorKind
  29431. * - VertexBuffer.MatricesIndicesKind
  29432. * - VertexBuffer.MatricesIndicesExtraKind
  29433. * - VertexBuffer.MatricesWeightsKind
  29434. * - VertexBuffer.MatricesWeightsExtraKind
  29435. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29436. */
  29437. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29438. /**
  29439. * Tests if a specific vertex buffer is associated with this mesh
  29440. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29441. * - VertexBuffer.PositionKind
  29442. * - VertexBuffer.NormalKind
  29443. * - VertexBuffer.UVKind
  29444. * - VertexBuffer.UV2Kind
  29445. * - VertexBuffer.UV3Kind
  29446. * - VertexBuffer.UV4Kind
  29447. * - VertexBuffer.UV5Kind
  29448. * - VertexBuffer.UV6Kind
  29449. * - VertexBuffer.ColorKind
  29450. * - VertexBuffer.MatricesIndicesKind
  29451. * - VertexBuffer.MatricesIndicesExtraKind
  29452. * - VertexBuffer.MatricesWeightsKind
  29453. * - VertexBuffer.MatricesWeightsExtraKind
  29454. * @returns a boolean
  29455. */
  29456. isVerticesDataPresent(kind: string): boolean;
  29457. /**
  29458. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29459. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29460. * - VertexBuffer.PositionKind
  29461. * - VertexBuffer.UVKind
  29462. * - VertexBuffer.UV2Kind
  29463. * - VertexBuffer.UV3Kind
  29464. * - VertexBuffer.UV4Kind
  29465. * - VertexBuffer.UV5Kind
  29466. * - VertexBuffer.UV6Kind
  29467. * - VertexBuffer.ColorKind
  29468. * - VertexBuffer.MatricesIndicesKind
  29469. * - VertexBuffer.MatricesIndicesExtraKind
  29470. * - VertexBuffer.MatricesWeightsKind
  29471. * - VertexBuffer.MatricesWeightsExtraKind
  29472. * @returns a boolean
  29473. */
  29474. isVertexBufferUpdatable(kind: string): boolean;
  29475. /**
  29476. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29477. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29478. * - VertexBuffer.PositionKind
  29479. * - VertexBuffer.NormalKind
  29480. * - VertexBuffer.UVKind
  29481. * - VertexBuffer.UV2Kind
  29482. * - VertexBuffer.UV3Kind
  29483. * - VertexBuffer.UV4Kind
  29484. * - VertexBuffer.UV5Kind
  29485. * - VertexBuffer.UV6Kind
  29486. * - VertexBuffer.ColorKind
  29487. * - VertexBuffer.MatricesIndicesKind
  29488. * - VertexBuffer.MatricesIndicesExtraKind
  29489. * - VertexBuffer.MatricesWeightsKind
  29490. * - VertexBuffer.MatricesWeightsExtraKind
  29491. * @returns an array of strings
  29492. */
  29493. getVerticesDataKinds(): string[];
  29494. /**
  29495. * Returns a positive integer : the total number of indices in this mesh geometry.
  29496. * @returns the numner of indices or zero if the mesh has no geometry.
  29497. */
  29498. getTotalIndices(): number;
  29499. /**
  29500. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29501. * @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.
  29502. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29503. * @returns the indices array or an empty array if the mesh has no geometry
  29504. */
  29505. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29506. get isBlocked(): boolean;
  29507. /**
  29508. * Determine if the current mesh is ready to be rendered
  29509. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29510. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29511. * @returns true if all associated assets are ready (material, textures, shaders)
  29512. */
  29513. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29514. /**
  29515. * 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.
  29516. */
  29517. get areNormalsFrozen(): boolean;
  29518. /**
  29519. * 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.
  29520. * @returns the current mesh
  29521. */
  29522. freezeNormals(): Mesh;
  29523. /**
  29524. * 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
  29525. * @returns the current mesh
  29526. */
  29527. unfreezeNormals(): Mesh;
  29528. /**
  29529. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29530. */
  29531. set overridenInstanceCount(count: number);
  29532. /** @hidden */
  29533. _preActivate(): Mesh;
  29534. /** @hidden */
  29535. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29536. /** @hidden */
  29537. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29538. protected _afterComputeWorldMatrix(): void;
  29539. /** @hidden */
  29540. _postActivate(): void;
  29541. /**
  29542. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29543. * This means the mesh underlying bounding box and sphere are recomputed.
  29544. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29545. * @returns the current mesh
  29546. */
  29547. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29548. /** @hidden */
  29549. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29550. /**
  29551. * This function will subdivide the mesh into multiple submeshes
  29552. * @param count defines the expected number of submeshes
  29553. */
  29554. subdivide(count: number): void;
  29555. /**
  29556. * Copy a FloatArray into a specific associated vertex buffer
  29557. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29558. * - VertexBuffer.PositionKind
  29559. * - VertexBuffer.UVKind
  29560. * - VertexBuffer.UV2Kind
  29561. * - VertexBuffer.UV3Kind
  29562. * - VertexBuffer.UV4Kind
  29563. * - VertexBuffer.UV5Kind
  29564. * - VertexBuffer.UV6Kind
  29565. * - VertexBuffer.ColorKind
  29566. * - VertexBuffer.MatricesIndicesKind
  29567. * - VertexBuffer.MatricesIndicesExtraKind
  29568. * - VertexBuffer.MatricesWeightsKind
  29569. * - VertexBuffer.MatricesWeightsExtraKind
  29570. * @param data defines the data source
  29571. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29572. * @param stride defines the data stride size (can be null)
  29573. * @returns the current mesh
  29574. */
  29575. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29576. /**
  29577. * Delete a vertex buffer associated with this mesh
  29578. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29579. * - VertexBuffer.PositionKind
  29580. * - VertexBuffer.UVKind
  29581. * - VertexBuffer.UV2Kind
  29582. * - VertexBuffer.UV3Kind
  29583. * - VertexBuffer.UV4Kind
  29584. * - VertexBuffer.UV5Kind
  29585. * - VertexBuffer.UV6Kind
  29586. * - VertexBuffer.ColorKind
  29587. * - VertexBuffer.MatricesIndicesKind
  29588. * - VertexBuffer.MatricesIndicesExtraKind
  29589. * - VertexBuffer.MatricesWeightsKind
  29590. * - VertexBuffer.MatricesWeightsExtraKind
  29591. */
  29592. removeVerticesData(kind: string): void;
  29593. /**
  29594. * Flags an associated vertex buffer as updatable
  29595. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29596. * - VertexBuffer.PositionKind
  29597. * - VertexBuffer.UVKind
  29598. * - VertexBuffer.UV2Kind
  29599. * - VertexBuffer.UV3Kind
  29600. * - VertexBuffer.UV4Kind
  29601. * - VertexBuffer.UV5Kind
  29602. * - VertexBuffer.UV6Kind
  29603. * - VertexBuffer.ColorKind
  29604. * - VertexBuffer.MatricesIndicesKind
  29605. * - VertexBuffer.MatricesIndicesExtraKind
  29606. * - VertexBuffer.MatricesWeightsKind
  29607. * - VertexBuffer.MatricesWeightsExtraKind
  29608. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29609. */
  29610. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29611. /**
  29612. * Sets the mesh global Vertex Buffer
  29613. * @param buffer defines the buffer to use
  29614. * @returns the current mesh
  29615. */
  29616. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29617. /**
  29618. * Update a specific associated vertex buffer
  29619. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29620. * - VertexBuffer.PositionKind
  29621. * - VertexBuffer.UVKind
  29622. * - VertexBuffer.UV2Kind
  29623. * - VertexBuffer.UV3Kind
  29624. * - VertexBuffer.UV4Kind
  29625. * - VertexBuffer.UV5Kind
  29626. * - VertexBuffer.UV6Kind
  29627. * - VertexBuffer.ColorKind
  29628. * - VertexBuffer.MatricesIndicesKind
  29629. * - VertexBuffer.MatricesIndicesExtraKind
  29630. * - VertexBuffer.MatricesWeightsKind
  29631. * - VertexBuffer.MatricesWeightsExtraKind
  29632. * @param data defines the data source
  29633. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29634. * @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)
  29635. * @returns the current mesh
  29636. */
  29637. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29638. /**
  29639. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29640. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29641. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29642. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29643. * @returns the current mesh
  29644. */
  29645. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29646. /**
  29647. * Creates a un-shared specific occurence of the geometry for the mesh.
  29648. * @returns the current mesh
  29649. */
  29650. makeGeometryUnique(): Mesh;
  29651. /**
  29652. * Set the index buffer of this mesh
  29653. * @param indices defines the source data
  29654. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29655. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29656. * @returns the current mesh
  29657. */
  29658. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29659. /**
  29660. * Update the current index buffer
  29661. * @param indices defines the source data
  29662. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29663. * @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)
  29664. * @returns the current mesh
  29665. */
  29666. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29667. /**
  29668. * Invert the geometry to move from a right handed system to a left handed one.
  29669. * @returns the current mesh
  29670. */
  29671. toLeftHanded(): Mesh;
  29672. /** @hidden */
  29673. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29674. /** @hidden */
  29675. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29676. /**
  29677. * Registers for this mesh a javascript function called just before the rendering process
  29678. * @param func defines the function to call before rendering this mesh
  29679. * @returns the current mesh
  29680. */
  29681. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29682. /**
  29683. * Disposes a previously registered javascript function called before the rendering
  29684. * @param func defines the function to remove
  29685. * @returns the current mesh
  29686. */
  29687. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29688. /**
  29689. * Registers for this mesh a javascript function called just after the rendering is complete
  29690. * @param func defines the function to call after rendering this mesh
  29691. * @returns the current mesh
  29692. */
  29693. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29694. /**
  29695. * Disposes a previously registered javascript function called after the rendering.
  29696. * @param func defines the function to remove
  29697. * @returns the current mesh
  29698. */
  29699. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29700. /** @hidden */
  29701. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29702. /** @hidden */
  29703. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29704. /** @hidden */
  29705. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29706. /** @hidden */
  29707. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29708. /** @hidden */
  29709. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29710. /** @hidden */
  29711. _rebuild(): void;
  29712. /** @hidden */
  29713. _freeze(): void;
  29714. /** @hidden */
  29715. _unFreeze(): void;
  29716. /**
  29717. * 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
  29718. * @param subMesh defines the subMesh to render
  29719. * @param enableAlphaMode defines if alpha mode can be changed
  29720. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29721. * @returns the current mesh
  29722. */
  29723. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29724. private _onBeforeDraw;
  29725. /**
  29726. * Renormalize the mesh and patch it up if there are no weights
  29727. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29728. * However in the case of zero weights then we set just a single influence to 1.
  29729. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29730. */
  29731. cleanMatrixWeights(): void;
  29732. private normalizeSkinFourWeights;
  29733. private normalizeSkinWeightsAndExtra;
  29734. /**
  29735. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29736. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29737. * the user know there was an issue with importing the mesh
  29738. * @returns a validation object with skinned, valid and report string
  29739. */
  29740. validateSkinning(): {
  29741. skinned: boolean;
  29742. valid: boolean;
  29743. report: string;
  29744. };
  29745. /** @hidden */
  29746. _checkDelayState(): Mesh;
  29747. private _queueLoad;
  29748. /**
  29749. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29750. * A mesh is in the frustum if its bounding box intersects the frustum
  29751. * @param frustumPlanes defines the frustum to test
  29752. * @returns true if the mesh is in the frustum planes
  29753. */
  29754. isInFrustum(frustumPlanes: Plane[]): boolean;
  29755. /**
  29756. * Sets the mesh material by the material or multiMaterial `id` property
  29757. * @param id is a string identifying the material or the multiMaterial
  29758. * @returns the current mesh
  29759. */
  29760. setMaterialByID(id: string): Mesh;
  29761. /**
  29762. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29763. * @returns an array of IAnimatable
  29764. */
  29765. getAnimatables(): IAnimatable[];
  29766. /**
  29767. * Modifies the mesh geometry according to the passed transformation matrix.
  29768. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29769. * The mesh normals are modified using the same transformation.
  29770. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29771. * @param transform defines the transform matrix to use
  29772. * @see https://doc.babylonjs.com/resources/baking_transformations
  29773. * @returns the current mesh
  29774. */
  29775. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29776. /**
  29777. * Modifies the mesh geometry according to its own current World Matrix.
  29778. * The mesh World Matrix is then reset.
  29779. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29780. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29781. * @see https://doc.babylonjs.com/resources/baking_transformations
  29782. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29783. * @returns the current mesh
  29784. */
  29785. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29786. /** @hidden */
  29787. get _positions(): Nullable<Vector3[]>;
  29788. /** @hidden */
  29789. _resetPointsArrayCache(): Mesh;
  29790. /** @hidden */
  29791. _generatePointsArray(): boolean;
  29792. /**
  29793. * Returns a new Mesh object generated from the current mesh properties.
  29794. * This method must not get confused with createInstance()
  29795. * @param name is a string, the name given to the new mesh
  29796. * @param newParent can be any Node object (default `null`)
  29797. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29798. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29799. * @returns a new mesh
  29800. */
  29801. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29802. /**
  29803. * Releases resources associated with this mesh.
  29804. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29805. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29806. */
  29807. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29808. /** @hidden */
  29809. _disposeInstanceSpecificData(): void;
  29810. /** @hidden */
  29811. _disposeThinInstanceSpecificData(): void;
  29812. /**
  29813. * Modifies the mesh geometry according to a displacement map.
  29814. * 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.
  29815. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29816. * @param url is a string, the URL from the image file is to be downloaded.
  29817. * @param minHeight is the lower limit of the displacement.
  29818. * @param maxHeight is the upper limit of the displacement.
  29819. * @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.
  29820. * @param uvOffset is an optional vector2 used to offset UV.
  29821. * @param uvScale is an optional vector2 used to scale UV.
  29822. * @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.
  29823. * @returns the Mesh.
  29824. */
  29825. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29826. /**
  29827. * Modifies the mesh geometry according to a displacementMap buffer.
  29828. * 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.
  29829. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29830. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29831. * @param heightMapWidth is the width of the buffer image.
  29832. * @param heightMapHeight is the height of the buffer image.
  29833. * @param minHeight is the lower limit of the displacement.
  29834. * @param maxHeight is the upper limit of the displacement.
  29835. * @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.
  29836. * @param uvOffset is an optional vector2 used to offset UV.
  29837. * @param uvScale is an optional vector2 used to scale UV.
  29838. * @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.
  29839. * @returns the Mesh.
  29840. */
  29841. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29842. /**
  29843. * Modify the mesh to get a flat shading rendering.
  29844. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29845. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29846. * @returns current mesh
  29847. */
  29848. convertToFlatShadedMesh(): Mesh;
  29849. /**
  29850. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29851. * In other words, more vertices, no more indices and a single bigger VBO.
  29852. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29853. * @returns current mesh
  29854. */
  29855. convertToUnIndexedMesh(): Mesh;
  29856. /**
  29857. * Inverses facet orientations.
  29858. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29859. * @param flipNormals will also inverts the normals
  29860. * @returns current mesh
  29861. */
  29862. flipFaces(flipNormals?: boolean): Mesh;
  29863. /**
  29864. * Increase the number of facets and hence vertices in a mesh
  29865. * Vertex normals are interpolated from existing vertex normals
  29866. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29867. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29868. */
  29869. increaseVertices(numberPerEdge: number): void;
  29870. /**
  29871. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29872. * This will undo any application of covertToFlatShadedMesh
  29873. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29874. */
  29875. forceSharedVertices(): void;
  29876. /** @hidden */
  29877. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29878. /** @hidden */
  29879. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29880. /**
  29881. * Creates a new InstancedMesh object from the mesh model.
  29882. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29883. * @param name defines the name of the new instance
  29884. * @returns a new InstancedMesh
  29885. */
  29886. createInstance(name: string): InstancedMesh;
  29887. /**
  29888. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29889. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29890. * @returns the current mesh
  29891. */
  29892. synchronizeInstances(): Mesh;
  29893. /**
  29894. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29895. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29896. * This should be used together with the simplification to avoid disappearing triangles.
  29897. * @param successCallback an optional success callback to be called after the optimization finished.
  29898. * @returns the current mesh
  29899. */
  29900. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29901. /**
  29902. * Serialize current mesh
  29903. * @param serializationObject defines the object which will receive the serialization data
  29904. */
  29905. serialize(serializationObject: any): void;
  29906. /** @hidden */
  29907. _syncGeometryWithMorphTargetManager(): void;
  29908. /** @hidden */
  29909. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29910. /**
  29911. * Returns a new Mesh object parsed from the source provided.
  29912. * @param parsedMesh is the source
  29913. * @param scene defines the hosting scene
  29914. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29915. * @returns a new Mesh
  29916. */
  29917. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29918. /**
  29919. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29920. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29921. * @param name defines the name of the mesh to create
  29922. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29923. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29924. * @param closePath creates a seam between the first and the last points of each path of the path array
  29925. * @param offset is taken in account only if the `pathArray` is containing a single path
  29926. * @param scene defines the hosting scene
  29927. * @param updatable defines if the mesh must be flagged as updatable
  29928. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29929. * @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)
  29930. * @returns a new Mesh
  29931. */
  29932. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29933. /**
  29934. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29935. * @param name defines the name of the mesh to create
  29936. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29937. * @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
  29938. * @param scene defines the hosting scene
  29939. * @param updatable defines if the mesh must be flagged as updatable
  29940. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29941. * @returns a new Mesh
  29942. */
  29943. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29944. /**
  29945. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29946. * @param name defines the name of the mesh to create
  29947. * @param size sets the size (float) of each box side (default 1)
  29948. * @param scene defines the hosting scene
  29949. * @param updatable defines if the mesh must be flagged as updatable
  29950. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29951. * @returns a new Mesh
  29952. */
  29953. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29954. /**
  29955. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29956. * @param name defines the name of the mesh to create
  29957. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29958. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29959. * @param scene defines the hosting scene
  29960. * @param updatable defines if the mesh must be flagged as updatable
  29961. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29962. * @returns a new Mesh
  29963. */
  29964. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29965. /**
  29966. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29967. * @param name defines the name of the mesh to create
  29968. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29969. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29970. * @param scene defines the hosting scene
  29971. * @returns a new Mesh
  29972. */
  29973. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29974. /**
  29975. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29976. * @param name defines the name of the mesh to create
  29977. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29978. * @param diameterTop set the top cap diameter (floats, default 1)
  29979. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29980. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29981. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29982. * @param scene defines the hosting scene
  29983. * @param updatable defines if the mesh must be flagged as updatable
  29984. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29985. * @returns a new Mesh
  29986. */
  29987. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29988. /**
  29989. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29990. * @param name defines the name of the mesh to create
  29991. * @param diameter sets the diameter size (float) of the torus (default 1)
  29992. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29993. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29994. * @param scene defines the hosting scene
  29995. * @param updatable defines if the mesh must be flagged as updatable
  29996. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29997. * @returns a new Mesh
  29998. */
  29999. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30000. /**
  30001. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30002. * @param name defines the name of the mesh to create
  30003. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30004. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30005. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30006. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30007. * @param p the number of windings on X axis (positive integers, default 2)
  30008. * @param q the number of windings on Y axis (positive integers, default 3)
  30009. * @param scene defines the hosting scene
  30010. * @param updatable defines if the mesh must be flagged as updatable
  30011. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30012. * @returns a new Mesh
  30013. */
  30014. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30015. /**
  30016. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30017. * @param name defines the name of the mesh to create
  30018. * @param points is an array successive Vector3
  30019. * @param scene defines the hosting scene
  30020. * @param updatable defines if the mesh must be flagged as updatable
  30021. * @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).
  30022. * @returns a new Mesh
  30023. */
  30024. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30025. /**
  30026. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30027. * @param name defines the name of the mesh to create
  30028. * @param points is an array successive Vector3
  30029. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30030. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30031. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30032. * @param scene defines the hosting scene
  30033. * @param updatable defines if the mesh must be flagged as updatable
  30034. * @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)
  30035. * @returns a new Mesh
  30036. */
  30037. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30038. /**
  30039. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30040. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30041. * 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.
  30042. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30043. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30044. * Remember you can only change the shape positions, not their number when updating a polygon.
  30045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30046. * @param name defines the name of the mesh to create
  30047. * @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
  30048. * @param scene defines the hosting scene
  30049. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30050. * @param updatable defines if the mesh must be flagged as updatable
  30051. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30052. * @param earcutInjection can be used to inject your own earcut reference
  30053. * @returns a new Mesh
  30054. */
  30055. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30056. /**
  30057. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30059. * @param name defines the name of the mesh to create
  30060. * @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
  30061. * @param depth defines the height of extrusion
  30062. * @param scene defines the hosting scene
  30063. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30064. * @param updatable defines if the mesh must be flagged as updatable
  30065. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30066. * @param earcutInjection can be used to inject your own earcut reference
  30067. * @returns a new Mesh
  30068. */
  30069. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30070. /**
  30071. * Creates an extruded shape mesh.
  30072. * 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
  30073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30075. * @param name defines the name of the mesh to create
  30076. * @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
  30077. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30078. * @param scale is the value to scale the shape
  30079. * @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
  30080. * @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
  30081. * @param scene defines the hosting scene
  30082. * @param updatable defines if the mesh must be flagged as updatable
  30083. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30084. * @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)
  30085. * @returns a new Mesh
  30086. */
  30087. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30088. /**
  30089. * Creates an custom extruded shape mesh.
  30090. * The custom extrusion is a parametric shape.
  30091. * It has no predefined shape. Its final shape will depend on the input parameters.
  30092. * Please consider using the same method from the MeshBuilder class instead
  30093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30094. * @param name defines the name of the mesh to create
  30095. * @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
  30096. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30097. * @param scaleFunction is a custom Javascript function called on each path point
  30098. * @param rotationFunction is a custom Javascript function called on each path point
  30099. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30100. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30101. * @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
  30102. * @param scene defines the hosting scene
  30103. * @param updatable defines if the mesh must be flagged as updatable
  30104. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30105. * @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)
  30106. * @returns a new Mesh
  30107. */
  30108. 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;
  30109. /**
  30110. * Creates lathe mesh.
  30111. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30112. * Please consider using the same method from the MeshBuilder class instead
  30113. * @param name defines the name of the mesh to create
  30114. * @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
  30115. * @param radius is the radius value of the lathe
  30116. * @param tessellation is the side number of the lathe.
  30117. * @param scene defines the hosting scene
  30118. * @param updatable defines if the mesh must be flagged as updatable
  30119. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30120. * @returns a new Mesh
  30121. */
  30122. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30123. /**
  30124. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30125. * @param name defines the name of the mesh to create
  30126. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30127. * @param scene defines the hosting scene
  30128. * @param updatable defines if the mesh must be flagged as updatable
  30129. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30130. * @returns a new Mesh
  30131. */
  30132. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30133. /**
  30134. * Creates a ground mesh.
  30135. * Please consider using the same method from the MeshBuilder class instead
  30136. * @param name defines the name of the mesh to create
  30137. * @param width set the width of the ground
  30138. * @param height set the height of the ground
  30139. * @param subdivisions sets the number of subdivisions per side
  30140. * @param scene defines the hosting scene
  30141. * @param updatable defines if the mesh must be flagged as updatable
  30142. * @returns a new Mesh
  30143. */
  30144. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30145. /**
  30146. * Creates a tiled ground mesh.
  30147. * Please consider using the same method from the MeshBuilder class instead
  30148. * @param name defines the name of the mesh to create
  30149. * @param xmin set the ground minimum X coordinate
  30150. * @param zmin set the ground minimum Y coordinate
  30151. * @param xmax set the ground maximum X coordinate
  30152. * @param zmax set the ground maximum Z coordinate
  30153. * @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
  30154. * @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
  30155. * @param scene defines the hosting scene
  30156. * @param updatable defines if the mesh must be flagged as updatable
  30157. * @returns a new Mesh
  30158. */
  30159. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30160. w: number;
  30161. h: number;
  30162. }, precision: {
  30163. w: number;
  30164. h: number;
  30165. }, scene: Scene, updatable?: boolean): Mesh;
  30166. /**
  30167. * Creates a ground mesh from a height map.
  30168. * Please consider using the same method from the MeshBuilder class instead
  30169. * @see https://doc.babylonjs.com/babylon101/height_map
  30170. * @param name defines the name of the mesh to create
  30171. * @param url sets the URL of the height map image resource
  30172. * @param width set the ground width size
  30173. * @param height set the ground height size
  30174. * @param subdivisions sets the number of subdivision per side
  30175. * @param minHeight is the minimum altitude on the ground
  30176. * @param maxHeight is the maximum altitude on the ground
  30177. * @param scene defines the hosting scene
  30178. * @param updatable defines if the mesh must be flagged as updatable
  30179. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30180. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30181. * @returns a new Mesh
  30182. */
  30183. 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;
  30184. /**
  30185. * Creates a tube mesh.
  30186. * The tube is a parametric shape.
  30187. * It has no predefined shape. Its final shape will depend on the input parameters.
  30188. * Please consider using the same method from the MeshBuilder class instead
  30189. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30190. * @param name defines the name of the mesh to create
  30191. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30192. * @param radius sets the tube radius size
  30193. * @param tessellation is the number of sides on the tubular surface
  30194. * @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
  30195. * @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
  30196. * @param scene defines the hosting scene
  30197. * @param updatable defines if the mesh must be flagged as updatable
  30198. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30199. * @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)
  30200. * @returns a new Mesh
  30201. */
  30202. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30203. (i: number, distance: number): number;
  30204. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30205. /**
  30206. * Creates a polyhedron mesh.
  30207. * Please consider using the same method from the MeshBuilder class instead.
  30208. * * 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
  30209. * * The parameter `size` (positive float, default 1) sets the polygon size
  30210. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30211. * * 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`
  30212. * * 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
  30213. * * 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)`)
  30214. * * 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
  30215. * * 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
  30216. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30219. * @param name defines the name of the mesh to create
  30220. * @param options defines the options used to create the mesh
  30221. * @param scene defines the hosting scene
  30222. * @returns a new Mesh
  30223. */
  30224. static CreatePolyhedron(name: string, options: {
  30225. type?: number;
  30226. size?: number;
  30227. sizeX?: number;
  30228. sizeY?: number;
  30229. sizeZ?: number;
  30230. custom?: any;
  30231. faceUV?: Vector4[];
  30232. faceColors?: Color4[];
  30233. updatable?: boolean;
  30234. sideOrientation?: number;
  30235. }, scene: Scene): Mesh;
  30236. /**
  30237. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30238. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30239. * * 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`)
  30240. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30241. * * 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
  30242. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30245. * @param name defines the name of the mesh
  30246. * @param options defines the options used to create the mesh
  30247. * @param scene defines the hosting scene
  30248. * @returns a new Mesh
  30249. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30250. */
  30251. static CreateIcoSphere(name: string, options: {
  30252. radius?: number;
  30253. flat?: boolean;
  30254. subdivisions?: number;
  30255. sideOrientation?: number;
  30256. updatable?: boolean;
  30257. }, scene: Scene): Mesh;
  30258. /**
  30259. * Creates a decal mesh.
  30260. * Please consider using the same method from the MeshBuilder class instead.
  30261. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30262. * @param name defines the name of the mesh
  30263. * @param sourceMesh defines the mesh receiving the decal
  30264. * @param position sets the position of the decal in world coordinates
  30265. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30266. * @param size sets the decal scaling
  30267. * @param angle sets the angle to rotate the decal
  30268. * @returns a new Mesh
  30269. */
  30270. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30271. /**
  30272. * Prepare internal position array for software CPU skinning
  30273. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30274. */
  30275. setPositionsForCPUSkinning(): Float32Array;
  30276. /**
  30277. * Prepare internal normal array for software CPU skinning
  30278. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30279. */
  30280. setNormalsForCPUSkinning(): Float32Array;
  30281. /**
  30282. * Updates the vertex buffer by applying transformation from the bones
  30283. * @param skeleton defines the skeleton to apply to current mesh
  30284. * @returns the current mesh
  30285. */
  30286. applySkeleton(skeleton: Skeleton): Mesh;
  30287. /**
  30288. * 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
  30289. * @param meshes defines the list of meshes to scan
  30290. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30291. */
  30292. static MinMax(meshes: AbstractMesh[]): {
  30293. min: Vector3;
  30294. max: Vector3;
  30295. };
  30296. /**
  30297. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30298. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30299. * @returns a vector3
  30300. */
  30301. static Center(meshesOrMinMaxVector: {
  30302. min: Vector3;
  30303. max: Vector3;
  30304. } | AbstractMesh[]): Vector3;
  30305. /**
  30306. * Merge the array of meshes into a single mesh for performance reasons.
  30307. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30308. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30309. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30310. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30311. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30312. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30313. * @returns a new mesh
  30314. */
  30315. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30316. /** @hidden */
  30317. addInstance(instance: InstancedMesh): void;
  30318. /** @hidden */
  30319. removeInstance(instance: InstancedMesh): void;
  30320. }
  30321. }
  30322. declare module "babylonjs/Cameras/camera" {
  30323. import { SmartArray } from "babylonjs/Misc/smartArray";
  30324. import { Observable } from "babylonjs/Misc/observable";
  30325. import { Nullable } from "babylonjs/types";
  30326. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30327. import { Scene } from "babylonjs/scene";
  30328. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30329. import { Node } from "babylonjs/node";
  30330. import { Mesh } from "babylonjs/Meshes/mesh";
  30331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30332. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30333. import { Viewport } from "babylonjs/Maths/math.viewport";
  30334. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30335. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30336. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30337. import { Ray } from "babylonjs/Culling/ray";
  30338. /**
  30339. * This is the base class of all the camera used in the application.
  30340. * @see https://doc.babylonjs.com/features/cameras
  30341. */
  30342. export class Camera extends Node {
  30343. /** @hidden */
  30344. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30345. /**
  30346. * This is the default projection mode used by the cameras.
  30347. * It helps recreating a feeling of perspective and better appreciate depth.
  30348. * This is the best way to simulate real life cameras.
  30349. */
  30350. static readonly PERSPECTIVE_CAMERA: number;
  30351. /**
  30352. * This helps creating camera with an orthographic mode.
  30353. * 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.
  30354. */
  30355. static readonly ORTHOGRAPHIC_CAMERA: number;
  30356. /**
  30357. * This is the default FOV mode for perspective cameras.
  30358. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30359. */
  30360. static readonly FOVMODE_VERTICAL_FIXED: number;
  30361. /**
  30362. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30363. */
  30364. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30365. /**
  30366. * This specifies ther is no need for a camera rig.
  30367. * Basically only one eye is rendered corresponding to the camera.
  30368. */
  30369. static readonly RIG_MODE_NONE: number;
  30370. /**
  30371. * Simulates a camera Rig with one blue eye and one red eye.
  30372. * This can be use with 3d blue and red glasses.
  30373. */
  30374. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30375. /**
  30376. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30377. */
  30378. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30379. /**
  30380. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30381. */
  30382. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30383. /**
  30384. * Defines that both eyes of the camera will be rendered over under each other.
  30385. */
  30386. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30387. /**
  30388. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30389. */
  30390. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30391. /**
  30392. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30393. */
  30394. static readonly RIG_MODE_VR: number;
  30395. /**
  30396. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30397. */
  30398. static readonly RIG_MODE_WEBVR: number;
  30399. /**
  30400. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30401. */
  30402. static readonly RIG_MODE_CUSTOM: number;
  30403. /**
  30404. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30405. */
  30406. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30407. /**
  30408. * Define the input manager associated with the camera.
  30409. */
  30410. inputs: CameraInputsManager<Camera>;
  30411. /** @hidden */
  30412. _position: Vector3;
  30413. /**
  30414. * Define the current local position of the camera in the scene
  30415. */
  30416. get position(): Vector3;
  30417. set position(newPosition: Vector3);
  30418. protected _upVector: Vector3;
  30419. /**
  30420. * The vector the camera should consider as up.
  30421. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30422. */
  30423. set upVector(vec: Vector3);
  30424. get upVector(): Vector3;
  30425. /**
  30426. * Define the current limit on the left side for an orthographic camera
  30427. * In scene unit
  30428. */
  30429. orthoLeft: Nullable<number>;
  30430. /**
  30431. * Define the current limit on the right side for an orthographic camera
  30432. * In scene unit
  30433. */
  30434. orthoRight: Nullable<number>;
  30435. /**
  30436. * Define the current limit on the bottom side for an orthographic camera
  30437. * In scene unit
  30438. */
  30439. orthoBottom: Nullable<number>;
  30440. /**
  30441. * Define the current limit on the top side for an orthographic camera
  30442. * In scene unit
  30443. */
  30444. orthoTop: Nullable<number>;
  30445. /**
  30446. * Field Of View is set in Radians. (default is 0.8)
  30447. */
  30448. fov: number;
  30449. /**
  30450. * Define the minimum distance the camera can see from.
  30451. * This is important to note that the depth buffer are not infinite and the closer it starts
  30452. * the more your scene might encounter depth fighting issue.
  30453. */
  30454. minZ: number;
  30455. /**
  30456. * Define the maximum distance the camera can see to.
  30457. * This is important to note that the depth buffer are not infinite and the further it end
  30458. * the more your scene might encounter depth fighting issue.
  30459. */
  30460. maxZ: number;
  30461. /**
  30462. * Define the default inertia of the camera.
  30463. * This helps giving a smooth feeling to the camera movement.
  30464. */
  30465. inertia: number;
  30466. /**
  30467. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30468. */
  30469. mode: number;
  30470. /**
  30471. * Define whether the camera is intermediate.
  30472. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30473. */
  30474. isIntermediate: boolean;
  30475. /**
  30476. * Define the viewport of the camera.
  30477. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30478. */
  30479. viewport: Viewport;
  30480. /**
  30481. * Restricts the camera to viewing objects with the same layerMask.
  30482. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30483. */
  30484. layerMask: number;
  30485. /**
  30486. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30487. */
  30488. fovMode: number;
  30489. /**
  30490. * Rig mode of the camera.
  30491. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30492. * This is normally controlled byt the camera themselves as internal use.
  30493. */
  30494. cameraRigMode: number;
  30495. /**
  30496. * Defines the distance between both "eyes" in case of a RIG
  30497. */
  30498. interaxialDistance: number;
  30499. /**
  30500. * Defines if stereoscopic rendering is done side by side or over under.
  30501. */
  30502. isStereoscopicSideBySide: boolean;
  30503. /**
  30504. * 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
  30505. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30506. * else in the scene. (Eg. security camera)
  30507. *
  30508. * 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)
  30509. */
  30510. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30511. /**
  30512. * When set, the camera will render to this render target instead of the default canvas
  30513. *
  30514. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30515. */
  30516. outputRenderTarget: Nullable<RenderTargetTexture>;
  30517. /**
  30518. * Observable triggered when the camera view matrix has changed.
  30519. */
  30520. onViewMatrixChangedObservable: Observable<Camera>;
  30521. /**
  30522. * Observable triggered when the camera Projection matrix has changed.
  30523. */
  30524. onProjectionMatrixChangedObservable: Observable<Camera>;
  30525. /**
  30526. * Observable triggered when the inputs have been processed.
  30527. */
  30528. onAfterCheckInputsObservable: Observable<Camera>;
  30529. /**
  30530. * Observable triggered when reset has been called and applied to the camera.
  30531. */
  30532. onRestoreStateObservable: Observable<Camera>;
  30533. /**
  30534. * Is this camera a part of a rig system?
  30535. */
  30536. isRigCamera: boolean;
  30537. /**
  30538. * If isRigCamera set to true this will be set with the parent camera.
  30539. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30540. */
  30541. rigParent?: Camera;
  30542. /** @hidden */
  30543. _cameraRigParams: any;
  30544. /** @hidden */
  30545. _rigCameras: Camera[];
  30546. /** @hidden */
  30547. _rigPostProcess: Nullable<PostProcess>;
  30548. protected _webvrViewMatrix: Matrix;
  30549. /** @hidden */
  30550. _skipRendering: boolean;
  30551. /** @hidden */
  30552. _projectionMatrix: Matrix;
  30553. /** @hidden */
  30554. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30555. /** @hidden */
  30556. _activeMeshes: SmartArray<AbstractMesh>;
  30557. protected _globalPosition: Vector3;
  30558. /** @hidden */
  30559. _computedViewMatrix: Matrix;
  30560. private _doNotComputeProjectionMatrix;
  30561. private _transformMatrix;
  30562. private _frustumPlanes;
  30563. private _refreshFrustumPlanes;
  30564. private _storedFov;
  30565. private _stateStored;
  30566. /**
  30567. * Instantiates a new camera object.
  30568. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30569. * @see https://doc.babylonjs.com/features/cameras
  30570. * @param name Defines the name of the camera in the scene
  30571. * @param position Defines the position of the camera
  30572. * @param scene Defines the scene the camera belongs too
  30573. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30574. */
  30575. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30576. /**
  30577. * Store current camera state (fov, position, etc..)
  30578. * @returns the camera
  30579. */
  30580. storeState(): Camera;
  30581. /**
  30582. * Restores the camera state values if it has been stored. You must call storeState() first
  30583. */
  30584. protected _restoreStateValues(): boolean;
  30585. /**
  30586. * Restored camera state. You must call storeState() first.
  30587. * @returns true if restored and false otherwise
  30588. */
  30589. restoreState(): boolean;
  30590. /**
  30591. * Gets the class name of the camera.
  30592. * @returns the class name
  30593. */
  30594. getClassName(): string;
  30595. /** @hidden */
  30596. readonly _isCamera: boolean;
  30597. /**
  30598. * Gets a string representation of the camera useful for debug purpose.
  30599. * @param fullDetails Defines that a more verboe level of logging is required
  30600. * @returns the string representation
  30601. */
  30602. toString(fullDetails?: boolean): string;
  30603. /**
  30604. * Gets the current world space position of the camera.
  30605. */
  30606. get globalPosition(): Vector3;
  30607. /**
  30608. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30609. * @returns the active meshe list
  30610. */
  30611. getActiveMeshes(): SmartArray<AbstractMesh>;
  30612. /**
  30613. * Check whether a mesh is part of the current active mesh list of the camera
  30614. * @param mesh Defines the mesh to check
  30615. * @returns true if active, false otherwise
  30616. */
  30617. isActiveMesh(mesh: Mesh): boolean;
  30618. /**
  30619. * Is this camera ready to be used/rendered
  30620. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30621. * @return true if the camera is ready
  30622. */
  30623. isReady(completeCheck?: boolean): boolean;
  30624. /** @hidden */
  30625. _initCache(): void;
  30626. /** @hidden */
  30627. _updateCache(ignoreParentClass?: boolean): void;
  30628. /** @hidden */
  30629. _isSynchronized(): boolean;
  30630. /** @hidden */
  30631. _isSynchronizedViewMatrix(): boolean;
  30632. /** @hidden */
  30633. _isSynchronizedProjectionMatrix(): boolean;
  30634. /**
  30635. * Attach the input controls to a specific dom element to get the input from.
  30636. * @param element Defines the element the controls should be listened from
  30637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30638. */
  30639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30640. /**
  30641. * Detach the current controls from the specified dom element.
  30642. * @param element Defines the element to stop listening the inputs from
  30643. */
  30644. detachControl(element: HTMLElement): void;
  30645. /**
  30646. * Update the camera state according to the different inputs gathered during the frame.
  30647. */
  30648. update(): void;
  30649. /** @hidden */
  30650. _checkInputs(): void;
  30651. /** @hidden */
  30652. get rigCameras(): Camera[];
  30653. /**
  30654. * Gets the post process used by the rig cameras
  30655. */
  30656. get rigPostProcess(): Nullable<PostProcess>;
  30657. /**
  30658. * Internal, gets the first post proces.
  30659. * @returns the first post process to be run on this camera.
  30660. */
  30661. _getFirstPostProcess(): Nullable<PostProcess>;
  30662. private _cascadePostProcessesToRigCams;
  30663. /**
  30664. * Attach a post process to the camera.
  30665. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30666. * @param postProcess The post process to attach to the camera
  30667. * @param insertAt The position of the post process in case several of them are in use in the scene
  30668. * @returns the position the post process has been inserted at
  30669. */
  30670. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30671. /**
  30672. * Detach a post process to the camera.
  30673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30674. * @param postProcess The post process to detach from the camera
  30675. */
  30676. detachPostProcess(postProcess: PostProcess): void;
  30677. /**
  30678. * Gets the current world matrix of the camera
  30679. */
  30680. getWorldMatrix(): Matrix;
  30681. /** @hidden */
  30682. _getViewMatrix(): Matrix;
  30683. /**
  30684. * Gets the current view matrix of the camera.
  30685. * @param force forces the camera to recompute the matrix without looking at the cached state
  30686. * @returns the view matrix
  30687. */
  30688. getViewMatrix(force?: boolean): Matrix;
  30689. /**
  30690. * Freeze the projection matrix.
  30691. * It will prevent the cache check of the camera projection compute and can speed up perf
  30692. * if no parameter of the camera are meant to change
  30693. * @param projection Defines manually a projection if necessary
  30694. */
  30695. freezeProjectionMatrix(projection?: Matrix): void;
  30696. /**
  30697. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30698. */
  30699. unfreezeProjectionMatrix(): void;
  30700. /**
  30701. * Gets the current projection matrix of the camera.
  30702. * @param force forces the camera to recompute the matrix without looking at the cached state
  30703. * @returns the projection matrix
  30704. */
  30705. getProjectionMatrix(force?: boolean): Matrix;
  30706. /**
  30707. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30708. * @returns a Matrix
  30709. */
  30710. getTransformationMatrix(): Matrix;
  30711. private _updateFrustumPlanes;
  30712. /**
  30713. * Checks if a cullable object (mesh...) is in the camera frustum
  30714. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30715. * @param target The object to check
  30716. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30717. * @returns true if the object is in frustum otherwise false
  30718. */
  30719. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30720. /**
  30721. * Checks if a cullable object (mesh...) is in the camera frustum
  30722. * Unlike isInFrustum this cheks the full bounding box
  30723. * @param target The object to check
  30724. * @returns true if the object is in frustum otherwise false
  30725. */
  30726. isCompletelyInFrustum(target: ICullable): boolean;
  30727. /**
  30728. * Gets a ray in the forward direction from the camera.
  30729. * @param length Defines the length of the ray to create
  30730. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30731. * @param origin Defines the start point of the ray which defaults to the camera position
  30732. * @returns the forward ray
  30733. */
  30734. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30735. /**
  30736. * Gets a ray in the forward direction from the camera.
  30737. * @param refRay the ray to (re)use when setting the values
  30738. * @param length Defines the length of the ray to create
  30739. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30740. * @param origin Defines the start point of the ray which defaults to the camera position
  30741. * @returns the forward ray
  30742. */
  30743. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30744. /**
  30745. * Releases resources associated with this node.
  30746. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30747. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30748. */
  30749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30750. /** @hidden */
  30751. _isLeftCamera: boolean;
  30752. /**
  30753. * Gets the left camera of a rig setup in case of Rigged Camera
  30754. */
  30755. get isLeftCamera(): boolean;
  30756. /** @hidden */
  30757. _isRightCamera: boolean;
  30758. /**
  30759. * Gets the right camera of a rig setup in case of Rigged Camera
  30760. */
  30761. get isRightCamera(): boolean;
  30762. /**
  30763. * Gets the left camera of a rig setup in case of Rigged Camera
  30764. */
  30765. get leftCamera(): Nullable<FreeCamera>;
  30766. /**
  30767. * Gets the right camera of a rig setup in case of Rigged Camera
  30768. */
  30769. get rightCamera(): Nullable<FreeCamera>;
  30770. /**
  30771. * Gets the left camera target of a rig setup in case of Rigged Camera
  30772. * @returns the target position
  30773. */
  30774. getLeftTarget(): Nullable<Vector3>;
  30775. /**
  30776. * Gets the right camera target of a rig setup in case of Rigged Camera
  30777. * @returns the target position
  30778. */
  30779. getRightTarget(): Nullable<Vector3>;
  30780. /**
  30781. * @hidden
  30782. */
  30783. setCameraRigMode(mode: number, rigParams: any): void;
  30784. /** @hidden */
  30785. static _setStereoscopicRigMode(camera: Camera): void;
  30786. /** @hidden */
  30787. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30788. /** @hidden */
  30789. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30790. /** @hidden */
  30791. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30792. /** @hidden */
  30793. _getVRProjectionMatrix(): Matrix;
  30794. protected _updateCameraRotationMatrix(): void;
  30795. protected _updateWebVRCameraRotationMatrix(): void;
  30796. /**
  30797. * This function MUST be overwritten by the different WebVR cameras available.
  30798. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30799. * @hidden
  30800. */
  30801. _getWebVRProjectionMatrix(): Matrix;
  30802. /**
  30803. * This function MUST be overwritten by the different WebVR cameras available.
  30804. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30805. * @hidden
  30806. */
  30807. _getWebVRViewMatrix(): Matrix;
  30808. /** @hidden */
  30809. setCameraRigParameter(name: string, value: any): void;
  30810. /**
  30811. * needs to be overridden by children so sub has required properties to be copied
  30812. * @hidden
  30813. */
  30814. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30815. /**
  30816. * May need to be overridden by children
  30817. * @hidden
  30818. */
  30819. _updateRigCameras(): void;
  30820. /** @hidden */
  30821. _setupInputs(): void;
  30822. /**
  30823. * Serialiaze the camera setup to a json represention
  30824. * @returns the JSON representation
  30825. */
  30826. serialize(): any;
  30827. /**
  30828. * Clones the current camera.
  30829. * @param name The cloned camera name
  30830. * @returns the cloned camera
  30831. */
  30832. clone(name: string): Camera;
  30833. /**
  30834. * Gets the direction of the camera relative to a given local axis.
  30835. * @param localAxis Defines the reference axis to provide a relative direction.
  30836. * @return the direction
  30837. */
  30838. getDirection(localAxis: Vector3): Vector3;
  30839. /**
  30840. * Returns the current camera absolute rotation
  30841. */
  30842. get absoluteRotation(): Quaternion;
  30843. /**
  30844. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30845. * @param localAxis Defines the reference axis to provide a relative direction.
  30846. * @param result Defines the vector to store the result in
  30847. */
  30848. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30849. /**
  30850. * Gets a camera constructor for a given camera type
  30851. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30852. * @param name The name of the camera the result will be able to instantiate
  30853. * @param scene The scene the result will construct the camera in
  30854. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30855. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30856. * @returns a factory method to construc the camera
  30857. */
  30858. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30859. /**
  30860. * Compute the world matrix of the camera.
  30861. * @returns the camera world matrix
  30862. */
  30863. computeWorldMatrix(): Matrix;
  30864. /**
  30865. * Parse a JSON and creates the camera from the parsed information
  30866. * @param parsedCamera The JSON to parse
  30867. * @param scene The scene to instantiate the camera in
  30868. * @returns the newly constructed camera
  30869. */
  30870. static Parse(parsedCamera: any, scene: Scene): Camera;
  30871. }
  30872. }
  30873. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30874. import { Nullable } from "babylonjs/types";
  30875. import { Scene } from "babylonjs/scene";
  30876. import { Vector4 } from "babylonjs/Maths/math.vector";
  30877. import { Mesh } from "babylonjs/Meshes/mesh";
  30878. /**
  30879. * Class containing static functions to help procedurally build meshes
  30880. */
  30881. export class DiscBuilder {
  30882. /**
  30883. * Creates a plane polygonal mesh. By default, this is a disc
  30884. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30885. * * 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
  30886. * * 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
  30887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30890. * @param name defines the name of the mesh
  30891. * @param options defines the options used to create the mesh
  30892. * @param scene defines the hosting scene
  30893. * @returns the plane polygonal mesh
  30894. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30895. */
  30896. static CreateDisc(name: string, options: {
  30897. radius?: number;
  30898. tessellation?: number;
  30899. arc?: number;
  30900. updatable?: boolean;
  30901. sideOrientation?: number;
  30902. frontUVs?: Vector4;
  30903. backUVs?: Vector4;
  30904. }, scene?: Nullable<Scene>): Mesh;
  30905. }
  30906. }
  30907. declare module "babylonjs/Materials/fresnelParameters" {
  30908. import { DeepImmutable } from "babylonjs/types";
  30909. import { Color3 } from "babylonjs/Maths/math.color";
  30910. /**
  30911. * Options to be used when creating a FresnelParameters.
  30912. */
  30913. export type IFresnelParametersCreationOptions = {
  30914. /**
  30915. * Define the color used on edges (grazing angle)
  30916. */
  30917. leftColor?: Color3;
  30918. /**
  30919. * Define the color used on center
  30920. */
  30921. rightColor?: Color3;
  30922. /**
  30923. * Define bias applied to computed fresnel term
  30924. */
  30925. bias?: number;
  30926. /**
  30927. * Defined the power exponent applied to fresnel term
  30928. */
  30929. power?: number;
  30930. /**
  30931. * Define if the fresnel effect is enable or not.
  30932. */
  30933. isEnabled?: boolean;
  30934. };
  30935. /**
  30936. * Serialized format for FresnelParameters.
  30937. */
  30938. export type IFresnelParametersSerialized = {
  30939. /**
  30940. * Define the color used on edges (grazing angle) [as an array]
  30941. */
  30942. leftColor: number[];
  30943. /**
  30944. * Define the color used on center [as an array]
  30945. */
  30946. rightColor: number[];
  30947. /**
  30948. * Define bias applied to computed fresnel term
  30949. */
  30950. bias: number;
  30951. /**
  30952. * Defined the power exponent applied to fresnel term
  30953. */
  30954. power?: number;
  30955. /**
  30956. * Define if the fresnel effect is enable or not.
  30957. */
  30958. isEnabled: boolean;
  30959. };
  30960. /**
  30961. * This represents all the required information to add a fresnel effect on a material:
  30962. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30963. */
  30964. export class FresnelParameters {
  30965. private _isEnabled;
  30966. /**
  30967. * Define if the fresnel effect is enable or not.
  30968. */
  30969. get isEnabled(): boolean;
  30970. set isEnabled(value: boolean);
  30971. /**
  30972. * Define the color used on edges (grazing angle)
  30973. */
  30974. leftColor: Color3;
  30975. /**
  30976. * Define the color used on center
  30977. */
  30978. rightColor: Color3;
  30979. /**
  30980. * Define bias applied to computed fresnel term
  30981. */
  30982. bias: number;
  30983. /**
  30984. * Defined the power exponent applied to fresnel term
  30985. */
  30986. power: number;
  30987. /**
  30988. * Creates a new FresnelParameters object.
  30989. *
  30990. * @param options provide your own settings to optionally to override defaults
  30991. */
  30992. constructor(options?: IFresnelParametersCreationOptions);
  30993. /**
  30994. * Clones the current fresnel and its valuues
  30995. * @returns a clone fresnel configuration
  30996. */
  30997. clone(): FresnelParameters;
  30998. /**
  30999. * Determines equality between FresnelParameters objects
  31000. * @param otherFresnelParameters defines the second operand
  31001. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31002. */
  31003. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31004. /**
  31005. * Serializes the current fresnel parameters to a JSON representation.
  31006. * @return the JSON serialization
  31007. */
  31008. serialize(): IFresnelParametersSerialized;
  31009. /**
  31010. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31011. * @param parsedFresnelParameters Define the JSON representation
  31012. * @returns the parsed parameters
  31013. */
  31014. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31015. }
  31016. }
  31017. declare module "babylonjs/Materials/materialFlags" {
  31018. /**
  31019. * This groups all the flags used to control the materials channel.
  31020. */
  31021. export class MaterialFlags {
  31022. private static _DiffuseTextureEnabled;
  31023. /**
  31024. * Are diffuse textures enabled in the application.
  31025. */
  31026. static get DiffuseTextureEnabled(): boolean;
  31027. static set DiffuseTextureEnabled(value: boolean);
  31028. private static _DetailTextureEnabled;
  31029. /**
  31030. * Are detail textures enabled in the application.
  31031. */
  31032. static get DetailTextureEnabled(): boolean;
  31033. static set DetailTextureEnabled(value: boolean);
  31034. private static _AmbientTextureEnabled;
  31035. /**
  31036. * Are ambient textures enabled in the application.
  31037. */
  31038. static get AmbientTextureEnabled(): boolean;
  31039. static set AmbientTextureEnabled(value: boolean);
  31040. private static _OpacityTextureEnabled;
  31041. /**
  31042. * Are opacity textures enabled in the application.
  31043. */
  31044. static get OpacityTextureEnabled(): boolean;
  31045. static set OpacityTextureEnabled(value: boolean);
  31046. private static _ReflectionTextureEnabled;
  31047. /**
  31048. * Are reflection textures enabled in the application.
  31049. */
  31050. static get ReflectionTextureEnabled(): boolean;
  31051. static set ReflectionTextureEnabled(value: boolean);
  31052. private static _EmissiveTextureEnabled;
  31053. /**
  31054. * Are emissive textures enabled in the application.
  31055. */
  31056. static get EmissiveTextureEnabled(): boolean;
  31057. static set EmissiveTextureEnabled(value: boolean);
  31058. private static _SpecularTextureEnabled;
  31059. /**
  31060. * Are specular textures enabled in the application.
  31061. */
  31062. static get SpecularTextureEnabled(): boolean;
  31063. static set SpecularTextureEnabled(value: boolean);
  31064. private static _BumpTextureEnabled;
  31065. /**
  31066. * Are bump textures enabled in the application.
  31067. */
  31068. static get BumpTextureEnabled(): boolean;
  31069. static set BumpTextureEnabled(value: boolean);
  31070. private static _LightmapTextureEnabled;
  31071. /**
  31072. * Are lightmap textures enabled in the application.
  31073. */
  31074. static get LightmapTextureEnabled(): boolean;
  31075. static set LightmapTextureEnabled(value: boolean);
  31076. private static _RefractionTextureEnabled;
  31077. /**
  31078. * Are refraction textures enabled in the application.
  31079. */
  31080. static get RefractionTextureEnabled(): boolean;
  31081. static set RefractionTextureEnabled(value: boolean);
  31082. private static _ColorGradingTextureEnabled;
  31083. /**
  31084. * Are color grading textures enabled in the application.
  31085. */
  31086. static get ColorGradingTextureEnabled(): boolean;
  31087. static set ColorGradingTextureEnabled(value: boolean);
  31088. private static _FresnelEnabled;
  31089. /**
  31090. * Are fresnels enabled in the application.
  31091. */
  31092. static get FresnelEnabled(): boolean;
  31093. static set FresnelEnabled(value: boolean);
  31094. private static _ClearCoatTextureEnabled;
  31095. /**
  31096. * Are clear coat textures enabled in the application.
  31097. */
  31098. static get ClearCoatTextureEnabled(): boolean;
  31099. static set ClearCoatTextureEnabled(value: boolean);
  31100. private static _ClearCoatBumpTextureEnabled;
  31101. /**
  31102. * Are clear coat bump textures enabled in the application.
  31103. */
  31104. static get ClearCoatBumpTextureEnabled(): boolean;
  31105. static set ClearCoatBumpTextureEnabled(value: boolean);
  31106. private static _ClearCoatTintTextureEnabled;
  31107. /**
  31108. * Are clear coat tint textures enabled in the application.
  31109. */
  31110. static get ClearCoatTintTextureEnabled(): boolean;
  31111. static set ClearCoatTintTextureEnabled(value: boolean);
  31112. private static _SheenTextureEnabled;
  31113. /**
  31114. * Are sheen textures enabled in the application.
  31115. */
  31116. static get SheenTextureEnabled(): boolean;
  31117. static set SheenTextureEnabled(value: boolean);
  31118. private static _AnisotropicTextureEnabled;
  31119. /**
  31120. * Are anisotropic textures enabled in the application.
  31121. */
  31122. static get AnisotropicTextureEnabled(): boolean;
  31123. static set AnisotropicTextureEnabled(value: boolean);
  31124. private static _ThicknessTextureEnabled;
  31125. /**
  31126. * Are thickness textures enabled in the application.
  31127. */
  31128. static get ThicknessTextureEnabled(): boolean;
  31129. static set ThicknessTextureEnabled(value: boolean);
  31130. }
  31131. }
  31132. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31133. /** @hidden */
  31134. export var defaultFragmentDeclaration: {
  31135. name: string;
  31136. shader: string;
  31137. };
  31138. }
  31139. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31140. /** @hidden */
  31141. export var defaultUboDeclaration: {
  31142. name: string;
  31143. shader: string;
  31144. };
  31145. }
  31146. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31147. /** @hidden */
  31148. export var prePassDeclaration: {
  31149. name: string;
  31150. shader: string;
  31151. };
  31152. }
  31153. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31154. /** @hidden */
  31155. export var lightFragmentDeclaration: {
  31156. name: string;
  31157. shader: string;
  31158. };
  31159. }
  31160. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31161. /** @hidden */
  31162. export var lightUboDeclaration: {
  31163. name: string;
  31164. shader: string;
  31165. };
  31166. }
  31167. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31168. /** @hidden */
  31169. export var lightsFragmentFunctions: {
  31170. name: string;
  31171. shader: string;
  31172. };
  31173. }
  31174. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31175. /** @hidden */
  31176. export var shadowsFragmentFunctions: {
  31177. name: string;
  31178. shader: string;
  31179. };
  31180. }
  31181. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31182. /** @hidden */
  31183. export var fresnelFunction: {
  31184. name: string;
  31185. shader: string;
  31186. };
  31187. }
  31188. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31189. /** @hidden */
  31190. export var bumpFragmentMainFunctions: {
  31191. name: string;
  31192. shader: string;
  31193. };
  31194. }
  31195. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31196. /** @hidden */
  31197. export var bumpFragmentFunctions: {
  31198. name: string;
  31199. shader: string;
  31200. };
  31201. }
  31202. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31203. /** @hidden */
  31204. export var logDepthDeclaration: {
  31205. name: string;
  31206. shader: string;
  31207. };
  31208. }
  31209. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31210. /** @hidden */
  31211. export var bumpFragment: {
  31212. name: string;
  31213. shader: string;
  31214. };
  31215. }
  31216. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31217. /** @hidden */
  31218. export var depthPrePass: {
  31219. name: string;
  31220. shader: string;
  31221. };
  31222. }
  31223. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31224. /** @hidden */
  31225. export var lightFragment: {
  31226. name: string;
  31227. shader: string;
  31228. };
  31229. }
  31230. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31231. /** @hidden */
  31232. export var logDepthFragment: {
  31233. name: string;
  31234. shader: string;
  31235. };
  31236. }
  31237. declare module "babylonjs/Shaders/default.fragment" {
  31238. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31239. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31240. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31241. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31242. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31243. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31244. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31245. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31246. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31247. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31248. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31249. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31250. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31251. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31252. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31253. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31254. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31255. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31256. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31257. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31258. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31259. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31260. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31261. /** @hidden */
  31262. export var defaultPixelShader: {
  31263. name: string;
  31264. shader: string;
  31265. };
  31266. }
  31267. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31268. /** @hidden */
  31269. export var defaultVertexDeclaration: {
  31270. name: string;
  31271. shader: string;
  31272. };
  31273. }
  31274. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31275. /** @hidden */
  31276. export var bumpVertexDeclaration: {
  31277. name: string;
  31278. shader: string;
  31279. };
  31280. }
  31281. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31282. /** @hidden */
  31283. export var bumpVertex: {
  31284. name: string;
  31285. shader: string;
  31286. };
  31287. }
  31288. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31289. /** @hidden */
  31290. export var fogVertex: {
  31291. name: string;
  31292. shader: string;
  31293. };
  31294. }
  31295. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31296. /** @hidden */
  31297. export var shadowsVertex: {
  31298. name: string;
  31299. shader: string;
  31300. };
  31301. }
  31302. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31303. /** @hidden */
  31304. export var pointCloudVertex: {
  31305. name: string;
  31306. shader: string;
  31307. };
  31308. }
  31309. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31310. /** @hidden */
  31311. export var logDepthVertex: {
  31312. name: string;
  31313. shader: string;
  31314. };
  31315. }
  31316. declare module "babylonjs/Shaders/default.vertex" {
  31317. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31318. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31319. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31320. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31321. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31322. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31323. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31324. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31326. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31329. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31331. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31332. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31333. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31334. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31335. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31336. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31337. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31338. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31339. /** @hidden */
  31340. export var defaultVertexShader: {
  31341. name: string;
  31342. shader: string;
  31343. };
  31344. }
  31345. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31346. import { Nullable } from "babylonjs/types";
  31347. import { Scene } from "babylonjs/scene";
  31348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31349. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31350. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31351. /**
  31352. * @hidden
  31353. */
  31354. export interface IMaterialDetailMapDefines {
  31355. DETAIL: boolean;
  31356. DETAILDIRECTUV: number;
  31357. DETAIL_NORMALBLENDMETHOD: number;
  31358. /** @hidden */
  31359. _areTexturesDirty: boolean;
  31360. }
  31361. /**
  31362. * Define the code related to the detail map parameters of a material
  31363. *
  31364. * Inspired from:
  31365. * 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
  31366. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31367. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31368. */
  31369. export class DetailMapConfiguration {
  31370. private _texture;
  31371. /**
  31372. * The detail texture of the material.
  31373. */
  31374. texture: Nullable<BaseTexture>;
  31375. /**
  31376. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31377. * Bigger values mean stronger blending
  31378. */
  31379. diffuseBlendLevel: number;
  31380. /**
  31381. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31382. * Bigger values mean stronger blending. Only used with PBR materials
  31383. */
  31384. roughnessBlendLevel: number;
  31385. /**
  31386. * Defines how strong the bump effect from the detail map is
  31387. * Bigger values mean stronger effect
  31388. */
  31389. bumpLevel: number;
  31390. private _normalBlendMethod;
  31391. /**
  31392. * The method used to blend the bump and detail normals together
  31393. */
  31394. normalBlendMethod: number;
  31395. private _isEnabled;
  31396. /**
  31397. * Enable or disable the detail map on this material
  31398. */
  31399. isEnabled: boolean;
  31400. /** @hidden */
  31401. private _internalMarkAllSubMeshesAsTexturesDirty;
  31402. /** @hidden */
  31403. _markAllSubMeshesAsTexturesDirty(): void;
  31404. /**
  31405. * Instantiate a new detail map
  31406. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31407. */
  31408. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31409. /**
  31410. * Gets whether the submesh is ready to be used or not.
  31411. * @param defines the list of "defines" to update.
  31412. * @param scene defines the scene the material belongs to.
  31413. * @returns - boolean indicating that the submesh is ready or not.
  31414. */
  31415. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31416. /**
  31417. * Update the defines for detail map usage
  31418. * @param defines the list of "defines" to update.
  31419. * @param scene defines the scene the material belongs to.
  31420. */
  31421. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31422. /**
  31423. * Binds the material data.
  31424. * @param uniformBuffer defines the Uniform buffer to fill in.
  31425. * @param scene defines the scene the material belongs to.
  31426. * @param isFrozen defines whether the material is frozen or not.
  31427. */
  31428. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31429. /**
  31430. * Checks to see if a texture is used in the material.
  31431. * @param texture - Base texture to use.
  31432. * @returns - Boolean specifying if a texture is used in the material.
  31433. */
  31434. hasTexture(texture: BaseTexture): boolean;
  31435. /**
  31436. * Returns an array of the actively used textures.
  31437. * @param activeTextures Array of BaseTextures
  31438. */
  31439. getActiveTextures(activeTextures: BaseTexture[]): void;
  31440. /**
  31441. * Returns the animatable textures.
  31442. * @param animatables Array of animatable textures.
  31443. */
  31444. getAnimatables(animatables: IAnimatable[]): void;
  31445. /**
  31446. * Disposes the resources of the material.
  31447. * @param forceDisposeTextures - Forces the disposal of all textures.
  31448. */
  31449. dispose(forceDisposeTextures?: boolean): void;
  31450. /**
  31451. * Get the current class name useful for serialization or dynamic coding.
  31452. * @returns "DetailMap"
  31453. */
  31454. getClassName(): string;
  31455. /**
  31456. * Add the required uniforms to the current list.
  31457. * @param uniforms defines the current uniform list.
  31458. */
  31459. static AddUniforms(uniforms: string[]): void;
  31460. /**
  31461. * Add the required samplers to the current list.
  31462. * @param samplers defines the current sampler list.
  31463. */
  31464. static AddSamplers(samplers: string[]): void;
  31465. /**
  31466. * Add the required uniforms to the current buffer.
  31467. * @param uniformBuffer defines the current uniform buffer.
  31468. */
  31469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31470. /**
  31471. * Makes a duplicate of the current instance into another one.
  31472. * @param detailMap define the instance where to copy the info
  31473. */
  31474. copyTo(detailMap: DetailMapConfiguration): void;
  31475. /**
  31476. * Serializes this detail map instance
  31477. * @returns - An object with the serialized instance.
  31478. */
  31479. serialize(): any;
  31480. /**
  31481. * Parses a detail map setting from a serialized object.
  31482. * @param source - Serialized object.
  31483. * @param scene Defines the scene we are parsing for
  31484. * @param rootUrl Defines the rootUrl to load from
  31485. */
  31486. parse(source: any, scene: Scene, rootUrl: string): void;
  31487. }
  31488. }
  31489. declare module "babylonjs/Materials/standardMaterial" {
  31490. import { SmartArray } from "babylonjs/Misc/smartArray";
  31491. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31492. import { Nullable } from "babylonjs/types";
  31493. import { Scene } from "babylonjs/scene";
  31494. import { Matrix } from "babylonjs/Maths/math.vector";
  31495. import { Color3 } from "babylonjs/Maths/math.color";
  31496. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31498. import { Mesh } from "babylonjs/Meshes/mesh";
  31499. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31500. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31501. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31502. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31503. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31506. import "babylonjs/Shaders/default.fragment";
  31507. import "babylonjs/Shaders/default.vertex";
  31508. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31509. /** @hidden */
  31510. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31511. MAINUV1: boolean;
  31512. MAINUV2: boolean;
  31513. DIFFUSE: boolean;
  31514. DIFFUSEDIRECTUV: number;
  31515. DETAIL: boolean;
  31516. DETAILDIRECTUV: number;
  31517. DETAIL_NORMALBLENDMETHOD: number;
  31518. AMBIENT: boolean;
  31519. AMBIENTDIRECTUV: number;
  31520. OPACITY: boolean;
  31521. OPACITYDIRECTUV: number;
  31522. OPACITYRGB: boolean;
  31523. REFLECTION: boolean;
  31524. EMISSIVE: boolean;
  31525. EMISSIVEDIRECTUV: number;
  31526. SPECULAR: boolean;
  31527. SPECULARDIRECTUV: number;
  31528. BUMP: boolean;
  31529. BUMPDIRECTUV: number;
  31530. PARALLAX: boolean;
  31531. PARALLAXOCCLUSION: boolean;
  31532. SPECULAROVERALPHA: boolean;
  31533. CLIPPLANE: boolean;
  31534. CLIPPLANE2: boolean;
  31535. CLIPPLANE3: boolean;
  31536. CLIPPLANE4: boolean;
  31537. CLIPPLANE5: boolean;
  31538. CLIPPLANE6: boolean;
  31539. ALPHATEST: boolean;
  31540. DEPTHPREPASS: boolean;
  31541. ALPHAFROMDIFFUSE: boolean;
  31542. POINTSIZE: boolean;
  31543. FOG: boolean;
  31544. SPECULARTERM: boolean;
  31545. DIFFUSEFRESNEL: boolean;
  31546. OPACITYFRESNEL: boolean;
  31547. REFLECTIONFRESNEL: boolean;
  31548. REFRACTIONFRESNEL: boolean;
  31549. EMISSIVEFRESNEL: boolean;
  31550. FRESNEL: boolean;
  31551. NORMAL: boolean;
  31552. UV1: boolean;
  31553. UV2: boolean;
  31554. VERTEXCOLOR: boolean;
  31555. VERTEXALPHA: boolean;
  31556. NUM_BONE_INFLUENCERS: number;
  31557. BonesPerMesh: number;
  31558. BONETEXTURE: boolean;
  31559. INSTANCES: boolean;
  31560. THIN_INSTANCES: boolean;
  31561. GLOSSINESS: boolean;
  31562. ROUGHNESS: boolean;
  31563. EMISSIVEASILLUMINATION: boolean;
  31564. LINKEMISSIVEWITHDIFFUSE: boolean;
  31565. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31566. LIGHTMAP: boolean;
  31567. LIGHTMAPDIRECTUV: number;
  31568. OBJECTSPACE_NORMALMAP: boolean;
  31569. USELIGHTMAPASSHADOWMAP: boolean;
  31570. REFLECTIONMAP_3D: boolean;
  31571. REFLECTIONMAP_SPHERICAL: boolean;
  31572. REFLECTIONMAP_PLANAR: boolean;
  31573. REFLECTIONMAP_CUBIC: boolean;
  31574. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31575. REFLECTIONMAP_PROJECTION: boolean;
  31576. REFLECTIONMAP_SKYBOX: boolean;
  31577. REFLECTIONMAP_EXPLICIT: boolean;
  31578. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31579. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31580. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31581. INVERTCUBICMAP: boolean;
  31582. LOGARITHMICDEPTH: boolean;
  31583. REFRACTION: boolean;
  31584. REFRACTIONMAP_3D: boolean;
  31585. REFLECTIONOVERALPHA: boolean;
  31586. TWOSIDEDLIGHTING: boolean;
  31587. SHADOWFLOAT: boolean;
  31588. MORPHTARGETS: boolean;
  31589. MORPHTARGETS_NORMAL: boolean;
  31590. MORPHTARGETS_TANGENT: boolean;
  31591. MORPHTARGETS_UV: boolean;
  31592. NUM_MORPH_INFLUENCERS: number;
  31593. NONUNIFORMSCALING: boolean;
  31594. PREMULTIPLYALPHA: boolean;
  31595. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31596. ALPHABLEND: boolean;
  31597. PREPASS: boolean;
  31598. SCENE_MRT_COUNT: number;
  31599. RGBDLIGHTMAP: boolean;
  31600. RGBDREFLECTION: boolean;
  31601. RGBDREFRACTION: boolean;
  31602. IMAGEPROCESSING: boolean;
  31603. VIGNETTE: boolean;
  31604. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31605. VIGNETTEBLENDMODEOPAQUE: boolean;
  31606. TONEMAPPING: boolean;
  31607. TONEMAPPING_ACES: boolean;
  31608. CONTRAST: boolean;
  31609. COLORCURVES: boolean;
  31610. COLORGRADING: boolean;
  31611. COLORGRADING3D: boolean;
  31612. SAMPLER3DGREENDEPTH: boolean;
  31613. SAMPLER3DBGRMAP: boolean;
  31614. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31615. MULTIVIEW: boolean;
  31616. /**
  31617. * If the reflection texture on this material is in linear color space
  31618. * @hidden
  31619. */
  31620. IS_REFLECTION_LINEAR: boolean;
  31621. /**
  31622. * If the refraction texture on this material is in linear color space
  31623. * @hidden
  31624. */
  31625. IS_REFRACTION_LINEAR: boolean;
  31626. EXPOSURE: boolean;
  31627. constructor();
  31628. setReflectionMode(modeToEnable: string): void;
  31629. }
  31630. /**
  31631. * This is the default material used in Babylon. It is the best trade off between quality
  31632. * and performances.
  31633. * @see https://doc.babylonjs.com/babylon101/materials
  31634. */
  31635. export class StandardMaterial extends PushMaterial {
  31636. private _diffuseTexture;
  31637. /**
  31638. * The basic texture of the material as viewed under a light.
  31639. */
  31640. diffuseTexture: Nullable<BaseTexture>;
  31641. private _ambientTexture;
  31642. /**
  31643. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31644. */
  31645. ambientTexture: Nullable<BaseTexture>;
  31646. private _opacityTexture;
  31647. /**
  31648. * Define the transparency of the material from a texture.
  31649. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31650. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31651. */
  31652. opacityTexture: Nullable<BaseTexture>;
  31653. private _reflectionTexture;
  31654. /**
  31655. * Define the texture used to display the reflection.
  31656. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31657. */
  31658. reflectionTexture: Nullable<BaseTexture>;
  31659. private _emissiveTexture;
  31660. /**
  31661. * Define texture of the material as if self lit.
  31662. * This will be mixed in the final result even in the absence of light.
  31663. */
  31664. emissiveTexture: Nullable<BaseTexture>;
  31665. private _specularTexture;
  31666. /**
  31667. * Define how the color and intensity of the highlight given by the light in the material.
  31668. */
  31669. specularTexture: Nullable<BaseTexture>;
  31670. private _bumpTexture;
  31671. /**
  31672. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31673. * 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.
  31674. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31675. */
  31676. bumpTexture: Nullable<BaseTexture>;
  31677. private _lightmapTexture;
  31678. /**
  31679. * Complex lighting can be computationally expensive to compute at runtime.
  31680. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31681. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31682. */
  31683. lightmapTexture: Nullable<BaseTexture>;
  31684. private _refractionTexture;
  31685. /**
  31686. * Define the texture used to display the refraction.
  31687. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31688. */
  31689. refractionTexture: Nullable<BaseTexture>;
  31690. /**
  31691. * The color of the material lit by the environmental background lighting.
  31692. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31693. */
  31694. ambientColor: Color3;
  31695. /**
  31696. * The basic color of the material as viewed under a light.
  31697. */
  31698. diffuseColor: Color3;
  31699. /**
  31700. * Define how the color and intensity of the highlight given by the light in the material.
  31701. */
  31702. specularColor: Color3;
  31703. /**
  31704. * Define the color of the material as if self lit.
  31705. * This will be mixed in the final result even in the absence of light.
  31706. */
  31707. emissiveColor: Color3;
  31708. /**
  31709. * Defines how sharp are the highlights in the material.
  31710. * The bigger the value the sharper giving a more glossy feeling to the result.
  31711. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31712. */
  31713. specularPower: number;
  31714. private _useAlphaFromDiffuseTexture;
  31715. /**
  31716. * Does the transparency come from the diffuse texture alpha channel.
  31717. */
  31718. useAlphaFromDiffuseTexture: boolean;
  31719. private _useEmissiveAsIllumination;
  31720. /**
  31721. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31722. */
  31723. useEmissiveAsIllumination: boolean;
  31724. private _linkEmissiveWithDiffuse;
  31725. /**
  31726. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31727. * the emissive level when the final color is close to one.
  31728. */
  31729. linkEmissiveWithDiffuse: boolean;
  31730. private _useSpecularOverAlpha;
  31731. /**
  31732. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31733. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31734. */
  31735. useSpecularOverAlpha: boolean;
  31736. private _useReflectionOverAlpha;
  31737. /**
  31738. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31739. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31740. */
  31741. useReflectionOverAlpha: boolean;
  31742. private _disableLighting;
  31743. /**
  31744. * Does lights from the scene impacts this material.
  31745. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31746. */
  31747. disableLighting: boolean;
  31748. private _useObjectSpaceNormalMap;
  31749. /**
  31750. * Allows using an object space normal map (instead of tangent space).
  31751. */
  31752. useObjectSpaceNormalMap: boolean;
  31753. private _useParallax;
  31754. /**
  31755. * Is parallax enabled or not.
  31756. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31757. */
  31758. useParallax: boolean;
  31759. private _useParallaxOcclusion;
  31760. /**
  31761. * Is parallax occlusion enabled or not.
  31762. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31763. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31764. */
  31765. useParallaxOcclusion: boolean;
  31766. /**
  31767. * 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.
  31768. */
  31769. parallaxScaleBias: number;
  31770. private _roughness;
  31771. /**
  31772. * Helps to define how blurry the reflections should appears in the material.
  31773. */
  31774. roughness: number;
  31775. /**
  31776. * In case of refraction, define the value of the index of refraction.
  31777. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31778. */
  31779. indexOfRefraction: number;
  31780. /**
  31781. * Invert the refraction texture alongside the y axis.
  31782. * It can be useful with procedural textures or probe for instance.
  31783. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31784. */
  31785. invertRefractionY: boolean;
  31786. /**
  31787. * Defines the alpha limits in alpha test mode.
  31788. */
  31789. alphaCutOff: number;
  31790. private _useLightmapAsShadowmap;
  31791. /**
  31792. * In case of light mapping, define whether the map contains light or shadow informations.
  31793. */
  31794. useLightmapAsShadowmap: boolean;
  31795. private _diffuseFresnelParameters;
  31796. /**
  31797. * Define the diffuse fresnel parameters of the material.
  31798. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31799. */
  31800. diffuseFresnelParameters: FresnelParameters;
  31801. private _opacityFresnelParameters;
  31802. /**
  31803. * Define the opacity fresnel parameters of the material.
  31804. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31805. */
  31806. opacityFresnelParameters: FresnelParameters;
  31807. private _reflectionFresnelParameters;
  31808. /**
  31809. * Define the reflection fresnel parameters of the material.
  31810. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31811. */
  31812. reflectionFresnelParameters: FresnelParameters;
  31813. private _refractionFresnelParameters;
  31814. /**
  31815. * Define the refraction fresnel parameters of the material.
  31816. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31817. */
  31818. refractionFresnelParameters: FresnelParameters;
  31819. private _emissiveFresnelParameters;
  31820. /**
  31821. * Define the emissive fresnel parameters of the material.
  31822. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31823. */
  31824. emissiveFresnelParameters: FresnelParameters;
  31825. private _useReflectionFresnelFromSpecular;
  31826. /**
  31827. * If true automatically deducts the fresnels values from the material specularity.
  31828. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31829. */
  31830. useReflectionFresnelFromSpecular: boolean;
  31831. private _useGlossinessFromSpecularMapAlpha;
  31832. /**
  31833. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31834. */
  31835. useGlossinessFromSpecularMapAlpha: boolean;
  31836. private _maxSimultaneousLights;
  31837. /**
  31838. * Defines the maximum number of lights that can be used in the material
  31839. */
  31840. maxSimultaneousLights: number;
  31841. private _invertNormalMapX;
  31842. /**
  31843. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31844. */
  31845. invertNormalMapX: boolean;
  31846. private _invertNormalMapY;
  31847. /**
  31848. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31849. */
  31850. invertNormalMapY: boolean;
  31851. private _twoSidedLighting;
  31852. /**
  31853. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31854. */
  31855. twoSidedLighting: boolean;
  31856. /**
  31857. * Default configuration related to image processing available in the standard Material.
  31858. */
  31859. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31860. /**
  31861. * Gets the image processing configuration used either in this material.
  31862. */
  31863. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31864. /**
  31865. * Sets the Default image processing configuration used either in the this material.
  31866. *
  31867. * If sets to null, the scene one is in use.
  31868. */
  31869. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31870. /**
  31871. * Keep track of the image processing observer to allow dispose and replace.
  31872. */
  31873. private _imageProcessingObserver;
  31874. /**
  31875. * Attaches a new image processing configuration to the Standard Material.
  31876. * @param configuration
  31877. */
  31878. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31879. /**
  31880. * Gets wether the color curves effect is enabled.
  31881. */
  31882. get cameraColorCurvesEnabled(): boolean;
  31883. /**
  31884. * Sets wether the color curves effect is enabled.
  31885. */
  31886. set cameraColorCurvesEnabled(value: boolean);
  31887. /**
  31888. * Gets wether the color grading effect is enabled.
  31889. */
  31890. get cameraColorGradingEnabled(): boolean;
  31891. /**
  31892. * Gets wether the color grading effect is enabled.
  31893. */
  31894. set cameraColorGradingEnabled(value: boolean);
  31895. /**
  31896. * Gets wether tonemapping is enabled or not.
  31897. */
  31898. get cameraToneMappingEnabled(): boolean;
  31899. /**
  31900. * Sets wether tonemapping is enabled or not
  31901. */
  31902. set cameraToneMappingEnabled(value: boolean);
  31903. /**
  31904. * The camera exposure used on this material.
  31905. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31906. * This corresponds to a photographic exposure.
  31907. */
  31908. get cameraExposure(): number;
  31909. /**
  31910. * The camera exposure used on this material.
  31911. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31912. * This corresponds to a photographic exposure.
  31913. */
  31914. set cameraExposure(value: number);
  31915. /**
  31916. * Gets The camera contrast used on this material.
  31917. */
  31918. get cameraContrast(): number;
  31919. /**
  31920. * Sets The camera contrast used on this material.
  31921. */
  31922. set cameraContrast(value: number);
  31923. /**
  31924. * Gets the Color Grading 2D Lookup Texture.
  31925. */
  31926. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31927. /**
  31928. * Sets the Color Grading 2D Lookup Texture.
  31929. */
  31930. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31931. /**
  31932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31934. * 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;
  31935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31936. */
  31937. get cameraColorCurves(): Nullable<ColorCurves>;
  31938. /**
  31939. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31940. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31941. * 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;
  31942. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31943. */
  31944. set cameraColorCurves(value: Nullable<ColorCurves>);
  31945. /**
  31946. * Can this material render to several textures at once
  31947. */
  31948. get canRenderToMRT(): boolean;
  31949. /**
  31950. * Defines the detail map parameters for the material.
  31951. */
  31952. readonly detailMap: DetailMapConfiguration;
  31953. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31954. protected _worldViewProjectionMatrix: Matrix;
  31955. protected _globalAmbientColor: Color3;
  31956. protected _useLogarithmicDepth: boolean;
  31957. protected _rebuildInParallel: boolean;
  31958. /**
  31959. * Instantiates a new standard material.
  31960. * This is the default material used in Babylon. It is the best trade off between quality
  31961. * and performances.
  31962. * @see https://doc.babylonjs.com/babylon101/materials
  31963. * @param name Define the name of the material in the scene
  31964. * @param scene Define the scene the material belong to
  31965. */
  31966. constructor(name: string, scene: Scene);
  31967. /**
  31968. * Gets a boolean indicating that current material needs to register RTT
  31969. */
  31970. get hasRenderTargetTextures(): boolean;
  31971. /**
  31972. * Gets the current class name of the material e.g. "StandardMaterial"
  31973. * Mainly use in serialization.
  31974. * @returns the class name
  31975. */
  31976. getClassName(): string;
  31977. /**
  31978. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31979. * You can try switching to logarithmic depth.
  31980. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31981. */
  31982. get useLogarithmicDepth(): boolean;
  31983. set useLogarithmicDepth(value: boolean);
  31984. /**
  31985. * Specifies if the material will require alpha blending
  31986. * @returns a boolean specifying if alpha blending is needed
  31987. */
  31988. needAlphaBlending(): boolean;
  31989. /**
  31990. * Specifies if this material should be rendered in alpha test mode
  31991. * @returns a boolean specifying if an alpha test is needed.
  31992. */
  31993. needAlphaTesting(): boolean;
  31994. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31995. /**
  31996. * Get the texture used for alpha test purpose.
  31997. * @returns the diffuse texture in case of the standard material.
  31998. */
  31999. getAlphaTestTexture(): Nullable<BaseTexture>;
  32000. /**
  32001. * Get if the submesh is ready to be used and all its information available.
  32002. * Child classes can use it to update shaders
  32003. * @param mesh defines the mesh to check
  32004. * @param subMesh defines which submesh to check
  32005. * @param useInstances specifies that instances should be used
  32006. * @returns a boolean indicating that the submesh is ready or not
  32007. */
  32008. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32009. /**
  32010. * Builds the material UBO layouts.
  32011. * Used internally during the effect preparation.
  32012. */
  32013. buildUniformLayout(): void;
  32014. /**
  32015. * Unbinds the material from the mesh
  32016. */
  32017. unbind(): void;
  32018. /**
  32019. * Binds the submesh to this material by preparing the effect and shader to draw
  32020. * @param world defines the world transformation matrix
  32021. * @param mesh defines the mesh containing the submesh
  32022. * @param subMesh defines the submesh to bind the material to
  32023. */
  32024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32025. /**
  32026. * Get the list of animatables in the material.
  32027. * @returns the list of animatables object used in the material
  32028. */
  32029. getAnimatables(): IAnimatable[];
  32030. /**
  32031. * Gets the active textures from the material
  32032. * @returns an array of textures
  32033. */
  32034. getActiveTextures(): BaseTexture[];
  32035. /**
  32036. * Specifies if the material uses a texture
  32037. * @param texture defines the texture to check against the material
  32038. * @returns a boolean specifying if the material uses the texture
  32039. */
  32040. hasTexture(texture: BaseTexture): boolean;
  32041. /**
  32042. * Disposes the material
  32043. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32044. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32045. */
  32046. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32047. /**
  32048. * Makes a duplicate of the material, and gives it a new name
  32049. * @param name defines the new name for the duplicated material
  32050. * @returns the cloned material
  32051. */
  32052. clone(name: string): StandardMaterial;
  32053. /**
  32054. * Serializes this material in a JSON representation
  32055. * @returns the serialized material object
  32056. */
  32057. serialize(): any;
  32058. /**
  32059. * Creates a standard material from parsed material data
  32060. * @param source defines the JSON representation of the material
  32061. * @param scene defines the hosting scene
  32062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32063. * @returns a new standard material
  32064. */
  32065. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32066. /**
  32067. * Are diffuse textures enabled in the application.
  32068. */
  32069. static get DiffuseTextureEnabled(): boolean;
  32070. static set DiffuseTextureEnabled(value: boolean);
  32071. /**
  32072. * Are detail textures enabled in the application.
  32073. */
  32074. static get DetailTextureEnabled(): boolean;
  32075. static set DetailTextureEnabled(value: boolean);
  32076. /**
  32077. * Are ambient textures enabled in the application.
  32078. */
  32079. static get AmbientTextureEnabled(): boolean;
  32080. static set AmbientTextureEnabled(value: boolean);
  32081. /**
  32082. * Are opacity textures enabled in the application.
  32083. */
  32084. static get OpacityTextureEnabled(): boolean;
  32085. static set OpacityTextureEnabled(value: boolean);
  32086. /**
  32087. * Are reflection textures enabled in the application.
  32088. */
  32089. static get ReflectionTextureEnabled(): boolean;
  32090. static set ReflectionTextureEnabled(value: boolean);
  32091. /**
  32092. * Are emissive textures enabled in the application.
  32093. */
  32094. static get EmissiveTextureEnabled(): boolean;
  32095. static set EmissiveTextureEnabled(value: boolean);
  32096. /**
  32097. * Are specular textures enabled in the application.
  32098. */
  32099. static get SpecularTextureEnabled(): boolean;
  32100. static set SpecularTextureEnabled(value: boolean);
  32101. /**
  32102. * Are bump textures enabled in the application.
  32103. */
  32104. static get BumpTextureEnabled(): boolean;
  32105. static set BumpTextureEnabled(value: boolean);
  32106. /**
  32107. * Are lightmap textures enabled in the application.
  32108. */
  32109. static get LightmapTextureEnabled(): boolean;
  32110. static set LightmapTextureEnabled(value: boolean);
  32111. /**
  32112. * Are refraction textures enabled in the application.
  32113. */
  32114. static get RefractionTextureEnabled(): boolean;
  32115. static set RefractionTextureEnabled(value: boolean);
  32116. /**
  32117. * Are color grading textures enabled in the application.
  32118. */
  32119. static get ColorGradingTextureEnabled(): boolean;
  32120. static set ColorGradingTextureEnabled(value: boolean);
  32121. /**
  32122. * Are fresnels enabled in the application.
  32123. */
  32124. static get FresnelEnabled(): boolean;
  32125. static set FresnelEnabled(value: boolean);
  32126. }
  32127. }
  32128. declare module "babylonjs/Particles/solidParticleSystem" {
  32129. import { Nullable } from "babylonjs/types";
  32130. import { Mesh } from "babylonjs/Meshes/mesh";
  32131. import { Scene, IDisposable } from "babylonjs/scene";
  32132. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32133. import { Material } from "babylonjs/Materials/material";
  32134. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32136. /**
  32137. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32138. *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.
  32139. * The SPS is also a particle system. It provides some methods to manage the particles.
  32140. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32141. *
  32142. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32143. */
  32144. export class SolidParticleSystem implements IDisposable {
  32145. /**
  32146. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32147. * Example : var p = SPS.particles[i];
  32148. */
  32149. particles: SolidParticle[];
  32150. /**
  32151. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32152. */
  32153. nbParticles: number;
  32154. /**
  32155. * If the particles must ever face the camera (default false). Useful for planar particles.
  32156. */
  32157. billboard: boolean;
  32158. /**
  32159. * Recompute normals when adding a shape
  32160. */
  32161. recomputeNormals: boolean;
  32162. /**
  32163. * This a counter ofr your own usage. It's not set by any SPS functions.
  32164. */
  32165. counter: number;
  32166. /**
  32167. * The SPS name. This name is also given to the underlying mesh.
  32168. */
  32169. name: string;
  32170. /**
  32171. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32172. */
  32173. mesh: Mesh;
  32174. /**
  32175. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32176. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32177. */
  32178. vars: any;
  32179. /**
  32180. * This array is populated when the SPS is set as 'pickable'.
  32181. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32182. * Each element of this array is an object `{idx: int, faceId: int}`.
  32183. * `idx` is the picked particle index in the `SPS.particles` array
  32184. * `faceId` is the picked face index counted within this particle.
  32185. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32186. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32187. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32188. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32189. */
  32190. pickedParticles: {
  32191. idx: number;
  32192. faceId: number;
  32193. }[];
  32194. /**
  32195. * This array is populated when the SPS is set as 'pickable'
  32196. * Each key of this array is a submesh index.
  32197. * Each element of this array is a second array defined like this :
  32198. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32199. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32200. * `idx` is the picked particle index in the `SPS.particles` array
  32201. * `faceId` is the picked face index counted within this particle.
  32202. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32203. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32204. */
  32205. pickedBySubMesh: {
  32206. idx: number;
  32207. faceId: number;
  32208. }[][];
  32209. /**
  32210. * This array is populated when `enableDepthSort` is set to true.
  32211. * Each element of this array is an instance of the class DepthSortedParticle.
  32212. */
  32213. depthSortedParticles: DepthSortedParticle[];
  32214. /**
  32215. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32216. * @hidden
  32217. */
  32218. _bSphereOnly: boolean;
  32219. /**
  32220. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32221. * @hidden
  32222. */
  32223. _bSphereRadiusFactor: number;
  32224. private _scene;
  32225. private _positions;
  32226. private _indices;
  32227. private _normals;
  32228. private _colors;
  32229. private _uvs;
  32230. private _indices32;
  32231. private _positions32;
  32232. private _normals32;
  32233. private _fixedNormal32;
  32234. private _colors32;
  32235. private _uvs32;
  32236. private _index;
  32237. private _updatable;
  32238. private _pickable;
  32239. private _isVisibilityBoxLocked;
  32240. private _alwaysVisible;
  32241. private _depthSort;
  32242. private _expandable;
  32243. private _shapeCounter;
  32244. private _copy;
  32245. private _color;
  32246. private _computeParticleColor;
  32247. private _computeParticleTexture;
  32248. private _computeParticleRotation;
  32249. private _computeParticleVertex;
  32250. private _computeBoundingBox;
  32251. private _depthSortParticles;
  32252. private _camera;
  32253. private _mustUnrotateFixedNormals;
  32254. private _particlesIntersect;
  32255. private _needs32Bits;
  32256. private _isNotBuilt;
  32257. private _lastParticleId;
  32258. private _idxOfId;
  32259. private _multimaterialEnabled;
  32260. private _useModelMaterial;
  32261. private _indicesByMaterial;
  32262. private _materialIndexes;
  32263. private _depthSortFunction;
  32264. private _materialSortFunction;
  32265. private _materials;
  32266. private _multimaterial;
  32267. private _materialIndexesById;
  32268. private _defaultMaterial;
  32269. private _autoUpdateSubMeshes;
  32270. private _tmpVertex;
  32271. /**
  32272. * Creates a SPS (Solid Particle System) object.
  32273. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32274. * @param scene (Scene) is the scene in which the SPS is added.
  32275. * @param options defines the options of the sps e.g.
  32276. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32277. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32278. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32279. * * 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.
  32280. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32281. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32282. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32283. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32284. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32285. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32286. */
  32287. constructor(name: string, scene: Scene, options?: {
  32288. updatable?: boolean;
  32289. isPickable?: boolean;
  32290. enableDepthSort?: boolean;
  32291. particleIntersection?: boolean;
  32292. boundingSphereOnly?: boolean;
  32293. bSphereRadiusFactor?: number;
  32294. expandable?: boolean;
  32295. useModelMaterial?: boolean;
  32296. enableMultiMaterial?: boolean;
  32297. });
  32298. /**
  32299. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32300. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32301. * @returns the created mesh
  32302. */
  32303. buildMesh(): Mesh;
  32304. /**
  32305. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32306. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32307. * Thus the particles generated from `digest()` have their property `position` set yet.
  32308. * @param mesh ( Mesh ) is the mesh to be digested
  32309. * @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
  32310. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32311. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32312. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32313. * @returns the current SPS
  32314. */
  32315. digest(mesh: Mesh, options?: {
  32316. facetNb?: number;
  32317. number?: number;
  32318. delta?: number;
  32319. storage?: [];
  32320. }): SolidParticleSystem;
  32321. /**
  32322. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32323. * @hidden
  32324. */
  32325. private _unrotateFixedNormals;
  32326. /**
  32327. * Resets the temporary working copy particle
  32328. * @hidden
  32329. */
  32330. private _resetCopy;
  32331. /**
  32332. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32333. * @param p the current index in the positions array to be updated
  32334. * @param ind the current index in the indices array
  32335. * @param shape a Vector3 array, the shape geometry
  32336. * @param positions the positions array to be updated
  32337. * @param meshInd the shape indices array
  32338. * @param indices the indices array to be updated
  32339. * @param meshUV the shape uv array
  32340. * @param uvs the uv array to be updated
  32341. * @param meshCol the shape color array
  32342. * @param colors the color array to be updated
  32343. * @param meshNor the shape normals array
  32344. * @param normals the normals array to be updated
  32345. * @param idx the particle index
  32346. * @param idxInShape the particle index in its shape
  32347. * @param options the addShape() method passed options
  32348. * @model the particle model
  32349. * @hidden
  32350. */
  32351. private _meshBuilder;
  32352. /**
  32353. * Returns a shape Vector3 array from positions float array
  32354. * @param positions float array
  32355. * @returns a vector3 array
  32356. * @hidden
  32357. */
  32358. private _posToShape;
  32359. /**
  32360. * Returns a shapeUV array from a float uvs (array deep copy)
  32361. * @param uvs as a float array
  32362. * @returns a shapeUV array
  32363. * @hidden
  32364. */
  32365. private _uvsToShapeUV;
  32366. /**
  32367. * Adds a new particle object in the particles array
  32368. * @param idx particle index in particles array
  32369. * @param id particle id
  32370. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32371. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32372. * @param model particle ModelShape object
  32373. * @param shapeId model shape identifier
  32374. * @param idxInShape index of the particle in the current model
  32375. * @param bInfo model bounding info object
  32376. * @param storage target storage array, if any
  32377. * @hidden
  32378. */
  32379. private _addParticle;
  32380. /**
  32381. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32382. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32383. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32384. * @param nb (positive integer) the number of particles to be created from this model
  32385. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32386. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32387. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32388. * @returns the number of shapes in the system
  32389. */
  32390. addShape(mesh: Mesh, nb: number, options?: {
  32391. positionFunction?: any;
  32392. vertexFunction?: any;
  32393. storage?: [];
  32394. }): number;
  32395. /**
  32396. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32397. * @hidden
  32398. */
  32399. private _rebuildParticle;
  32400. /**
  32401. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32402. * @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.
  32403. * @returns the SPS.
  32404. */
  32405. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32406. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32407. * Returns an array with the removed particles.
  32408. * 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.
  32409. * The SPS can't be empty so at least one particle needs to remain in place.
  32410. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32411. * @param start index of the first particle to remove
  32412. * @param end index of the last particle to remove (included)
  32413. * @returns an array populated with the removed particles
  32414. */
  32415. removeParticles(start: number, end: number): SolidParticle[];
  32416. /**
  32417. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32418. * @param solidParticleArray an array populated with Solid Particles objects
  32419. * @returns the SPS
  32420. */
  32421. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32422. /**
  32423. * Creates a new particle and modifies the SPS mesh geometry :
  32424. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32425. * - calls _addParticle() to populate the particle array
  32426. * factorized code from addShape() and insertParticlesFromArray()
  32427. * @param idx particle index in the particles array
  32428. * @param i particle index in its shape
  32429. * @param modelShape particle ModelShape object
  32430. * @param shape shape vertex array
  32431. * @param meshInd shape indices array
  32432. * @param meshUV shape uv array
  32433. * @param meshCol shape color array
  32434. * @param meshNor shape normals array
  32435. * @param bbInfo shape bounding info
  32436. * @param storage target particle storage
  32437. * @options addShape() passed options
  32438. * @hidden
  32439. */
  32440. private _insertNewParticle;
  32441. /**
  32442. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32443. * This method calls `updateParticle()` for each particle of the SPS.
  32444. * For an animated SPS, it is usually called within the render loop.
  32445. * 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.
  32446. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32447. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32448. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32449. * @returns the SPS.
  32450. */
  32451. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32452. /**
  32453. * Disposes the SPS.
  32454. */
  32455. dispose(): void;
  32456. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32457. * idx is the particle index in the SPS
  32458. * faceId is the picked face index counted within this particle.
  32459. * Returns null if the pickInfo can't identify a picked particle.
  32460. * @param pickingInfo (PickingInfo object)
  32461. * @returns {idx: number, faceId: number} or null
  32462. */
  32463. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32464. idx: number;
  32465. faceId: number;
  32466. }>;
  32467. /**
  32468. * Returns a SolidParticle object from its identifier : particle.id
  32469. * @param id (integer) the particle Id
  32470. * @returns the searched particle or null if not found in the SPS.
  32471. */
  32472. getParticleById(id: number): Nullable<SolidParticle>;
  32473. /**
  32474. * Returns a new array populated with the particles having the passed shapeId.
  32475. * @param shapeId (integer) the shape identifier
  32476. * @returns a new solid particle array
  32477. */
  32478. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32479. /**
  32480. * Populates the passed array "ref" with the particles having the passed shapeId.
  32481. * @param shapeId the shape identifier
  32482. * @returns the SPS
  32483. * @param ref
  32484. */
  32485. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32486. /**
  32487. * Computes the required SubMeshes according the materials assigned to the particles.
  32488. * @returns the solid particle system.
  32489. * Does nothing if called before the SPS mesh is built.
  32490. */
  32491. computeSubMeshes(): SolidParticleSystem;
  32492. /**
  32493. * Sorts the solid particles by material when MultiMaterial is enabled.
  32494. * Updates the indices32 array.
  32495. * Updates the indicesByMaterial array.
  32496. * Updates the mesh indices array.
  32497. * @returns the SPS
  32498. * @hidden
  32499. */
  32500. private _sortParticlesByMaterial;
  32501. /**
  32502. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32503. * @hidden
  32504. */
  32505. private _setMaterialIndexesById;
  32506. /**
  32507. * Returns an array with unique values of Materials from the passed array
  32508. * @param array the material array to be checked and filtered
  32509. * @hidden
  32510. */
  32511. private _filterUniqueMaterialId;
  32512. /**
  32513. * Sets a new Standard Material as _defaultMaterial if not already set.
  32514. * @hidden
  32515. */
  32516. private _setDefaultMaterial;
  32517. /**
  32518. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32519. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32520. * @returns the SPS.
  32521. */
  32522. refreshVisibleSize(): SolidParticleSystem;
  32523. /**
  32524. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32525. * @param size the size (float) of the visibility box
  32526. * note : this doesn't lock the SPS mesh bounding box.
  32527. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32528. */
  32529. setVisibilityBox(size: number): void;
  32530. /**
  32531. * Gets whether the SPS as always visible or not
  32532. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32533. */
  32534. get isAlwaysVisible(): boolean;
  32535. /**
  32536. * Sets the SPS as always visible or not
  32537. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32538. */
  32539. set isAlwaysVisible(val: boolean);
  32540. /**
  32541. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32542. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32543. */
  32544. set isVisibilityBoxLocked(val: boolean);
  32545. /**
  32546. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32547. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32548. */
  32549. get isVisibilityBoxLocked(): boolean;
  32550. /**
  32551. * Tells to `setParticles()` to compute the particle rotations or not.
  32552. * Default value : true. The SPS is faster when it's set to false.
  32553. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32554. */
  32555. set computeParticleRotation(val: boolean);
  32556. /**
  32557. * Tells to `setParticles()` to compute the particle colors or not.
  32558. * Default value : true. The SPS is faster when it's set to false.
  32559. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32560. */
  32561. set computeParticleColor(val: boolean);
  32562. set computeParticleTexture(val: boolean);
  32563. /**
  32564. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32565. * Default value : false. The SPS is faster when it's set to false.
  32566. * Note : the particle custom vertex positions aren't stored values.
  32567. */
  32568. set computeParticleVertex(val: boolean);
  32569. /**
  32570. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32571. */
  32572. set computeBoundingBox(val: boolean);
  32573. /**
  32574. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32575. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32576. * Default : `true`
  32577. */
  32578. set depthSortParticles(val: boolean);
  32579. /**
  32580. * Gets if `setParticles()` computes the particle rotations or not.
  32581. * Default value : true. The SPS is faster when it's set to false.
  32582. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32583. */
  32584. get computeParticleRotation(): boolean;
  32585. /**
  32586. * Gets if `setParticles()` computes the particle colors or not.
  32587. * Default value : true. The SPS is faster when it's set to false.
  32588. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32589. */
  32590. get computeParticleColor(): boolean;
  32591. /**
  32592. * Gets if `setParticles()` computes the particle textures or not.
  32593. * Default value : true. The SPS is faster when it's set to false.
  32594. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32595. */
  32596. get computeParticleTexture(): boolean;
  32597. /**
  32598. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32599. * Default value : false. The SPS is faster when it's set to false.
  32600. * Note : the particle custom vertex positions aren't stored values.
  32601. */
  32602. get computeParticleVertex(): boolean;
  32603. /**
  32604. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32605. */
  32606. get computeBoundingBox(): boolean;
  32607. /**
  32608. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32609. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32610. * Default : `true`
  32611. */
  32612. get depthSortParticles(): boolean;
  32613. /**
  32614. * Gets if the SPS is created as expandable at construction time.
  32615. * Default : `false`
  32616. */
  32617. get expandable(): boolean;
  32618. /**
  32619. * Gets if the SPS supports the Multi Materials
  32620. */
  32621. get multimaterialEnabled(): boolean;
  32622. /**
  32623. * Gets if the SPS uses the model materials for its own multimaterial.
  32624. */
  32625. get useModelMaterial(): boolean;
  32626. /**
  32627. * The SPS used material array.
  32628. */
  32629. get materials(): Material[];
  32630. /**
  32631. * Sets the SPS MultiMaterial from the passed materials.
  32632. * Note : the passed array is internally copied and not used then by reference.
  32633. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32634. */
  32635. setMultiMaterial(materials: Material[]): void;
  32636. /**
  32637. * The SPS computed multimaterial object
  32638. */
  32639. get multimaterial(): MultiMaterial;
  32640. set multimaterial(mm: MultiMaterial);
  32641. /**
  32642. * If the subMeshes must be updated on the next call to setParticles()
  32643. */
  32644. get autoUpdateSubMeshes(): boolean;
  32645. set autoUpdateSubMeshes(val: boolean);
  32646. /**
  32647. * This function does nothing. It may be overwritten to set all the particle first values.
  32648. * The SPS doesn't call this function, you may have to call it by your own.
  32649. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32650. */
  32651. initParticles(): void;
  32652. /**
  32653. * This function does nothing. It may be overwritten to recycle a particle.
  32654. * The SPS doesn't call this function, you may have to call it by your own.
  32655. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32656. * @param particle The particle to recycle
  32657. * @returns the recycled particle
  32658. */
  32659. recycleParticle(particle: SolidParticle): SolidParticle;
  32660. /**
  32661. * Updates a particle : this function should be overwritten by the user.
  32662. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32663. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32664. * @example : just set a particle position or velocity and recycle conditions
  32665. * @param particle The particle to update
  32666. * @returns the updated particle
  32667. */
  32668. updateParticle(particle: SolidParticle): SolidParticle;
  32669. /**
  32670. * Updates a vertex of a particle : it can be overwritten by the user.
  32671. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32672. * @param particle the current particle
  32673. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32674. * @param pt the index of the current vertex in the particle shape
  32675. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32676. * @example : just set a vertex particle position or color
  32677. * @returns the sps
  32678. */
  32679. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32680. /**
  32681. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32682. * This does nothing and may be overwritten by the user.
  32683. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32684. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32685. * @param update the boolean update value actually passed to setParticles()
  32686. */
  32687. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32688. /**
  32689. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32690. * This will be passed three parameters.
  32691. * This does nothing and may be overwritten by the user.
  32692. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32693. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32694. * @param update the boolean update value actually passed to setParticles()
  32695. */
  32696. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32697. }
  32698. }
  32699. declare module "babylonjs/Particles/solidParticle" {
  32700. import { Nullable } from "babylonjs/types";
  32701. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32702. import { Color4 } from "babylonjs/Maths/math.color";
  32703. import { Mesh } from "babylonjs/Meshes/mesh";
  32704. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32705. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32706. import { Plane } from "babylonjs/Maths/math.plane";
  32707. import { Material } from "babylonjs/Materials/material";
  32708. /**
  32709. * Represents one particle of a solid particle system.
  32710. */
  32711. export class SolidParticle {
  32712. /**
  32713. * particle global index
  32714. */
  32715. idx: number;
  32716. /**
  32717. * particle identifier
  32718. */
  32719. id: number;
  32720. /**
  32721. * The color of the particle
  32722. */
  32723. color: Nullable<Color4>;
  32724. /**
  32725. * The world space position of the particle.
  32726. */
  32727. position: Vector3;
  32728. /**
  32729. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32730. */
  32731. rotation: Vector3;
  32732. /**
  32733. * The world space rotation quaternion of the particle.
  32734. */
  32735. rotationQuaternion: Nullable<Quaternion>;
  32736. /**
  32737. * The scaling of the particle.
  32738. */
  32739. scaling: Vector3;
  32740. /**
  32741. * The uvs of the particle.
  32742. */
  32743. uvs: Vector4;
  32744. /**
  32745. * The current speed of the particle.
  32746. */
  32747. velocity: Vector3;
  32748. /**
  32749. * The pivot point in the particle local space.
  32750. */
  32751. pivot: Vector3;
  32752. /**
  32753. * Must the particle be translated from its pivot point in its local space ?
  32754. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32755. * Default : false
  32756. */
  32757. translateFromPivot: boolean;
  32758. /**
  32759. * Is the particle active or not ?
  32760. */
  32761. alive: boolean;
  32762. /**
  32763. * Is the particle visible or not ?
  32764. */
  32765. isVisible: boolean;
  32766. /**
  32767. * Index of this particle in the global "positions" array (Internal use)
  32768. * @hidden
  32769. */
  32770. _pos: number;
  32771. /**
  32772. * @hidden Index of this particle in the global "indices" array (Internal use)
  32773. */
  32774. _ind: number;
  32775. /**
  32776. * @hidden ModelShape of this particle (Internal use)
  32777. */
  32778. _model: ModelShape;
  32779. /**
  32780. * ModelShape id of this particle
  32781. */
  32782. shapeId: number;
  32783. /**
  32784. * Index of the particle in its shape id
  32785. */
  32786. idxInShape: number;
  32787. /**
  32788. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32789. */
  32790. _modelBoundingInfo: BoundingInfo;
  32791. /**
  32792. * @hidden Particle BoundingInfo object (Internal use)
  32793. */
  32794. _boundingInfo: BoundingInfo;
  32795. /**
  32796. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32797. */
  32798. _sps: SolidParticleSystem;
  32799. /**
  32800. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32801. */
  32802. _stillInvisible: boolean;
  32803. /**
  32804. * @hidden Last computed particle rotation matrix
  32805. */
  32806. _rotationMatrix: number[];
  32807. /**
  32808. * Parent particle Id, if any.
  32809. * Default null.
  32810. */
  32811. parentId: Nullable<number>;
  32812. /**
  32813. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32814. */
  32815. materialIndex: Nullable<number>;
  32816. /**
  32817. * Custom object or properties.
  32818. */
  32819. props: Nullable<any>;
  32820. /**
  32821. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32822. * The possible values are :
  32823. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32824. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32826. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32827. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32828. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32829. * */
  32830. cullingStrategy: number;
  32831. /**
  32832. * @hidden Internal global position in the SPS.
  32833. */
  32834. _globalPosition: Vector3;
  32835. /**
  32836. * Creates a Solid Particle object.
  32837. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32838. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32839. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32840. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32841. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32842. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32843. * @param shapeId (integer) is the model shape identifier in the SPS.
  32844. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32845. * @param sps defines the sps it is associated to
  32846. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32847. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32848. */
  32849. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32850. /**
  32851. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32852. * @param target the particle target
  32853. * @returns the current particle
  32854. */
  32855. copyToRef(target: SolidParticle): SolidParticle;
  32856. /**
  32857. * Legacy support, changed scale to scaling
  32858. */
  32859. get scale(): Vector3;
  32860. /**
  32861. * Legacy support, changed scale to scaling
  32862. */
  32863. set scale(scale: Vector3);
  32864. /**
  32865. * Legacy support, changed quaternion to rotationQuaternion
  32866. */
  32867. get quaternion(): Nullable<Quaternion>;
  32868. /**
  32869. * Legacy support, changed quaternion to rotationQuaternion
  32870. */
  32871. set quaternion(q: Nullable<Quaternion>);
  32872. /**
  32873. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32874. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32875. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32876. * @returns true if it intersects
  32877. */
  32878. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32879. /**
  32880. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32881. * A particle is in the frustum if its bounding box intersects the frustum
  32882. * @param frustumPlanes defines the frustum to test
  32883. * @returns true if the particle is in the frustum planes
  32884. */
  32885. isInFrustum(frustumPlanes: Plane[]): boolean;
  32886. /**
  32887. * get the rotation matrix of the particle
  32888. * @hidden
  32889. */
  32890. getRotationMatrix(m: Matrix): void;
  32891. }
  32892. /**
  32893. * Represents the shape of the model used by one particle of a solid particle system.
  32894. * SPS internal tool, don't use it manually.
  32895. */
  32896. export class ModelShape {
  32897. /**
  32898. * The shape id
  32899. * @hidden
  32900. */
  32901. shapeID: number;
  32902. /**
  32903. * flat array of model positions (internal use)
  32904. * @hidden
  32905. */
  32906. _shape: Vector3[];
  32907. /**
  32908. * flat array of model UVs (internal use)
  32909. * @hidden
  32910. */
  32911. _shapeUV: number[];
  32912. /**
  32913. * color array of the model
  32914. * @hidden
  32915. */
  32916. _shapeColors: number[];
  32917. /**
  32918. * indices array of the model
  32919. * @hidden
  32920. */
  32921. _indices: number[];
  32922. /**
  32923. * normals array of the model
  32924. * @hidden
  32925. */
  32926. _normals: number[];
  32927. /**
  32928. * length of the shape in the model indices array (internal use)
  32929. * @hidden
  32930. */
  32931. _indicesLength: number;
  32932. /**
  32933. * Custom position function (internal use)
  32934. * @hidden
  32935. */
  32936. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32937. /**
  32938. * Custom vertex function (internal use)
  32939. * @hidden
  32940. */
  32941. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32942. /**
  32943. * Model material (internal use)
  32944. * @hidden
  32945. */
  32946. _material: Nullable<Material>;
  32947. /**
  32948. * 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.
  32949. * SPS internal tool, don't use it manually.
  32950. * @hidden
  32951. */
  32952. 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>);
  32953. }
  32954. /**
  32955. * Represents a Depth Sorted Particle in the solid particle system.
  32956. * @hidden
  32957. */
  32958. export class DepthSortedParticle {
  32959. /**
  32960. * Particle index
  32961. */
  32962. idx: number;
  32963. /**
  32964. * Index of the particle in the "indices" array
  32965. */
  32966. ind: number;
  32967. /**
  32968. * Length of the particle shape in the "indices" array
  32969. */
  32970. indicesLength: number;
  32971. /**
  32972. * Squared distance from the particle to the camera
  32973. */
  32974. sqDistance: number;
  32975. /**
  32976. * Material index when used with MultiMaterials
  32977. */
  32978. materialIndex: number;
  32979. /**
  32980. * Creates a new sorted particle
  32981. * @param materialIndex
  32982. */
  32983. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32984. }
  32985. /**
  32986. * Represents a solid particle vertex
  32987. */
  32988. export class SolidParticleVertex {
  32989. /**
  32990. * Vertex position
  32991. */
  32992. position: Vector3;
  32993. /**
  32994. * Vertex color
  32995. */
  32996. color: Color4;
  32997. /**
  32998. * Vertex UV
  32999. */
  33000. uv: Vector2;
  33001. /**
  33002. * Creates a new solid particle vertex
  33003. */
  33004. constructor();
  33005. /** Vertex x coordinate */
  33006. get x(): number;
  33007. set x(val: number);
  33008. /** Vertex y coordinate */
  33009. get y(): number;
  33010. set y(val: number);
  33011. /** Vertex z coordinate */
  33012. get z(): number;
  33013. set z(val: number);
  33014. }
  33015. }
  33016. declare module "babylonjs/Collisions/meshCollisionData" {
  33017. import { Collider } from "babylonjs/Collisions/collider";
  33018. import { Vector3 } from "babylonjs/Maths/math.vector";
  33019. import { Nullable } from "babylonjs/types";
  33020. import { Observer } from "babylonjs/Misc/observable";
  33021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33022. /**
  33023. * @hidden
  33024. */
  33025. export class _MeshCollisionData {
  33026. _checkCollisions: boolean;
  33027. _collisionMask: number;
  33028. _collisionGroup: number;
  33029. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33030. _collider: Nullable<Collider>;
  33031. _oldPositionForCollisions: Vector3;
  33032. _diffPositionForCollisions: Vector3;
  33033. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33034. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33035. }
  33036. }
  33037. declare module "babylonjs/Meshes/abstractMesh" {
  33038. import { Observable } from "babylonjs/Misc/observable";
  33039. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33040. import { Camera } from "babylonjs/Cameras/camera";
  33041. import { Scene, IDisposable } from "babylonjs/scene";
  33042. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33043. import { Node } from "babylonjs/node";
  33044. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33045. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33046. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33047. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33048. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33049. import { Material } from "babylonjs/Materials/material";
  33050. import { Light } from "babylonjs/Lights/light";
  33051. import { Skeleton } from "babylonjs/Bones/skeleton";
  33052. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33053. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33054. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33055. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33056. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33057. import { Plane } from "babylonjs/Maths/math.plane";
  33058. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33059. import { Ray } from "babylonjs/Culling/ray";
  33060. import { Collider } from "babylonjs/Collisions/collider";
  33061. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33062. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33063. /** @hidden */
  33064. class _FacetDataStorage {
  33065. facetPositions: Vector3[];
  33066. facetNormals: Vector3[];
  33067. facetPartitioning: number[][];
  33068. facetNb: number;
  33069. partitioningSubdivisions: number;
  33070. partitioningBBoxRatio: number;
  33071. facetDataEnabled: boolean;
  33072. facetParameters: any;
  33073. bbSize: Vector3;
  33074. subDiv: {
  33075. max: number;
  33076. X: number;
  33077. Y: number;
  33078. Z: number;
  33079. };
  33080. facetDepthSort: boolean;
  33081. facetDepthSortEnabled: boolean;
  33082. depthSortedIndices: IndicesArray;
  33083. depthSortedFacets: {
  33084. ind: number;
  33085. sqDistance: number;
  33086. }[];
  33087. facetDepthSortFunction: (f1: {
  33088. ind: number;
  33089. sqDistance: number;
  33090. }, f2: {
  33091. ind: number;
  33092. sqDistance: number;
  33093. }) => number;
  33094. facetDepthSortFrom: Vector3;
  33095. facetDepthSortOrigin: Vector3;
  33096. invertedMatrix: Matrix;
  33097. }
  33098. /**
  33099. * @hidden
  33100. **/
  33101. class _InternalAbstractMeshDataInfo {
  33102. _hasVertexAlpha: boolean;
  33103. _useVertexColors: boolean;
  33104. _numBoneInfluencers: number;
  33105. _applyFog: boolean;
  33106. _receiveShadows: boolean;
  33107. _facetData: _FacetDataStorage;
  33108. _visibility: number;
  33109. _skeleton: Nullable<Skeleton>;
  33110. _layerMask: number;
  33111. _computeBonesUsingShaders: boolean;
  33112. _isActive: boolean;
  33113. _onlyForInstances: boolean;
  33114. _isActiveIntermediate: boolean;
  33115. _onlyForInstancesIntermediate: boolean;
  33116. _actAsRegularMesh: boolean;
  33117. }
  33118. /**
  33119. * Class used to store all common mesh properties
  33120. */
  33121. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33122. /** No occlusion */
  33123. static OCCLUSION_TYPE_NONE: number;
  33124. /** Occlusion set to optimisitic */
  33125. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33126. /** Occlusion set to strict */
  33127. static OCCLUSION_TYPE_STRICT: number;
  33128. /** Use an accurante occlusion algorithm */
  33129. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33130. /** Use a conservative occlusion algorithm */
  33131. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33132. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33133. * Test order :
  33134. * Is the bounding sphere outside the frustum ?
  33135. * If not, are the bounding box vertices outside the frustum ?
  33136. * It not, then the cullable object is in the frustum.
  33137. */
  33138. static readonly CULLINGSTRATEGY_STANDARD: number;
  33139. /** Culling strategy : Bounding Sphere Only.
  33140. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33141. * It's also less accurate than the standard because some not visible objects can still be selected.
  33142. * Test : is the bounding sphere outside the frustum ?
  33143. * If not, then the cullable object is in the frustum.
  33144. */
  33145. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33146. /** Culling strategy : Optimistic Inclusion.
  33147. * This in an inclusion test first, then the standard exclusion test.
  33148. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33149. * 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.
  33150. * Anyway, it's as accurate as the standard strategy.
  33151. * Test :
  33152. * Is the cullable object bounding sphere center in the frustum ?
  33153. * If not, apply the default culling strategy.
  33154. */
  33155. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33156. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33157. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33158. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33159. * 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.
  33160. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33161. * Test :
  33162. * Is the cullable object bounding sphere center in the frustum ?
  33163. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33164. */
  33165. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33166. /**
  33167. * No billboard
  33168. */
  33169. static get BILLBOARDMODE_NONE(): number;
  33170. /** Billboard on X axis */
  33171. static get BILLBOARDMODE_X(): number;
  33172. /** Billboard on Y axis */
  33173. static get BILLBOARDMODE_Y(): number;
  33174. /** Billboard on Z axis */
  33175. static get BILLBOARDMODE_Z(): number;
  33176. /** Billboard on all axes */
  33177. static get BILLBOARDMODE_ALL(): number;
  33178. /** Billboard on using position instead of orientation */
  33179. static get BILLBOARDMODE_USE_POSITION(): number;
  33180. /** @hidden */
  33181. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33182. /**
  33183. * The culling strategy to use to check whether the mesh must be rendered or not.
  33184. * This value can be changed at any time and will be used on the next render mesh selection.
  33185. * The possible values are :
  33186. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33187. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33188. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33190. * Please read each static variable documentation to get details about the culling process.
  33191. * */
  33192. cullingStrategy: number;
  33193. /**
  33194. * Gets the number of facets in the mesh
  33195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33196. */
  33197. get facetNb(): number;
  33198. /**
  33199. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33200. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33201. */
  33202. get partitioningSubdivisions(): number;
  33203. set partitioningSubdivisions(nb: number);
  33204. /**
  33205. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33206. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33207. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33208. */
  33209. get partitioningBBoxRatio(): number;
  33210. set partitioningBBoxRatio(ratio: number);
  33211. /**
  33212. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33213. * Works only for updatable meshes.
  33214. * Doesn't work with multi-materials
  33215. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33216. */
  33217. get mustDepthSortFacets(): boolean;
  33218. set mustDepthSortFacets(sort: boolean);
  33219. /**
  33220. * The location (Vector3) where the facet depth sort must be computed from.
  33221. * By default, the active camera position.
  33222. * Used only when facet depth sort is enabled
  33223. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33224. */
  33225. get facetDepthSortFrom(): Vector3;
  33226. set facetDepthSortFrom(location: Vector3);
  33227. /**
  33228. * gets a boolean indicating if facetData is enabled
  33229. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33230. */
  33231. get isFacetDataEnabled(): boolean;
  33232. /** @hidden */
  33233. _updateNonUniformScalingState(value: boolean): boolean;
  33234. /**
  33235. * An event triggered when this mesh collides with another one
  33236. */
  33237. onCollideObservable: Observable<AbstractMesh>;
  33238. /** Set a function to call when this mesh collides with another one */
  33239. set onCollide(callback: () => void);
  33240. /**
  33241. * An event triggered when the collision's position changes
  33242. */
  33243. onCollisionPositionChangeObservable: Observable<Vector3>;
  33244. /** Set a function to call when the collision's position changes */
  33245. set onCollisionPositionChange(callback: () => void);
  33246. /**
  33247. * An event triggered when material is changed
  33248. */
  33249. onMaterialChangedObservable: Observable<AbstractMesh>;
  33250. /**
  33251. * Gets or sets the orientation for POV movement & rotation
  33252. */
  33253. definedFacingForward: boolean;
  33254. /** @hidden */
  33255. _occlusionQuery: Nullable<WebGLQuery>;
  33256. /** @hidden */
  33257. _renderingGroup: Nullable<RenderingGroup>;
  33258. /**
  33259. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33260. */
  33261. get visibility(): number;
  33262. /**
  33263. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33264. */
  33265. set visibility(value: number);
  33266. /** Gets or sets the alpha index used to sort transparent meshes
  33267. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33268. */
  33269. alphaIndex: number;
  33270. /**
  33271. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33272. */
  33273. isVisible: boolean;
  33274. /**
  33275. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33276. */
  33277. isPickable: boolean;
  33278. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33279. showSubMeshesBoundingBox: boolean;
  33280. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33281. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33282. */
  33283. isBlocker: boolean;
  33284. /**
  33285. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33286. */
  33287. enablePointerMoveEvents: boolean;
  33288. private _renderingGroupId;
  33289. /**
  33290. * Specifies the rendering group id for this mesh (0 by default)
  33291. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33292. */
  33293. get renderingGroupId(): number;
  33294. set renderingGroupId(value: number);
  33295. private _material;
  33296. /** Gets or sets current material */
  33297. get material(): Nullable<Material>;
  33298. set material(value: Nullable<Material>);
  33299. /**
  33300. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33301. * @see https://doc.babylonjs.com/babylon101/shadows
  33302. */
  33303. get receiveShadows(): boolean;
  33304. set receiveShadows(value: boolean);
  33305. /** Defines color to use when rendering outline */
  33306. outlineColor: Color3;
  33307. /** Define width to use when rendering outline */
  33308. outlineWidth: number;
  33309. /** Defines color to use when rendering overlay */
  33310. overlayColor: Color3;
  33311. /** Defines alpha to use when rendering overlay */
  33312. overlayAlpha: number;
  33313. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33314. get hasVertexAlpha(): boolean;
  33315. set hasVertexAlpha(value: boolean);
  33316. /** 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) */
  33317. get useVertexColors(): boolean;
  33318. set useVertexColors(value: boolean);
  33319. /**
  33320. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33321. */
  33322. get computeBonesUsingShaders(): boolean;
  33323. set computeBonesUsingShaders(value: boolean);
  33324. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33325. get numBoneInfluencers(): number;
  33326. set numBoneInfluencers(value: number);
  33327. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33328. get applyFog(): boolean;
  33329. set applyFog(value: boolean);
  33330. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33331. useOctreeForRenderingSelection: boolean;
  33332. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33333. useOctreeForPicking: boolean;
  33334. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33335. useOctreeForCollisions: boolean;
  33336. /**
  33337. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33338. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33339. */
  33340. get layerMask(): number;
  33341. set layerMask(value: number);
  33342. /**
  33343. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33344. */
  33345. alwaysSelectAsActiveMesh: boolean;
  33346. /**
  33347. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33348. */
  33349. doNotSyncBoundingInfo: boolean;
  33350. /**
  33351. * Gets or sets the current action manager
  33352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33353. */
  33354. actionManager: Nullable<AbstractActionManager>;
  33355. private _meshCollisionData;
  33356. /**
  33357. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33358. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33359. */
  33360. ellipsoid: Vector3;
  33361. /**
  33362. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33363. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33364. */
  33365. ellipsoidOffset: Vector3;
  33366. /**
  33367. * Gets or sets a collision mask used to mask collisions (default is -1).
  33368. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33369. */
  33370. get collisionMask(): number;
  33371. set collisionMask(mask: number);
  33372. /**
  33373. * Gets or sets the current collision group mask (-1 by default).
  33374. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33375. */
  33376. get collisionGroup(): number;
  33377. set collisionGroup(mask: number);
  33378. /**
  33379. * Gets or sets current surrounding meshes (null by default).
  33380. *
  33381. * By default collision detection is tested against every mesh in the scene.
  33382. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33383. * meshes will be tested for the collision.
  33384. *
  33385. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33386. */
  33387. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33388. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33389. /**
  33390. * Defines edge width used when edgesRenderer is enabled
  33391. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33392. */
  33393. edgesWidth: number;
  33394. /**
  33395. * Defines edge color used when edgesRenderer is enabled
  33396. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33397. */
  33398. edgesColor: Color4;
  33399. /** @hidden */
  33400. _edgesRenderer: Nullable<IEdgesRenderer>;
  33401. /** @hidden */
  33402. _masterMesh: Nullable<AbstractMesh>;
  33403. /** @hidden */
  33404. _boundingInfo: Nullable<BoundingInfo>;
  33405. /** @hidden */
  33406. _renderId: number;
  33407. /**
  33408. * Gets or sets the list of subMeshes
  33409. * @see https://doc.babylonjs.com/how_to/multi_materials
  33410. */
  33411. subMeshes: SubMesh[];
  33412. /** @hidden */
  33413. _intersectionsInProgress: AbstractMesh[];
  33414. /** @hidden */
  33415. _unIndexed: boolean;
  33416. /** @hidden */
  33417. _lightSources: Light[];
  33418. /** Gets the list of lights affecting that mesh */
  33419. get lightSources(): Light[];
  33420. /** @hidden */
  33421. get _positions(): Nullable<Vector3[]>;
  33422. /** @hidden */
  33423. _waitingData: {
  33424. lods: Nullable<any>;
  33425. actions: Nullable<any>;
  33426. freezeWorldMatrix: Nullable<boolean>;
  33427. };
  33428. /** @hidden */
  33429. _bonesTransformMatrices: Nullable<Float32Array>;
  33430. /** @hidden */
  33431. _transformMatrixTexture: Nullable<RawTexture>;
  33432. /**
  33433. * Gets or sets a skeleton to apply skining transformations
  33434. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33435. */
  33436. set skeleton(value: Nullable<Skeleton>);
  33437. get skeleton(): Nullable<Skeleton>;
  33438. /**
  33439. * An event triggered when the mesh is rebuilt.
  33440. */
  33441. onRebuildObservable: Observable<AbstractMesh>;
  33442. /**
  33443. * Creates a new AbstractMesh
  33444. * @param name defines the name of the mesh
  33445. * @param scene defines the hosting scene
  33446. */
  33447. constructor(name: string, scene?: Nullable<Scene>);
  33448. /**
  33449. * Returns the string "AbstractMesh"
  33450. * @returns "AbstractMesh"
  33451. */
  33452. getClassName(): string;
  33453. /**
  33454. * Gets a string representation of the current mesh
  33455. * @param fullDetails defines a boolean indicating if full details must be included
  33456. * @returns a string representation of the current mesh
  33457. */
  33458. toString(fullDetails?: boolean): string;
  33459. /**
  33460. * @hidden
  33461. */
  33462. protected _getEffectiveParent(): Nullable<Node>;
  33463. /** @hidden */
  33464. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33465. /** @hidden */
  33466. _rebuild(): void;
  33467. /** @hidden */
  33468. _resyncLightSources(): void;
  33469. /** @hidden */
  33470. _resyncLightSource(light: Light): void;
  33471. /** @hidden */
  33472. _unBindEffect(): void;
  33473. /** @hidden */
  33474. _removeLightSource(light: Light, dispose: boolean): void;
  33475. private _markSubMeshesAsDirty;
  33476. /** @hidden */
  33477. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33478. /** @hidden */
  33479. _markSubMeshesAsAttributesDirty(): void;
  33480. /** @hidden */
  33481. _markSubMeshesAsMiscDirty(): void;
  33482. /**
  33483. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33484. */
  33485. get scaling(): Vector3;
  33486. set scaling(newScaling: Vector3);
  33487. /**
  33488. * Returns true if the mesh is blocked. Implemented by child classes
  33489. */
  33490. get isBlocked(): boolean;
  33491. /**
  33492. * Returns the mesh itself by default. Implemented by child classes
  33493. * @param camera defines the camera to use to pick the right LOD level
  33494. * @returns the currentAbstractMesh
  33495. */
  33496. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33497. /**
  33498. * Returns 0 by default. Implemented by child classes
  33499. * @returns an integer
  33500. */
  33501. getTotalVertices(): number;
  33502. /**
  33503. * Returns a positive integer : the total number of indices in this mesh geometry.
  33504. * @returns the numner of indices or zero if the mesh has no geometry.
  33505. */
  33506. getTotalIndices(): number;
  33507. /**
  33508. * Returns null by default. Implemented by child classes
  33509. * @returns null
  33510. */
  33511. getIndices(): Nullable<IndicesArray>;
  33512. /**
  33513. * Returns the array of the requested vertex data kind. Implemented by child classes
  33514. * @param kind defines the vertex data kind to use
  33515. * @returns null
  33516. */
  33517. getVerticesData(kind: string): Nullable<FloatArray>;
  33518. /**
  33519. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33520. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33521. * Note that a new underlying VertexBuffer object is created each call.
  33522. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33523. * @param kind defines vertex data kind:
  33524. * * VertexBuffer.PositionKind
  33525. * * VertexBuffer.UVKind
  33526. * * VertexBuffer.UV2Kind
  33527. * * VertexBuffer.UV3Kind
  33528. * * VertexBuffer.UV4Kind
  33529. * * VertexBuffer.UV5Kind
  33530. * * VertexBuffer.UV6Kind
  33531. * * VertexBuffer.ColorKind
  33532. * * VertexBuffer.MatricesIndicesKind
  33533. * * VertexBuffer.MatricesIndicesExtraKind
  33534. * * VertexBuffer.MatricesWeightsKind
  33535. * * VertexBuffer.MatricesWeightsExtraKind
  33536. * @param data defines the data source
  33537. * @param updatable defines if the data must be flagged as updatable (or static)
  33538. * @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
  33539. * @returns the current mesh
  33540. */
  33541. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33542. /**
  33543. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33544. * If the mesh has no geometry, it is simply returned as it is.
  33545. * @param kind defines vertex data kind:
  33546. * * VertexBuffer.PositionKind
  33547. * * VertexBuffer.UVKind
  33548. * * VertexBuffer.UV2Kind
  33549. * * VertexBuffer.UV3Kind
  33550. * * VertexBuffer.UV4Kind
  33551. * * VertexBuffer.UV5Kind
  33552. * * VertexBuffer.UV6Kind
  33553. * * VertexBuffer.ColorKind
  33554. * * VertexBuffer.MatricesIndicesKind
  33555. * * VertexBuffer.MatricesIndicesExtraKind
  33556. * * VertexBuffer.MatricesWeightsKind
  33557. * * VertexBuffer.MatricesWeightsExtraKind
  33558. * @param data defines the data source
  33559. * @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
  33560. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33561. * @returns the current mesh
  33562. */
  33563. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33564. /**
  33565. * Sets the mesh indices,
  33566. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33567. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33568. * @param totalVertices Defines the total number of vertices
  33569. * @returns the current mesh
  33570. */
  33571. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33572. /**
  33573. * Gets a boolean indicating if specific vertex data is present
  33574. * @param kind defines the vertex data kind to use
  33575. * @returns true is data kind is present
  33576. */
  33577. isVerticesDataPresent(kind: string): boolean;
  33578. /**
  33579. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33580. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33581. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33582. * @returns a BoundingInfo
  33583. */
  33584. getBoundingInfo(): BoundingInfo;
  33585. /**
  33586. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33587. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33588. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33589. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33590. * @returns the current mesh
  33591. */
  33592. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33593. /**
  33594. * Overwrite the current bounding info
  33595. * @param boundingInfo defines the new bounding info
  33596. * @returns the current mesh
  33597. */
  33598. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33599. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33600. get useBones(): boolean;
  33601. /** @hidden */
  33602. _preActivate(): void;
  33603. /** @hidden */
  33604. _preActivateForIntermediateRendering(renderId: number): void;
  33605. /** @hidden */
  33606. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33607. /** @hidden */
  33608. _postActivate(): void;
  33609. /** @hidden */
  33610. _freeze(): void;
  33611. /** @hidden */
  33612. _unFreeze(): void;
  33613. /**
  33614. * Gets the current world matrix
  33615. * @returns a Matrix
  33616. */
  33617. getWorldMatrix(): Matrix;
  33618. /** @hidden */
  33619. _getWorldMatrixDeterminant(): number;
  33620. /**
  33621. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33622. */
  33623. get isAnInstance(): boolean;
  33624. /**
  33625. * Gets a boolean indicating if this mesh has instances
  33626. */
  33627. get hasInstances(): boolean;
  33628. /**
  33629. * Gets a boolean indicating if this mesh has thin instances
  33630. */
  33631. get hasThinInstances(): boolean;
  33632. /**
  33633. * Perform relative position change from the point of view of behind the front of the mesh.
  33634. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33635. * Supports definition of mesh facing forward or backward
  33636. * @param amountRight defines the distance on the right axis
  33637. * @param amountUp defines the distance on the up axis
  33638. * @param amountForward defines the distance on the forward axis
  33639. * @returns the current mesh
  33640. */
  33641. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33642. /**
  33643. * Calculate relative position change from the point of view of behind the front of the mesh.
  33644. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33645. * Supports definition of mesh facing forward or backward
  33646. * @param amountRight defines the distance on the right axis
  33647. * @param amountUp defines the distance on the up axis
  33648. * @param amountForward defines the distance on the forward axis
  33649. * @returns the new displacement vector
  33650. */
  33651. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33652. /**
  33653. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33654. * Supports definition of mesh facing forward or backward
  33655. * @param flipBack defines the flip
  33656. * @param twirlClockwise defines the twirl
  33657. * @param tiltRight defines the tilt
  33658. * @returns the current mesh
  33659. */
  33660. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33661. /**
  33662. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33663. * Supports definition of mesh facing forward or backward.
  33664. * @param flipBack defines the flip
  33665. * @param twirlClockwise defines the twirl
  33666. * @param tiltRight defines the tilt
  33667. * @returns the new rotation vector
  33668. */
  33669. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33670. /**
  33671. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33672. * This means the mesh underlying bounding box and sphere are recomputed.
  33673. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33674. * @returns the current mesh
  33675. */
  33676. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33677. /** @hidden */
  33678. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33679. /** @hidden */
  33680. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33681. /** @hidden */
  33682. _updateBoundingInfo(): AbstractMesh;
  33683. /** @hidden */
  33684. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33685. /** @hidden */
  33686. protected _afterComputeWorldMatrix(): void;
  33687. /** @hidden */
  33688. get _effectiveMesh(): AbstractMesh;
  33689. /**
  33690. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33691. * A mesh is in the frustum if its bounding box intersects the frustum
  33692. * @param frustumPlanes defines the frustum to test
  33693. * @returns true if the mesh is in the frustum planes
  33694. */
  33695. isInFrustum(frustumPlanes: Plane[]): boolean;
  33696. /**
  33697. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33698. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33699. * @param frustumPlanes defines the frustum to test
  33700. * @returns true if the mesh is completely in the frustum planes
  33701. */
  33702. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33703. /**
  33704. * True if the mesh intersects another mesh or a SolidParticle object
  33705. * @param mesh defines a target mesh or SolidParticle to test
  33706. * @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)
  33707. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33708. * @returns true if there is an intersection
  33709. */
  33710. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33711. /**
  33712. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33713. * @param point defines the point to test
  33714. * @returns true if there is an intersection
  33715. */
  33716. intersectsPoint(point: Vector3): boolean;
  33717. /**
  33718. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33719. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33720. */
  33721. get checkCollisions(): boolean;
  33722. set checkCollisions(collisionEnabled: boolean);
  33723. /**
  33724. * Gets Collider object used to compute collisions (not physics)
  33725. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33726. */
  33727. get collider(): Nullable<Collider>;
  33728. /**
  33729. * Move the mesh using collision engine
  33730. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33731. * @param displacement defines the requested displacement vector
  33732. * @returns the current mesh
  33733. */
  33734. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33735. private _onCollisionPositionChange;
  33736. /** @hidden */
  33737. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33738. /** @hidden */
  33739. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33740. /** @hidden */
  33741. _checkCollision(collider: Collider): AbstractMesh;
  33742. /** @hidden */
  33743. _generatePointsArray(): boolean;
  33744. /**
  33745. * Checks if the passed Ray intersects with the mesh
  33746. * @param ray defines the ray to use
  33747. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33748. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33749. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33750. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33751. * @returns the picking info
  33752. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33753. */
  33754. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33755. /**
  33756. * Clones the current mesh
  33757. * @param name defines the mesh name
  33758. * @param newParent defines the new mesh parent
  33759. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33760. * @returns the new mesh
  33761. */
  33762. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33763. /**
  33764. * Disposes all the submeshes of the current meshnp
  33765. * @returns the current mesh
  33766. */
  33767. releaseSubMeshes(): AbstractMesh;
  33768. /**
  33769. * Releases resources associated with this abstract mesh.
  33770. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33771. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33772. */
  33773. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33774. /**
  33775. * Adds the passed mesh as a child to the current mesh
  33776. * @param mesh defines the child mesh
  33777. * @returns the current mesh
  33778. */
  33779. addChild(mesh: AbstractMesh): AbstractMesh;
  33780. /**
  33781. * Removes the passed mesh from the current mesh children list
  33782. * @param mesh defines the child mesh
  33783. * @returns the current mesh
  33784. */
  33785. removeChild(mesh: AbstractMesh): AbstractMesh;
  33786. /** @hidden */
  33787. private _initFacetData;
  33788. /**
  33789. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33790. * This method can be called within the render loop.
  33791. * 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
  33792. * @returns the current mesh
  33793. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33794. */
  33795. updateFacetData(): AbstractMesh;
  33796. /**
  33797. * Returns the facetLocalNormals array.
  33798. * The normals are expressed in the mesh local spac
  33799. * @returns an array of Vector3
  33800. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33801. */
  33802. getFacetLocalNormals(): Vector3[];
  33803. /**
  33804. * Returns the facetLocalPositions array.
  33805. * The facet positions are expressed in the mesh local space
  33806. * @returns an array of Vector3
  33807. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33808. */
  33809. getFacetLocalPositions(): Vector3[];
  33810. /**
  33811. * Returns the facetLocalPartioning array
  33812. * @returns an array of array of numbers
  33813. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33814. */
  33815. getFacetLocalPartitioning(): number[][];
  33816. /**
  33817. * Returns the i-th facet position in the world system.
  33818. * This method allocates a new Vector3 per call
  33819. * @param i defines the facet index
  33820. * @returns a new Vector3
  33821. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33822. */
  33823. getFacetPosition(i: number): Vector3;
  33824. /**
  33825. * Sets the reference Vector3 with the i-th facet position in the world system
  33826. * @param i defines the facet index
  33827. * @param ref defines the target vector
  33828. * @returns the current mesh
  33829. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33830. */
  33831. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33832. /**
  33833. * Returns the i-th facet normal in the world system.
  33834. * This method allocates a new Vector3 per call
  33835. * @param i defines the facet index
  33836. * @returns a new Vector3
  33837. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33838. */
  33839. getFacetNormal(i: number): Vector3;
  33840. /**
  33841. * Sets the reference Vector3 with the i-th facet normal in the world system
  33842. * @param i defines the facet index
  33843. * @param ref defines the target vector
  33844. * @returns the current mesh
  33845. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33846. */
  33847. getFacetNormalToRef(i: number, ref: Vector3): this;
  33848. /**
  33849. * 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)
  33850. * @param x defines x coordinate
  33851. * @param y defines y coordinate
  33852. * @param z defines z coordinate
  33853. * @returns the array of facet indexes
  33854. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33855. */
  33856. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33857. /**
  33858. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33859. * @param projected sets as the (x,y,z) world projection on the facet
  33860. * @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
  33861. * @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
  33862. * @param x defines x coordinate
  33863. * @param y defines y coordinate
  33864. * @param z defines z coordinate
  33865. * @returns the face index if found (or null instead)
  33866. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33867. */
  33868. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33869. /**
  33870. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33871. * @param projected sets as the (x,y,z) local projection on the facet
  33872. * @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
  33873. * @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
  33874. * @param x defines x coordinate
  33875. * @param y defines y coordinate
  33876. * @param z defines z coordinate
  33877. * @returns the face index if found (or null instead)
  33878. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33879. */
  33880. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33881. /**
  33882. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33883. * @returns the parameters
  33884. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33885. */
  33886. getFacetDataParameters(): any;
  33887. /**
  33888. * Disables the feature FacetData and frees the related memory
  33889. * @returns the current mesh
  33890. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33891. */
  33892. disableFacetData(): AbstractMesh;
  33893. /**
  33894. * Updates the AbstractMesh indices array
  33895. * @param indices defines the data source
  33896. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33897. * @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)
  33898. * @returns the current mesh
  33899. */
  33900. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33901. /**
  33902. * Creates new normals data for the mesh
  33903. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33904. * @returns the current mesh
  33905. */
  33906. createNormals(updatable: boolean): AbstractMesh;
  33907. /**
  33908. * Align the mesh with a normal
  33909. * @param normal defines the normal to use
  33910. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33911. * @returns the current mesh
  33912. */
  33913. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33914. /** @hidden */
  33915. _checkOcclusionQuery(): boolean;
  33916. /**
  33917. * Disables the mesh edge rendering mode
  33918. * @returns the currentAbstractMesh
  33919. */
  33920. disableEdgesRendering(): AbstractMesh;
  33921. /**
  33922. * Enables the edge rendering mode on the mesh.
  33923. * This mode makes the mesh edges visible
  33924. * @param epsilon defines the maximal distance between two angles to detect a face
  33925. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33926. * @returns the currentAbstractMesh
  33927. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33928. */
  33929. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33930. /**
  33931. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33932. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33933. */
  33934. getConnectedParticleSystems(): IParticleSystem[];
  33935. }
  33936. }
  33937. declare module "babylonjs/Actions/actionEvent" {
  33938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33939. import { Nullable } from "babylonjs/types";
  33940. import { Sprite } from "babylonjs/Sprites/sprite";
  33941. import { Scene } from "babylonjs/scene";
  33942. import { Vector2 } from "babylonjs/Maths/math.vector";
  33943. /**
  33944. * Interface used to define ActionEvent
  33945. */
  33946. export interface IActionEvent {
  33947. /** The mesh or sprite that triggered the action */
  33948. source: any;
  33949. /** The X mouse cursor position at the time of the event */
  33950. pointerX: number;
  33951. /** The Y mouse cursor position at the time of the event */
  33952. pointerY: number;
  33953. /** The mesh that is currently pointed at (can be null) */
  33954. meshUnderPointer: Nullable<AbstractMesh>;
  33955. /** the original (browser) event that triggered the ActionEvent */
  33956. sourceEvent?: any;
  33957. /** additional data for the event */
  33958. additionalData?: any;
  33959. }
  33960. /**
  33961. * ActionEvent is the event being sent when an action is triggered.
  33962. */
  33963. export class ActionEvent implements IActionEvent {
  33964. /** The mesh or sprite that triggered the action */
  33965. source: any;
  33966. /** The X mouse cursor position at the time of the event */
  33967. pointerX: number;
  33968. /** The Y mouse cursor position at the time of the event */
  33969. pointerY: number;
  33970. /** The mesh that is currently pointed at (can be null) */
  33971. meshUnderPointer: Nullable<AbstractMesh>;
  33972. /** the original (browser) event that triggered the ActionEvent */
  33973. sourceEvent?: any;
  33974. /** additional data for the event */
  33975. additionalData?: any;
  33976. /**
  33977. * Creates a new ActionEvent
  33978. * @param source The mesh or sprite that triggered the action
  33979. * @param pointerX The X mouse cursor position at the time of the event
  33980. * @param pointerY The Y mouse cursor position at the time of the event
  33981. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33982. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33983. * @param additionalData additional data for the event
  33984. */
  33985. constructor(
  33986. /** The mesh or sprite that triggered the action */
  33987. source: any,
  33988. /** The X mouse cursor position at the time of the event */
  33989. pointerX: number,
  33990. /** The Y mouse cursor position at the time of the event */
  33991. pointerY: number,
  33992. /** The mesh that is currently pointed at (can be null) */
  33993. meshUnderPointer: Nullable<AbstractMesh>,
  33994. /** the original (browser) event that triggered the ActionEvent */
  33995. sourceEvent?: any,
  33996. /** additional data for the event */
  33997. additionalData?: any);
  33998. /**
  33999. * Helper function to auto-create an ActionEvent from a source mesh.
  34000. * @param source The source mesh that triggered the event
  34001. * @param evt The original (browser) event
  34002. * @param additionalData additional data for the event
  34003. * @returns the new ActionEvent
  34004. */
  34005. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34006. /**
  34007. * Helper function to auto-create an ActionEvent from a source sprite
  34008. * @param source The source sprite that triggered the event
  34009. * @param scene Scene associated with the sprite
  34010. * @param evt The original (browser) event
  34011. * @param additionalData additional data for the event
  34012. * @returns the new ActionEvent
  34013. */
  34014. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34015. /**
  34016. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34017. * @param scene the scene where the event occurred
  34018. * @param evt The original (browser) event
  34019. * @returns the new ActionEvent
  34020. */
  34021. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34022. /**
  34023. * Helper function to auto-create an ActionEvent from a primitive
  34024. * @param prim defines the target primitive
  34025. * @param pointerPos defines the pointer position
  34026. * @param evt The original (browser) event
  34027. * @param additionalData additional data for the event
  34028. * @returns the new ActionEvent
  34029. */
  34030. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34031. }
  34032. }
  34033. declare module "babylonjs/Actions/abstractActionManager" {
  34034. import { IDisposable } from "babylonjs/scene";
  34035. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34036. import { IAction } from "babylonjs/Actions/action";
  34037. import { Nullable } from "babylonjs/types";
  34038. /**
  34039. * Abstract class used to decouple action Manager from scene and meshes.
  34040. * Do not instantiate.
  34041. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34042. */
  34043. export abstract class AbstractActionManager implements IDisposable {
  34044. /** Gets the list of active triggers */
  34045. static Triggers: {
  34046. [key: string]: number;
  34047. };
  34048. /** Gets the cursor to use when hovering items */
  34049. hoverCursor: string;
  34050. /** Gets the list of actions */
  34051. actions: IAction[];
  34052. /**
  34053. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34054. */
  34055. isRecursive: boolean;
  34056. /**
  34057. * Releases all associated resources
  34058. */
  34059. abstract dispose(): void;
  34060. /**
  34061. * Does this action manager has pointer triggers
  34062. */
  34063. abstract get hasPointerTriggers(): boolean;
  34064. /**
  34065. * Does this action manager has pick triggers
  34066. */
  34067. abstract get hasPickTriggers(): boolean;
  34068. /**
  34069. * Process a specific trigger
  34070. * @param trigger defines the trigger to process
  34071. * @param evt defines the event details to be processed
  34072. */
  34073. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34074. /**
  34075. * Does this action manager handles actions of any of the given triggers
  34076. * @param triggers defines the triggers to be tested
  34077. * @return a boolean indicating whether one (or more) of the triggers is handled
  34078. */
  34079. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34080. /**
  34081. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34082. * speed.
  34083. * @param triggerA defines the trigger to be tested
  34084. * @param triggerB defines the trigger to be tested
  34085. * @return a boolean indicating whether one (or more) of the triggers is handled
  34086. */
  34087. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34088. /**
  34089. * Does this action manager handles actions of a given trigger
  34090. * @param trigger defines the trigger to be tested
  34091. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34092. * @return whether the trigger is handled
  34093. */
  34094. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34095. /**
  34096. * Serialize this manager to a JSON object
  34097. * @param name defines the property name to store this manager
  34098. * @returns a JSON representation of this manager
  34099. */
  34100. abstract serialize(name: string): any;
  34101. /**
  34102. * Registers an action to this action manager
  34103. * @param action defines the action to be registered
  34104. * @return the action amended (prepared) after registration
  34105. */
  34106. abstract registerAction(action: IAction): Nullable<IAction>;
  34107. /**
  34108. * Unregisters an action to this action manager
  34109. * @param action defines the action to be unregistered
  34110. * @return a boolean indicating whether the action has been unregistered
  34111. */
  34112. abstract unregisterAction(action: IAction): Boolean;
  34113. /**
  34114. * Does exist one action manager with at least one trigger
  34115. **/
  34116. static get HasTriggers(): boolean;
  34117. /**
  34118. * Does exist one action manager with at least one pick trigger
  34119. **/
  34120. static get HasPickTriggers(): boolean;
  34121. /**
  34122. * Does exist one action manager that handles actions of a given trigger
  34123. * @param trigger defines the trigger to be tested
  34124. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34125. **/
  34126. static HasSpecificTrigger(trigger: number): boolean;
  34127. }
  34128. }
  34129. declare module "babylonjs/node" {
  34130. import { Scene } from "babylonjs/scene";
  34131. import { Nullable } from "babylonjs/types";
  34132. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34133. import { Engine } from "babylonjs/Engines/engine";
  34134. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34135. import { Observable } from "babylonjs/Misc/observable";
  34136. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34137. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34138. import { Animatable } from "babylonjs/Animations/animatable";
  34139. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34140. import { Animation } from "babylonjs/Animations/animation";
  34141. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34143. /**
  34144. * Defines how a node can be built from a string name.
  34145. */
  34146. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34147. /**
  34148. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34149. */
  34150. export class Node implements IBehaviorAware<Node> {
  34151. /** @hidden */
  34152. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34153. private static _NodeConstructors;
  34154. /**
  34155. * Add a new node constructor
  34156. * @param type defines the type name of the node to construct
  34157. * @param constructorFunc defines the constructor function
  34158. */
  34159. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34160. /**
  34161. * Returns a node constructor based on type name
  34162. * @param type defines the type name
  34163. * @param name defines the new node name
  34164. * @param scene defines the hosting scene
  34165. * @param options defines optional options to transmit to constructors
  34166. * @returns the new constructor or null
  34167. */
  34168. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34169. /**
  34170. * Gets or sets the name of the node
  34171. */
  34172. name: string;
  34173. /**
  34174. * Gets or sets the id of the node
  34175. */
  34176. id: string;
  34177. /**
  34178. * Gets or sets the unique id of the node
  34179. */
  34180. uniqueId: number;
  34181. /**
  34182. * Gets or sets a string used to store user defined state for the node
  34183. */
  34184. state: string;
  34185. /**
  34186. * Gets or sets an object used to store user defined information for the node
  34187. */
  34188. metadata: any;
  34189. /**
  34190. * For internal use only. Please do not use.
  34191. */
  34192. reservedDataStore: any;
  34193. /**
  34194. * List of inspectable custom properties (used by the Inspector)
  34195. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34196. */
  34197. inspectableCustomProperties: IInspectable[];
  34198. private _doNotSerialize;
  34199. /**
  34200. * Gets or sets a boolean used to define if the node must be serialized
  34201. */
  34202. get doNotSerialize(): boolean;
  34203. set doNotSerialize(value: boolean);
  34204. /** @hidden */
  34205. _isDisposed: boolean;
  34206. /**
  34207. * Gets a list of Animations associated with the node
  34208. */
  34209. animations: import("babylonjs/Animations/animation").Animation[];
  34210. protected _ranges: {
  34211. [name: string]: Nullable<AnimationRange>;
  34212. };
  34213. /**
  34214. * Callback raised when the node is ready to be used
  34215. */
  34216. onReady: Nullable<(node: Node) => void>;
  34217. private _isEnabled;
  34218. private _isParentEnabled;
  34219. private _isReady;
  34220. /** @hidden */
  34221. _currentRenderId: number;
  34222. private _parentUpdateId;
  34223. /** @hidden */
  34224. _childUpdateId: number;
  34225. /** @hidden */
  34226. _waitingParentId: Nullable<string>;
  34227. /** @hidden */
  34228. _scene: Scene;
  34229. /** @hidden */
  34230. _cache: any;
  34231. private _parentNode;
  34232. private _children;
  34233. /** @hidden */
  34234. _worldMatrix: Matrix;
  34235. /** @hidden */
  34236. _worldMatrixDeterminant: number;
  34237. /** @hidden */
  34238. _worldMatrixDeterminantIsDirty: boolean;
  34239. /** @hidden */
  34240. private _sceneRootNodesIndex;
  34241. /**
  34242. * Gets a boolean indicating if the node has been disposed
  34243. * @returns true if the node was disposed
  34244. */
  34245. isDisposed(): boolean;
  34246. /**
  34247. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34248. * @see https://doc.babylonjs.com/how_to/parenting
  34249. */
  34250. set parent(parent: Nullable<Node>);
  34251. get parent(): Nullable<Node>;
  34252. /** @hidden */
  34253. _addToSceneRootNodes(): void;
  34254. /** @hidden */
  34255. _removeFromSceneRootNodes(): void;
  34256. private _animationPropertiesOverride;
  34257. /**
  34258. * Gets or sets the animation properties override
  34259. */
  34260. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34261. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34262. /**
  34263. * Gets a string identifying the name of the class
  34264. * @returns "Node" string
  34265. */
  34266. getClassName(): string;
  34267. /** @hidden */
  34268. readonly _isNode: boolean;
  34269. /**
  34270. * An event triggered when the mesh is disposed
  34271. */
  34272. onDisposeObservable: Observable<Node>;
  34273. private _onDisposeObserver;
  34274. /**
  34275. * Sets a callback that will be raised when the node will be disposed
  34276. */
  34277. set onDispose(callback: () => void);
  34278. /**
  34279. * Creates a new Node
  34280. * @param name the name and id to be given to this node
  34281. * @param scene the scene this node will be added to
  34282. */
  34283. constructor(name: string, scene?: Nullable<Scene>);
  34284. /**
  34285. * Gets the scene of the node
  34286. * @returns a scene
  34287. */
  34288. getScene(): Scene;
  34289. /**
  34290. * Gets the engine of the node
  34291. * @returns a Engine
  34292. */
  34293. getEngine(): Engine;
  34294. private _behaviors;
  34295. /**
  34296. * Attach a behavior to the node
  34297. * @see https://doc.babylonjs.com/features/behaviour
  34298. * @param behavior defines the behavior to attach
  34299. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34300. * @returns the current Node
  34301. */
  34302. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34303. /**
  34304. * Remove an attached behavior
  34305. * @see https://doc.babylonjs.com/features/behaviour
  34306. * @param behavior defines the behavior to attach
  34307. * @returns the current Node
  34308. */
  34309. removeBehavior(behavior: Behavior<Node>): Node;
  34310. /**
  34311. * Gets the list of attached behaviors
  34312. * @see https://doc.babylonjs.com/features/behaviour
  34313. */
  34314. get behaviors(): Behavior<Node>[];
  34315. /**
  34316. * Gets an attached behavior by name
  34317. * @param name defines the name of the behavior to look for
  34318. * @see https://doc.babylonjs.com/features/behaviour
  34319. * @returns null if behavior was not found else the requested behavior
  34320. */
  34321. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34322. /**
  34323. * Returns the latest update of the World matrix
  34324. * @returns a Matrix
  34325. */
  34326. getWorldMatrix(): Matrix;
  34327. /** @hidden */
  34328. _getWorldMatrixDeterminant(): number;
  34329. /**
  34330. * Returns directly the latest state of the mesh World matrix.
  34331. * A Matrix is returned.
  34332. */
  34333. get worldMatrixFromCache(): Matrix;
  34334. /** @hidden */
  34335. _initCache(): void;
  34336. /** @hidden */
  34337. updateCache(force?: boolean): void;
  34338. /** @hidden */
  34339. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34340. /** @hidden */
  34341. _updateCache(ignoreParentClass?: boolean): void;
  34342. /** @hidden */
  34343. _isSynchronized(): boolean;
  34344. /** @hidden */
  34345. _markSyncedWithParent(): void;
  34346. /** @hidden */
  34347. isSynchronizedWithParent(): boolean;
  34348. /** @hidden */
  34349. isSynchronized(): boolean;
  34350. /**
  34351. * Is this node ready to be used/rendered
  34352. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34353. * @return true if the node is ready
  34354. */
  34355. isReady(completeCheck?: boolean): boolean;
  34356. /**
  34357. * Is this node enabled?
  34358. * 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
  34359. * @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
  34360. * @return whether this node (and its parent) is enabled
  34361. */
  34362. isEnabled(checkAncestors?: boolean): boolean;
  34363. /** @hidden */
  34364. protected _syncParentEnabledState(): void;
  34365. /**
  34366. * Set the enabled state of this node
  34367. * @param value defines the new enabled state
  34368. */
  34369. setEnabled(value: boolean): void;
  34370. /**
  34371. * Is this node a descendant of the given node?
  34372. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34373. * @param ancestor defines the parent node to inspect
  34374. * @returns a boolean indicating if this node is a descendant of the given node
  34375. */
  34376. isDescendantOf(ancestor: Node): boolean;
  34377. /** @hidden */
  34378. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34379. /**
  34380. * Will return all nodes that have this node as ascendant
  34381. * @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
  34382. * @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
  34383. * @return all children nodes of all types
  34384. */
  34385. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34386. /**
  34387. * Get all child-meshes of this node
  34388. * @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)
  34389. * @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
  34390. * @returns an array of AbstractMesh
  34391. */
  34392. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34393. /**
  34394. * Get all direct children of this node
  34395. * @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
  34396. * @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)
  34397. * @returns an array of Node
  34398. */
  34399. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34400. /** @hidden */
  34401. _setReady(state: boolean): void;
  34402. /**
  34403. * Get an animation by name
  34404. * @param name defines the name of the animation to look for
  34405. * @returns null if not found else the requested animation
  34406. */
  34407. getAnimationByName(name: string): Nullable<Animation>;
  34408. /**
  34409. * Creates an animation range for this node
  34410. * @param name defines the name of the range
  34411. * @param from defines the starting key
  34412. * @param to defines the end key
  34413. */
  34414. createAnimationRange(name: string, from: number, to: number): void;
  34415. /**
  34416. * Delete a specific animation range
  34417. * @param name defines the name of the range to delete
  34418. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34419. */
  34420. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34421. /**
  34422. * Get an animation range by name
  34423. * @param name defines the name of the animation range to look for
  34424. * @returns null if not found else the requested animation range
  34425. */
  34426. getAnimationRange(name: string): Nullable<AnimationRange>;
  34427. /**
  34428. * Gets the list of all animation ranges defined on this node
  34429. * @returns an array
  34430. */
  34431. getAnimationRanges(): Nullable<AnimationRange>[];
  34432. /**
  34433. * Will start the animation sequence
  34434. * @param name defines the range frames for animation sequence
  34435. * @param loop defines if the animation should loop (false by default)
  34436. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34437. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34438. * @returns the object created for this animation. If range does not exist, it will return null
  34439. */
  34440. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34441. /**
  34442. * Serialize animation ranges into a JSON compatible object
  34443. * @returns serialization object
  34444. */
  34445. serializeAnimationRanges(): any;
  34446. /**
  34447. * Computes the world matrix of the node
  34448. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34449. * @returns the world matrix
  34450. */
  34451. computeWorldMatrix(force?: boolean): Matrix;
  34452. /**
  34453. * Releases resources associated with this node.
  34454. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34455. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34456. */
  34457. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34458. /**
  34459. * Parse animation range data from a serialization object and store them into a given node
  34460. * @param node defines where to store the animation ranges
  34461. * @param parsedNode defines the serialization object to read data from
  34462. * @param scene defines the hosting scene
  34463. */
  34464. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34465. /**
  34466. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34467. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34468. * @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
  34469. * @returns the new bounding vectors
  34470. */
  34471. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34472. min: Vector3;
  34473. max: Vector3;
  34474. };
  34475. }
  34476. }
  34477. declare module "babylonjs/Animations/animation" {
  34478. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34479. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34480. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34481. import { Nullable } from "babylonjs/types";
  34482. import { Scene } from "babylonjs/scene";
  34483. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34484. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34485. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34486. import { Node } from "babylonjs/node";
  34487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34488. import { Size } from "babylonjs/Maths/math.size";
  34489. import { Animatable } from "babylonjs/Animations/animatable";
  34490. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34491. /**
  34492. * @hidden
  34493. */
  34494. export class _IAnimationState {
  34495. key: number;
  34496. repeatCount: number;
  34497. workValue?: any;
  34498. loopMode?: number;
  34499. offsetValue?: any;
  34500. highLimitValue?: any;
  34501. }
  34502. /**
  34503. * Class used to store any kind of animation
  34504. */
  34505. export class Animation {
  34506. /**Name of the animation */
  34507. name: string;
  34508. /**Property to animate */
  34509. targetProperty: string;
  34510. /**The frames per second of the animation */
  34511. framePerSecond: number;
  34512. /**The data type of the animation */
  34513. dataType: number;
  34514. /**The loop mode of the animation */
  34515. loopMode?: number | undefined;
  34516. /**Specifies if blending should be enabled */
  34517. enableBlending?: boolean | undefined;
  34518. /**
  34519. * Use matrix interpolation instead of using direct key value when animating matrices
  34520. */
  34521. static AllowMatricesInterpolation: boolean;
  34522. /**
  34523. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34524. */
  34525. static AllowMatrixDecomposeForInterpolation: boolean;
  34526. /** Define the Url to load snippets */
  34527. static SnippetUrl: string;
  34528. /** Snippet ID if the animation was created from the snippet server */
  34529. snippetId: string;
  34530. /**
  34531. * Stores the key frames of the animation
  34532. */
  34533. private _keys;
  34534. /**
  34535. * Stores the easing function of the animation
  34536. */
  34537. private _easingFunction;
  34538. /**
  34539. * @hidden Internal use only
  34540. */
  34541. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34542. /**
  34543. * The set of event that will be linked to this animation
  34544. */
  34545. private _events;
  34546. /**
  34547. * Stores an array of target property paths
  34548. */
  34549. targetPropertyPath: string[];
  34550. /**
  34551. * Stores the blending speed of the animation
  34552. */
  34553. blendingSpeed: number;
  34554. /**
  34555. * Stores the animation ranges for the animation
  34556. */
  34557. private _ranges;
  34558. /**
  34559. * @hidden Internal use
  34560. */
  34561. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34562. /**
  34563. * Sets up an animation
  34564. * @param property The property to animate
  34565. * @param animationType The animation type to apply
  34566. * @param framePerSecond The frames per second of the animation
  34567. * @param easingFunction The easing function used in the animation
  34568. * @returns The created animation
  34569. */
  34570. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34571. /**
  34572. * Create and start an animation on a node
  34573. * @param name defines the name of the global animation that will be run on all nodes
  34574. * @param node defines the root node where the animation will take place
  34575. * @param targetProperty defines property to animate
  34576. * @param framePerSecond defines the number of frame per second yo use
  34577. * @param totalFrame defines the number of frames in total
  34578. * @param from defines the initial value
  34579. * @param to defines the final value
  34580. * @param loopMode defines which loop mode you want to use (off by default)
  34581. * @param easingFunction defines the easing function to use (linear by default)
  34582. * @param onAnimationEnd defines the callback to call when animation end
  34583. * @returns the animatable created for this animation
  34584. */
  34585. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34586. /**
  34587. * Create and start an animation on a node and its descendants
  34588. * @param name defines the name of the global animation that will be run on all nodes
  34589. * @param node defines the root node where the animation will take place
  34590. * @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
  34591. * @param targetProperty defines property to animate
  34592. * @param framePerSecond defines the number of frame per second to use
  34593. * @param totalFrame defines the number of frames in total
  34594. * @param from defines the initial value
  34595. * @param to defines the final value
  34596. * @param loopMode defines which loop mode you want to use (off by default)
  34597. * @param easingFunction defines the easing function to use (linear by default)
  34598. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34599. * @returns the list of animatables created for all nodes
  34600. * @example https://www.babylonjs-playground.com/#MH0VLI
  34601. */
  34602. 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[]>;
  34603. /**
  34604. * Creates a new animation, merges it with the existing animations and starts it
  34605. * @param name Name of the animation
  34606. * @param node Node which contains the scene that begins the animations
  34607. * @param targetProperty Specifies which property to animate
  34608. * @param framePerSecond The frames per second of the animation
  34609. * @param totalFrame The total number of frames
  34610. * @param from The frame at the beginning of the animation
  34611. * @param to The frame at the end of the animation
  34612. * @param loopMode Specifies the loop mode of the animation
  34613. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34614. * @param onAnimationEnd Callback to run once the animation is complete
  34615. * @returns Nullable animation
  34616. */
  34617. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34618. /**
  34619. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34620. * @param sourceAnimation defines the Animation containing keyframes to convert
  34621. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34622. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34623. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34624. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34625. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34626. */
  34627. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34628. /**
  34629. * Transition property of an host to the target Value
  34630. * @param property The property to transition
  34631. * @param targetValue The target Value of the property
  34632. * @param host The object where the property to animate belongs
  34633. * @param scene Scene used to run the animation
  34634. * @param frameRate Framerate (in frame/s) to use
  34635. * @param transition The transition type we want to use
  34636. * @param duration The duration of the animation, in milliseconds
  34637. * @param onAnimationEnd Callback trigger at the end of the animation
  34638. * @returns Nullable animation
  34639. */
  34640. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34641. /**
  34642. * Return the array of runtime animations currently using this animation
  34643. */
  34644. get runtimeAnimations(): RuntimeAnimation[];
  34645. /**
  34646. * Specifies if any of the runtime animations are currently running
  34647. */
  34648. get hasRunningRuntimeAnimations(): boolean;
  34649. /**
  34650. * Initializes the animation
  34651. * @param name Name of the animation
  34652. * @param targetProperty Property to animate
  34653. * @param framePerSecond The frames per second of the animation
  34654. * @param dataType The data type of the animation
  34655. * @param loopMode The loop mode of the animation
  34656. * @param enableBlending Specifies if blending should be enabled
  34657. */
  34658. constructor(
  34659. /**Name of the animation */
  34660. name: string,
  34661. /**Property to animate */
  34662. targetProperty: string,
  34663. /**The frames per second of the animation */
  34664. framePerSecond: number,
  34665. /**The data type of the animation */
  34666. dataType: number,
  34667. /**The loop mode of the animation */
  34668. loopMode?: number | undefined,
  34669. /**Specifies if blending should be enabled */
  34670. enableBlending?: boolean | undefined);
  34671. /**
  34672. * Converts the animation to a string
  34673. * @param fullDetails support for multiple levels of logging within scene loading
  34674. * @returns String form of the animation
  34675. */
  34676. toString(fullDetails?: boolean): string;
  34677. /**
  34678. * Add an event to this animation
  34679. * @param event Event to add
  34680. */
  34681. addEvent(event: AnimationEvent): void;
  34682. /**
  34683. * Remove all events found at the given frame
  34684. * @param frame The frame to remove events from
  34685. */
  34686. removeEvents(frame: number): void;
  34687. /**
  34688. * Retrieves all the events from the animation
  34689. * @returns Events from the animation
  34690. */
  34691. getEvents(): AnimationEvent[];
  34692. /**
  34693. * Creates an animation range
  34694. * @param name Name of the animation range
  34695. * @param from Starting frame of the animation range
  34696. * @param to Ending frame of the animation
  34697. */
  34698. createRange(name: string, from: number, to: number): void;
  34699. /**
  34700. * Deletes an animation range by name
  34701. * @param name Name of the animation range to delete
  34702. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34703. */
  34704. deleteRange(name: string, deleteFrames?: boolean): void;
  34705. /**
  34706. * Gets the animation range by name, or null if not defined
  34707. * @param name Name of the animation range
  34708. * @returns Nullable animation range
  34709. */
  34710. getRange(name: string): Nullable<AnimationRange>;
  34711. /**
  34712. * Gets the key frames from the animation
  34713. * @returns The key frames of the animation
  34714. */
  34715. getKeys(): Array<IAnimationKey>;
  34716. /**
  34717. * Gets the highest frame rate of the animation
  34718. * @returns Highest frame rate of the animation
  34719. */
  34720. getHighestFrame(): number;
  34721. /**
  34722. * Gets the easing function of the animation
  34723. * @returns Easing function of the animation
  34724. */
  34725. getEasingFunction(): IEasingFunction;
  34726. /**
  34727. * Sets the easing function of the animation
  34728. * @param easingFunction A custom mathematical formula for animation
  34729. */
  34730. setEasingFunction(easingFunction: EasingFunction): void;
  34731. /**
  34732. * Interpolates a scalar linearly
  34733. * @param startValue Start value of the animation curve
  34734. * @param endValue End value of the animation curve
  34735. * @param gradient Scalar amount to interpolate
  34736. * @returns Interpolated scalar value
  34737. */
  34738. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34739. /**
  34740. * Interpolates a scalar cubically
  34741. * @param startValue Start value of the animation curve
  34742. * @param outTangent End tangent of the animation
  34743. * @param endValue End value of the animation curve
  34744. * @param inTangent Start tangent of the animation curve
  34745. * @param gradient Scalar amount to interpolate
  34746. * @returns Interpolated scalar value
  34747. */
  34748. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34749. /**
  34750. * Interpolates a quaternion using a spherical linear interpolation
  34751. * @param startValue Start value of the animation curve
  34752. * @param endValue End value of the animation curve
  34753. * @param gradient Scalar amount to interpolate
  34754. * @returns Interpolated quaternion value
  34755. */
  34756. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34757. /**
  34758. * Interpolates a quaternion cubically
  34759. * @param startValue Start value of the animation curve
  34760. * @param outTangent End tangent of the animation curve
  34761. * @param endValue End value of the animation curve
  34762. * @param inTangent Start tangent of the animation curve
  34763. * @param gradient Scalar amount to interpolate
  34764. * @returns Interpolated quaternion value
  34765. */
  34766. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34767. /**
  34768. * Interpolates a Vector3 linearl
  34769. * @param startValue Start value of the animation curve
  34770. * @param endValue End value of the animation curve
  34771. * @param gradient Scalar amount to interpolate
  34772. * @returns Interpolated scalar value
  34773. */
  34774. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34775. /**
  34776. * Interpolates a Vector3 cubically
  34777. * @param startValue Start value of the animation curve
  34778. * @param outTangent End tangent of the animation
  34779. * @param endValue End value of the animation curve
  34780. * @param inTangent Start tangent of the animation curve
  34781. * @param gradient Scalar amount to interpolate
  34782. * @returns InterpolatedVector3 value
  34783. */
  34784. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34785. /**
  34786. * Interpolates a Vector2 linearly
  34787. * @param startValue Start value of the animation curve
  34788. * @param endValue End value of the animation curve
  34789. * @param gradient Scalar amount to interpolate
  34790. * @returns Interpolated Vector2 value
  34791. */
  34792. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34793. /**
  34794. * Interpolates a Vector2 cubically
  34795. * @param startValue Start value of the animation curve
  34796. * @param outTangent End tangent of the animation
  34797. * @param endValue End value of the animation curve
  34798. * @param inTangent Start tangent of the animation curve
  34799. * @param gradient Scalar amount to interpolate
  34800. * @returns Interpolated Vector2 value
  34801. */
  34802. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34803. /**
  34804. * Interpolates a size linearly
  34805. * @param startValue Start value of the animation curve
  34806. * @param endValue End value of the animation curve
  34807. * @param gradient Scalar amount to interpolate
  34808. * @returns Interpolated Size value
  34809. */
  34810. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34811. /**
  34812. * Interpolates a Color3 linearly
  34813. * @param startValue Start value of the animation curve
  34814. * @param endValue End value of the animation curve
  34815. * @param gradient Scalar amount to interpolate
  34816. * @returns Interpolated Color3 value
  34817. */
  34818. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34819. /**
  34820. * Interpolates a Color4 linearly
  34821. * @param startValue Start value of the animation curve
  34822. * @param endValue End value of the animation curve
  34823. * @param gradient Scalar amount to interpolate
  34824. * @returns Interpolated Color3 value
  34825. */
  34826. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34827. /**
  34828. * @hidden Internal use only
  34829. */
  34830. _getKeyValue(value: any): any;
  34831. /**
  34832. * @hidden Internal use only
  34833. */
  34834. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34835. /**
  34836. * Defines the function to use to interpolate matrices
  34837. * @param startValue defines the start matrix
  34838. * @param endValue defines the end matrix
  34839. * @param gradient defines the gradient between both matrices
  34840. * @param result defines an optional target matrix where to store the interpolation
  34841. * @returns the interpolated matrix
  34842. */
  34843. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34844. /**
  34845. * Makes a copy of the animation
  34846. * @returns Cloned animation
  34847. */
  34848. clone(): Animation;
  34849. /**
  34850. * Sets the key frames of the animation
  34851. * @param values The animation key frames to set
  34852. */
  34853. setKeys(values: Array<IAnimationKey>): void;
  34854. /**
  34855. * Serializes the animation to an object
  34856. * @returns Serialized object
  34857. */
  34858. serialize(): any;
  34859. /**
  34860. * Float animation type
  34861. */
  34862. static readonly ANIMATIONTYPE_FLOAT: number;
  34863. /**
  34864. * Vector3 animation type
  34865. */
  34866. static readonly ANIMATIONTYPE_VECTOR3: number;
  34867. /**
  34868. * Quaternion animation type
  34869. */
  34870. static readonly ANIMATIONTYPE_QUATERNION: number;
  34871. /**
  34872. * Matrix animation type
  34873. */
  34874. static readonly ANIMATIONTYPE_MATRIX: number;
  34875. /**
  34876. * Color3 animation type
  34877. */
  34878. static readonly ANIMATIONTYPE_COLOR3: number;
  34879. /**
  34880. * Color3 animation type
  34881. */
  34882. static readonly ANIMATIONTYPE_COLOR4: number;
  34883. /**
  34884. * Vector2 animation type
  34885. */
  34886. static readonly ANIMATIONTYPE_VECTOR2: number;
  34887. /**
  34888. * Size animation type
  34889. */
  34890. static readonly ANIMATIONTYPE_SIZE: number;
  34891. /**
  34892. * Relative Loop Mode
  34893. */
  34894. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34895. /**
  34896. * Cycle Loop Mode
  34897. */
  34898. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34899. /**
  34900. * Constant Loop Mode
  34901. */
  34902. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34903. /** @hidden */
  34904. static _UniversalLerp(left: any, right: any, amount: number): any;
  34905. /**
  34906. * Parses an animation object and creates an animation
  34907. * @param parsedAnimation Parsed animation object
  34908. * @returns Animation object
  34909. */
  34910. static Parse(parsedAnimation: any): Animation;
  34911. /**
  34912. * Appends the serialized animations from the source animations
  34913. * @param source Source containing the animations
  34914. * @param destination Target to store the animations
  34915. */
  34916. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34917. /**
  34918. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34919. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34920. * @param url defines the url to load from
  34921. * @returns a promise that will resolve to the new animation or an array of animations
  34922. */
  34923. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34924. /**
  34925. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34926. * @param snippetId defines the snippet to load
  34927. * @returns a promise that will resolve to the new animation or a new array of animations
  34928. */
  34929. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34930. }
  34931. }
  34932. declare module "babylonjs/Animations/animatable.interface" {
  34933. import { Nullable } from "babylonjs/types";
  34934. import { Animation } from "babylonjs/Animations/animation";
  34935. /**
  34936. * Interface containing an array of animations
  34937. */
  34938. export interface IAnimatable {
  34939. /**
  34940. * Array of animations
  34941. */
  34942. animations: Nullable<Array<Animation>>;
  34943. }
  34944. }
  34945. declare module "babylonjs/Misc/decorators" {
  34946. import { Nullable } from "babylonjs/types";
  34947. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34948. import { Scene } from "babylonjs/scene";
  34949. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34950. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34951. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34953. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34954. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34955. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34956. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34957. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34958. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34959. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34960. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34961. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34962. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34963. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34964. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34965. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34966. /**
  34967. * Decorator used to define property that can be serialized as reference to a camera
  34968. * @param sourceName defines the name of the property to decorate
  34969. */
  34970. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34971. /**
  34972. * Class used to help serialization objects
  34973. */
  34974. export class SerializationHelper {
  34975. /** @hidden */
  34976. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34977. /** @hidden */
  34978. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34979. /** @hidden */
  34980. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34981. /** @hidden */
  34982. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34983. /**
  34984. * Appends the serialized animations from the source animations
  34985. * @param source Source containing the animations
  34986. * @param destination Target to store the animations
  34987. */
  34988. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34989. /**
  34990. * Static function used to serialized a specific entity
  34991. * @param entity defines the entity to serialize
  34992. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34993. * @returns a JSON compatible object representing the serialization of the entity
  34994. */
  34995. static Serialize<T>(entity: T, serializationObject?: any): any;
  34996. /**
  34997. * Creates a new entity from a serialization data object
  34998. * @param creationFunction defines a function used to instanciated the new entity
  34999. * @param source defines the source serialization data
  35000. * @param scene defines the hosting scene
  35001. * @param rootUrl defines the root url for resources
  35002. * @returns a new entity
  35003. */
  35004. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35005. /**
  35006. * Clones an object
  35007. * @param creationFunction defines the function used to instanciate the new object
  35008. * @param source defines the source object
  35009. * @returns the cloned object
  35010. */
  35011. static Clone<T>(creationFunction: () => T, source: T): T;
  35012. /**
  35013. * Instanciates a new object based on a source one (some data will be shared between both object)
  35014. * @param creationFunction defines the function used to instanciate the new object
  35015. * @param source defines the source object
  35016. * @returns the new object
  35017. */
  35018. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35019. }
  35020. }
  35021. declare module "babylonjs/Materials/Textures/baseTexture" {
  35022. import { Observable } from "babylonjs/Misc/observable";
  35023. import { Nullable } from "babylonjs/types";
  35024. import { Scene } from "babylonjs/scene";
  35025. import { Matrix } from "babylonjs/Maths/math.vector";
  35026. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35027. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35028. import { ISize } from "babylonjs/Maths/math.size";
  35029. import "babylonjs/Misc/fileTools";
  35030. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35031. /**
  35032. * Base class of all the textures in babylon.
  35033. * It groups all the common properties the materials, post process, lights... might need
  35034. * in order to make a correct use of the texture.
  35035. */
  35036. export class BaseTexture implements IAnimatable {
  35037. /**
  35038. * Default anisotropic filtering level for the application.
  35039. * It is set to 4 as a good tradeoff between perf and quality.
  35040. */
  35041. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35042. /**
  35043. * Gets or sets the unique id of the texture
  35044. */
  35045. uniqueId: number;
  35046. /**
  35047. * Define the name of the texture.
  35048. */
  35049. name: string;
  35050. /**
  35051. * Gets or sets an object used to store user defined information.
  35052. */
  35053. metadata: any;
  35054. /**
  35055. * For internal use only. Please do not use.
  35056. */
  35057. reservedDataStore: any;
  35058. private _hasAlpha;
  35059. /**
  35060. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35061. */
  35062. set hasAlpha(value: boolean);
  35063. get hasAlpha(): boolean;
  35064. /**
  35065. * Defines if the alpha value should be determined via the rgb values.
  35066. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35067. */
  35068. getAlphaFromRGB: boolean;
  35069. /**
  35070. * Intensity or strength of the texture.
  35071. * It is commonly used by materials to fine tune the intensity of the texture
  35072. */
  35073. level: number;
  35074. /**
  35075. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35076. * This is part of the texture as textures usually maps to one uv set.
  35077. */
  35078. coordinatesIndex: number;
  35079. protected _coordinatesMode: number;
  35080. /**
  35081. * How a texture is mapped.
  35082. *
  35083. * | Value | Type | Description |
  35084. * | ----- | ----------------------------------- | ----------- |
  35085. * | 0 | EXPLICIT_MODE | |
  35086. * | 1 | SPHERICAL_MODE | |
  35087. * | 2 | PLANAR_MODE | |
  35088. * | 3 | CUBIC_MODE | |
  35089. * | 4 | PROJECTION_MODE | |
  35090. * | 5 | SKYBOX_MODE | |
  35091. * | 6 | INVCUBIC_MODE | |
  35092. * | 7 | EQUIRECTANGULAR_MODE | |
  35093. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35094. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35095. */
  35096. set coordinatesMode(value: number);
  35097. get coordinatesMode(): number;
  35098. private _wrapU;
  35099. /**
  35100. * | Value | Type | Description |
  35101. * | ----- | ------------------ | ----------- |
  35102. * | 0 | CLAMP_ADDRESSMODE | |
  35103. * | 1 | WRAP_ADDRESSMODE | |
  35104. * | 2 | MIRROR_ADDRESSMODE | |
  35105. */
  35106. get wrapU(): number;
  35107. set wrapU(value: number);
  35108. private _wrapV;
  35109. /**
  35110. * | Value | Type | Description |
  35111. * | ----- | ------------------ | ----------- |
  35112. * | 0 | CLAMP_ADDRESSMODE | |
  35113. * | 1 | WRAP_ADDRESSMODE | |
  35114. * | 2 | MIRROR_ADDRESSMODE | |
  35115. */
  35116. get wrapV(): number;
  35117. set wrapV(value: number);
  35118. /**
  35119. * | Value | Type | Description |
  35120. * | ----- | ------------------ | ----------- |
  35121. * | 0 | CLAMP_ADDRESSMODE | |
  35122. * | 1 | WRAP_ADDRESSMODE | |
  35123. * | 2 | MIRROR_ADDRESSMODE | |
  35124. */
  35125. wrapR: number;
  35126. /**
  35127. * With compliant hardware and browser (supporting anisotropic filtering)
  35128. * this defines the level of anisotropic filtering in the texture.
  35129. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35130. */
  35131. anisotropicFilteringLevel: number;
  35132. /**
  35133. * Define if the texture is a cube texture or if false a 2d texture.
  35134. */
  35135. get isCube(): boolean;
  35136. set isCube(value: boolean);
  35137. /**
  35138. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35139. */
  35140. get is3D(): boolean;
  35141. set is3D(value: boolean);
  35142. /**
  35143. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35144. */
  35145. get is2DArray(): boolean;
  35146. set is2DArray(value: boolean);
  35147. private _gammaSpace;
  35148. /**
  35149. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35150. * HDR texture are usually stored in linear space.
  35151. * This only impacts the PBR and Background materials
  35152. */
  35153. get gammaSpace(): boolean;
  35154. set gammaSpace(gamma: boolean);
  35155. /**
  35156. * Gets or sets whether or not the texture contains RGBD data.
  35157. */
  35158. get isRGBD(): boolean;
  35159. set isRGBD(value: boolean);
  35160. /**
  35161. * Is Z inverted in the texture (useful in a cube texture).
  35162. */
  35163. invertZ: boolean;
  35164. /**
  35165. * Are mip maps generated for this texture or not.
  35166. */
  35167. get noMipmap(): boolean;
  35168. /**
  35169. * @hidden
  35170. */
  35171. lodLevelInAlpha: boolean;
  35172. /**
  35173. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35174. */
  35175. get lodGenerationOffset(): number;
  35176. set lodGenerationOffset(value: number);
  35177. /**
  35178. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35179. */
  35180. get lodGenerationScale(): number;
  35181. set lodGenerationScale(value: number);
  35182. /**
  35183. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35184. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35185. * average roughness values.
  35186. */
  35187. get linearSpecularLOD(): boolean;
  35188. set linearSpecularLOD(value: boolean);
  35189. /**
  35190. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35191. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35192. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35193. */
  35194. get irradianceTexture(): Nullable<BaseTexture>;
  35195. set irradianceTexture(value: Nullable<BaseTexture>);
  35196. /**
  35197. * Define if the texture is a render target.
  35198. */
  35199. isRenderTarget: boolean;
  35200. /**
  35201. * Define the unique id of the texture in the scene.
  35202. */
  35203. get uid(): string;
  35204. /** @hidden */
  35205. _prefiltered: boolean;
  35206. /**
  35207. * Return a string representation of the texture.
  35208. * @returns the texture as a string
  35209. */
  35210. toString(): string;
  35211. /**
  35212. * Get the class name of the texture.
  35213. * @returns "BaseTexture"
  35214. */
  35215. getClassName(): string;
  35216. /**
  35217. * Define the list of animation attached to the texture.
  35218. */
  35219. animations: import("babylonjs/Animations/animation").Animation[];
  35220. /**
  35221. * An event triggered when the texture is disposed.
  35222. */
  35223. onDisposeObservable: Observable<BaseTexture>;
  35224. private _onDisposeObserver;
  35225. /**
  35226. * Callback triggered when the texture has been disposed.
  35227. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35228. */
  35229. set onDispose(callback: () => void);
  35230. /**
  35231. * Define the current state of the loading sequence when in delayed load mode.
  35232. */
  35233. delayLoadState: number;
  35234. protected _scene: Nullable<Scene>;
  35235. protected _engine: Nullable<ThinEngine>;
  35236. /** @hidden */
  35237. _texture: Nullable<InternalTexture>;
  35238. private _uid;
  35239. /**
  35240. * Define if the texture is preventinga material to render or not.
  35241. * If not and the texture is not ready, the engine will use a default black texture instead.
  35242. */
  35243. get isBlocking(): boolean;
  35244. /**
  35245. * Instantiates a new BaseTexture.
  35246. * Base class of all the textures in babylon.
  35247. * It groups all the common properties the materials, post process, lights... might need
  35248. * in order to make a correct use of the texture.
  35249. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35250. */
  35251. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35252. /**
  35253. * Get the scene the texture belongs to.
  35254. * @returns the scene or null if undefined
  35255. */
  35256. getScene(): Nullable<Scene>;
  35257. /** @hidden */
  35258. protected _getEngine(): Nullable<ThinEngine>;
  35259. /**
  35260. * Get the texture transform matrix used to offset tile the texture for istance.
  35261. * @returns the transformation matrix
  35262. */
  35263. getTextureMatrix(): Matrix;
  35264. /**
  35265. * Get the texture reflection matrix used to rotate/transform the reflection.
  35266. * @returns the reflection matrix
  35267. */
  35268. getReflectionTextureMatrix(): Matrix;
  35269. /**
  35270. * Get the underlying lower level texture from Babylon.
  35271. * @returns the insternal texture
  35272. */
  35273. getInternalTexture(): Nullable<InternalTexture>;
  35274. /**
  35275. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35276. * @returns true if ready or not blocking
  35277. */
  35278. isReadyOrNotBlocking(): boolean;
  35279. /**
  35280. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35281. * @returns true if fully ready
  35282. */
  35283. isReady(): boolean;
  35284. private _cachedSize;
  35285. /**
  35286. * Get the size of the texture.
  35287. * @returns the texture size.
  35288. */
  35289. getSize(): ISize;
  35290. /**
  35291. * Get the base size of the texture.
  35292. * It can be different from the size if the texture has been resized for POT for instance
  35293. * @returns the base size
  35294. */
  35295. getBaseSize(): ISize;
  35296. /**
  35297. * Update the sampling mode of the texture.
  35298. * Default is Trilinear mode.
  35299. *
  35300. * | Value | Type | Description |
  35301. * | ----- | ------------------ | ----------- |
  35302. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35303. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35304. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35305. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35306. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35307. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35308. * | 7 | NEAREST_LINEAR | |
  35309. * | 8 | NEAREST_NEAREST | |
  35310. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35311. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35312. * | 11 | LINEAR_LINEAR | |
  35313. * | 12 | LINEAR_NEAREST | |
  35314. *
  35315. * > _mag_: magnification filter (close to the viewer)
  35316. * > _min_: minification filter (far from the viewer)
  35317. * > _mip_: filter used between mip map levels
  35318. *@param samplingMode Define the new sampling mode of the texture
  35319. */
  35320. updateSamplingMode(samplingMode: number): void;
  35321. /**
  35322. * Scales the texture if is `canRescale()`
  35323. * @param ratio the resize factor we want to use to rescale
  35324. */
  35325. scale(ratio: number): void;
  35326. /**
  35327. * Get if the texture can rescale.
  35328. */
  35329. get canRescale(): boolean;
  35330. /** @hidden */
  35331. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35332. /** @hidden */
  35333. _rebuild(): void;
  35334. /**
  35335. * Triggers the load sequence in delayed load mode.
  35336. */
  35337. delayLoad(): void;
  35338. /**
  35339. * Clones the texture.
  35340. * @returns the cloned texture
  35341. */
  35342. clone(): Nullable<BaseTexture>;
  35343. /**
  35344. * Get the texture underlying type (INT, FLOAT...)
  35345. */
  35346. get textureType(): number;
  35347. /**
  35348. * Get the texture underlying format (RGB, RGBA...)
  35349. */
  35350. get textureFormat(): number;
  35351. /**
  35352. * Indicates that textures need to be re-calculated for all materials
  35353. */
  35354. protected _markAllSubMeshesAsTexturesDirty(): void;
  35355. /**
  35356. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35357. * This will returns an RGBA array buffer containing either in values (0-255) or
  35358. * float values (0-1) depending of the underlying buffer type.
  35359. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35360. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35361. * @param buffer defines a user defined buffer to fill with data (can be null)
  35362. * @returns The Array buffer containing the pixels data.
  35363. */
  35364. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35365. /**
  35366. * Release and destroy the underlying lower level texture aka internalTexture.
  35367. */
  35368. releaseInternalTexture(): void;
  35369. /** @hidden */
  35370. get _lodTextureHigh(): Nullable<BaseTexture>;
  35371. /** @hidden */
  35372. get _lodTextureMid(): Nullable<BaseTexture>;
  35373. /** @hidden */
  35374. get _lodTextureLow(): Nullable<BaseTexture>;
  35375. /**
  35376. * Dispose the texture and release its associated resources.
  35377. */
  35378. dispose(): void;
  35379. /**
  35380. * Serialize the texture into a JSON representation that can be parsed later on.
  35381. * @returns the JSON representation of the texture
  35382. */
  35383. serialize(): any;
  35384. /**
  35385. * Helper function to be called back once a list of texture contains only ready textures.
  35386. * @param textures Define the list of textures to wait for
  35387. * @param callback Define the callback triggered once the entire list will be ready
  35388. */
  35389. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35390. private static _isScene;
  35391. }
  35392. }
  35393. declare module "babylonjs/Materials/effect" {
  35394. import { Observable } from "babylonjs/Misc/observable";
  35395. import { Nullable } from "babylonjs/types";
  35396. import { IDisposable } from "babylonjs/scene";
  35397. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35398. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35399. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35400. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35401. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35402. import { Engine } from "babylonjs/Engines/engine";
  35403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35407. /**
  35408. * Options to be used when creating an effect.
  35409. */
  35410. export interface IEffectCreationOptions {
  35411. /**
  35412. * Atrributes that will be used in the shader.
  35413. */
  35414. attributes: string[];
  35415. /**
  35416. * Uniform varible names that will be set in the shader.
  35417. */
  35418. uniformsNames: string[];
  35419. /**
  35420. * Uniform buffer variable names that will be set in the shader.
  35421. */
  35422. uniformBuffersNames: string[];
  35423. /**
  35424. * Sampler texture variable names that will be set in the shader.
  35425. */
  35426. samplers: string[];
  35427. /**
  35428. * Define statements that will be set in the shader.
  35429. */
  35430. defines: any;
  35431. /**
  35432. * Possible fallbacks for this effect to improve performance when needed.
  35433. */
  35434. fallbacks: Nullable<IEffectFallbacks>;
  35435. /**
  35436. * Callback that will be called when the shader is compiled.
  35437. */
  35438. onCompiled: Nullable<(effect: Effect) => void>;
  35439. /**
  35440. * Callback that will be called if an error occurs during shader compilation.
  35441. */
  35442. onError: Nullable<(effect: Effect, errors: string) => void>;
  35443. /**
  35444. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35445. */
  35446. indexParameters?: any;
  35447. /**
  35448. * Max number of lights that can be used in the shader.
  35449. */
  35450. maxSimultaneousLights?: number;
  35451. /**
  35452. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35453. */
  35454. transformFeedbackVaryings?: Nullable<string[]>;
  35455. /**
  35456. * 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
  35457. */
  35458. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35459. /**
  35460. * Is this effect rendering to several color attachments ?
  35461. */
  35462. multiTarget?: boolean;
  35463. }
  35464. /**
  35465. * Effect containing vertex and fragment shader that can be executed on an object.
  35466. */
  35467. export class Effect implements IDisposable {
  35468. /**
  35469. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35470. */
  35471. static ShadersRepository: string;
  35472. /**
  35473. * Enable logging of the shader code when a compilation error occurs
  35474. */
  35475. static LogShaderCodeOnCompilationError: boolean;
  35476. /**
  35477. * Name of the effect.
  35478. */
  35479. name: any;
  35480. /**
  35481. * String container all the define statements that should be set on the shader.
  35482. */
  35483. defines: string;
  35484. /**
  35485. * Callback that will be called when the shader is compiled.
  35486. */
  35487. onCompiled: Nullable<(effect: Effect) => void>;
  35488. /**
  35489. * Callback that will be called if an error occurs during shader compilation.
  35490. */
  35491. onError: Nullable<(effect: Effect, errors: string) => void>;
  35492. /**
  35493. * Callback that will be called when effect is bound.
  35494. */
  35495. onBind: Nullable<(effect: Effect) => void>;
  35496. /**
  35497. * Unique ID of the effect.
  35498. */
  35499. uniqueId: number;
  35500. /**
  35501. * Observable that will be called when the shader is compiled.
  35502. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35503. */
  35504. onCompileObservable: Observable<Effect>;
  35505. /**
  35506. * Observable that will be called if an error occurs during shader compilation.
  35507. */
  35508. onErrorObservable: Observable<Effect>;
  35509. /** @hidden */
  35510. _onBindObservable: Nullable<Observable<Effect>>;
  35511. /**
  35512. * @hidden
  35513. * Specifies if the effect was previously ready
  35514. */
  35515. _wasPreviouslyReady: boolean;
  35516. /**
  35517. * Observable that will be called when effect is bound.
  35518. */
  35519. get onBindObservable(): Observable<Effect>;
  35520. /** @hidden */
  35521. _bonesComputationForcedToCPU: boolean;
  35522. /** @hidden */
  35523. _multiTarget: boolean;
  35524. private static _uniqueIdSeed;
  35525. private _engine;
  35526. private _uniformBuffersNames;
  35527. private _uniformBuffersNamesList;
  35528. private _uniformsNames;
  35529. private _samplerList;
  35530. private _samplers;
  35531. private _isReady;
  35532. private _compilationError;
  35533. private _allFallbacksProcessed;
  35534. private _attributesNames;
  35535. private _attributes;
  35536. private _attributeLocationByName;
  35537. private _uniforms;
  35538. /**
  35539. * Key for the effect.
  35540. * @hidden
  35541. */
  35542. _key: string;
  35543. private _indexParameters;
  35544. private _fallbacks;
  35545. private _vertexSourceCode;
  35546. private _fragmentSourceCode;
  35547. private _vertexSourceCodeOverride;
  35548. private _fragmentSourceCodeOverride;
  35549. private _transformFeedbackVaryings;
  35550. /**
  35551. * Compiled shader to webGL program.
  35552. * @hidden
  35553. */
  35554. _pipelineContext: Nullable<IPipelineContext>;
  35555. private _valueCache;
  35556. private static _baseCache;
  35557. /**
  35558. * Instantiates an effect.
  35559. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35560. * @param baseName Name of the effect.
  35561. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35562. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35563. * @param samplers List of sampler variables that will be passed to the shader.
  35564. * @param engine Engine to be used to render the effect
  35565. * @param defines Define statements to be added to the shader.
  35566. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35567. * @param onCompiled Callback that will be called when the shader is compiled.
  35568. * @param onError Callback that will be called if an error occurs during shader compilation.
  35569. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35570. */
  35571. 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);
  35572. private _useFinalCode;
  35573. /**
  35574. * Unique key for this effect
  35575. */
  35576. get key(): string;
  35577. /**
  35578. * If the effect has been compiled and prepared.
  35579. * @returns if the effect is compiled and prepared.
  35580. */
  35581. isReady(): boolean;
  35582. private _isReadyInternal;
  35583. /**
  35584. * The engine the effect was initialized with.
  35585. * @returns the engine.
  35586. */
  35587. getEngine(): Engine;
  35588. /**
  35589. * The pipeline context for this effect
  35590. * @returns the associated pipeline context
  35591. */
  35592. getPipelineContext(): Nullable<IPipelineContext>;
  35593. /**
  35594. * The set of names of attribute variables for the shader.
  35595. * @returns An array of attribute names.
  35596. */
  35597. getAttributesNames(): string[];
  35598. /**
  35599. * Returns the attribute at the given index.
  35600. * @param index The index of the attribute.
  35601. * @returns The location of the attribute.
  35602. */
  35603. getAttributeLocation(index: number): number;
  35604. /**
  35605. * Returns the attribute based on the name of the variable.
  35606. * @param name of the attribute to look up.
  35607. * @returns the attribute location.
  35608. */
  35609. getAttributeLocationByName(name: string): number;
  35610. /**
  35611. * The number of attributes.
  35612. * @returns the numnber of attributes.
  35613. */
  35614. getAttributesCount(): number;
  35615. /**
  35616. * Gets the index of a uniform variable.
  35617. * @param uniformName of the uniform to look up.
  35618. * @returns the index.
  35619. */
  35620. getUniformIndex(uniformName: string): number;
  35621. /**
  35622. * Returns the attribute based on the name of the variable.
  35623. * @param uniformName of the uniform to look up.
  35624. * @returns the location of the uniform.
  35625. */
  35626. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35627. /**
  35628. * Returns an array of sampler variable names
  35629. * @returns The array of sampler variable names.
  35630. */
  35631. getSamplers(): string[];
  35632. /**
  35633. * Returns an array of uniform variable names
  35634. * @returns The array of uniform variable names.
  35635. */
  35636. getUniformNames(): string[];
  35637. /**
  35638. * Returns an array of uniform buffer variable names
  35639. * @returns The array of uniform buffer variable names.
  35640. */
  35641. getUniformBuffersNames(): string[];
  35642. /**
  35643. * Returns the index parameters used to create the effect
  35644. * @returns The index parameters object
  35645. */
  35646. getIndexParameters(): any;
  35647. /**
  35648. * The error from the last compilation.
  35649. * @returns the error string.
  35650. */
  35651. getCompilationError(): string;
  35652. /**
  35653. * Gets a boolean indicating that all fallbacks were used during compilation
  35654. * @returns true if all fallbacks were used
  35655. */
  35656. allFallbacksProcessed(): boolean;
  35657. /**
  35658. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35659. * @param func The callback to be used.
  35660. */
  35661. executeWhenCompiled(func: (effect: Effect) => void): void;
  35662. private _checkIsReady;
  35663. private _loadShader;
  35664. /**
  35665. * Gets the vertex shader source code of this effect
  35666. */
  35667. get vertexSourceCode(): string;
  35668. /**
  35669. * Gets the fragment shader source code of this effect
  35670. */
  35671. get fragmentSourceCode(): string;
  35672. /**
  35673. * Recompiles the webGL program
  35674. * @param vertexSourceCode The source code for the vertex shader.
  35675. * @param fragmentSourceCode The source code for the fragment shader.
  35676. * @param onCompiled Callback called when completed.
  35677. * @param onError Callback called on error.
  35678. * @hidden
  35679. */
  35680. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35681. /**
  35682. * Prepares the effect
  35683. * @hidden
  35684. */
  35685. _prepareEffect(): void;
  35686. private _getShaderCodeAndErrorLine;
  35687. private _processCompilationErrors;
  35688. /**
  35689. * Checks if the effect is supported. (Must be called after compilation)
  35690. */
  35691. get isSupported(): boolean;
  35692. /**
  35693. * Binds a texture to the engine to be used as output of the shader.
  35694. * @param channel Name of the output variable.
  35695. * @param texture Texture to bind.
  35696. * @hidden
  35697. */
  35698. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35699. /**
  35700. * Sets a texture on the engine to be used in the shader.
  35701. * @param channel Name of the sampler variable.
  35702. * @param texture Texture to set.
  35703. */
  35704. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35705. /**
  35706. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35707. * @param channel Name of the sampler variable.
  35708. * @param texture Texture to set.
  35709. */
  35710. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35711. /**
  35712. * Sets an array of textures on the engine to be used in the shader.
  35713. * @param channel Name of the variable.
  35714. * @param textures Textures to set.
  35715. */
  35716. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35717. /**
  35718. * 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)
  35719. * @param channel Name of the sampler variable.
  35720. * @param postProcess Post process to get the input texture from.
  35721. */
  35722. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35723. /**
  35724. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35725. * 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)
  35726. * @param channel Name of the sampler variable.
  35727. * @param postProcess Post process to get the output texture from.
  35728. */
  35729. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35730. /** @hidden */
  35731. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35732. /** @hidden */
  35733. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35734. /** @hidden */
  35735. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35736. /** @hidden */
  35737. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35738. /**
  35739. * Binds a buffer to a uniform.
  35740. * @param buffer Buffer to bind.
  35741. * @param name Name of the uniform variable to bind to.
  35742. */
  35743. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35744. /**
  35745. * Binds block to a uniform.
  35746. * @param blockName Name of the block to bind.
  35747. * @param index Index to bind.
  35748. */
  35749. bindUniformBlock(blockName: string, index: number): void;
  35750. /**
  35751. * Sets an interger value on a uniform variable.
  35752. * @param uniformName Name of the variable.
  35753. * @param value Value to be set.
  35754. * @returns this effect.
  35755. */
  35756. setInt(uniformName: string, value: number): Effect;
  35757. /**
  35758. * Sets an int array on a uniform variable.
  35759. * @param uniformName Name of the variable.
  35760. * @param array array to be set.
  35761. * @returns this effect.
  35762. */
  35763. setIntArray(uniformName: string, array: Int32Array): Effect;
  35764. /**
  35765. * 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)
  35766. * @param uniformName Name of the variable.
  35767. * @param array array to be set.
  35768. * @returns this effect.
  35769. */
  35770. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35771. /**
  35772. * 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)
  35773. * @param uniformName Name of the variable.
  35774. * @param array array to be set.
  35775. * @returns this effect.
  35776. */
  35777. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35778. /**
  35779. * 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)
  35780. * @param uniformName Name of the variable.
  35781. * @param array array to be set.
  35782. * @returns this effect.
  35783. */
  35784. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35785. /**
  35786. * Sets an float array on a uniform variable.
  35787. * @param uniformName Name of the variable.
  35788. * @param array array to be set.
  35789. * @returns this effect.
  35790. */
  35791. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35792. /**
  35793. * 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)
  35794. * @param uniformName Name of the variable.
  35795. * @param array array to be set.
  35796. * @returns this effect.
  35797. */
  35798. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35799. /**
  35800. * 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)
  35801. * @param uniformName Name of the variable.
  35802. * @param array array to be set.
  35803. * @returns this effect.
  35804. */
  35805. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35806. /**
  35807. * 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)
  35808. * @param uniformName Name of the variable.
  35809. * @param array array to be set.
  35810. * @returns this effect.
  35811. */
  35812. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35813. /**
  35814. * Sets an array on a uniform variable.
  35815. * @param uniformName Name of the variable.
  35816. * @param array array to be set.
  35817. * @returns this effect.
  35818. */
  35819. setArray(uniformName: string, array: number[]): Effect;
  35820. /**
  35821. * 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)
  35822. * @param uniformName Name of the variable.
  35823. * @param array array to be set.
  35824. * @returns this effect.
  35825. */
  35826. setArray2(uniformName: string, array: number[]): Effect;
  35827. /**
  35828. * 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)
  35829. * @param uniformName Name of the variable.
  35830. * @param array array to be set.
  35831. * @returns this effect.
  35832. */
  35833. setArray3(uniformName: string, array: number[]): Effect;
  35834. /**
  35835. * 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)
  35836. * @param uniformName Name of the variable.
  35837. * @param array array to be set.
  35838. * @returns this effect.
  35839. */
  35840. setArray4(uniformName: string, array: number[]): Effect;
  35841. /**
  35842. * Sets matrices on a uniform variable.
  35843. * @param uniformName Name of the variable.
  35844. * @param matrices matrices to be set.
  35845. * @returns this effect.
  35846. */
  35847. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35848. /**
  35849. * Sets matrix on a uniform variable.
  35850. * @param uniformName Name of the variable.
  35851. * @param matrix matrix to be set.
  35852. * @returns this effect.
  35853. */
  35854. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35855. /**
  35856. * 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)
  35857. * @param uniformName Name of the variable.
  35858. * @param matrix matrix to be set.
  35859. * @returns this effect.
  35860. */
  35861. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35862. /**
  35863. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35864. * @param uniformName Name of the variable.
  35865. * @param matrix matrix to be set.
  35866. * @returns this effect.
  35867. */
  35868. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35869. /**
  35870. * Sets a float on a uniform variable.
  35871. * @param uniformName Name of the variable.
  35872. * @param value value to be set.
  35873. * @returns this effect.
  35874. */
  35875. setFloat(uniformName: string, value: number): Effect;
  35876. /**
  35877. * Sets a boolean on a uniform variable.
  35878. * @param uniformName Name of the variable.
  35879. * @param bool value to be set.
  35880. * @returns this effect.
  35881. */
  35882. setBool(uniformName: string, bool: boolean): Effect;
  35883. /**
  35884. * Sets a Vector2 on a uniform variable.
  35885. * @param uniformName Name of the variable.
  35886. * @param vector2 vector2 to be set.
  35887. * @returns this effect.
  35888. */
  35889. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35890. /**
  35891. * Sets a float2 on a uniform variable.
  35892. * @param uniformName Name of the variable.
  35893. * @param x First float in float2.
  35894. * @param y Second float in float2.
  35895. * @returns this effect.
  35896. */
  35897. setFloat2(uniformName: string, x: number, y: number): Effect;
  35898. /**
  35899. * Sets a Vector3 on a uniform variable.
  35900. * @param uniformName Name of the variable.
  35901. * @param vector3 Value to be set.
  35902. * @returns this effect.
  35903. */
  35904. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35905. /**
  35906. * Sets a float3 on a uniform variable.
  35907. * @param uniformName Name of the variable.
  35908. * @param x First float in float3.
  35909. * @param y Second float in float3.
  35910. * @param z Third float in float3.
  35911. * @returns this effect.
  35912. */
  35913. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35914. /**
  35915. * Sets a Vector4 on a uniform variable.
  35916. * @param uniformName Name of the variable.
  35917. * @param vector4 Value to be set.
  35918. * @returns this effect.
  35919. */
  35920. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35921. /**
  35922. * Sets a float4 on a uniform variable.
  35923. * @param uniformName Name of the variable.
  35924. * @param x First float in float4.
  35925. * @param y Second float in float4.
  35926. * @param z Third float in float4.
  35927. * @param w Fourth float in float4.
  35928. * @returns this effect.
  35929. */
  35930. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35931. /**
  35932. * Sets a Color3 on a uniform variable.
  35933. * @param uniformName Name of the variable.
  35934. * @param color3 Value to be set.
  35935. * @returns this effect.
  35936. */
  35937. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35938. /**
  35939. * Sets a Color4 on a uniform variable.
  35940. * @param uniformName Name of the variable.
  35941. * @param color3 Value to be set.
  35942. * @param alpha Alpha value to be set.
  35943. * @returns this effect.
  35944. */
  35945. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35946. /**
  35947. * Sets a Color4 on a uniform variable
  35948. * @param uniformName defines the name of the variable
  35949. * @param color4 defines the value to be set
  35950. * @returns this effect.
  35951. */
  35952. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35953. /** Release all associated resources */
  35954. dispose(): void;
  35955. /**
  35956. * This function will add a new shader to the shader store
  35957. * @param name the name of the shader
  35958. * @param pixelShader optional pixel shader content
  35959. * @param vertexShader optional vertex shader content
  35960. */
  35961. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35962. /**
  35963. * Store of each shader (The can be looked up using effect.key)
  35964. */
  35965. static ShadersStore: {
  35966. [key: string]: string;
  35967. };
  35968. /**
  35969. * Store of each included file for a shader (The can be looked up using effect.key)
  35970. */
  35971. static IncludesShadersStore: {
  35972. [key: string]: string;
  35973. };
  35974. /**
  35975. * Resets the cache of effects.
  35976. */
  35977. static ResetCache(): void;
  35978. }
  35979. }
  35980. declare module "babylonjs/Engines/engineCapabilities" {
  35981. /**
  35982. * Interface used to describe the capabilities of the engine relatively to the current browser
  35983. */
  35984. export interface EngineCapabilities {
  35985. /** Maximum textures units per fragment shader */
  35986. maxTexturesImageUnits: number;
  35987. /** Maximum texture units per vertex shader */
  35988. maxVertexTextureImageUnits: number;
  35989. /** Maximum textures units in the entire pipeline */
  35990. maxCombinedTexturesImageUnits: number;
  35991. /** Maximum texture size */
  35992. maxTextureSize: number;
  35993. /** Maximum texture samples */
  35994. maxSamples?: number;
  35995. /** Maximum cube texture size */
  35996. maxCubemapTextureSize: number;
  35997. /** Maximum render texture size */
  35998. maxRenderTextureSize: number;
  35999. /** Maximum number of vertex attributes */
  36000. maxVertexAttribs: number;
  36001. /** Maximum number of varyings */
  36002. maxVaryingVectors: number;
  36003. /** Maximum number of uniforms per vertex shader */
  36004. maxVertexUniformVectors: number;
  36005. /** Maximum number of uniforms per fragment shader */
  36006. maxFragmentUniformVectors: number;
  36007. /** Defines if standard derivates (dx/dy) are supported */
  36008. standardDerivatives: boolean;
  36009. /** Defines if s3tc texture compression is supported */
  36010. s3tc?: WEBGL_compressed_texture_s3tc;
  36011. /** Defines if pvrtc texture compression is supported */
  36012. pvrtc: any;
  36013. /** Defines if etc1 texture compression is supported */
  36014. etc1: any;
  36015. /** Defines if etc2 texture compression is supported */
  36016. etc2: any;
  36017. /** Defines if astc texture compression is supported */
  36018. astc: any;
  36019. /** Defines if bptc texture compression is supported */
  36020. bptc: any;
  36021. /** Defines if float textures are supported */
  36022. textureFloat: boolean;
  36023. /** Defines if vertex array objects are supported */
  36024. vertexArrayObject: boolean;
  36025. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36026. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36027. /** Gets the maximum level of anisotropy supported */
  36028. maxAnisotropy: number;
  36029. /** Defines if instancing is supported */
  36030. instancedArrays: boolean;
  36031. /** Defines if 32 bits indices are supported */
  36032. uintIndices: boolean;
  36033. /** Defines if high precision shaders are supported */
  36034. highPrecisionShaderSupported: boolean;
  36035. /** Defines if depth reading in the fragment shader is supported */
  36036. fragmentDepthSupported: boolean;
  36037. /** Defines if float texture linear filtering is supported*/
  36038. textureFloatLinearFiltering: boolean;
  36039. /** Defines if rendering to float textures is supported */
  36040. textureFloatRender: boolean;
  36041. /** Defines if half float textures are supported*/
  36042. textureHalfFloat: boolean;
  36043. /** Defines if half float texture linear filtering is supported*/
  36044. textureHalfFloatLinearFiltering: boolean;
  36045. /** Defines if rendering to half float textures is supported */
  36046. textureHalfFloatRender: boolean;
  36047. /** Defines if textureLOD shader command is supported */
  36048. textureLOD: boolean;
  36049. /** Defines if draw buffers extension is supported */
  36050. drawBuffersExtension: boolean;
  36051. /** Defines if depth textures are supported */
  36052. depthTextureExtension: boolean;
  36053. /** Defines if float color buffer are supported */
  36054. colorBufferFloat: boolean;
  36055. /** Gets disjoint timer query extension (null if not supported) */
  36056. timerQuery?: EXT_disjoint_timer_query;
  36057. /** Defines if timestamp can be used with timer query */
  36058. canUseTimestampForTimerQuery: boolean;
  36059. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36060. multiview?: any;
  36061. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36062. oculusMultiview?: any;
  36063. /** Function used to let the system compiles shaders in background */
  36064. parallelShaderCompile?: {
  36065. COMPLETION_STATUS_KHR: number;
  36066. };
  36067. /** Max number of texture samples for MSAA */
  36068. maxMSAASamples: number;
  36069. /** Defines if the blend min max extension is supported */
  36070. blendMinMax: boolean;
  36071. }
  36072. }
  36073. declare module "babylonjs/States/depthCullingState" {
  36074. import { Nullable } from "babylonjs/types";
  36075. /**
  36076. * @hidden
  36077. **/
  36078. export class DepthCullingState {
  36079. private _isDepthTestDirty;
  36080. private _isDepthMaskDirty;
  36081. private _isDepthFuncDirty;
  36082. private _isCullFaceDirty;
  36083. private _isCullDirty;
  36084. private _isZOffsetDirty;
  36085. private _isFrontFaceDirty;
  36086. private _depthTest;
  36087. private _depthMask;
  36088. private _depthFunc;
  36089. private _cull;
  36090. private _cullFace;
  36091. private _zOffset;
  36092. private _frontFace;
  36093. /**
  36094. * Initializes the state.
  36095. */
  36096. constructor();
  36097. get isDirty(): boolean;
  36098. get zOffset(): number;
  36099. set zOffset(value: number);
  36100. get cullFace(): Nullable<number>;
  36101. set cullFace(value: Nullable<number>);
  36102. get cull(): Nullable<boolean>;
  36103. set cull(value: Nullable<boolean>);
  36104. get depthFunc(): Nullable<number>;
  36105. set depthFunc(value: Nullable<number>);
  36106. get depthMask(): boolean;
  36107. set depthMask(value: boolean);
  36108. get depthTest(): boolean;
  36109. set depthTest(value: boolean);
  36110. get frontFace(): Nullable<number>;
  36111. set frontFace(value: Nullable<number>);
  36112. reset(): void;
  36113. apply(gl: WebGLRenderingContext): void;
  36114. }
  36115. }
  36116. declare module "babylonjs/States/stencilState" {
  36117. /**
  36118. * @hidden
  36119. **/
  36120. export class StencilState {
  36121. /** 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 */
  36122. static readonly ALWAYS: number;
  36123. /** Passed to stencilOperation to specify that stencil value must be kept */
  36124. static readonly KEEP: number;
  36125. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36126. static readonly REPLACE: number;
  36127. private _isStencilTestDirty;
  36128. private _isStencilMaskDirty;
  36129. private _isStencilFuncDirty;
  36130. private _isStencilOpDirty;
  36131. private _stencilTest;
  36132. private _stencilMask;
  36133. private _stencilFunc;
  36134. private _stencilFuncRef;
  36135. private _stencilFuncMask;
  36136. private _stencilOpStencilFail;
  36137. private _stencilOpDepthFail;
  36138. private _stencilOpStencilDepthPass;
  36139. get isDirty(): boolean;
  36140. get stencilFunc(): number;
  36141. set stencilFunc(value: number);
  36142. get stencilFuncRef(): number;
  36143. set stencilFuncRef(value: number);
  36144. get stencilFuncMask(): number;
  36145. set stencilFuncMask(value: number);
  36146. get stencilOpStencilFail(): number;
  36147. set stencilOpStencilFail(value: number);
  36148. get stencilOpDepthFail(): number;
  36149. set stencilOpDepthFail(value: number);
  36150. get stencilOpStencilDepthPass(): number;
  36151. set stencilOpStencilDepthPass(value: number);
  36152. get stencilMask(): number;
  36153. set stencilMask(value: number);
  36154. get stencilTest(): boolean;
  36155. set stencilTest(value: boolean);
  36156. constructor();
  36157. reset(): void;
  36158. apply(gl: WebGLRenderingContext): void;
  36159. }
  36160. }
  36161. declare module "babylonjs/States/alphaCullingState" {
  36162. /**
  36163. * @hidden
  36164. **/
  36165. export class AlphaState {
  36166. private _isAlphaBlendDirty;
  36167. private _isBlendFunctionParametersDirty;
  36168. private _isBlendEquationParametersDirty;
  36169. private _isBlendConstantsDirty;
  36170. private _alphaBlend;
  36171. private _blendFunctionParameters;
  36172. private _blendEquationParameters;
  36173. private _blendConstants;
  36174. /**
  36175. * Initializes the state.
  36176. */
  36177. constructor();
  36178. get isDirty(): boolean;
  36179. get alphaBlend(): boolean;
  36180. set alphaBlend(value: boolean);
  36181. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36182. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36183. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36184. reset(): void;
  36185. apply(gl: WebGLRenderingContext): void;
  36186. }
  36187. }
  36188. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36189. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36190. /** @hidden */
  36191. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36192. attributeProcessor(attribute: string): string;
  36193. varyingProcessor(varying: string, isFragment: boolean): string;
  36194. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36195. }
  36196. }
  36197. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36198. /**
  36199. * Interface for attribute information associated with buffer instanciation
  36200. */
  36201. export interface InstancingAttributeInfo {
  36202. /**
  36203. * Name of the GLSL attribute
  36204. * if attribute index is not specified, this is used to retrieve the index from the effect
  36205. */
  36206. attributeName: string;
  36207. /**
  36208. * Index/offset of the attribute in the vertex shader
  36209. * if not specified, this will be computes from the name.
  36210. */
  36211. index?: number;
  36212. /**
  36213. * size of the attribute, 1, 2, 3 or 4
  36214. */
  36215. attributeSize: number;
  36216. /**
  36217. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36218. */
  36219. offset: number;
  36220. /**
  36221. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36222. * default to 1
  36223. */
  36224. divisor?: number;
  36225. /**
  36226. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36227. * default is FLOAT
  36228. */
  36229. attributeType?: number;
  36230. /**
  36231. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36232. */
  36233. normalized?: boolean;
  36234. }
  36235. }
  36236. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36238. import { Nullable } from "babylonjs/types";
  36239. module "babylonjs/Engines/thinEngine" {
  36240. interface ThinEngine {
  36241. /**
  36242. * Update a video texture
  36243. * @param texture defines the texture to update
  36244. * @param video defines the video element to use
  36245. * @param invertY defines if data must be stored with Y axis inverted
  36246. */
  36247. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36248. }
  36249. }
  36250. }
  36251. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36253. import { Nullable } from "babylonjs/types";
  36254. module "babylonjs/Engines/thinEngine" {
  36255. interface ThinEngine {
  36256. /**
  36257. * Creates a dynamic texture
  36258. * @param width defines the width of the texture
  36259. * @param height defines the height of the texture
  36260. * @param generateMipMaps defines if the engine should generate the mip levels
  36261. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36262. * @returns the dynamic texture inside an InternalTexture
  36263. */
  36264. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36265. /**
  36266. * Update the content of a dynamic texture
  36267. * @param texture defines the texture to update
  36268. * @param canvas defines the canvas containing the source
  36269. * @param invertY defines if data must be stored with Y axis inverted
  36270. * @param premulAlpha defines if alpha is stored as premultiplied
  36271. * @param format defines the format of the data
  36272. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36273. */
  36274. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36275. }
  36276. }
  36277. }
  36278. declare module "babylonjs/Materials/Textures/videoTexture" {
  36279. import { Observable } from "babylonjs/Misc/observable";
  36280. import { Nullable } from "babylonjs/types";
  36281. import { Scene } from "babylonjs/scene";
  36282. import { Texture } from "babylonjs/Materials/Textures/texture";
  36283. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36284. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36285. /**
  36286. * Settings for finer control over video usage
  36287. */
  36288. export interface VideoTextureSettings {
  36289. /**
  36290. * Applies `autoplay` to video, if specified
  36291. */
  36292. autoPlay?: boolean;
  36293. /**
  36294. * Applies `loop` to video, if specified
  36295. */
  36296. loop?: boolean;
  36297. /**
  36298. * Automatically updates internal texture from video at every frame in the render loop
  36299. */
  36300. autoUpdateTexture: boolean;
  36301. /**
  36302. * Image src displayed during the video loading or until the user interacts with the video.
  36303. */
  36304. poster?: string;
  36305. }
  36306. /**
  36307. * If you want to display a video in your scene, this is the special texture for that.
  36308. * This special texture works similar to other textures, with the exception of a few parameters.
  36309. * @see https://doc.babylonjs.com/how_to/video_texture
  36310. */
  36311. export class VideoTexture extends Texture {
  36312. /**
  36313. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36314. */
  36315. readonly autoUpdateTexture: boolean;
  36316. /**
  36317. * The video instance used by the texture internally
  36318. */
  36319. readonly video: HTMLVideoElement;
  36320. private _onUserActionRequestedObservable;
  36321. /**
  36322. * Event triggerd when a dom action is required by the user to play the video.
  36323. * This happens due to recent changes in browser policies preventing video to auto start.
  36324. */
  36325. get onUserActionRequestedObservable(): Observable<Texture>;
  36326. private _generateMipMaps;
  36327. private _stillImageCaptured;
  36328. private _displayingPosterTexture;
  36329. private _settings;
  36330. private _createInternalTextureOnEvent;
  36331. private _frameId;
  36332. private _currentSrc;
  36333. /**
  36334. * Creates a video texture.
  36335. * If you want to display a video in your scene, this is the special texture for that.
  36336. * This special texture works similar to other textures, with the exception of a few parameters.
  36337. * @see https://doc.babylonjs.com/how_to/video_texture
  36338. * @param name optional name, will detect from video source, if not defined
  36339. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36340. * @param scene is obviously the current scene.
  36341. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36342. * @param invertY is false by default but can be used to invert video on Y axis
  36343. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36344. * @param settings allows finer control over video usage
  36345. */
  36346. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36347. private _getName;
  36348. private _getVideo;
  36349. private _createInternalTexture;
  36350. private reset;
  36351. /**
  36352. * @hidden Internal method to initiate `update`.
  36353. */
  36354. _rebuild(): void;
  36355. /**
  36356. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36357. */
  36358. update(): void;
  36359. /**
  36360. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36361. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36362. */
  36363. updateTexture(isVisible: boolean): void;
  36364. protected _updateInternalTexture: () => void;
  36365. /**
  36366. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36367. * @param url New url.
  36368. */
  36369. updateURL(url: string): void;
  36370. /**
  36371. * Clones the texture.
  36372. * @returns the cloned texture
  36373. */
  36374. clone(): VideoTexture;
  36375. /**
  36376. * Dispose the texture and release its associated resources.
  36377. */
  36378. dispose(): void;
  36379. /**
  36380. * Creates a video texture straight from a stream.
  36381. * @param scene Define the scene the texture should be created in
  36382. * @param stream Define the stream the texture should be created from
  36383. * @returns The created video texture as a promise
  36384. */
  36385. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36386. /**
  36387. * Creates a video texture straight from your WebCam video feed.
  36388. * @param scene Define the scene the texture should be created in
  36389. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36390. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36391. * @returns The created video texture as a promise
  36392. */
  36393. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36394. minWidth: number;
  36395. maxWidth: number;
  36396. minHeight: number;
  36397. maxHeight: number;
  36398. deviceId: string;
  36399. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36400. /**
  36401. * Creates a video texture straight from your WebCam video feed.
  36402. * @param scene Define the scene the texture should be created in
  36403. * @param onReady Define a callback to triggered once the texture will be ready
  36404. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36405. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36406. */
  36407. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36408. minWidth: number;
  36409. maxWidth: number;
  36410. minHeight: number;
  36411. maxHeight: number;
  36412. deviceId: string;
  36413. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36414. }
  36415. }
  36416. declare module "babylonjs/Engines/thinEngine" {
  36417. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36418. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36419. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36420. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36421. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36422. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36423. import { Observable } from "babylonjs/Misc/observable";
  36424. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36425. import { StencilState } from "babylonjs/States/stencilState";
  36426. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36427. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36428. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36429. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36430. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36431. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36432. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36433. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36434. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36435. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36436. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36437. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36438. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36439. import { WebRequest } from "babylonjs/Misc/webRequest";
  36440. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36441. /**
  36442. * Defines the interface used by objects working like Scene
  36443. * @hidden
  36444. */
  36445. export interface ISceneLike {
  36446. _addPendingData(data: any): void;
  36447. _removePendingData(data: any): void;
  36448. offlineProvider: IOfflineProvider;
  36449. }
  36450. /**
  36451. * Information about the current host
  36452. */
  36453. export interface HostInformation {
  36454. /**
  36455. * Defines if the current host is a mobile
  36456. */
  36457. isMobile: boolean;
  36458. }
  36459. /** Interface defining initialization parameters for Engine class */
  36460. export interface EngineOptions extends WebGLContextAttributes {
  36461. /**
  36462. * Defines if the engine should no exceed a specified device ratio
  36463. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36464. */
  36465. limitDeviceRatio?: number;
  36466. /**
  36467. * Defines if webvr should be enabled automatically
  36468. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36469. */
  36470. autoEnableWebVR?: boolean;
  36471. /**
  36472. * Defines if webgl2 should be turned off even if supported
  36473. * @see https://doc.babylonjs.com/features/webgl2
  36474. */
  36475. disableWebGL2Support?: boolean;
  36476. /**
  36477. * Defines if webaudio should be initialized as well
  36478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36479. */
  36480. audioEngine?: boolean;
  36481. /**
  36482. * Defines if animations should run using a deterministic lock step
  36483. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36484. */
  36485. deterministicLockstep?: boolean;
  36486. /** Defines the maximum steps to use with deterministic lock step mode */
  36487. lockstepMaxSteps?: number;
  36488. /** Defines the seconds between each deterministic lock step */
  36489. timeStep?: number;
  36490. /**
  36491. * Defines that engine should ignore context lost events
  36492. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36493. */
  36494. doNotHandleContextLost?: boolean;
  36495. /**
  36496. * Defines that engine should ignore modifying touch action attribute and style
  36497. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36498. */
  36499. doNotHandleTouchAction?: boolean;
  36500. /**
  36501. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36502. */
  36503. useHighPrecisionFloats?: boolean;
  36504. /**
  36505. * Make the canvas XR Compatible for XR sessions
  36506. */
  36507. xrCompatible?: boolean;
  36508. /**
  36509. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36510. */
  36511. useHighPrecisionMatrix?: boolean;
  36512. }
  36513. /**
  36514. * The base engine class (root of all engines)
  36515. */
  36516. export class ThinEngine {
  36517. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36518. static ExceptionList: ({
  36519. key: string;
  36520. capture: string;
  36521. captureConstraint: number;
  36522. targets: string[];
  36523. } | {
  36524. key: string;
  36525. capture: null;
  36526. captureConstraint: null;
  36527. targets: string[];
  36528. })[];
  36529. /** @hidden */
  36530. static _TextureLoaders: IInternalTextureLoader[];
  36531. /**
  36532. * Returns the current npm package of the sdk
  36533. */
  36534. static get NpmPackage(): string;
  36535. /**
  36536. * Returns the current version of the framework
  36537. */
  36538. static get Version(): string;
  36539. /**
  36540. * Returns a string describing the current engine
  36541. */
  36542. get description(): string;
  36543. /**
  36544. * Gets or sets the epsilon value used by collision engine
  36545. */
  36546. static CollisionsEpsilon: number;
  36547. /**
  36548. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36549. */
  36550. static get ShadersRepository(): string;
  36551. static set ShadersRepository(value: string);
  36552. /** @hidden */
  36553. _shaderProcessor: IShaderProcessor;
  36554. /**
  36555. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36556. */
  36557. forcePOTTextures: boolean;
  36558. /**
  36559. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36560. */
  36561. isFullscreen: boolean;
  36562. /**
  36563. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36564. */
  36565. cullBackFaces: boolean;
  36566. /**
  36567. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36568. */
  36569. renderEvenInBackground: boolean;
  36570. /**
  36571. * Gets or sets a boolean indicating that cache can be kept between frames
  36572. */
  36573. preventCacheWipeBetweenFrames: boolean;
  36574. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36575. validateShaderPrograms: boolean;
  36576. /**
  36577. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36578. * This can provide greater z depth for distant objects.
  36579. */
  36580. useReverseDepthBuffer: boolean;
  36581. /**
  36582. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36583. */
  36584. disableUniformBuffers: boolean;
  36585. /** @hidden */
  36586. _uniformBuffers: UniformBuffer[];
  36587. /**
  36588. * Gets a boolean indicating that the engine supports uniform buffers
  36589. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36590. */
  36591. get supportsUniformBuffers(): boolean;
  36592. /** @hidden */
  36593. _gl: WebGLRenderingContext;
  36594. /** @hidden */
  36595. _webGLVersion: number;
  36596. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36597. protected _windowIsBackground: boolean;
  36598. protected _creationOptions: EngineOptions;
  36599. protected _highPrecisionShadersAllowed: boolean;
  36600. /** @hidden */
  36601. get _shouldUseHighPrecisionShader(): boolean;
  36602. /**
  36603. * Gets a boolean indicating that only power of 2 textures are supported
  36604. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36605. */
  36606. get needPOTTextures(): boolean;
  36607. /** @hidden */
  36608. _badOS: boolean;
  36609. /** @hidden */
  36610. _badDesktopOS: boolean;
  36611. private _hardwareScalingLevel;
  36612. /** @hidden */
  36613. _caps: EngineCapabilities;
  36614. private _isStencilEnable;
  36615. private _glVersion;
  36616. private _glRenderer;
  36617. private _glVendor;
  36618. /** @hidden */
  36619. _videoTextureSupported: boolean;
  36620. protected _renderingQueueLaunched: boolean;
  36621. protected _activeRenderLoops: (() => void)[];
  36622. /**
  36623. * Observable signaled when a context lost event is raised
  36624. */
  36625. onContextLostObservable: Observable<ThinEngine>;
  36626. /**
  36627. * Observable signaled when a context restored event is raised
  36628. */
  36629. onContextRestoredObservable: Observable<ThinEngine>;
  36630. private _onContextLost;
  36631. private _onContextRestored;
  36632. protected _contextWasLost: boolean;
  36633. /** @hidden */
  36634. _doNotHandleContextLost: boolean;
  36635. /**
  36636. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36637. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36638. */
  36639. get doNotHandleContextLost(): boolean;
  36640. set doNotHandleContextLost(value: boolean);
  36641. /**
  36642. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36643. */
  36644. disableVertexArrayObjects: boolean;
  36645. /** @hidden */
  36646. protected _colorWrite: boolean;
  36647. /** @hidden */
  36648. protected _colorWriteChanged: boolean;
  36649. /** @hidden */
  36650. protected _depthCullingState: DepthCullingState;
  36651. /** @hidden */
  36652. protected _stencilState: StencilState;
  36653. /** @hidden */
  36654. _alphaState: AlphaState;
  36655. /** @hidden */
  36656. _alphaMode: number;
  36657. /** @hidden */
  36658. _alphaEquation: number;
  36659. /** @hidden */
  36660. _internalTexturesCache: InternalTexture[];
  36661. /** @hidden */
  36662. protected _activeChannel: number;
  36663. private _currentTextureChannel;
  36664. /** @hidden */
  36665. protected _boundTexturesCache: {
  36666. [key: string]: Nullable<InternalTexture>;
  36667. };
  36668. /** @hidden */
  36669. protected _currentEffect: Nullable<Effect>;
  36670. /** @hidden */
  36671. protected _currentProgram: Nullable<WebGLProgram>;
  36672. private _compiledEffects;
  36673. private _vertexAttribArraysEnabled;
  36674. /** @hidden */
  36675. protected _cachedViewport: Nullable<IViewportLike>;
  36676. private _cachedVertexArrayObject;
  36677. /** @hidden */
  36678. protected _cachedVertexBuffers: any;
  36679. /** @hidden */
  36680. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36681. /** @hidden */
  36682. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36683. /** @hidden */
  36684. _currentRenderTarget: Nullable<InternalTexture>;
  36685. private _uintIndicesCurrentlySet;
  36686. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36687. /** @hidden */
  36688. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36689. /** @hidden */
  36690. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36691. private _currentBufferPointers;
  36692. private _currentInstanceLocations;
  36693. private _currentInstanceBuffers;
  36694. private _textureUnits;
  36695. /** @hidden */
  36696. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36697. /** @hidden */
  36698. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36699. /** @hidden */
  36700. _boundRenderFunction: any;
  36701. private _vaoRecordInProgress;
  36702. private _mustWipeVertexAttributes;
  36703. private _emptyTexture;
  36704. private _emptyCubeTexture;
  36705. private _emptyTexture3D;
  36706. private _emptyTexture2DArray;
  36707. /** @hidden */
  36708. _frameHandler: number;
  36709. private _nextFreeTextureSlots;
  36710. private _maxSimultaneousTextures;
  36711. private _activeRequests;
  36712. /** @hidden */
  36713. _transformTextureUrl: Nullable<(url: string) => string>;
  36714. /**
  36715. * Gets information about the current host
  36716. */
  36717. hostInformation: HostInformation;
  36718. protected get _supportsHardwareTextureRescaling(): boolean;
  36719. private _framebufferDimensionsObject;
  36720. /**
  36721. * sets the object from which width and height will be taken from when getting render width and height
  36722. * Will fallback to the gl object
  36723. * @param dimensions the framebuffer width and height that will be used.
  36724. */
  36725. set framebufferDimensionsObject(dimensions: Nullable<{
  36726. framebufferWidth: number;
  36727. framebufferHeight: number;
  36728. }>);
  36729. /**
  36730. * Gets the current viewport
  36731. */
  36732. get currentViewport(): Nullable<IViewportLike>;
  36733. /**
  36734. * Gets the default empty texture
  36735. */
  36736. get emptyTexture(): InternalTexture;
  36737. /**
  36738. * Gets the default empty 3D texture
  36739. */
  36740. get emptyTexture3D(): InternalTexture;
  36741. /**
  36742. * Gets the default empty 2D array texture
  36743. */
  36744. get emptyTexture2DArray(): InternalTexture;
  36745. /**
  36746. * Gets the default empty cube texture
  36747. */
  36748. get emptyCubeTexture(): InternalTexture;
  36749. /**
  36750. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36751. */
  36752. readonly premultipliedAlpha: boolean;
  36753. /**
  36754. * Observable event triggered before each texture is initialized
  36755. */
  36756. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36757. /**
  36758. * Creates a new engine
  36759. * @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
  36760. * @param antialias defines enable antialiasing (default: false)
  36761. * @param options defines further options to be sent to the getContext() function
  36762. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36763. */
  36764. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36765. private _rebuildInternalTextures;
  36766. private _rebuildEffects;
  36767. /**
  36768. * Gets a boolean indicating if all created effects are ready
  36769. * @returns true if all effects are ready
  36770. */
  36771. areAllEffectsReady(): boolean;
  36772. protected _rebuildBuffers(): void;
  36773. protected _initGLContext(): void;
  36774. /**
  36775. * Gets version of the current webGL context
  36776. */
  36777. get webGLVersion(): number;
  36778. /**
  36779. * Gets a string identifying the name of the class
  36780. * @returns "Engine" string
  36781. */
  36782. getClassName(): string;
  36783. /**
  36784. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36785. */
  36786. get isStencilEnable(): boolean;
  36787. /** @hidden */
  36788. _prepareWorkingCanvas(): void;
  36789. /**
  36790. * Reset the texture cache to empty state
  36791. */
  36792. resetTextureCache(): void;
  36793. /**
  36794. * Gets an object containing information about the current webGL context
  36795. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36796. */
  36797. getGlInfo(): {
  36798. vendor: string;
  36799. renderer: string;
  36800. version: string;
  36801. };
  36802. /**
  36803. * Defines the hardware scaling level.
  36804. * By default the hardware scaling level is computed from the window device ratio.
  36805. * 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.
  36806. * @param level defines the level to use
  36807. */
  36808. setHardwareScalingLevel(level: number): void;
  36809. /**
  36810. * Gets the current hardware scaling level.
  36811. * By default the hardware scaling level is computed from the window device ratio.
  36812. * 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.
  36813. * @returns a number indicating the current hardware scaling level
  36814. */
  36815. getHardwareScalingLevel(): number;
  36816. /**
  36817. * Gets the list of loaded textures
  36818. * @returns an array containing all loaded textures
  36819. */
  36820. getLoadedTexturesCache(): InternalTexture[];
  36821. /**
  36822. * Gets the object containing all engine capabilities
  36823. * @returns the EngineCapabilities object
  36824. */
  36825. getCaps(): EngineCapabilities;
  36826. /**
  36827. * stop executing a render loop function and remove it from the execution array
  36828. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36829. */
  36830. stopRenderLoop(renderFunction?: () => void): void;
  36831. /** @hidden */
  36832. _renderLoop(): void;
  36833. /**
  36834. * Gets the HTML canvas attached with the current webGL context
  36835. * @returns a HTML canvas
  36836. */
  36837. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36838. /**
  36839. * Gets host window
  36840. * @returns the host window object
  36841. */
  36842. getHostWindow(): Nullable<Window>;
  36843. /**
  36844. * Gets the current render width
  36845. * @param useScreen defines if screen size must be used (or the current render target if any)
  36846. * @returns a number defining the current render width
  36847. */
  36848. getRenderWidth(useScreen?: boolean): number;
  36849. /**
  36850. * Gets the current render height
  36851. * @param useScreen defines if screen size must be used (or the current render target if any)
  36852. * @returns a number defining the current render height
  36853. */
  36854. getRenderHeight(useScreen?: boolean): number;
  36855. /**
  36856. * Can be used to override the current requestAnimationFrame requester.
  36857. * @hidden
  36858. */
  36859. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36860. /**
  36861. * Register and execute a render loop. The engine can have more than one render function
  36862. * @param renderFunction defines the function to continuously execute
  36863. */
  36864. runRenderLoop(renderFunction: () => void): void;
  36865. /**
  36866. * Clear the current render buffer or the current render target (if any is set up)
  36867. * @param color defines the color to use
  36868. * @param backBuffer defines if the back buffer must be cleared
  36869. * @param depth defines if the depth buffer must be cleared
  36870. * @param stencil defines if the stencil buffer must be cleared
  36871. */
  36872. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36873. private _viewportCached;
  36874. /** @hidden */
  36875. _viewport(x: number, y: number, width: number, height: number): void;
  36876. /**
  36877. * Set the WebGL's viewport
  36878. * @param viewport defines the viewport element to be used
  36879. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36880. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36881. */
  36882. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36883. /**
  36884. * Begin a new frame
  36885. */
  36886. beginFrame(): void;
  36887. /**
  36888. * Enf the current frame
  36889. */
  36890. endFrame(): void;
  36891. /**
  36892. * Resize the view according to the canvas' size
  36893. */
  36894. resize(): void;
  36895. /**
  36896. * Force a specific size of the canvas
  36897. * @param width defines the new canvas' width
  36898. * @param height defines the new canvas' height
  36899. * @returns true if the size was changed
  36900. */
  36901. setSize(width: number, height: number): boolean;
  36902. /**
  36903. * Binds the frame buffer to the specified texture.
  36904. * @param texture The texture to render to or null for the default canvas
  36905. * @param faceIndex The face of the texture to render to in case of cube texture
  36906. * @param requiredWidth The width of the target to render to
  36907. * @param requiredHeight The height of the target to render to
  36908. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36909. * @param lodLevel defines the lod level to bind to the frame buffer
  36910. * @param layer defines the 2d array index to bind to frame buffer to
  36911. */
  36912. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36913. /** @hidden */
  36914. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36915. /**
  36916. * Unbind the current render target texture from the webGL context
  36917. * @param texture defines the render target texture to unbind
  36918. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36919. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36920. */
  36921. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36922. /**
  36923. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36924. */
  36925. flushFramebuffer(): void;
  36926. /**
  36927. * Unbind the current render target and bind the default framebuffer
  36928. */
  36929. restoreDefaultFramebuffer(): void;
  36930. /** @hidden */
  36931. protected _resetVertexBufferBinding(): void;
  36932. /**
  36933. * Creates a vertex buffer
  36934. * @param data the data for the vertex buffer
  36935. * @returns the new WebGL static buffer
  36936. */
  36937. createVertexBuffer(data: DataArray): DataBuffer;
  36938. private _createVertexBuffer;
  36939. /**
  36940. * Creates a dynamic vertex buffer
  36941. * @param data the data for the dynamic vertex buffer
  36942. * @returns the new WebGL dynamic buffer
  36943. */
  36944. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36945. protected _resetIndexBufferBinding(): void;
  36946. /**
  36947. * Creates a new index buffer
  36948. * @param indices defines the content of the index buffer
  36949. * @param updatable defines if the index buffer must be updatable
  36950. * @returns a new webGL buffer
  36951. */
  36952. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36953. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36954. /**
  36955. * Bind a webGL buffer to the webGL context
  36956. * @param buffer defines the buffer to bind
  36957. */
  36958. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36959. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36960. private bindBuffer;
  36961. /**
  36962. * update the bound buffer with the given data
  36963. * @param data defines the data to update
  36964. */
  36965. updateArrayBuffer(data: Float32Array): void;
  36966. private _vertexAttribPointer;
  36967. /** @hidden */
  36968. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36969. private _bindVertexBuffersAttributes;
  36970. /**
  36971. * Records a vertex array object
  36972. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36973. * @param vertexBuffers defines the list of vertex buffers to store
  36974. * @param indexBuffer defines the index buffer to store
  36975. * @param effect defines the effect to store
  36976. * @returns the new vertex array object
  36977. */
  36978. recordVertexArrayObject(vertexBuffers: {
  36979. [key: string]: VertexBuffer;
  36980. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36981. /**
  36982. * Bind a specific vertex array object
  36983. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36984. * @param vertexArrayObject defines the vertex array object to bind
  36985. * @param indexBuffer defines the index buffer to bind
  36986. */
  36987. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36988. /**
  36989. * Bind webGl buffers directly to the webGL context
  36990. * @param vertexBuffer defines the vertex buffer to bind
  36991. * @param indexBuffer defines the index buffer to bind
  36992. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36993. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36994. * @param effect defines the effect associated with the vertex buffer
  36995. */
  36996. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36997. private _unbindVertexArrayObject;
  36998. /**
  36999. * Bind a list of vertex buffers to the webGL context
  37000. * @param vertexBuffers defines the list of vertex buffers to bind
  37001. * @param indexBuffer defines the index buffer to bind
  37002. * @param effect defines the effect associated with the vertex buffers
  37003. */
  37004. bindBuffers(vertexBuffers: {
  37005. [key: string]: Nullable<VertexBuffer>;
  37006. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37007. /**
  37008. * Unbind all instance attributes
  37009. */
  37010. unbindInstanceAttributes(): void;
  37011. /**
  37012. * Release and free the memory of a vertex array object
  37013. * @param vao defines the vertex array object to delete
  37014. */
  37015. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37016. /** @hidden */
  37017. _releaseBuffer(buffer: DataBuffer): boolean;
  37018. protected _deleteBuffer(buffer: DataBuffer): void;
  37019. /**
  37020. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37021. * @param instancesBuffer defines the webGL buffer to update and bind
  37022. * @param data defines the data to store in the buffer
  37023. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37024. */
  37025. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37026. /**
  37027. * Bind the content of a webGL buffer used with instantiation
  37028. * @param instancesBuffer defines the webGL buffer to bind
  37029. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37030. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37031. */
  37032. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37033. /**
  37034. * Disable the instance attribute corresponding to the name in parameter
  37035. * @param name defines the name of the attribute to disable
  37036. */
  37037. disableInstanceAttributeByName(name: string): void;
  37038. /**
  37039. * Disable the instance attribute corresponding to the location in parameter
  37040. * @param attributeLocation defines the attribute location of the attribute to disable
  37041. */
  37042. disableInstanceAttribute(attributeLocation: number): void;
  37043. /**
  37044. * Disable the attribute corresponding to the location in parameter
  37045. * @param attributeLocation defines the attribute location of the attribute to disable
  37046. */
  37047. disableAttributeByIndex(attributeLocation: number): void;
  37048. /**
  37049. * Send a draw order
  37050. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37051. * @param indexStart defines the starting index
  37052. * @param indexCount defines the number of index to draw
  37053. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37054. */
  37055. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37056. /**
  37057. * Draw a list of points
  37058. * @param verticesStart defines the index of first vertex to draw
  37059. * @param verticesCount defines the count of vertices to draw
  37060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37061. */
  37062. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37063. /**
  37064. * Draw a list of unindexed primitives
  37065. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37066. * @param verticesStart defines the index of first vertex to draw
  37067. * @param verticesCount defines the count of vertices to draw
  37068. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37069. */
  37070. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37071. /**
  37072. * Draw a list of indexed primitives
  37073. * @param fillMode defines the primitive to use
  37074. * @param indexStart defines the starting index
  37075. * @param indexCount defines the number of index to draw
  37076. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37077. */
  37078. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37079. /**
  37080. * Draw a list of unindexed primitives
  37081. * @param fillMode defines the primitive to use
  37082. * @param verticesStart defines the index of first vertex to draw
  37083. * @param verticesCount defines the count of vertices to draw
  37084. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37085. */
  37086. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37087. private _drawMode;
  37088. /** @hidden */
  37089. protected _reportDrawCall(): void;
  37090. /** @hidden */
  37091. _releaseEffect(effect: Effect): void;
  37092. /** @hidden */
  37093. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37094. /**
  37095. * Create a new effect (used to store vertex/fragment shaders)
  37096. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37097. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37098. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37099. * @param samplers defines an array of string used to represent textures
  37100. * @param defines defines the string containing the defines to use to compile the shaders
  37101. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37102. * @param onCompiled defines a function to call when the effect creation is successful
  37103. * @param onError defines a function to call when the effect creation has failed
  37104. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37105. * @returns the new Effect
  37106. */
  37107. 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;
  37108. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37109. private _compileShader;
  37110. private _compileRawShader;
  37111. /** @hidden */
  37112. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37113. /**
  37114. * Directly creates a webGL program
  37115. * @param pipelineContext defines the pipeline context to attach to
  37116. * @param vertexCode defines the vertex shader code to use
  37117. * @param fragmentCode defines the fragment shader code to use
  37118. * @param context defines the webGL context to use (if not set, the current one will be used)
  37119. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37120. * @returns the new webGL program
  37121. */
  37122. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37123. /**
  37124. * Creates a webGL program
  37125. * @param pipelineContext defines the pipeline context to attach to
  37126. * @param vertexCode defines the vertex shader code to use
  37127. * @param fragmentCode defines the fragment shader code to use
  37128. * @param defines defines the string containing the defines to use to compile the shaders
  37129. * @param context defines the webGL context to use (if not set, the current one will be used)
  37130. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37131. * @returns the new webGL program
  37132. */
  37133. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37134. /**
  37135. * Creates a new pipeline context
  37136. * @returns the new pipeline
  37137. */
  37138. createPipelineContext(): IPipelineContext;
  37139. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37140. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37141. /** @hidden */
  37142. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37143. /** @hidden */
  37144. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37145. /** @hidden */
  37146. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37147. /**
  37148. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37149. * @param pipelineContext defines the pipeline context to use
  37150. * @param uniformsNames defines the list of uniform names
  37151. * @returns an array of webGL uniform locations
  37152. */
  37153. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37154. /**
  37155. * Gets the lsit of active attributes for a given webGL program
  37156. * @param pipelineContext defines the pipeline context to use
  37157. * @param attributesNames defines the list of attribute names to get
  37158. * @returns an array of indices indicating the offset of each attribute
  37159. */
  37160. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37161. /**
  37162. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37163. * @param effect defines the effect to activate
  37164. */
  37165. enableEffect(effect: Nullable<Effect>): void;
  37166. /**
  37167. * Set the value of an uniform to a number (int)
  37168. * @param uniform defines the webGL uniform location where to store the value
  37169. * @param value defines the int number to store
  37170. */
  37171. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37172. /**
  37173. * Set the value of an uniform to an array of int32
  37174. * @param uniform defines the webGL uniform location where to store the value
  37175. * @param array defines the array of int32 to store
  37176. */
  37177. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37178. /**
  37179. * Set the value of an uniform to an array of int32 (stored as vec2)
  37180. * @param uniform defines the webGL uniform location where to store the value
  37181. * @param array defines the array of int32 to store
  37182. */
  37183. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37184. /**
  37185. * Set the value of an uniform to an array of int32 (stored as vec3)
  37186. * @param uniform defines the webGL uniform location where to store the value
  37187. * @param array defines the array of int32 to store
  37188. */
  37189. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37190. /**
  37191. * Set the value of an uniform to an array of int32 (stored as vec4)
  37192. * @param uniform defines the webGL uniform location where to store the value
  37193. * @param array defines the array of int32 to store
  37194. */
  37195. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37196. /**
  37197. * Set the value of an uniform to an array of number
  37198. * @param uniform defines the webGL uniform location where to store the value
  37199. * @param array defines the array of number to store
  37200. */
  37201. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37202. /**
  37203. * Set the value of an uniform to an array of number (stored as vec2)
  37204. * @param uniform defines the webGL uniform location where to store the value
  37205. * @param array defines the array of number to store
  37206. */
  37207. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37208. /**
  37209. * Set the value of an uniform to an array of number (stored as vec3)
  37210. * @param uniform defines the webGL uniform location where to store the value
  37211. * @param array defines the array of number to store
  37212. */
  37213. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37214. /**
  37215. * Set the value of an uniform to an array of number (stored as vec4)
  37216. * @param uniform defines the webGL uniform location where to store the value
  37217. * @param array defines the array of number to store
  37218. */
  37219. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37220. /**
  37221. * Set the value of an uniform to an array of float32 (stored as matrices)
  37222. * @param uniform defines the webGL uniform location where to store the value
  37223. * @param matrices defines the array of float32 to store
  37224. */
  37225. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37226. /**
  37227. * Set the value of an uniform to a matrix (3x3)
  37228. * @param uniform defines the webGL uniform location where to store the value
  37229. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37230. */
  37231. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37232. /**
  37233. * Set the value of an uniform to a matrix (2x2)
  37234. * @param uniform defines the webGL uniform location where to store the value
  37235. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37236. */
  37237. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37238. /**
  37239. * Set the value of an uniform to a number (float)
  37240. * @param uniform defines the webGL uniform location where to store the value
  37241. * @param value defines the float number to store
  37242. */
  37243. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37244. /**
  37245. * Set the value of an uniform to a vec2
  37246. * @param uniform defines the webGL uniform location where to store the value
  37247. * @param x defines the 1st component of the value
  37248. * @param y defines the 2nd component of the value
  37249. */
  37250. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37251. /**
  37252. * Set the value of an uniform to a vec3
  37253. * @param uniform defines the webGL uniform location where to store the value
  37254. * @param x defines the 1st component of the value
  37255. * @param y defines the 2nd component of the value
  37256. * @param z defines the 3rd component of the value
  37257. */
  37258. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37259. /**
  37260. * Set the value of an uniform to a vec4
  37261. * @param uniform defines the webGL uniform location where to store the value
  37262. * @param x defines the 1st component of the value
  37263. * @param y defines the 2nd component of the value
  37264. * @param z defines the 3rd component of the value
  37265. * @param w defines the 4th component of the value
  37266. */
  37267. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37268. /**
  37269. * Apply all cached states (depth, culling, stencil and alpha)
  37270. */
  37271. applyStates(): void;
  37272. /**
  37273. * Enable or disable color writing
  37274. * @param enable defines the state to set
  37275. */
  37276. setColorWrite(enable: boolean): void;
  37277. /**
  37278. * Gets a boolean indicating if color writing is enabled
  37279. * @returns the current color writing state
  37280. */
  37281. getColorWrite(): boolean;
  37282. /**
  37283. * Gets the depth culling state manager
  37284. */
  37285. get depthCullingState(): DepthCullingState;
  37286. /**
  37287. * Gets the alpha state manager
  37288. */
  37289. get alphaState(): AlphaState;
  37290. /**
  37291. * Gets the stencil state manager
  37292. */
  37293. get stencilState(): StencilState;
  37294. /**
  37295. * Clears the list of texture accessible through engine.
  37296. * This can help preventing texture load conflict due to name collision.
  37297. */
  37298. clearInternalTexturesCache(): void;
  37299. /**
  37300. * Force the entire cache to be cleared
  37301. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37302. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37303. */
  37304. wipeCaches(bruteForce?: boolean): void;
  37305. /** @hidden */
  37306. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37307. min: number;
  37308. mag: number;
  37309. };
  37310. /** @hidden */
  37311. _createTexture(): WebGLTexture;
  37312. /**
  37313. * Usually called from Texture.ts.
  37314. * Passed information to create a WebGLTexture
  37315. * @param url defines a value which contains one of the following:
  37316. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37317. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37318. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37319. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37320. * @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)
  37321. * @param scene needed for loading to the correct scene
  37322. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37323. * @param onLoad optional callback to be called upon successful completion
  37324. * @param onError optional callback to be called upon failure
  37325. * @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
  37326. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37327. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37328. * @param forcedExtension defines the extension to use to pick the right loader
  37329. * @param mimeType defines an optional mime type
  37330. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37331. */
  37332. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  37333. /**
  37334. * Loads an image as an HTMLImageElement.
  37335. * @param input url string, ArrayBuffer, or Blob to load
  37336. * @param onLoad callback called when the image successfully loads
  37337. * @param onError callback called when the image fails to load
  37338. * @param offlineProvider offline provider for caching
  37339. * @param mimeType optional mime type
  37340. * @returns the HTMLImageElement of the loaded image
  37341. * @hidden
  37342. */
  37343. 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>;
  37344. /**
  37345. * @hidden
  37346. */
  37347. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37348. private _unpackFlipYCached;
  37349. /**
  37350. * In case you are sharing the context with other applications, it might
  37351. * be interested to not cache the unpack flip y state to ensure a consistent
  37352. * value would be set.
  37353. */
  37354. enableUnpackFlipYCached: boolean;
  37355. /** @hidden */
  37356. _unpackFlipY(value: boolean): void;
  37357. /** @hidden */
  37358. _getUnpackAlignement(): number;
  37359. private _getTextureTarget;
  37360. /**
  37361. * Update the sampling mode of a given texture
  37362. * @param samplingMode defines the required sampling mode
  37363. * @param texture defines the texture to update
  37364. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37365. */
  37366. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37367. /**
  37368. * Update the sampling mode of a given texture
  37369. * @param texture defines the texture to update
  37370. * @param wrapU defines the texture wrap mode of the u coordinates
  37371. * @param wrapV defines the texture wrap mode of the v coordinates
  37372. * @param wrapR defines the texture wrap mode of the r coordinates
  37373. */
  37374. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37375. /** @hidden */
  37376. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37377. width: number;
  37378. height: number;
  37379. layers?: number;
  37380. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37381. /** @hidden */
  37382. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37383. /** @hidden */
  37384. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37385. /**
  37386. * Update a portion of an internal texture
  37387. * @param texture defines the texture to update
  37388. * @param imageData defines the data to store into the texture
  37389. * @param xOffset defines the x coordinates of the update rectangle
  37390. * @param yOffset defines the y coordinates of the update rectangle
  37391. * @param width defines the width of the update rectangle
  37392. * @param height defines the height of the update rectangle
  37393. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37394. * @param lod defines the lod level to update (0 by default)
  37395. */
  37396. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37397. /** @hidden */
  37398. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37399. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37400. private _prepareWebGLTexture;
  37401. /** @hidden */
  37402. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37403. private _getDepthStencilBuffer;
  37404. /** @hidden */
  37405. _releaseFramebufferObjects(texture: InternalTexture): void;
  37406. /** @hidden */
  37407. _releaseTexture(texture: InternalTexture): void;
  37408. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37409. protected _setProgram(program: WebGLProgram): void;
  37410. protected _boundUniforms: {
  37411. [key: number]: WebGLUniformLocation;
  37412. };
  37413. /**
  37414. * Binds an effect to the webGL context
  37415. * @param effect defines the effect to bind
  37416. */
  37417. bindSamplers(effect: Effect): void;
  37418. private _activateCurrentTexture;
  37419. /** @hidden */
  37420. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37421. /** @hidden */
  37422. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37423. /**
  37424. * Unbind all textures from the webGL context
  37425. */
  37426. unbindAllTextures(): void;
  37427. /**
  37428. * Sets a texture to the according uniform.
  37429. * @param channel The texture channel
  37430. * @param uniform The uniform to set
  37431. * @param texture The texture to apply
  37432. */
  37433. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37434. private _bindSamplerUniformToChannel;
  37435. private _getTextureWrapMode;
  37436. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37437. /**
  37438. * Sets an array of texture to the webGL context
  37439. * @param channel defines the channel where the texture array must be set
  37440. * @param uniform defines the associated uniform location
  37441. * @param textures defines the array of textures to bind
  37442. */
  37443. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37444. /** @hidden */
  37445. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37446. private _setTextureParameterFloat;
  37447. private _setTextureParameterInteger;
  37448. /**
  37449. * Unbind all vertex attributes from the webGL context
  37450. */
  37451. unbindAllAttributes(): void;
  37452. /**
  37453. * 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
  37454. */
  37455. releaseEffects(): void;
  37456. /**
  37457. * Dispose and release all associated resources
  37458. */
  37459. dispose(): void;
  37460. /**
  37461. * Attach a new callback raised when context lost event is fired
  37462. * @param callback defines the callback to call
  37463. */
  37464. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37465. /**
  37466. * Attach a new callback raised when context restored event is fired
  37467. * @param callback defines the callback to call
  37468. */
  37469. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37470. /**
  37471. * Get the current error code of the webGL context
  37472. * @returns the error code
  37473. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37474. */
  37475. getError(): number;
  37476. private _canRenderToFloatFramebuffer;
  37477. private _canRenderToHalfFloatFramebuffer;
  37478. private _canRenderToFramebuffer;
  37479. /** @hidden */
  37480. _getWebGLTextureType(type: number): number;
  37481. /** @hidden */
  37482. _getInternalFormat(format: number): number;
  37483. /** @hidden */
  37484. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37485. /** @hidden */
  37486. _getRGBAMultiSampleBufferFormat(type: number): number;
  37487. /** @hidden */
  37488. _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;
  37489. /**
  37490. * Loads a file from a url
  37491. * @param url url to load
  37492. * @param onSuccess callback called when the file successfully loads
  37493. * @param onProgress callback called while file is loading (if the server supports this mode)
  37494. * @param offlineProvider defines the offline provider for caching
  37495. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37496. * @param onError callback called when the file fails to load
  37497. * @returns a file request object
  37498. * @hidden
  37499. */
  37500. 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;
  37501. /**
  37502. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37503. * @param x defines the x coordinate of the rectangle where pixels must be read
  37504. * @param y defines the y coordinate of the rectangle where pixels must be read
  37505. * @param width defines the width of the rectangle where pixels must be read
  37506. * @param height defines the height of the rectangle where pixels must be read
  37507. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37508. * @returns a Uint8Array containing RGBA colors
  37509. */
  37510. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37511. private static _isSupported;
  37512. /**
  37513. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37514. * @returns true if the engine can be created
  37515. * @ignorenaming
  37516. */
  37517. static isSupported(): boolean;
  37518. /**
  37519. * Find the next highest power of two.
  37520. * @param x Number to start search from.
  37521. * @return Next highest power of two.
  37522. */
  37523. static CeilingPOT(x: number): number;
  37524. /**
  37525. * Find the next lowest power of two.
  37526. * @param x Number to start search from.
  37527. * @return Next lowest power of two.
  37528. */
  37529. static FloorPOT(x: number): number;
  37530. /**
  37531. * Find the nearest power of two.
  37532. * @param x Number to start search from.
  37533. * @return Next nearest power of two.
  37534. */
  37535. static NearestPOT(x: number): number;
  37536. /**
  37537. * Get the closest exponent of two
  37538. * @param value defines the value to approximate
  37539. * @param max defines the maximum value to return
  37540. * @param mode defines how to define the closest value
  37541. * @returns closest exponent of two of the given value
  37542. */
  37543. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37544. /**
  37545. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37546. * @param func - the function to be called
  37547. * @param requester - the object that will request the next frame. Falls back to window.
  37548. * @returns frame number
  37549. */
  37550. static QueueNewFrame(func: () => void, requester?: any): number;
  37551. /**
  37552. * Gets host document
  37553. * @returns the host document object
  37554. */
  37555. getHostDocument(): Nullable<Document>;
  37556. }
  37557. }
  37558. declare module "babylonjs/Maths/sphericalPolynomial" {
  37559. import { Vector3 } from "babylonjs/Maths/math.vector";
  37560. import { Color3 } from "babylonjs/Maths/math.color";
  37561. /**
  37562. * Class representing spherical harmonics coefficients to the 3rd degree
  37563. */
  37564. export class SphericalHarmonics {
  37565. /**
  37566. * Defines whether or not the harmonics have been prescaled for rendering.
  37567. */
  37568. preScaled: boolean;
  37569. /**
  37570. * The l0,0 coefficients of the spherical harmonics
  37571. */
  37572. l00: Vector3;
  37573. /**
  37574. * The l1,-1 coefficients of the spherical harmonics
  37575. */
  37576. l1_1: Vector3;
  37577. /**
  37578. * The l1,0 coefficients of the spherical harmonics
  37579. */
  37580. l10: Vector3;
  37581. /**
  37582. * The l1,1 coefficients of the spherical harmonics
  37583. */
  37584. l11: Vector3;
  37585. /**
  37586. * The l2,-2 coefficients of the spherical harmonics
  37587. */
  37588. l2_2: Vector3;
  37589. /**
  37590. * The l2,-1 coefficients of the spherical harmonics
  37591. */
  37592. l2_1: Vector3;
  37593. /**
  37594. * The l2,0 coefficients of the spherical harmonics
  37595. */
  37596. l20: Vector3;
  37597. /**
  37598. * The l2,1 coefficients of the spherical harmonics
  37599. */
  37600. l21: Vector3;
  37601. /**
  37602. * The l2,2 coefficients of the spherical harmonics
  37603. */
  37604. l22: Vector3;
  37605. /**
  37606. * Adds a light to the spherical harmonics
  37607. * @param direction the direction of the light
  37608. * @param color the color of the light
  37609. * @param deltaSolidAngle the delta solid angle of the light
  37610. */
  37611. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37612. /**
  37613. * Scales the spherical harmonics by the given amount
  37614. * @param scale the amount to scale
  37615. */
  37616. scaleInPlace(scale: number): void;
  37617. /**
  37618. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37619. *
  37620. * ```
  37621. * E_lm = A_l * L_lm
  37622. * ```
  37623. *
  37624. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37625. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37626. * the scaling factors are given in equation 9.
  37627. */
  37628. convertIncidentRadianceToIrradiance(): void;
  37629. /**
  37630. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37631. *
  37632. * ```
  37633. * L = (1/pi) * E * rho
  37634. * ```
  37635. *
  37636. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37637. */
  37638. convertIrradianceToLambertianRadiance(): void;
  37639. /**
  37640. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37641. * required operations at run time.
  37642. *
  37643. * This is simply done by scaling back the SH with Ylm constants parameter.
  37644. * The trigonometric part being applied by the shader at run time.
  37645. */
  37646. preScaleForRendering(): void;
  37647. /**
  37648. * Constructs a spherical harmonics from an array.
  37649. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37650. * @returns the spherical harmonics
  37651. */
  37652. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37653. /**
  37654. * Gets the spherical harmonics from polynomial
  37655. * @param polynomial the spherical polynomial
  37656. * @returns the spherical harmonics
  37657. */
  37658. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37659. }
  37660. /**
  37661. * Class representing spherical polynomial coefficients to the 3rd degree
  37662. */
  37663. export class SphericalPolynomial {
  37664. private _harmonics;
  37665. /**
  37666. * The spherical harmonics used to create the polynomials.
  37667. */
  37668. get preScaledHarmonics(): SphericalHarmonics;
  37669. /**
  37670. * The x coefficients of the spherical polynomial
  37671. */
  37672. x: Vector3;
  37673. /**
  37674. * The y coefficients of the spherical polynomial
  37675. */
  37676. y: Vector3;
  37677. /**
  37678. * The z coefficients of the spherical polynomial
  37679. */
  37680. z: Vector3;
  37681. /**
  37682. * The xx coefficients of the spherical polynomial
  37683. */
  37684. xx: Vector3;
  37685. /**
  37686. * The yy coefficients of the spherical polynomial
  37687. */
  37688. yy: Vector3;
  37689. /**
  37690. * The zz coefficients of the spherical polynomial
  37691. */
  37692. zz: Vector3;
  37693. /**
  37694. * The xy coefficients of the spherical polynomial
  37695. */
  37696. xy: Vector3;
  37697. /**
  37698. * The yz coefficients of the spherical polynomial
  37699. */
  37700. yz: Vector3;
  37701. /**
  37702. * The zx coefficients of the spherical polynomial
  37703. */
  37704. zx: Vector3;
  37705. /**
  37706. * Adds an ambient color to the spherical polynomial
  37707. * @param color the color to add
  37708. */
  37709. addAmbient(color: Color3): void;
  37710. /**
  37711. * Scales the spherical polynomial by the given amount
  37712. * @param scale the amount to scale
  37713. */
  37714. scaleInPlace(scale: number): void;
  37715. /**
  37716. * Gets the spherical polynomial from harmonics
  37717. * @param harmonics the spherical harmonics
  37718. * @returns the spherical polynomial
  37719. */
  37720. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37721. /**
  37722. * Constructs a spherical polynomial from an array.
  37723. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37724. * @returns the spherical polynomial
  37725. */
  37726. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37727. }
  37728. }
  37729. declare module "babylonjs/Materials/Textures/internalTexture" {
  37730. import { Observable } from "babylonjs/Misc/observable";
  37731. import { Nullable, int } from "babylonjs/types";
  37732. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37734. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37735. /**
  37736. * Defines the source of the internal texture
  37737. */
  37738. export enum InternalTextureSource {
  37739. /**
  37740. * The source of the texture data is unknown
  37741. */
  37742. Unknown = 0,
  37743. /**
  37744. * Texture data comes from an URL
  37745. */
  37746. Url = 1,
  37747. /**
  37748. * Texture data is only used for temporary storage
  37749. */
  37750. Temp = 2,
  37751. /**
  37752. * Texture data comes from raw data (ArrayBuffer)
  37753. */
  37754. Raw = 3,
  37755. /**
  37756. * Texture content is dynamic (video or dynamic texture)
  37757. */
  37758. Dynamic = 4,
  37759. /**
  37760. * Texture content is generated by rendering to it
  37761. */
  37762. RenderTarget = 5,
  37763. /**
  37764. * Texture content is part of a multi render target process
  37765. */
  37766. MultiRenderTarget = 6,
  37767. /**
  37768. * Texture data comes from a cube data file
  37769. */
  37770. Cube = 7,
  37771. /**
  37772. * Texture data comes from a raw cube data
  37773. */
  37774. CubeRaw = 8,
  37775. /**
  37776. * Texture data come from a prefiltered cube data file
  37777. */
  37778. CubePrefiltered = 9,
  37779. /**
  37780. * Texture content is raw 3D data
  37781. */
  37782. Raw3D = 10,
  37783. /**
  37784. * Texture content is raw 2D array data
  37785. */
  37786. Raw2DArray = 11,
  37787. /**
  37788. * Texture content is a depth texture
  37789. */
  37790. Depth = 12,
  37791. /**
  37792. * Texture data comes from a raw cube data encoded with RGBD
  37793. */
  37794. CubeRawRGBD = 13
  37795. }
  37796. /**
  37797. * Class used to store data associated with WebGL texture data for the engine
  37798. * This class should not be used directly
  37799. */
  37800. export class InternalTexture {
  37801. /** @hidden */
  37802. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37803. /**
  37804. * Defines if the texture is ready
  37805. */
  37806. isReady: boolean;
  37807. /**
  37808. * Defines if the texture is a cube texture
  37809. */
  37810. isCube: boolean;
  37811. /**
  37812. * Defines if the texture contains 3D data
  37813. */
  37814. is3D: boolean;
  37815. /**
  37816. * Defines if the texture contains 2D array data
  37817. */
  37818. is2DArray: boolean;
  37819. /**
  37820. * Defines if the texture contains multiview data
  37821. */
  37822. isMultiview: boolean;
  37823. /**
  37824. * Gets the URL used to load this texture
  37825. */
  37826. url: string;
  37827. /**
  37828. * Gets the sampling mode of the texture
  37829. */
  37830. samplingMode: number;
  37831. /**
  37832. * Gets a boolean indicating if the texture needs mipmaps generation
  37833. */
  37834. generateMipMaps: boolean;
  37835. /**
  37836. * Gets the number of samples used by the texture (WebGL2+ only)
  37837. */
  37838. samples: number;
  37839. /**
  37840. * Gets the type of the texture (int, float...)
  37841. */
  37842. type: number;
  37843. /**
  37844. * Gets the format of the texture (RGB, RGBA...)
  37845. */
  37846. format: number;
  37847. /**
  37848. * Observable called when the texture is loaded
  37849. */
  37850. onLoadedObservable: Observable<InternalTexture>;
  37851. /**
  37852. * Gets the width of the texture
  37853. */
  37854. width: number;
  37855. /**
  37856. * Gets the height of the texture
  37857. */
  37858. height: number;
  37859. /**
  37860. * Gets the depth of the texture
  37861. */
  37862. depth: number;
  37863. /**
  37864. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37865. */
  37866. baseWidth: number;
  37867. /**
  37868. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37869. */
  37870. baseHeight: number;
  37871. /**
  37872. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37873. */
  37874. baseDepth: number;
  37875. /**
  37876. * Gets a boolean indicating if the texture is inverted on Y axis
  37877. */
  37878. invertY: boolean;
  37879. /** @hidden */
  37880. _invertVScale: boolean;
  37881. /** @hidden */
  37882. _associatedChannel: number;
  37883. /** @hidden */
  37884. _source: InternalTextureSource;
  37885. /** @hidden */
  37886. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37887. /** @hidden */
  37888. _bufferView: Nullable<ArrayBufferView>;
  37889. /** @hidden */
  37890. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37891. /** @hidden */
  37892. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37893. /** @hidden */
  37894. _size: number;
  37895. /** @hidden */
  37896. _extension: string;
  37897. /** @hidden */
  37898. _files: Nullable<string[]>;
  37899. /** @hidden */
  37900. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37901. /** @hidden */
  37902. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37903. /** @hidden */
  37904. _framebuffer: Nullable<WebGLFramebuffer>;
  37905. /** @hidden */
  37906. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37907. /** @hidden */
  37908. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37909. /** @hidden */
  37910. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37911. /** @hidden */
  37912. _attachments: Nullable<number[]>;
  37913. /** @hidden */
  37914. _textureArray: Nullable<InternalTexture[]>;
  37915. /** @hidden */
  37916. _cachedCoordinatesMode: Nullable<number>;
  37917. /** @hidden */
  37918. _cachedWrapU: Nullable<number>;
  37919. /** @hidden */
  37920. _cachedWrapV: Nullable<number>;
  37921. /** @hidden */
  37922. _cachedWrapR: Nullable<number>;
  37923. /** @hidden */
  37924. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37925. /** @hidden */
  37926. _isDisabled: boolean;
  37927. /** @hidden */
  37928. _compression: Nullable<string>;
  37929. /** @hidden */
  37930. _generateStencilBuffer: boolean;
  37931. /** @hidden */
  37932. _generateDepthBuffer: boolean;
  37933. /** @hidden */
  37934. _comparisonFunction: number;
  37935. /** @hidden */
  37936. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37937. /** @hidden */
  37938. _lodGenerationScale: number;
  37939. /** @hidden */
  37940. _lodGenerationOffset: number;
  37941. /** @hidden */
  37942. _depthStencilTexture: Nullable<InternalTexture>;
  37943. /** @hidden */
  37944. _colorTextureArray: Nullable<WebGLTexture>;
  37945. /** @hidden */
  37946. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37947. /** @hidden */
  37948. _lodTextureHigh: Nullable<BaseTexture>;
  37949. /** @hidden */
  37950. _lodTextureMid: Nullable<BaseTexture>;
  37951. /** @hidden */
  37952. _lodTextureLow: Nullable<BaseTexture>;
  37953. /** @hidden */
  37954. _isRGBD: boolean;
  37955. /** @hidden */
  37956. _linearSpecularLOD: boolean;
  37957. /** @hidden */
  37958. _irradianceTexture: Nullable<BaseTexture>;
  37959. /** @hidden */
  37960. _webGLTexture: Nullable<WebGLTexture>;
  37961. /** @hidden */
  37962. _references: number;
  37963. /** @hidden */
  37964. _gammaSpace: Nullable<boolean>;
  37965. private _engine;
  37966. /**
  37967. * Gets the Engine the texture belongs to.
  37968. * @returns The babylon engine
  37969. */
  37970. getEngine(): ThinEngine;
  37971. /**
  37972. * Gets the data source type of the texture
  37973. */
  37974. get source(): InternalTextureSource;
  37975. /**
  37976. * Creates a new InternalTexture
  37977. * @param engine defines the engine to use
  37978. * @param source defines the type of data that will be used
  37979. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37980. */
  37981. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37982. /**
  37983. * Increments the number of references (ie. the number of Texture that point to it)
  37984. */
  37985. incrementReferences(): void;
  37986. /**
  37987. * Change the size of the texture (not the size of the content)
  37988. * @param width defines the new width
  37989. * @param height defines the new height
  37990. * @param depth defines the new depth (1 by default)
  37991. */
  37992. updateSize(width: int, height: int, depth?: int): void;
  37993. /** @hidden */
  37994. _rebuild(): void;
  37995. /** @hidden */
  37996. _swapAndDie(target: InternalTexture): void;
  37997. /**
  37998. * Dispose the current allocated resources
  37999. */
  38000. dispose(): void;
  38001. }
  38002. }
  38003. declare module "babylonjs/Audio/analyser" {
  38004. import { Scene } from "babylonjs/scene";
  38005. /**
  38006. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38007. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38008. */
  38009. export class Analyser {
  38010. /**
  38011. * Gets or sets the smoothing
  38012. * @ignorenaming
  38013. */
  38014. SMOOTHING: number;
  38015. /**
  38016. * Gets or sets the FFT table size
  38017. * @ignorenaming
  38018. */
  38019. FFT_SIZE: number;
  38020. /**
  38021. * Gets or sets the bar graph amplitude
  38022. * @ignorenaming
  38023. */
  38024. BARGRAPHAMPLITUDE: number;
  38025. /**
  38026. * Gets or sets the position of the debug canvas
  38027. * @ignorenaming
  38028. */
  38029. DEBUGCANVASPOS: {
  38030. x: number;
  38031. y: number;
  38032. };
  38033. /**
  38034. * Gets or sets the debug canvas size
  38035. * @ignorenaming
  38036. */
  38037. DEBUGCANVASSIZE: {
  38038. width: number;
  38039. height: number;
  38040. };
  38041. private _byteFreqs;
  38042. private _byteTime;
  38043. private _floatFreqs;
  38044. private _webAudioAnalyser;
  38045. private _debugCanvas;
  38046. private _debugCanvasContext;
  38047. private _scene;
  38048. private _registerFunc;
  38049. private _audioEngine;
  38050. /**
  38051. * Creates a new analyser
  38052. * @param scene defines hosting scene
  38053. */
  38054. constructor(scene: Scene);
  38055. /**
  38056. * Get the number of data values you will have to play with for the visualization
  38057. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38058. * @returns a number
  38059. */
  38060. getFrequencyBinCount(): number;
  38061. /**
  38062. * Gets the current frequency data as a byte array
  38063. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38064. * @returns a Uint8Array
  38065. */
  38066. getByteFrequencyData(): Uint8Array;
  38067. /**
  38068. * Gets the current waveform as a byte array
  38069. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38070. * @returns a Uint8Array
  38071. */
  38072. getByteTimeDomainData(): Uint8Array;
  38073. /**
  38074. * Gets the current frequency data as a float array
  38075. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38076. * @returns a Float32Array
  38077. */
  38078. getFloatFrequencyData(): Float32Array;
  38079. /**
  38080. * Renders the debug canvas
  38081. */
  38082. drawDebugCanvas(): void;
  38083. /**
  38084. * Stops rendering the debug canvas and removes it
  38085. */
  38086. stopDebugCanvas(): void;
  38087. /**
  38088. * Connects two audio nodes
  38089. * @param inputAudioNode defines first node to connect
  38090. * @param outputAudioNode defines second node to connect
  38091. */
  38092. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38093. /**
  38094. * Releases all associated resources
  38095. */
  38096. dispose(): void;
  38097. }
  38098. }
  38099. declare module "babylonjs/Audio/audioEngine" {
  38100. import { IDisposable } from "babylonjs/scene";
  38101. import { Analyser } from "babylonjs/Audio/analyser";
  38102. import { Nullable } from "babylonjs/types";
  38103. import { Observable } from "babylonjs/Misc/observable";
  38104. /**
  38105. * This represents an audio engine and it is responsible
  38106. * to play, synchronize and analyse sounds throughout the application.
  38107. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38108. */
  38109. export interface IAudioEngine extends IDisposable {
  38110. /**
  38111. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38112. */
  38113. readonly canUseWebAudio: boolean;
  38114. /**
  38115. * Gets the current AudioContext if available.
  38116. */
  38117. readonly audioContext: Nullable<AudioContext>;
  38118. /**
  38119. * The master gain node defines the global audio volume of your audio engine.
  38120. */
  38121. readonly masterGain: GainNode;
  38122. /**
  38123. * Gets whether or not mp3 are supported by your browser.
  38124. */
  38125. readonly isMP3supported: boolean;
  38126. /**
  38127. * Gets whether or not ogg are supported by your browser.
  38128. */
  38129. readonly isOGGsupported: boolean;
  38130. /**
  38131. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38132. * @ignoreNaming
  38133. */
  38134. WarnedWebAudioUnsupported: boolean;
  38135. /**
  38136. * Defines if the audio engine relies on a custom unlocked button.
  38137. * In this case, the embedded button will not be displayed.
  38138. */
  38139. useCustomUnlockedButton: boolean;
  38140. /**
  38141. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38142. */
  38143. readonly unlocked: boolean;
  38144. /**
  38145. * Event raised when audio has been unlocked on the browser.
  38146. */
  38147. onAudioUnlockedObservable: Observable<AudioEngine>;
  38148. /**
  38149. * Event raised when audio has been locked on the browser.
  38150. */
  38151. onAudioLockedObservable: Observable<AudioEngine>;
  38152. /**
  38153. * Flags the audio engine in Locked state.
  38154. * This happens due to new browser policies preventing audio to autoplay.
  38155. */
  38156. lock(): void;
  38157. /**
  38158. * Unlocks the audio engine once a user action has been done on the dom.
  38159. * This is helpful to resume play once browser policies have been satisfied.
  38160. */
  38161. unlock(): void;
  38162. /**
  38163. * Gets the global volume sets on the master gain.
  38164. * @returns the global volume if set or -1 otherwise
  38165. */
  38166. getGlobalVolume(): number;
  38167. /**
  38168. * Sets the global volume of your experience (sets on the master gain).
  38169. * @param newVolume Defines the new global volume of the application
  38170. */
  38171. setGlobalVolume(newVolume: number): void;
  38172. /**
  38173. * Connect the audio engine to an audio analyser allowing some amazing
  38174. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38175. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38176. * @param analyser The analyser to connect to the engine
  38177. */
  38178. connectToAnalyser(analyser: Analyser): void;
  38179. }
  38180. /**
  38181. * This represents the default audio engine used in babylon.
  38182. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38183. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38184. */
  38185. export class AudioEngine implements IAudioEngine {
  38186. private _audioContext;
  38187. private _audioContextInitialized;
  38188. private _muteButton;
  38189. private _hostElement;
  38190. /**
  38191. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38192. */
  38193. canUseWebAudio: boolean;
  38194. /**
  38195. * The master gain node defines the global audio volume of your audio engine.
  38196. */
  38197. masterGain: GainNode;
  38198. /**
  38199. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38200. * @ignoreNaming
  38201. */
  38202. WarnedWebAudioUnsupported: boolean;
  38203. /**
  38204. * Gets whether or not mp3 are supported by your browser.
  38205. */
  38206. isMP3supported: boolean;
  38207. /**
  38208. * Gets whether or not ogg are supported by your browser.
  38209. */
  38210. isOGGsupported: boolean;
  38211. /**
  38212. * Gets whether audio has been unlocked on the device.
  38213. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38214. * a user interaction has happened.
  38215. */
  38216. unlocked: boolean;
  38217. /**
  38218. * Defines if the audio engine relies on a custom unlocked button.
  38219. * In this case, the embedded button will not be displayed.
  38220. */
  38221. useCustomUnlockedButton: boolean;
  38222. /**
  38223. * Event raised when audio has been unlocked on the browser.
  38224. */
  38225. onAudioUnlockedObservable: Observable<AudioEngine>;
  38226. /**
  38227. * Event raised when audio has been locked on the browser.
  38228. */
  38229. onAudioLockedObservable: Observable<AudioEngine>;
  38230. /**
  38231. * Gets the current AudioContext if available.
  38232. */
  38233. get audioContext(): Nullable<AudioContext>;
  38234. private _connectedAnalyser;
  38235. /**
  38236. * Instantiates a new audio engine.
  38237. *
  38238. * There should be only one per page as some browsers restrict the number
  38239. * of audio contexts you can create.
  38240. * @param hostElement defines the host element where to display the mute icon if necessary
  38241. */
  38242. constructor(hostElement?: Nullable<HTMLElement>);
  38243. /**
  38244. * Flags the audio engine in Locked state.
  38245. * This happens due to new browser policies preventing audio to autoplay.
  38246. */
  38247. lock(): void;
  38248. /**
  38249. * Unlocks the audio engine once a user action has been done on the dom.
  38250. * This is helpful to resume play once browser policies have been satisfied.
  38251. */
  38252. unlock(): void;
  38253. private _resumeAudioContext;
  38254. private _initializeAudioContext;
  38255. private _tryToRun;
  38256. private _triggerRunningState;
  38257. private _triggerSuspendedState;
  38258. private _displayMuteButton;
  38259. private _moveButtonToTopLeft;
  38260. private _onResize;
  38261. private _hideMuteButton;
  38262. /**
  38263. * Destroy and release the resources associated with the audio ccontext.
  38264. */
  38265. dispose(): void;
  38266. /**
  38267. * Gets the global volume sets on the master gain.
  38268. * @returns the global volume if set or -1 otherwise
  38269. */
  38270. getGlobalVolume(): number;
  38271. /**
  38272. * Sets the global volume of your experience (sets on the master gain).
  38273. * @param newVolume Defines the new global volume of the application
  38274. */
  38275. setGlobalVolume(newVolume: number): void;
  38276. /**
  38277. * Connect the audio engine to an audio analyser allowing some amazing
  38278. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38279. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38280. * @param analyser The analyser to connect to the engine
  38281. */
  38282. connectToAnalyser(analyser: Analyser): void;
  38283. }
  38284. }
  38285. declare module "babylonjs/Loading/loadingScreen" {
  38286. /**
  38287. * Interface used to present a loading screen while loading a scene
  38288. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38289. */
  38290. export interface ILoadingScreen {
  38291. /**
  38292. * Function called to display the loading screen
  38293. */
  38294. displayLoadingUI: () => void;
  38295. /**
  38296. * Function called to hide the loading screen
  38297. */
  38298. hideLoadingUI: () => void;
  38299. /**
  38300. * Gets or sets the color to use for the background
  38301. */
  38302. loadingUIBackgroundColor: string;
  38303. /**
  38304. * Gets or sets the text to display while loading
  38305. */
  38306. loadingUIText: string;
  38307. }
  38308. /**
  38309. * Class used for the default loading screen
  38310. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38311. */
  38312. export class DefaultLoadingScreen implements ILoadingScreen {
  38313. private _renderingCanvas;
  38314. private _loadingText;
  38315. private _loadingDivBackgroundColor;
  38316. private _loadingDiv;
  38317. private _loadingTextDiv;
  38318. /** Gets or sets the logo url to use for the default loading screen */
  38319. static DefaultLogoUrl: string;
  38320. /** Gets or sets the spinner url to use for the default loading screen */
  38321. static DefaultSpinnerUrl: string;
  38322. /**
  38323. * Creates a new default loading screen
  38324. * @param _renderingCanvas defines the canvas used to render the scene
  38325. * @param _loadingText defines the default text to display
  38326. * @param _loadingDivBackgroundColor defines the default background color
  38327. */
  38328. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38329. /**
  38330. * Function called to display the loading screen
  38331. */
  38332. displayLoadingUI(): void;
  38333. /**
  38334. * Function called to hide the loading screen
  38335. */
  38336. hideLoadingUI(): void;
  38337. /**
  38338. * Gets or sets the text to display while loading
  38339. */
  38340. set loadingUIText(text: string);
  38341. get loadingUIText(): string;
  38342. /**
  38343. * Gets or sets the color to use for the background
  38344. */
  38345. get loadingUIBackgroundColor(): string;
  38346. set loadingUIBackgroundColor(color: string);
  38347. private _resizeLoadingUI;
  38348. }
  38349. }
  38350. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38351. /**
  38352. * Interface for any object that can request an animation frame
  38353. */
  38354. export interface ICustomAnimationFrameRequester {
  38355. /**
  38356. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38357. */
  38358. renderFunction?: Function;
  38359. /**
  38360. * Called to request the next frame to render to
  38361. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38362. */
  38363. requestAnimationFrame: Function;
  38364. /**
  38365. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38366. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38367. */
  38368. requestID?: number;
  38369. }
  38370. }
  38371. declare module "babylonjs/Misc/performanceMonitor" {
  38372. /**
  38373. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38374. */
  38375. export class PerformanceMonitor {
  38376. private _enabled;
  38377. private _rollingFrameTime;
  38378. private _lastFrameTimeMs;
  38379. /**
  38380. * constructor
  38381. * @param frameSampleSize The number of samples required to saturate the sliding window
  38382. */
  38383. constructor(frameSampleSize?: number);
  38384. /**
  38385. * Samples current frame
  38386. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38387. */
  38388. sampleFrame(timeMs?: number): void;
  38389. /**
  38390. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38391. */
  38392. get averageFrameTime(): number;
  38393. /**
  38394. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38395. */
  38396. get averageFrameTimeVariance(): number;
  38397. /**
  38398. * Returns the frame time of the most recent frame
  38399. */
  38400. get instantaneousFrameTime(): number;
  38401. /**
  38402. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38403. */
  38404. get averageFPS(): number;
  38405. /**
  38406. * Returns the average framerate in frames per second using the most recent frame time
  38407. */
  38408. get instantaneousFPS(): number;
  38409. /**
  38410. * Returns true if enough samples have been taken to completely fill the sliding window
  38411. */
  38412. get isSaturated(): boolean;
  38413. /**
  38414. * Enables contributions to the sliding window sample set
  38415. */
  38416. enable(): void;
  38417. /**
  38418. * Disables contributions to the sliding window sample set
  38419. * Samples will not be interpolated over the disabled period
  38420. */
  38421. disable(): void;
  38422. /**
  38423. * Returns true if sampling is enabled
  38424. */
  38425. get isEnabled(): boolean;
  38426. /**
  38427. * Resets performance monitor
  38428. */
  38429. reset(): void;
  38430. }
  38431. /**
  38432. * RollingAverage
  38433. *
  38434. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38435. */
  38436. export class RollingAverage {
  38437. /**
  38438. * Current average
  38439. */
  38440. average: number;
  38441. /**
  38442. * Current variance
  38443. */
  38444. variance: number;
  38445. protected _samples: Array<number>;
  38446. protected _sampleCount: number;
  38447. protected _pos: number;
  38448. protected _m2: number;
  38449. /**
  38450. * constructor
  38451. * @param length The number of samples required to saturate the sliding window
  38452. */
  38453. constructor(length: number);
  38454. /**
  38455. * Adds a sample to the sample set
  38456. * @param v The sample value
  38457. */
  38458. add(v: number): void;
  38459. /**
  38460. * Returns previously added values or null if outside of history or outside the sliding window domain
  38461. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38462. * @return Value previously recorded with add() or null if outside of range
  38463. */
  38464. history(i: number): number;
  38465. /**
  38466. * Returns true if enough samples have been taken to completely fill the sliding window
  38467. * @return true if sample-set saturated
  38468. */
  38469. isSaturated(): boolean;
  38470. /**
  38471. * Resets the rolling average (equivalent to 0 samples taken so far)
  38472. */
  38473. reset(): void;
  38474. /**
  38475. * Wraps a value around the sample range boundaries
  38476. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38477. * @return Wrapped position in sample range
  38478. */
  38479. protected _wrapPosition(i: number): number;
  38480. }
  38481. }
  38482. declare module "babylonjs/Misc/perfCounter" {
  38483. /**
  38484. * This class is used to track a performance counter which is number based.
  38485. * The user has access to many properties which give statistics of different nature.
  38486. *
  38487. * The implementer can track two kinds of Performance Counter: time and count.
  38488. * 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.
  38489. * 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.
  38490. */
  38491. export class PerfCounter {
  38492. /**
  38493. * Gets or sets a global boolean to turn on and off all the counters
  38494. */
  38495. static Enabled: boolean;
  38496. /**
  38497. * Returns the smallest value ever
  38498. */
  38499. get min(): number;
  38500. /**
  38501. * Returns the biggest value ever
  38502. */
  38503. get max(): number;
  38504. /**
  38505. * Returns the average value since the performance counter is running
  38506. */
  38507. get average(): number;
  38508. /**
  38509. * Returns the average value of the last second the counter was monitored
  38510. */
  38511. get lastSecAverage(): number;
  38512. /**
  38513. * Returns the current value
  38514. */
  38515. get current(): number;
  38516. /**
  38517. * Gets the accumulated total
  38518. */
  38519. get total(): number;
  38520. /**
  38521. * Gets the total value count
  38522. */
  38523. get count(): number;
  38524. /**
  38525. * Creates a new counter
  38526. */
  38527. constructor();
  38528. /**
  38529. * Call this method to start monitoring a new frame.
  38530. * 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.
  38531. */
  38532. fetchNewFrame(): void;
  38533. /**
  38534. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38535. * @param newCount the count value to add to the monitored count
  38536. * @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.
  38537. */
  38538. addCount(newCount: number, fetchResult: boolean): void;
  38539. /**
  38540. * Start monitoring this performance counter
  38541. */
  38542. beginMonitoring(): void;
  38543. /**
  38544. * Compute the time lapsed since the previous beginMonitoring() call.
  38545. * @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
  38546. */
  38547. endMonitoring(newFrame?: boolean): void;
  38548. private _fetchResult;
  38549. private _startMonitoringTime;
  38550. private _min;
  38551. private _max;
  38552. private _average;
  38553. private _current;
  38554. private _totalValueCount;
  38555. private _totalAccumulated;
  38556. private _lastSecAverage;
  38557. private _lastSecAccumulated;
  38558. private _lastSecTime;
  38559. private _lastSecValueCount;
  38560. }
  38561. }
  38562. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38564. import { Nullable } from "babylonjs/types";
  38565. module "babylonjs/Engines/thinEngine" {
  38566. interface ThinEngine {
  38567. /** @hidden */
  38568. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38569. }
  38570. }
  38571. }
  38572. declare module "babylonjs/Engines/engine" {
  38573. import { Observable } from "babylonjs/Misc/observable";
  38574. import { Nullable } from "babylonjs/types";
  38575. import { Scene } from "babylonjs/scene";
  38576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38577. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38578. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38579. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38580. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38581. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38582. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38583. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38584. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38585. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38586. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38587. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38588. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38589. import "babylonjs/Engines/Extensions/engine.alpha";
  38590. import "babylonjs/Engines/Extensions/engine.readTexture";
  38591. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38592. import { Material } from "babylonjs/Materials/material";
  38593. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38594. /**
  38595. * Defines the interface used by display changed events
  38596. */
  38597. export interface IDisplayChangedEventArgs {
  38598. /** Gets the vrDisplay object (if any) */
  38599. vrDisplay: Nullable<any>;
  38600. /** Gets a boolean indicating if webVR is supported */
  38601. vrSupported: boolean;
  38602. }
  38603. /**
  38604. * Defines the interface used by objects containing a viewport (like a camera)
  38605. */
  38606. interface IViewportOwnerLike {
  38607. /**
  38608. * Gets or sets the viewport
  38609. */
  38610. viewport: IViewportLike;
  38611. }
  38612. /**
  38613. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38614. */
  38615. export class Engine extends ThinEngine {
  38616. /** Defines that alpha blending is disabled */
  38617. static readonly ALPHA_DISABLE: number;
  38618. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38619. static readonly ALPHA_ADD: number;
  38620. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38621. static readonly ALPHA_COMBINE: number;
  38622. /** Defines that alpha blending to DEST - SRC * DEST */
  38623. static readonly ALPHA_SUBTRACT: number;
  38624. /** Defines that alpha blending to SRC * DEST */
  38625. static readonly ALPHA_MULTIPLY: number;
  38626. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38627. static readonly ALPHA_MAXIMIZED: number;
  38628. /** Defines that alpha blending to SRC + DEST */
  38629. static readonly ALPHA_ONEONE: number;
  38630. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38631. static readonly ALPHA_PREMULTIPLIED: number;
  38632. /**
  38633. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38634. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38635. */
  38636. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38637. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38638. static readonly ALPHA_INTERPOLATE: number;
  38639. /**
  38640. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38641. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38642. */
  38643. static readonly ALPHA_SCREENMODE: number;
  38644. /** Defines that the ressource is not delayed*/
  38645. static readonly DELAYLOADSTATE_NONE: number;
  38646. /** Defines that the ressource was successfully delay loaded */
  38647. static readonly DELAYLOADSTATE_LOADED: number;
  38648. /** Defines that the ressource is currently delay loading */
  38649. static readonly DELAYLOADSTATE_LOADING: number;
  38650. /** Defines that the ressource is delayed and has not started loading */
  38651. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38653. static readonly NEVER: number;
  38654. /** 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 */
  38655. static readonly ALWAYS: number;
  38656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38657. static readonly LESS: number;
  38658. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38659. static readonly EQUAL: number;
  38660. /** 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 */
  38661. static readonly LEQUAL: number;
  38662. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38663. static readonly GREATER: number;
  38664. /** 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 */
  38665. static readonly GEQUAL: number;
  38666. /** 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 */
  38667. static readonly NOTEQUAL: number;
  38668. /** Passed to stencilOperation to specify that stencil value must be kept */
  38669. static readonly KEEP: number;
  38670. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38671. static readonly REPLACE: number;
  38672. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38673. static readonly INCR: number;
  38674. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38675. static readonly DECR: number;
  38676. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38677. static readonly INVERT: number;
  38678. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38679. static readonly INCR_WRAP: number;
  38680. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38681. static readonly DECR_WRAP: number;
  38682. /** Texture is not repeating outside of 0..1 UVs */
  38683. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38684. /** Texture is repeating outside of 0..1 UVs */
  38685. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38686. /** Texture is repeating and mirrored */
  38687. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38688. /** ALPHA */
  38689. static readonly TEXTUREFORMAT_ALPHA: number;
  38690. /** LUMINANCE */
  38691. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38692. /** LUMINANCE_ALPHA */
  38693. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38694. /** RGB */
  38695. static readonly TEXTUREFORMAT_RGB: number;
  38696. /** RGBA */
  38697. static readonly TEXTUREFORMAT_RGBA: number;
  38698. /** RED */
  38699. static readonly TEXTUREFORMAT_RED: number;
  38700. /** RED (2nd reference) */
  38701. static readonly TEXTUREFORMAT_R: number;
  38702. /** RG */
  38703. static readonly TEXTUREFORMAT_RG: number;
  38704. /** RED_INTEGER */
  38705. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38706. /** RED_INTEGER (2nd reference) */
  38707. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38708. /** RG_INTEGER */
  38709. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38710. /** RGB_INTEGER */
  38711. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38712. /** RGBA_INTEGER */
  38713. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38714. /** UNSIGNED_BYTE */
  38715. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38716. /** UNSIGNED_BYTE (2nd reference) */
  38717. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38718. /** FLOAT */
  38719. static readonly TEXTURETYPE_FLOAT: number;
  38720. /** HALF_FLOAT */
  38721. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38722. /** BYTE */
  38723. static readonly TEXTURETYPE_BYTE: number;
  38724. /** SHORT */
  38725. static readonly TEXTURETYPE_SHORT: number;
  38726. /** UNSIGNED_SHORT */
  38727. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38728. /** INT */
  38729. static readonly TEXTURETYPE_INT: number;
  38730. /** UNSIGNED_INT */
  38731. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38732. /** UNSIGNED_SHORT_4_4_4_4 */
  38733. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38734. /** UNSIGNED_SHORT_5_5_5_1 */
  38735. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38736. /** UNSIGNED_SHORT_5_6_5 */
  38737. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38738. /** UNSIGNED_INT_2_10_10_10_REV */
  38739. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38740. /** UNSIGNED_INT_24_8 */
  38741. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38742. /** UNSIGNED_INT_10F_11F_11F_REV */
  38743. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38744. /** UNSIGNED_INT_5_9_9_9_REV */
  38745. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38746. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38747. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38748. /** nearest is mag = nearest and min = nearest and mip = linear */
  38749. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38750. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38751. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38752. /** Trilinear is mag = linear and min = linear and mip = linear */
  38753. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38754. /** nearest is mag = nearest and min = nearest and mip = linear */
  38755. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38756. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38757. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38758. /** Trilinear is mag = linear and min = linear and mip = linear */
  38759. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38760. /** mag = nearest and min = nearest and mip = nearest */
  38761. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38762. /** mag = nearest and min = linear and mip = nearest */
  38763. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38764. /** mag = nearest and min = linear and mip = linear */
  38765. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38766. /** mag = nearest and min = linear and mip = none */
  38767. static readonly TEXTURE_NEAREST_LINEAR: number;
  38768. /** mag = nearest and min = nearest and mip = none */
  38769. static readonly TEXTURE_NEAREST_NEAREST: number;
  38770. /** mag = linear and min = nearest and mip = nearest */
  38771. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38772. /** mag = linear and min = nearest and mip = linear */
  38773. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38774. /** mag = linear and min = linear and mip = none */
  38775. static readonly TEXTURE_LINEAR_LINEAR: number;
  38776. /** mag = linear and min = nearest and mip = none */
  38777. static readonly TEXTURE_LINEAR_NEAREST: number;
  38778. /** Explicit coordinates mode */
  38779. static readonly TEXTURE_EXPLICIT_MODE: number;
  38780. /** Spherical coordinates mode */
  38781. static readonly TEXTURE_SPHERICAL_MODE: number;
  38782. /** Planar coordinates mode */
  38783. static readonly TEXTURE_PLANAR_MODE: number;
  38784. /** Cubic coordinates mode */
  38785. static readonly TEXTURE_CUBIC_MODE: number;
  38786. /** Projection coordinates mode */
  38787. static readonly TEXTURE_PROJECTION_MODE: number;
  38788. /** Skybox coordinates mode */
  38789. static readonly TEXTURE_SKYBOX_MODE: number;
  38790. /** Inverse Cubic coordinates mode */
  38791. static readonly TEXTURE_INVCUBIC_MODE: number;
  38792. /** Equirectangular coordinates mode */
  38793. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38794. /** Equirectangular Fixed coordinates mode */
  38795. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38796. /** Equirectangular Fixed Mirrored coordinates mode */
  38797. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38798. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38799. static readonly SCALEMODE_FLOOR: number;
  38800. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38801. static readonly SCALEMODE_NEAREST: number;
  38802. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38803. static readonly SCALEMODE_CEILING: number;
  38804. /**
  38805. * Returns the current npm package of the sdk
  38806. */
  38807. static get NpmPackage(): string;
  38808. /**
  38809. * Returns the current version of the framework
  38810. */
  38811. static get Version(): string;
  38812. /** Gets the list of created engines */
  38813. static get Instances(): Engine[];
  38814. /**
  38815. * Gets the latest created engine
  38816. */
  38817. static get LastCreatedEngine(): Nullable<Engine>;
  38818. /**
  38819. * Gets the latest created scene
  38820. */
  38821. static get LastCreatedScene(): Nullable<Scene>;
  38822. /**
  38823. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38824. * @param flag defines which part of the materials must be marked as dirty
  38825. * @param predicate defines a predicate used to filter which materials should be affected
  38826. */
  38827. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38828. /**
  38829. * Method called to create the default loading screen.
  38830. * This can be overriden in your own app.
  38831. * @param canvas The rendering canvas element
  38832. * @returns The loading screen
  38833. */
  38834. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38835. /**
  38836. * Method called to create the default rescale post process on each engine.
  38837. */
  38838. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38839. /**
  38840. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38841. **/
  38842. enableOfflineSupport: boolean;
  38843. /**
  38844. * 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)
  38845. **/
  38846. disableManifestCheck: boolean;
  38847. /**
  38848. * Gets the list of created scenes
  38849. */
  38850. scenes: Scene[];
  38851. /**
  38852. * Event raised when a new scene is created
  38853. */
  38854. onNewSceneAddedObservable: Observable<Scene>;
  38855. /**
  38856. * Gets the list of created postprocesses
  38857. */
  38858. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38859. /**
  38860. * Gets a boolean indicating if the pointer is currently locked
  38861. */
  38862. isPointerLock: boolean;
  38863. /**
  38864. * Observable event triggered each time the rendering canvas is resized
  38865. */
  38866. onResizeObservable: Observable<Engine>;
  38867. /**
  38868. * Observable event triggered each time the canvas loses focus
  38869. */
  38870. onCanvasBlurObservable: Observable<Engine>;
  38871. /**
  38872. * Observable event triggered each time the canvas gains focus
  38873. */
  38874. onCanvasFocusObservable: Observable<Engine>;
  38875. /**
  38876. * Observable event triggered each time the canvas receives pointerout event
  38877. */
  38878. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38879. /**
  38880. * Observable raised when the engine begins a new frame
  38881. */
  38882. onBeginFrameObservable: Observable<Engine>;
  38883. /**
  38884. * If set, will be used to request the next animation frame for the render loop
  38885. */
  38886. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38887. /**
  38888. * Observable raised when the engine ends the current frame
  38889. */
  38890. onEndFrameObservable: Observable<Engine>;
  38891. /**
  38892. * Observable raised when the engine is about to compile a shader
  38893. */
  38894. onBeforeShaderCompilationObservable: Observable<Engine>;
  38895. /**
  38896. * Observable raised when the engine has jsut compiled a shader
  38897. */
  38898. onAfterShaderCompilationObservable: Observable<Engine>;
  38899. /**
  38900. * Gets the audio engine
  38901. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38902. * @ignorenaming
  38903. */
  38904. static audioEngine: IAudioEngine;
  38905. /**
  38906. * Default AudioEngine factory responsible of creating the Audio Engine.
  38907. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38908. */
  38909. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38910. /**
  38911. * Default offline support factory responsible of creating a tool used to store data locally.
  38912. * By default, this will create a Database object if the workload has been embedded.
  38913. */
  38914. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38915. private _loadingScreen;
  38916. private _pointerLockRequested;
  38917. private _rescalePostProcess;
  38918. private _deterministicLockstep;
  38919. private _lockstepMaxSteps;
  38920. private _timeStep;
  38921. protected get _supportsHardwareTextureRescaling(): boolean;
  38922. private _fps;
  38923. private _deltaTime;
  38924. /** @hidden */
  38925. _drawCalls: PerfCounter;
  38926. /** 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 */
  38927. canvasTabIndex: number;
  38928. /**
  38929. * Turn this value on if you want to pause FPS computation when in background
  38930. */
  38931. disablePerformanceMonitorInBackground: boolean;
  38932. private _performanceMonitor;
  38933. /**
  38934. * Gets the performance monitor attached to this engine
  38935. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38936. */
  38937. get performanceMonitor(): PerformanceMonitor;
  38938. private _onFocus;
  38939. private _onBlur;
  38940. private _onCanvasPointerOut;
  38941. private _onCanvasBlur;
  38942. private _onCanvasFocus;
  38943. private _onFullscreenChange;
  38944. private _onPointerLockChange;
  38945. /**
  38946. * Gets the HTML element used to attach event listeners
  38947. * @returns a HTML element
  38948. */
  38949. getInputElement(): Nullable<HTMLElement>;
  38950. /**
  38951. * Creates a new engine
  38952. * @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
  38953. * @param antialias defines enable antialiasing (default: false)
  38954. * @param options defines further options to be sent to the getContext() function
  38955. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38956. */
  38957. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38958. /**
  38959. * Gets current aspect ratio
  38960. * @param viewportOwner defines the camera to use to get the aspect ratio
  38961. * @param useScreen defines if screen size must be used (or the current render target if any)
  38962. * @returns a number defining the aspect ratio
  38963. */
  38964. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38965. /**
  38966. * Gets current screen aspect ratio
  38967. * @returns a number defining the aspect ratio
  38968. */
  38969. getScreenAspectRatio(): number;
  38970. /**
  38971. * Gets the client rect of the HTML canvas attached with the current webGL context
  38972. * @returns a client rectanglee
  38973. */
  38974. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38975. /**
  38976. * Gets the client rect of the HTML element used for events
  38977. * @returns a client rectanglee
  38978. */
  38979. getInputElementClientRect(): Nullable<ClientRect>;
  38980. /**
  38981. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38982. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38983. * @returns true if engine is in deterministic lock step mode
  38984. */
  38985. isDeterministicLockStep(): boolean;
  38986. /**
  38987. * Gets the max steps when engine is running in deterministic lock step
  38988. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38989. * @returns the max steps
  38990. */
  38991. getLockstepMaxSteps(): number;
  38992. /**
  38993. * Returns the time in ms between steps when using deterministic lock step.
  38994. * @returns time step in (ms)
  38995. */
  38996. getTimeStep(): number;
  38997. /**
  38998. * Force the mipmap generation for the given render target texture
  38999. * @param texture defines the render target texture to use
  39000. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39001. */
  39002. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39003. /** States */
  39004. /**
  39005. * Set various states to the webGL context
  39006. * @param culling defines backface culling state
  39007. * @param zOffset defines the value to apply to zOffset (0 by default)
  39008. * @param force defines if states must be applied even if cache is up to date
  39009. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39010. */
  39011. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39012. /**
  39013. * Set the z offset to apply to current rendering
  39014. * @param value defines the offset to apply
  39015. */
  39016. setZOffset(value: number): void;
  39017. /**
  39018. * Gets the current value of the zOffset
  39019. * @returns the current zOffset state
  39020. */
  39021. getZOffset(): number;
  39022. /**
  39023. * Enable or disable depth buffering
  39024. * @param enable defines the state to set
  39025. */
  39026. setDepthBuffer(enable: boolean): void;
  39027. /**
  39028. * Gets a boolean indicating if depth writing is enabled
  39029. * @returns the current depth writing state
  39030. */
  39031. getDepthWrite(): boolean;
  39032. /**
  39033. * Enable or disable depth writing
  39034. * @param enable defines the state to set
  39035. */
  39036. setDepthWrite(enable: boolean): void;
  39037. /**
  39038. * Gets a boolean indicating if stencil buffer is enabled
  39039. * @returns the current stencil buffer state
  39040. */
  39041. getStencilBuffer(): boolean;
  39042. /**
  39043. * Enable or disable the stencil buffer
  39044. * @param enable defines if the stencil buffer must be enabled or disabled
  39045. */
  39046. setStencilBuffer(enable: boolean): void;
  39047. /**
  39048. * Gets the current stencil mask
  39049. * @returns a number defining the new stencil mask to use
  39050. */
  39051. getStencilMask(): number;
  39052. /**
  39053. * Sets the current stencil mask
  39054. * @param mask defines the new stencil mask to use
  39055. */
  39056. setStencilMask(mask: number): void;
  39057. /**
  39058. * Gets the current stencil function
  39059. * @returns a number defining the stencil function to use
  39060. */
  39061. getStencilFunction(): number;
  39062. /**
  39063. * Gets the current stencil reference value
  39064. * @returns a number defining the stencil reference value to use
  39065. */
  39066. getStencilFunctionReference(): number;
  39067. /**
  39068. * Gets the current stencil mask
  39069. * @returns a number defining the stencil mask to use
  39070. */
  39071. getStencilFunctionMask(): number;
  39072. /**
  39073. * Sets the current stencil function
  39074. * @param stencilFunc defines the new stencil function to use
  39075. */
  39076. setStencilFunction(stencilFunc: number): void;
  39077. /**
  39078. * Sets the current stencil reference
  39079. * @param reference defines the new stencil reference to use
  39080. */
  39081. setStencilFunctionReference(reference: number): void;
  39082. /**
  39083. * Sets the current stencil mask
  39084. * @param mask defines the new stencil mask to use
  39085. */
  39086. setStencilFunctionMask(mask: number): void;
  39087. /**
  39088. * Gets the current stencil operation when stencil fails
  39089. * @returns a number defining stencil operation to use when stencil fails
  39090. */
  39091. getStencilOperationFail(): number;
  39092. /**
  39093. * Gets the current stencil operation when depth fails
  39094. * @returns a number defining stencil operation to use when depth fails
  39095. */
  39096. getStencilOperationDepthFail(): number;
  39097. /**
  39098. * Gets the current stencil operation when stencil passes
  39099. * @returns a number defining stencil operation to use when stencil passes
  39100. */
  39101. getStencilOperationPass(): number;
  39102. /**
  39103. * Sets the stencil operation to use when stencil fails
  39104. * @param operation defines the stencil operation to use when stencil fails
  39105. */
  39106. setStencilOperationFail(operation: number): void;
  39107. /**
  39108. * Sets the stencil operation to use when depth fails
  39109. * @param operation defines the stencil operation to use when depth fails
  39110. */
  39111. setStencilOperationDepthFail(operation: number): void;
  39112. /**
  39113. * Sets the stencil operation to use when stencil passes
  39114. * @param operation defines the stencil operation to use when stencil passes
  39115. */
  39116. setStencilOperationPass(operation: number): void;
  39117. /**
  39118. * Sets a boolean indicating if the dithering state is enabled or disabled
  39119. * @param value defines the dithering state
  39120. */
  39121. setDitheringState(value: boolean): void;
  39122. /**
  39123. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39124. * @param value defines the rasterizer state
  39125. */
  39126. setRasterizerState(value: boolean): void;
  39127. /**
  39128. * Gets the current depth function
  39129. * @returns a number defining the depth function
  39130. */
  39131. getDepthFunction(): Nullable<number>;
  39132. /**
  39133. * Sets the current depth function
  39134. * @param depthFunc defines the function to use
  39135. */
  39136. setDepthFunction(depthFunc: number): void;
  39137. /**
  39138. * Sets the current depth function to GREATER
  39139. */
  39140. setDepthFunctionToGreater(): void;
  39141. /**
  39142. * Sets the current depth function to GEQUAL
  39143. */
  39144. setDepthFunctionToGreaterOrEqual(): void;
  39145. /**
  39146. * Sets the current depth function to LESS
  39147. */
  39148. setDepthFunctionToLess(): void;
  39149. /**
  39150. * Sets the current depth function to LEQUAL
  39151. */
  39152. setDepthFunctionToLessOrEqual(): void;
  39153. private _cachedStencilBuffer;
  39154. private _cachedStencilFunction;
  39155. private _cachedStencilMask;
  39156. private _cachedStencilOperationPass;
  39157. private _cachedStencilOperationFail;
  39158. private _cachedStencilOperationDepthFail;
  39159. private _cachedStencilReference;
  39160. /**
  39161. * Caches the the state of the stencil buffer
  39162. */
  39163. cacheStencilState(): void;
  39164. /**
  39165. * Restores the state of the stencil buffer
  39166. */
  39167. restoreStencilState(): void;
  39168. /**
  39169. * Directly set the WebGL Viewport
  39170. * @param x defines the x coordinate of the viewport (in screen space)
  39171. * @param y defines the y coordinate of the viewport (in screen space)
  39172. * @param width defines the width of the viewport (in screen space)
  39173. * @param height defines the height of the viewport (in screen space)
  39174. * @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
  39175. */
  39176. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39177. /**
  39178. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39179. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39180. * @param y defines the y-coordinate of the corner of the clear rectangle
  39181. * @param width defines the width of the clear rectangle
  39182. * @param height defines the height of the clear rectangle
  39183. * @param clearColor defines the clear color
  39184. */
  39185. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39186. /**
  39187. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39188. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39189. * @param y defines the y-coordinate of the corner of the clear rectangle
  39190. * @param width defines the width of the clear rectangle
  39191. * @param height defines the height of the clear rectangle
  39192. */
  39193. enableScissor(x: number, y: number, width: number, height: number): void;
  39194. /**
  39195. * Disable previously set scissor test rectangle
  39196. */
  39197. disableScissor(): void;
  39198. protected _reportDrawCall(): void;
  39199. /**
  39200. * Initializes a webVR display and starts listening to display change events
  39201. * The onVRDisplayChangedObservable will be notified upon these changes
  39202. * @returns The onVRDisplayChangedObservable
  39203. */
  39204. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39205. /** @hidden */
  39206. _prepareVRComponent(): void;
  39207. /** @hidden */
  39208. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39209. /** @hidden */
  39210. _submitVRFrame(): void;
  39211. /**
  39212. * Call this function to leave webVR mode
  39213. * Will do nothing if webVR is not supported or if there is no webVR device
  39214. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39215. */
  39216. disableVR(): void;
  39217. /**
  39218. * Gets a boolean indicating that the system is in VR mode and is presenting
  39219. * @returns true if VR mode is engaged
  39220. */
  39221. isVRPresenting(): boolean;
  39222. /** @hidden */
  39223. _requestVRFrame(): void;
  39224. /** @hidden */
  39225. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39226. /**
  39227. * Gets the source code of the vertex shader associated with a specific webGL program
  39228. * @param program defines the program to use
  39229. * @returns a string containing the source code of the vertex shader associated with the program
  39230. */
  39231. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39232. /**
  39233. * Gets the source code of the fragment shader associated with a specific webGL program
  39234. * @param program defines the program to use
  39235. * @returns a string containing the source code of the fragment shader associated with the program
  39236. */
  39237. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39238. /**
  39239. * Sets a depth stencil texture from a render target to the according uniform.
  39240. * @param channel The texture channel
  39241. * @param uniform The uniform to set
  39242. * @param texture The render target texture containing the depth stencil texture to apply
  39243. */
  39244. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39245. /**
  39246. * Sets a texture to the webGL context from a postprocess
  39247. * @param channel defines the channel to use
  39248. * @param postProcess defines the source postprocess
  39249. */
  39250. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39251. /**
  39252. * Binds the output of the passed in post process to the texture channel specified
  39253. * @param channel The channel the texture should be bound to
  39254. * @param postProcess The post process which's output should be bound
  39255. */
  39256. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39257. protected _rebuildBuffers(): void;
  39258. /** @hidden */
  39259. _renderFrame(): void;
  39260. _renderLoop(): void;
  39261. /** @hidden */
  39262. _renderViews(): boolean;
  39263. /**
  39264. * Toggle full screen mode
  39265. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39266. */
  39267. switchFullscreen(requestPointerLock: boolean): void;
  39268. /**
  39269. * Enters full screen mode
  39270. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39271. */
  39272. enterFullscreen(requestPointerLock: boolean): void;
  39273. /**
  39274. * Exits full screen mode
  39275. */
  39276. exitFullscreen(): void;
  39277. /**
  39278. * Enters Pointerlock mode
  39279. */
  39280. enterPointerlock(): void;
  39281. /**
  39282. * Exits Pointerlock mode
  39283. */
  39284. exitPointerlock(): void;
  39285. /**
  39286. * Begin a new frame
  39287. */
  39288. beginFrame(): void;
  39289. /**
  39290. * Enf the current frame
  39291. */
  39292. endFrame(): void;
  39293. resize(): void;
  39294. /**
  39295. * Force a specific size of the canvas
  39296. * @param width defines the new canvas' width
  39297. * @param height defines the new canvas' height
  39298. * @returns true if the size was changed
  39299. */
  39300. setSize(width: number, height: number): boolean;
  39301. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39302. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39303. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39304. _releaseTexture(texture: InternalTexture): void;
  39305. /**
  39306. * @hidden
  39307. * Rescales a texture
  39308. * @param source input texutre
  39309. * @param destination destination texture
  39310. * @param scene scene to use to render the resize
  39311. * @param internalFormat format to use when resizing
  39312. * @param onComplete callback to be called when resize has completed
  39313. */
  39314. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39315. /**
  39316. * Gets the current framerate
  39317. * @returns a number representing the framerate
  39318. */
  39319. getFps(): number;
  39320. /**
  39321. * Gets the time spent between current and previous frame
  39322. * @returns a number representing the delta time in ms
  39323. */
  39324. getDeltaTime(): number;
  39325. private _measureFps;
  39326. /** @hidden */
  39327. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39328. /**
  39329. * Updates the sample count of a render target texture
  39330. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39331. * @param texture defines the texture to update
  39332. * @param samples defines the sample count to set
  39333. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39334. */
  39335. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39336. /**
  39337. * Updates a depth texture Comparison Mode and Function.
  39338. * If the comparison Function is equal to 0, the mode will be set to none.
  39339. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39340. * @param texture The texture to set the comparison function for
  39341. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39342. */
  39343. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39344. /**
  39345. * Creates a webGL buffer to use with instanciation
  39346. * @param capacity defines the size of the buffer
  39347. * @returns the webGL buffer
  39348. */
  39349. createInstancesBuffer(capacity: number): DataBuffer;
  39350. /**
  39351. * Delete a webGL buffer used with instanciation
  39352. * @param buffer defines the webGL buffer to delete
  39353. */
  39354. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39355. private _clientWaitAsync;
  39356. /** @hidden */
  39357. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39358. dispose(): void;
  39359. private _disableTouchAction;
  39360. /**
  39361. * Display the loading screen
  39362. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39363. */
  39364. displayLoadingUI(): void;
  39365. /**
  39366. * Hide the loading screen
  39367. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39368. */
  39369. hideLoadingUI(): void;
  39370. /**
  39371. * Gets the current loading screen object
  39372. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39373. */
  39374. get loadingScreen(): ILoadingScreen;
  39375. /**
  39376. * Sets the current loading screen object
  39377. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39378. */
  39379. set loadingScreen(loadingScreen: ILoadingScreen);
  39380. /**
  39381. * Sets the current loading screen text
  39382. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39383. */
  39384. set loadingUIText(text: string);
  39385. /**
  39386. * Sets the current loading screen background color
  39387. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39388. */
  39389. set loadingUIBackgroundColor(color: string);
  39390. /** Pointerlock and fullscreen */
  39391. /**
  39392. * Ask the browser to promote the current element to pointerlock mode
  39393. * @param element defines the DOM element to promote
  39394. */
  39395. static _RequestPointerlock(element: HTMLElement): void;
  39396. /**
  39397. * Asks the browser to exit pointerlock mode
  39398. */
  39399. static _ExitPointerlock(): void;
  39400. /**
  39401. * Ask the browser to promote the current element to fullscreen rendering mode
  39402. * @param element defines the DOM element to promote
  39403. */
  39404. static _RequestFullscreen(element: HTMLElement): void;
  39405. /**
  39406. * Asks the browser to exit fullscreen mode
  39407. */
  39408. static _ExitFullscreen(): void;
  39409. }
  39410. }
  39411. declare module "babylonjs/Engines/engineStore" {
  39412. import { Nullable } from "babylonjs/types";
  39413. import { Engine } from "babylonjs/Engines/engine";
  39414. import { Scene } from "babylonjs/scene";
  39415. /**
  39416. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39417. * during the life time of the application.
  39418. */
  39419. export class EngineStore {
  39420. /** Gets the list of created engines */
  39421. static Instances: import("babylonjs/Engines/engine").Engine[];
  39422. /** @hidden */
  39423. static _LastCreatedScene: Nullable<Scene>;
  39424. /**
  39425. * Gets the latest created engine
  39426. */
  39427. static get LastCreatedEngine(): Nullable<Engine>;
  39428. /**
  39429. * Gets the latest created scene
  39430. */
  39431. static get LastCreatedScene(): Nullable<Scene>;
  39432. /**
  39433. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39434. * @ignorenaming
  39435. */
  39436. static UseFallbackTexture: boolean;
  39437. /**
  39438. * Texture content used if a texture cannot loaded
  39439. * @ignorenaming
  39440. */
  39441. static FallbackTexture: string;
  39442. }
  39443. }
  39444. declare module "babylonjs/Misc/promise" {
  39445. /**
  39446. * Helper class that provides a small promise polyfill
  39447. */
  39448. export class PromisePolyfill {
  39449. /**
  39450. * Static function used to check if the polyfill is required
  39451. * If this is the case then the function will inject the polyfill to window.Promise
  39452. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39453. */
  39454. static Apply(force?: boolean): void;
  39455. }
  39456. }
  39457. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39458. /**
  39459. * Interface for screenshot methods with describe argument called `size` as object with options
  39460. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39461. */
  39462. export interface IScreenshotSize {
  39463. /**
  39464. * number in pixels for canvas height
  39465. */
  39466. height?: number;
  39467. /**
  39468. * multiplier allowing render at a higher or lower resolution
  39469. * If value is defined then height and width will be ignored and taken from camera
  39470. */
  39471. precision?: number;
  39472. /**
  39473. * number in pixels for canvas width
  39474. */
  39475. width?: number;
  39476. }
  39477. }
  39478. declare module "babylonjs/Misc/tools" {
  39479. import { Nullable, float } from "babylonjs/types";
  39480. import { DomManagement } from "babylonjs/Misc/domManagement";
  39481. import { WebRequest } from "babylonjs/Misc/webRequest";
  39482. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39483. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39484. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39485. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39486. import { Camera } from "babylonjs/Cameras/camera";
  39487. import { Engine } from "babylonjs/Engines/engine";
  39488. interface IColor4Like {
  39489. r: float;
  39490. g: float;
  39491. b: float;
  39492. a: float;
  39493. }
  39494. /**
  39495. * Class containing a set of static utilities functions
  39496. */
  39497. export class Tools {
  39498. /**
  39499. * Gets or sets the base URL to use to load assets
  39500. */
  39501. static get BaseUrl(): string;
  39502. static set BaseUrl(value: string);
  39503. /**
  39504. * Enable/Disable Custom HTTP Request Headers globally.
  39505. * default = false
  39506. * @see CustomRequestHeaders
  39507. */
  39508. static UseCustomRequestHeaders: boolean;
  39509. /**
  39510. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39511. * i.e. when loading files, where the server/service expects an Authorization header
  39512. */
  39513. static CustomRequestHeaders: {
  39514. [key: string]: string;
  39515. };
  39516. /**
  39517. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39518. */
  39519. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39520. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39521. /**
  39522. * Default behaviour for cors in the application.
  39523. * It can be a string if the expected behavior is identical in the entire app.
  39524. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39525. */
  39526. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39527. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39528. /**
  39529. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39530. * @ignorenaming
  39531. */
  39532. static get UseFallbackTexture(): boolean;
  39533. static set UseFallbackTexture(value: boolean);
  39534. /**
  39535. * Use this object to register external classes like custom textures or material
  39536. * to allow the laoders to instantiate them
  39537. */
  39538. static get RegisteredExternalClasses(): {
  39539. [key: string]: Object;
  39540. };
  39541. static set RegisteredExternalClasses(classes: {
  39542. [key: string]: Object;
  39543. });
  39544. /**
  39545. * Texture content used if a texture cannot loaded
  39546. * @ignorenaming
  39547. */
  39548. static get fallbackTexture(): string;
  39549. static set fallbackTexture(value: string);
  39550. /**
  39551. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39552. * @param u defines the coordinate on X axis
  39553. * @param v defines the coordinate on Y axis
  39554. * @param width defines the width of the source data
  39555. * @param height defines the height of the source data
  39556. * @param pixels defines the source byte array
  39557. * @param color defines the output color
  39558. */
  39559. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39560. /**
  39561. * Interpolates between a and b via alpha
  39562. * @param a The lower value (returned when alpha = 0)
  39563. * @param b The upper value (returned when alpha = 1)
  39564. * @param alpha The interpolation-factor
  39565. * @return The mixed value
  39566. */
  39567. static Mix(a: number, b: number, alpha: number): number;
  39568. /**
  39569. * Tries to instantiate a new object from a given class name
  39570. * @param className defines the class name to instantiate
  39571. * @returns the new object or null if the system was not able to do the instantiation
  39572. */
  39573. static Instantiate(className: string): any;
  39574. /**
  39575. * Provides a slice function that will work even on IE
  39576. * @param data defines the array to slice
  39577. * @param start defines the start of the data (optional)
  39578. * @param end defines the end of the data (optional)
  39579. * @returns the new sliced array
  39580. */
  39581. static Slice<T>(data: T, start?: number, end?: number): T;
  39582. /**
  39583. * Polyfill for setImmediate
  39584. * @param action defines the action to execute after the current execution block
  39585. */
  39586. static SetImmediate(action: () => void): void;
  39587. /**
  39588. * Function indicating if a number is an exponent of 2
  39589. * @param value defines the value to test
  39590. * @returns true if the value is an exponent of 2
  39591. */
  39592. static IsExponentOfTwo(value: number): boolean;
  39593. private static _tmpFloatArray;
  39594. /**
  39595. * Returns the nearest 32-bit single precision float representation of a Number
  39596. * @param value A Number. If the parameter is of a different type, it will get converted
  39597. * to a number or to NaN if it cannot be converted
  39598. * @returns number
  39599. */
  39600. static FloatRound(value: number): number;
  39601. /**
  39602. * Extracts the filename from a path
  39603. * @param path defines the path to use
  39604. * @returns the filename
  39605. */
  39606. static GetFilename(path: string): string;
  39607. /**
  39608. * Extracts the "folder" part of a path (everything before the filename).
  39609. * @param uri The URI to extract the info from
  39610. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39611. * @returns The "folder" part of the path
  39612. */
  39613. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39614. /**
  39615. * Extracts text content from a DOM element hierarchy
  39616. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39617. */
  39618. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39619. /**
  39620. * Convert an angle in radians to degrees
  39621. * @param angle defines the angle to convert
  39622. * @returns the angle in degrees
  39623. */
  39624. static ToDegrees(angle: number): number;
  39625. /**
  39626. * Convert an angle in degrees to radians
  39627. * @param angle defines the angle to convert
  39628. * @returns the angle in radians
  39629. */
  39630. static ToRadians(angle: number): number;
  39631. /**
  39632. * Returns an array if obj is not an array
  39633. * @param obj defines the object to evaluate as an array
  39634. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39635. * @returns either obj directly if obj is an array or a new array containing obj
  39636. */
  39637. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39638. /**
  39639. * Gets the pointer prefix to use
  39640. * @param engine defines the engine we are finding the prefix for
  39641. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39642. */
  39643. static GetPointerPrefix(engine: Engine): string;
  39644. /**
  39645. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39646. * @param url define the url we are trying
  39647. * @param element define the dom element where to configure the cors policy
  39648. */
  39649. static SetCorsBehavior(url: string | string[], element: {
  39650. crossOrigin: string | null;
  39651. }): void;
  39652. /**
  39653. * Removes unwanted characters from an url
  39654. * @param url defines the url to clean
  39655. * @returns the cleaned url
  39656. */
  39657. static CleanUrl(url: string): string;
  39658. /**
  39659. * Gets or sets a function used to pre-process url before using them to load assets
  39660. */
  39661. static get PreprocessUrl(): (url: string) => string;
  39662. static set PreprocessUrl(processor: (url: string) => string);
  39663. /**
  39664. * Loads an image as an HTMLImageElement.
  39665. * @param input url string, ArrayBuffer, or Blob to load
  39666. * @param onLoad callback called when the image successfully loads
  39667. * @param onError callback called when the image fails to load
  39668. * @param offlineProvider offline provider for caching
  39669. * @param mimeType optional mime type
  39670. * @returns the HTMLImageElement of the loaded image
  39671. */
  39672. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39673. /**
  39674. * Loads a file from a url
  39675. * @param url url string, ArrayBuffer, or Blob to load
  39676. * @param onSuccess callback called when the file successfully loads
  39677. * @param onProgress callback called while file is loading (if the server supports this mode)
  39678. * @param offlineProvider defines the offline provider for caching
  39679. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39680. * @param onError callback called when the file fails to load
  39681. * @returns a file request object
  39682. */
  39683. 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;
  39684. /**
  39685. * Loads a file from a url
  39686. * @param url the file url to load
  39687. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39688. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39689. */
  39690. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39691. /**
  39692. * Load a script (identified by an url). When the url returns, the
  39693. * content of this file is added into a new script element, attached to the DOM (body element)
  39694. * @param scriptUrl defines the url of the script to laod
  39695. * @param onSuccess defines the callback called when the script is loaded
  39696. * @param onError defines the callback to call if an error occurs
  39697. * @param scriptId defines the id of the script element
  39698. */
  39699. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39700. /**
  39701. * Load an asynchronous script (identified by an url). When the url returns, the
  39702. * content of this file is added into a new script element, attached to the DOM (body element)
  39703. * @param scriptUrl defines the url of the script to laod
  39704. * @param scriptId defines the id of the script element
  39705. * @returns a promise request object
  39706. */
  39707. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39708. /**
  39709. * Loads a file from a blob
  39710. * @param fileToLoad defines the blob to use
  39711. * @param callback defines the callback to call when data is loaded
  39712. * @param progressCallback defines the callback to call during loading process
  39713. * @returns a file request object
  39714. */
  39715. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39716. /**
  39717. * Reads a file from a File object
  39718. * @param file defines the file to load
  39719. * @param onSuccess defines the callback to call when data is loaded
  39720. * @param onProgress defines the callback to call during loading process
  39721. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39722. * @param onError defines the callback to call when an error occurs
  39723. * @returns a file request object
  39724. */
  39725. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39726. /**
  39727. * Creates a data url from a given string content
  39728. * @param content defines the content to convert
  39729. * @returns the new data url link
  39730. */
  39731. static FileAsURL(content: string): string;
  39732. /**
  39733. * Format the given number to a specific decimal format
  39734. * @param value defines the number to format
  39735. * @param decimals defines the number of decimals to use
  39736. * @returns the formatted string
  39737. */
  39738. static Format(value: number, decimals?: number): string;
  39739. /**
  39740. * Tries to copy an object by duplicating every property
  39741. * @param source defines the source object
  39742. * @param destination defines the target object
  39743. * @param doNotCopyList defines a list of properties to avoid
  39744. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39745. */
  39746. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39747. /**
  39748. * Gets a boolean indicating if the given object has no own property
  39749. * @param obj defines the object to test
  39750. * @returns true if object has no own property
  39751. */
  39752. static IsEmpty(obj: any): boolean;
  39753. /**
  39754. * Function used to register events at window level
  39755. * @param windowElement defines the Window object to use
  39756. * @param events defines the events to register
  39757. */
  39758. static RegisterTopRootEvents(windowElement: Window, events: {
  39759. name: string;
  39760. handler: Nullable<(e: FocusEvent) => any>;
  39761. }[]): void;
  39762. /**
  39763. * Function used to unregister events from window level
  39764. * @param windowElement defines the Window object to use
  39765. * @param events defines the events to unregister
  39766. */
  39767. static UnregisterTopRootEvents(windowElement: Window, events: {
  39768. name: string;
  39769. handler: Nullable<(e: FocusEvent) => any>;
  39770. }[]): void;
  39771. /**
  39772. * @ignore
  39773. */
  39774. static _ScreenshotCanvas: HTMLCanvasElement;
  39775. /**
  39776. * Dumps the current bound framebuffer
  39777. * @param width defines the rendering width
  39778. * @param height defines the rendering height
  39779. * @param engine defines the hosting engine
  39780. * @param successCallback defines the callback triggered once the data are available
  39781. * @param mimeType defines the mime type of the result
  39782. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39783. */
  39784. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39785. /**
  39786. * Converts the canvas data to blob.
  39787. * This acts as a polyfill for browsers not supporting the to blob function.
  39788. * @param canvas Defines the canvas to extract the data from
  39789. * @param successCallback Defines the callback triggered once the data are available
  39790. * @param mimeType Defines the mime type of the result
  39791. */
  39792. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39793. /**
  39794. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39795. * @param successCallback defines the callback triggered once the data are available
  39796. * @param mimeType defines the mime type of the result
  39797. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39798. */
  39799. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39800. /**
  39801. * Downloads a blob in the browser
  39802. * @param blob defines the blob to download
  39803. * @param fileName defines the name of the downloaded file
  39804. */
  39805. static Download(blob: Blob, fileName: string): void;
  39806. /**
  39807. * Captures a screenshot of the current rendering
  39808. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39809. * @param engine defines the rendering engine
  39810. * @param camera defines the source camera
  39811. * @param size This parameter can be set to a single number or to an object with the
  39812. * following (optional) properties: precision, width, height. If a single number is passed,
  39813. * it will be used for both width and height. If an object is passed, the screenshot size
  39814. * will be derived from the parameters. The precision property is a multiplier allowing
  39815. * rendering at a higher or lower resolution
  39816. * @param successCallback defines the callback receives a single parameter which contains the
  39817. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39818. * src parameter of an <img> to display it
  39819. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39820. * Check your browser for supported MIME types
  39821. */
  39822. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39823. /**
  39824. * Captures a screenshot of the current rendering
  39825. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39826. * @param engine defines the rendering engine
  39827. * @param camera defines the source camera
  39828. * @param size This parameter can be set to a single number or to an object with the
  39829. * following (optional) properties: precision, width, height. If a single number is passed,
  39830. * it will be used for both width and height. If an object is passed, the screenshot size
  39831. * will be derived from the parameters. The precision property is a multiplier allowing
  39832. * rendering at a higher or lower resolution
  39833. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39834. * Check your browser for supported MIME types
  39835. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39836. * to the src parameter of an <img> to display it
  39837. */
  39838. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39839. /**
  39840. * Generates an image screenshot from the specified camera.
  39841. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39842. * @param engine The engine to use for rendering
  39843. * @param camera The camera to use for rendering
  39844. * @param size This parameter can be set to a single number or to an object with the
  39845. * following (optional) properties: precision, width, height. If a single number is passed,
  39846. * it will be used for both width and height. If an object is passed, the screenshot size
  39847. * will be derived from the parameters. The precision property is a multiplier allowing
  39848. * rendering at a higher or lower resolution
  39849. * @param successCallback The callback receives a single parameter which contains the
  39850. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39851. * src parameter of an <img> to display it
  39852. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39853. * Check your browser for supported MIME types
  39854. * @param samples Texture samples (default: 1)
  39855. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39856. * @param fileName A name for for the downloaded file.
  39857. */
  39858. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39859. /**
  39860. * Generates an image screenshot from the specified camera.
  39861. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39862. * @param engine The engine to use for rendering
  39863. * @param camera The camera to use for rendering
  39864. * @param size This parameter can be set to a single number or to an object with the
  39865. * following (optional) properties: precision, width, height. If a single number is passed,
  39866. * it will be used for both width and height. If an object is passed, the screenshot size
  39867. * will be derived from the parameters. The precision property is a multiplier allowing
  39868. * rendering at a higher or lower resolution
  39869. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39870. * Check your browser for supported MIME types
  39871. * @param samples Texture samples (default: 1)
  39872. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39873. * @param fileName A name for for the downloaded file.
  39874. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39875. * to the src parameter of an <img> to display it
  39876. */
  39877. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39878. /**
  39879. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39880. * Be aware Math.random() could cause collisions, but:
  39881. * "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"
  39882. * @returns a pseudo random id
  39883. */
  39884. static RandomId(): string;
  39885. /**
  39886. * Test if the given uri is a base64 string
  39887. * @param uri The uri to test
  39888. * @return True if the uri is a base64 string or false otherwise
  39889. */
  39890. static IsBase64(uri: string): boolean;
  39891. /**
  39892. * Decode the given base64 uri.
  39893. * @param uri The uri to decode
  39894. * @return The decoded base64 data.
  39895. */
  39896. static DecodeBase64(uri: string): ArrayBuffer;
  39897. /**
  39898. * Gets the absolute url.
  39899. * @param url the input url
  39900. * @return the absolute url
  39901. */
  39902. static GetAbsoluteUrl(url: string): string;
  39903. /**
  39904. * No log
  39905. */
  39906. static readonly NoneLogLevel: number;
  39907. /**
  39908. * Only message logs
  39909. */
  39910. static readonly MessageLogLevel: number;
  39911. /**
  39912. * Only warning logs
  39913. */
  39914. static readonly WarningLogLevel: number;
  39915. /**
  39916. * Only error logs
  39917. */
  39918. static readonly ErrorLogLevel: number;
  39919. /**
  39920. * All logs
  39921. */
  39922. static readonly AllLogLevel: number;
  39923. /**
  39924. * Gets a value indicating the number of loading errors
  39925. * @ignorenaming
  39926. */
  39927. static get errorsCount(): number;
  39928. /**
  39929. * Callback called when a new log is added
  39930. */
  39931. static OnNewCacheEntry: (entry: string) => void;
  39932. /**
  39933. * Log a message to the console
  39934. * @param message defines the message to log
  39935. */
  39936. static Log(message: string): void;
  39937. /**
  39938. * Write a warning message to the console
  39939. * @param message defines the message to log
  39940. */
  39941. static Warn(message: string): void;
  39942. /**
  39943. * Write an error message to the console
  39944. * @param message defines the message to log
  39945. */
  39946. static Error(message: string): void;
  39947. /**
  39948. * Gets current log cache (list of logs)
  39949. */
  39950. static get LogCache(): string;
  39951. /**
  39952. * Clears the log cache
  39953. */
  39954. static ClearLogCache(): void;
  39955. /**
  39956. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39957. */
  39958. static set LogLevels(level: number);
  39959. /**
  39960. * Checks if the window object exists
  39961. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39962. */
  39963. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39964. /**
  39965. * No performance log
  39966. */
  39967. static readonly PerformanceNoneLogLevel: number;
  39968. /**
  39969. * Use user marks to log performance
  39970. */
  39971. static readonly PerformanceUserMarkLogLevel: number;
  39972. /**
  39973. * Log performance to the console
  39974. */
  39975. static readonly PerformanceConsoleLogLevel: number;
  39976. private static _performance;
  39977. /**
  39978. * Sets the current performance log level
  39979. */
  39980. static set PerformanceLogLevel(level: number);
  39981. private static _StartPerformanceCounterDisabled;
  39982. private static _EndPerformanceCounterDisabled;
  39983. private static _StartUserMark;
  39984. private static _EndUserMark;
  39985. private static _StartPerformanceConsole;
  39986. private static _EndPerformanceConsole;
  39987. /**
  39988. * Starts a performance counter
  39989. */
  39990. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39991. /**
  39992. * Ends a specific performance coutner
  39993. */
  39994. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39995. /**
  39996. * Gets either window.performance.now() if supported or Date.now() else
  39997. */
  39998. static get Now(): number;
  39999. /**
  40000. * This method will return the name of the class used to create the instance of the given object.
  40001. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40002. * @param object the object to get the class name from
  40003. * @param isType defines if the object is actually a type
  40004. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40005. */
  40006. static GetClassName(object: any, isType?: boolean): string;
  40007. /**
  40008. * Gets the first element of an array satisfying a given predicate
  40009. * @param array defines the array to browse
  40010. * @param predicate defines the predicate to use
  40011. * @returns null if not found or the element
  40012. */
  40013. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40014. /**
  40015. * This method will return the name of the full name of the class, including its owning module (if any).
  40016. * 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).
  40017. * @param object the object to get the class name from
  40018. * @param isType defines if the object is actually a type
  40019. * @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.
  40020. * @ignorenaming
  40021. */
  40022. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40023. /**
  40024. * Returns a promise that resolves after the given amount of time.
  40025. * @param delay Number of milliseconds to delay
  40026. * @returns Promise that resolves after the given amount of time
  40027. */
  40028. static DelayAsync(delay: number): Promise<void>;
  40029. /**
  40030. * Utility function to detect if the current user agent is Safari
  40031. * @returns whether or not the current user agent is safari
  40032. */
  40033. static IsSafari(): boolean;
  40034. }
  40035. /**
  40036. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40037. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40038. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40039. * @param name The name of the class, case should be preserved
  40040. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40041. */
  40042. export function className(name: string, module?: string): (target: Object) => void;
  40043. /**
  40044. * An implementation of a loop for asynchronous functions.
  40045. */
  40046. export class AsyncLoop {
  40047. /**
  40048. * Defines the number of iterations for the loop
  40049. */
  40050. iterations: number;
  40051. /**
  40052. * Defines the current index of the loop.
  40053. */
  40054. index: number;
  40055. private _done;
  40056. private _fn;
  40057. private _successCallback;
  40058. /**
  40059. * Constructor.
  40060. * @param iterations the number of iterations.
  40061. * @param func the function to run each iteration
  40062. * @param successCallback the callback that will be called upon succesful execution
  40063. * @param offset starting offset.
  40064. */
  40065. constructor(
  40066. /**
  40067. * Defines the number of iterations for the loop
  40068. */
  40069. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40070. /**
  40071. * Execute the next iteration. Must be called after the last iteration was finished.
  40072. */
  40073. executeNext(): void;
  40074. /**
  40075. * Break the loop and run the success callback.
  40076. */
  40077. breakLoop(): void;
  40078. /**
  40079. * Create and run an async loop.
  40080. * @param iterations the number of iterations.
  40081. * @param fn the function to run each iteration
  40082. * @param successCallback the callback that will be called upon succesful execution
  40083. * @param offset starting offset.
  40084. * @returns the created async loop object
  40085. */
  40086. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40087. /**
  40088. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40089. * @param iterations total number of iterations
  40090. * @param syncedIterations number of synchronous iterations in each async iteration.
  40091. * @param fn the function to call each iteration.
  40092. * @param callback a success call back that will be called when iterating stops.
  40093. * @param breakFunction a break condition (optional)
  40094. * @param timeout timeout settings for the setTimeout function. default - 0.
  40095. * @returns the created async loop object
  40096. */
  40097. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40098. }
  40099. }
  40100. declare module "babylonjs/Misc/stringDictionary" {
  40101. import { Nullable } from "babylonjs/types";
  40102. /**
  40103. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40104. * The underlying implementation relies on an associative array to ensure the best performances.
  40105. * The value can be anything including 'null' but except 'undefined'
  40106. */
  40107. export class StringDictionary<T> {
  40108. /**
  40109. * This will clear this dictionary and copy the content from the 'source' one.
  40110. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40111. * @param source the dictionary to take the content from and copy to this dictionary
  40112. */
  40113. copyFrom(source: StringDictionary<T>): void;
  40114. /**
  40115. * Get a value based from its key
  40116. * @param key the given key to get the matching value from
  40117. * @return the value if found, otherwise undefined is returned
  40118. */
  40119. get(key: string): T | undefined;
  40120. /**
  40121. * Get a value from its key or add it if it doesn't exist.
  40122. * This method will ensure you that a given key/data will be present in the dictionary.
  40123. * @param key the given key to get the matching value from
  40124. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40125. * The factory will only be invoked if there's no data for the given key.
  40126. * @return the value corresponding to the key.
  40127. */
  40128. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40129. /**
  40130. * Get a value from its key if present in the dictionary otherwise add it
  40131. * @param key the key to get the value from
  40132. * @param val if there's no such key/value pair in the dictionary add it with this value
  40133. * @return the value corresponding to the key
  40134. */
  40135. getOrAdd(key: string, val: T): T;
  40136. /**
  40137. * Check if there's a given key in the dictionary
  40138. * @param key the key to check for
  40139. * @return true if the key is present, false otherwise
  40140. */
  40141. contains(key: string): boolean;
  40142. /**
  40143. * Add a new key and its corresponding value
  40144. * @param key the key to add
  40145. * @param value the value corresponding to the key
  40146. * @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
  40147. */
  40148. add(key: string, value: T): boolean;
  40149. /**
  40150. * Update a specific value associated to a key
  40151. * @param key defines the key to use
  40152. * @param value defines the value to store
  40153. * @returns true if the value was updated (or false if the key was not found)
  40154. */
  40155. set(key: string, value: T): boolean;
  40156. /**
  40157. * Get the element of the given key and remove it from the dictionary
  40158. * @param key defines the key to search
  40159. * @returns the value associated with the key or null if not found
  40160. */
  40161. getAndRemove(key: string): Nullable<T>;
  40162. /**
  40163. * Remove a key/value from the dictionary.
  40164. * @param key the key to remove
  40165. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40166. */
  40167. remove(key: string): boolean;
  40168. /**
  40169. * Clear the whole content of the dictionary
  40170. */
  40171. clear(): void;
  40172. /**
  40173. * Gets the current count
  40174. */
  40175. get count(): number;
  40176. /**
  40177. * Execute a callback on each key/val of the dictionary.
  40178. * Note that you can remove any element in this dictionary in the callback implementation
  40179. * @param callback the callback to execute on a given key/value pair
  40180. */
  40181. forEach(callback: (key: string, val: T) => void): void;
  40182. /**
  40183. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40184. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40185. * Note that you can remove any element in this dictionary in the callback implementation
  40186. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40187. * @returns the first item
  40188. */
  40189. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40190. private _count;
  40191. private _data;
  40192. }
  40193. }
  40194. declare module "babylonjs/Collisions/collisionCoordinator" {
  40195. import { Nullable } from "babylonjs/types";
  40196. import { Scene } from "babylonjs/scene";
  40197. import { Vector3 } from "babylonjs/Maths/math.vector";
  40198. import { Collider } from "babylonjs/Collisions/collider";
  40199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40200. /** @hidden */
  40201. export interface ICollisionCoordinator {
  40202. createCollider(): Collider;
  40203. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40204. init(scene: Scene): void;
  40205. }
  40206. /** @hidden */
  40207. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40208. private _scene;
  40209. private _scaledPosition;
  40210. private _scaledVelocity;
  40211. private _finalPosition;
  40212. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40213. createCollider(): Collider;
  40214. init(scene: Scene): void;
  40215. private _collideWithWorld;
  40216. }
  40217. }
  40218. declare module "babylonjs/Inputs/scene.inputManager" {
  40219. import { Nullable } from "babylonjs/types";
  40220. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40221. import { Vector2 } from "babylonjs/Maths/math.vector";
  40222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40223. import { Scene } from "babylonjs/scene";
  40224. /**
  40225. * Class used to manage all inputs for the scene.
  40226. */
  40227. export class InputManager {
  40228. /** The distance in pixel that you have to move to prevent some events */
  40229. static DragMovementThreshold: number;
  40230. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40231. static LongPressDelay: number;
  40232. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40233. static DoubleClickDelay: number;
  40234. /** If you need to check double click without raising a single click at first click, enable this flag */
  40235. static ExclusiveDoubleClickMode: boolean;
  40236. /** 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. */
  40237. private _alreadyAttached;
  40238. private _wheelEventName;
  40239. private _onPointerMove;
  40240. private _onPointerDown;
  40241. private _onPointerUp;
  40242. private _initClickEvent;
  40243. private _initActionManager;
  40244. private _delayedSimpleClick;
  40245. private _delayedSimpleClickTimeout;
  40246. private _previousDelayedSimpleClickTimeout;
  40247. private _meshPickProceed;
  40248. private _previousButtonPressed;
  40249. private _currentPickResult;
  40250. private _previousPickResult;
  40251. private _totalPointersPressed;
  40252. private _doubleClickOccured;
  40253. private _pointerOverMesh;
  40254. private _pickedDownMesh;
  40255. private _pickedUpMesh;
  40256. private _pointerX;
  40257. private _pointerY;
  40258. private _unTranslatedPointerX;
  40259. private _unTranslatedPointerY;
  40260. private _startingPointerPosition;
  40261. private _previousStartingPointerPosition;
  40262. private _startingPointerTime;
  40263. private _previousStartingPointerTime;
  40264. private _pointerCaptures;
  40265. private _meshUnderPointerId;
  40266. private _onKeyDown;
  40267. private _onKeyUp;
  40268. private _onCanvasFocusObserver;
  40269. private _onCanvasBlurObserver;
  40270. private _scene;
  40271. /**
  40272. * Creates a new InputManager
  40273. * @param scene defines the hosting scene
  40274. */
  40275. constructor(scene: Scene);
  40276. /**
  40277. * Gets the mesh that is currently under the pointer
  40278. */
  40279. get meshUnderPointer(): Nullable<AbstractMesh>;
  40280. /**
  40281. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40282. * @param pointerId the pointer id to use
  40283. * @returns The mesh under this pointer id or null if not found
  40284. */
  40285. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40286. /**
  40287. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40288. */
  40289. get unTranslatedPointer(): Vector2;
  40290. /**
  40291. * Gets or sets the current on-screen X position of the pointer
  40292. */
  40293. get pointerX(): number;
  40294. set pointerX(value: number);
  40295. /**
  40296. * Gets or sets the current on-screen Y position of the pointer
  40297. */
  40298. get pointerY(): number;
  40299. set pointerY(value: number);
  40300. private _updatePointerPosition;
  40301. private _processPointerMove;
  40302. private _setRayOnPointerInfo;
  40303. private _checkPrePointerObservable;
  40304. /**
  40305. * Use this method to simulate a pointer move on a mesh
  40306. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40307. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40308. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40309. */
  40310. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40311. /**
  40312. * Use this method to simulate a pointer down on a mesh
  40313. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40314. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40315. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40316. */
  40317. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40318. private _processPointerDown;
  40319. /** @hidden */
  40320. _isPointerSwiping(): boolean;
  40321. /**
  40322. * Use this method to simulate a pointer up on a mesh
  40323. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40324. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40325. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40326. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40327. */
  40328. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40329. private _processPointerUp;
  40330. /**
  40331. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40332. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40333. * @returns true if the pointer was captured
  40334. */
  40335. isPointerCaptured(pointerId?: number): boolean;
  40336. /**
  40337. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40338. * @param attachUp defines if you want to attach events to pointerup
  40339. * @param attachDown defines if you want to attach events to pointerdown
  40340. * @param attachMove defines if you want to attach events to pointermove
  40341. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40342. */
  40343. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40344. /**
  40345. * Detaches all event handlers
  40346. */
  40347. detachControl(): void;
  40348. /**
  40349. * Force the value of meshUnderPointer
  40350. * @param mesh defines the mesh to use
  40351. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40352. */
  40353. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40354. /**
  40355. * Gets the mesh under the pointer
  40356. * @returns a Mesh or null if no mesh is under the pointer
  40357. */
  40358. getPointerOverMesh(): Nullable<AbstractMesh>;
  40359. }
  40360. }
  40361. declare module "babylonjs/Animations/animationGroup" {
  40362. import { Animatable } from "babylonjs/Animations/animatable";
  40363. import { Animation } from "babylonjs/Animations/animation";
  40364. import { Scene, IDisposable } from "babylonjs/scene";
  40365. import { Observable } from "babylonjs/Misc/observable";
  40366. import { Nullable } from "babylonjs/types";
  40367. import "babylonjs/Animations/animatable";
  40368. /**
  40369. * This class defines the direct association between an animation and a target
  40370. */
  40371. export class TargetedAnimation {
  40372. /**
  40373. * Animation to perform
  40374. */
  40375. animation: Animation;
  40376. /**
  40377. * Target to animate
  40378. */
  40379. target: any;
  40380. /**
  40381. * Returns the string "TargetedAnimation"
  40382. * @returns "TargetedAnimation"
  40383. */
  40384. getClassName(): string;
  40385. /**
  40386. * Serialize the object
  40387. * @returns the JSON object representing the current entity
  40388. */
  40389. serialize(): any;
  40390. }
  40391. /**
  40392. * Use this class to create coordinated animations on multiple targets
  40393. */
  40394. export class AnimationGroup implements IDisposable {
  40395. /** The name of the animation group */
  40396. name: string;
  40397. private _scene;
  40398. private _targetedAnimations;
  40399. private _animatables;
  40400. private _from;
  40401. private _to;
  40402. private _isStarted;
  40403. private _isPaused;
  40404. private _speedRatio;
  40405. private _loopAnimation;
  40406. private _isAdditive;
  40407. /**
  40408. * Gets or sets the unique id of the node
  40409. */
  40410. uniqueId: number;
  40411. /**
  40412. * This observable will notify when one animation have ended
  40413. */
  40414. onAnimationEndObservable: Observable<TargetedAnimation>;
  40415. /**
  40416. * Observer raised when one animation loops
  40417. */
  40418. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40419. /**
  40420. * Observer raised when all animations have looped
  40421. */
  40422. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40423. /**
  40424. * This observable will notify when all animations have ended.
  40425. */
  40426. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40427. /**
  40428. * This observable will notify when all animations have paused.
  40429. */
  40430. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40431. /**
  40432. * This observable will notify when all animations are playing.
  40433. */
  40434. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40435. /**
  40436. * Gets the first frame
  40437. */
  40438. get from(): number;
  40439. /**
  40440. * Gets the last frame
  40441. */
  40442. get to(): number;
  40443. /**
  40444. * Define if the animations are started
  40445. */
  40446. get isStarted(): boolean;
  40447. /**
  40448. * Gets a value indicating that the current group is playing
  40449. */
  40450. get isPlaying(): boolean;
  40451. /**
  40452. * Gets or sets the speed ratio to use for all animations
  40453. */
  40454. get speedRatio(): number;
  40455. /**
  40456. * Gets or sets the speed ratio to use for all animations
  40457. */
  40458. set speedRatio(value: number);
  40459. /**
  40460. * Gets or sets if all animations should loop or not
  40461. */
  40462. get loopAnimation(): boolean;
  40463. set loopAnimation(value: boolean);
  40464. /**
  40465. * Gets or sets if all animations should be evaluated additively
  40466. */
  40467. get isAdditive(): boolean;
  40468. set isAdditive(value: boolean);
  40469. /**
  40470. * Gets the targeted animations for this animation group
  40471. */
  40472. get targetedAnimations(): Array<TargetedAnimation>;
  40473. /**
  40474. * returning the list of animatables controlled by this animation group.
  40475. */
  40476. get animatables(): Array<Animatable>;
  40477. /**
  40478. * Gets the list of target animations
  40479. */
  40480. get children(): TargetedAnimation[];
  40481. /**
  40482. * Instantiates a new Animation Group.
  40483. * This helps managing several animations at once.
  40484. * @see https://doc.babylonjs.com/how_to/group
  40485. * @param name Defines the name of the group
  40486. * @param scene Defines the scene the group belongs to
  40487. */
  40488. constructor(
  40489. /** The name of the animation group */
  40490. name: string, scene?: Nullable<Scene>);
  40491. /**
  40492. * Add an animation (with its target) in the group
  40493. * @param animation defines the animation we want to add
  40494. * @param target defines the target of the animation
  40495. * @returns the TargetedAnimation object
  40496. */
  40497. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40498. /**
  40499. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40500. * It can add constant keys at begin or end
  40501. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40502. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40503. * @returns the animation group
  40504. */
  40505. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40506. private _animationLoopCount;
  40507. private _animationLoopFlags;
  40508. private _processLoop;
  40509. /**
  40510. * Start all animations on given targets
  40511. * @param loop defines if animations must loop
  40512. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40513. * @param from defines the from key (optional)
  40514. * @param to defines the to key (optional)
  40515. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40516. * @returns the current animation group
  40517. */
  40518. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40519. /**
  40520. * Pause all animations
  40521. * @returns the animation group
  40522. */
  40523. pause(): AnimationGroup;
  40524. /**
  40525. * Play all animations to initial state
  40526. * This function will start() the animations if they were not started or will restart() them if they were paused
  40527. * @param loop defines if animations must loop
  40528. * @returns the animation group
  40529. */
  40530. play(loop?: boolean): AnimationGroup;
  40531. /**
  40532. * Reset all animations to initial state
  40533. * @returns the animation group
  40534. */
  40535. reset(): AnimationGroup;
  40536. /**
  40537. * Restart animations from key 0
  40538. * @returns the animation group
  40539. */
  40540. restart(): AnimationGroup;
  40541. /**
  40542. * Stop all animations
  40543. * @returns the animation group
  40544. */
  40545. stop(): AnimationGroup;
  40546. /**
  40547. * Set animation weight for all animatables
  40548. * @param weight defines the weight to use
  40549. * @return the animationGroup
  40550. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40551. */
  40552. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40553. /**
  40554. * Synchronize and normalize all animatables with a source animatable
  40555. * @param root defines the root animatable to synchronize with
  40556. * @return the animationGroup
  40557. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40558. */
  40559. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40560. /**
  40561. * Goes to a specific frame in this animation group
  40562. * @param frame the frame number to go to
  40563. * @return the animationGroup
  40564. */
  40565. goToFrame(frame: number): AnimationGroup;
  40566. /**
  40567. * Dispose all associated resources
  40568. */
  40569. dispose(): void;
  40570. private _checkAnimationGroupEnded;
  40571. /**
  40572. * Clone the current animation group and returns a copy
  40573. * @param newName defines the name of the new group
  40574. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40575. * @returns the new aniamtion group
  40576. */
  40577. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40578. /**
  40579. * Serializes the animationGroup to an object
  40580. * @returns Serialized object
  40581. */
  40582. serialize(): any;
  40583. /**
  40584. * Returns a new AnimationGroup object parsed from the source provided.
  40585. * @param parsedAnimationGroup defines the source
  40586. * @param scene defines the scene that will receive the animationGroup
  40587. * @returns a new AnimationGroup
  40588. */
  40589. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40590. /**
  40591. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40592. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40593. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40594. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40595. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40596. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40597. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40598. */
  40599. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40600. /**
  40601. * Returns the string "AnimationGroup"
  40602. * @returns "AnimationGroup"
  40603. */
  40604. getClassName(): string;
  40605. /**
  40606. * Creates a detailled string about the object
  40607. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40608. * @returns a string representing the object
  40609. */
  40610. toString(fullDetails?: boolean): string;
  40611. }
  40612. }
  40613. declare module "babylonjs/scene" {
  40614. import { Nullable } from "babylonjs/types";
  40615. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40616. import { Observable } from "babylonjs/Misc/observable";
  40617. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40618. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40619. import { Geometry } from "babylonjs/Meshes/geometry";
  40620. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40621. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40623. import { Mesh } from "babylonjs/Meshes/mesh";
  40624. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40625. import { Bone } from "babylonjs/Bones/bone";
  40626. import { Skeleton } from "babylonjs/Bones/skeleton";
  40627. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40628. import { Camera } from "babylonjs/Cameras/camera";
  40629. import { AbstractScene } from "babylonjs/abstractScene";
  40630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40631. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40632. import { Material } from "babylonjs/Materials/material";
  40633. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40634. import { Effect } from "babylonjs/Materials/effect";
  40635. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40636. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40637. import { Light } from "babylonjs/Lights/light";
  40638. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40639. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40640. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40641. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40642. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40643. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40644. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40645. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40646. import { Engine } from "babylonjs/Engines/engine";
  40647. import { Node } from "babylonjs/node";
  40648. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40649. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40650. import { WebRequest } from "babylonjs/Misc/webRequest";
  40651. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40652. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40653. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40654. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40655. import { Plane } from "babylonjs/Maths/math.plane";
  40656. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40657. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40658. import { Ray } from "babylonjs/Culling/ray";
  40659. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40660. import { Animation } from "babylonjs/Animations/animation";
  40661. import { Animatable } from "babylonjs/Animations/animatable";
  40662. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40663. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40664. import { Collider } from "babylonjs/Collisions/collider";
  40665. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40666. /**
  40667. * Define an interface for all classes that will hold resources
  40668. */
  40669. export interface IDisposable {
  40670. /**
  40671. * Releases all held resources
  40672. */
  40673. dispose(): void;
  40674. }
  40675. /** Interface defining initialization parameters for Scene class */
  40676. export interface SceneOptions {
  40677. /**
  40678. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40679. * It will improve performance when the number of geometries becomes important.
  40680. */
  40681. useGeometryUniqueIdsMap?: boolean;
  40682. /**
  40683. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40684. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40685. */
  40686. useMaterialMeshMap?: boolean;
  40687. /**
  40688. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40689. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40690. */
  40691. useClonedMeshMap?: boolean;
  40692. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40693. virtual?: boolean;
  40694. }
  40695. /**
  40696. * Represents a scene to be rendered by the engine.
  40697. * @see https://doc.babylonjs.com/features/scene
  40698. */
  40699. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40700. /** The fog is deactivated */
  40701. static readonly FOGMODE_NONE: number;
  40702. /** The fog density is following an exponential function */
  40703. static readonly FOGMODE_EXP: number;
  40704. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40705. static readonly FOGMODE_EXP2: number;
  40706. /** The fog density is following a linear function. */
  40707. static readonly FOGMODE_LINEAR: number;
  40708. /**
  40709. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40710. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40711. */
  40712. static MinDeltaTime: number;
  40713. /**
  40714. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40715. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40716. */
  40717. static MaxDeltaTime: number;
  40718. /**
  40719. * Factory used to create the default material.
  40720. * @param name The name of the material to create
  40721. * @param scene The scene to create the material for
  40722. * @returns The default material
  40723. */
  40724. static DefaultMaterialFactory(scene: Scene): Material;
  40725. /**
  40726. * Factory used to create the a collision coordinator.
  40727. * @returns The collision coordinator
  40728. */
  40729. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40730. /** @hidden */
  40731. _inputManager: InputManager;
  40732. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40733. cameraToUseForPointers: Nullable<Camera>;
  40734. /** @hidden */
  40735. readonly _isScene: boolean;
  40736. /** @hidden */
  40737. _blockEntityCollection: boolean;
  40738. /**
  40739. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40740. */
  40741. autoClear: boolean;
  40742. /**
  40743. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40744. */
  40745. autoClearDepthAndStencil: boolean;
  40746. /**
  40747. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40748. */
  40749. clearColor: Color4;
  40750. /**
  40751. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40752. */
  40753. ambientColor: Color3;
  40754. /**
  40755. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40756. * It should only be one of the following (if not the default embedded one):
  40757. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40758. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40759. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40760. * The material properties need to be setup according to the type of texture in use.
  40761. */
  40762. environmentBRDFTexture: BaseTexture;
  40763. /**
  40764. * Texture used in all pbr material as the reflection texture.
  40765. * As in the majority of the scene they are the same (exception for multi room and so on),
  40766. * this is easier to reference from here than from all the materials.
  40767. */
  40768. get environmentTexture(): Nullable<BaseTexture>;
  40769. /**
  40770. * Texture used in all pbr material as the reflection texture.
  40771. * As in the majority of the scene they are the same (exception for multi room and so on),
  40772. * this is easier to set here than in all the materials.
  40773. */
  40774. set environmentTexture(value: Nullable<BaseTexture>);
  40775. /** @hidden */
  40776. protected _environmentIntensity: number;
  40777. /**
  40778. * Intensity of the environment in all pbr material.
  40779. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40780. * As in the majority of the scene they are the same (exception for multi room and so on),
  40781. * this is easier to reference from here than from all the materials.
  40782. */
  40783. get environmentIntensity(): number;
  40784. /**
  40785. * Intensity of the environment in all pbr material.
  40786. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40787. * As in the majority of the scene they are the same (exception for multi room and so on),
  40788. * this is easier to set here than in all the materials.
  40789. */
  40790. set environmentIntensity(value: number);
  40791. /** @hidden */
  40792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40793. /**
  40794. * Default image processing configuration used either in the rendering
  40795. * Forward main pass or through the imageProcessingPostProcess if present.
  40796. * As in the majority of the scene they are the same (exception for multi camera),
  40797. * this is easier to reference from here than from all the materials and post process.
  40798. *
  40799. * No setter as we it is a shared configuration, you can set the values instead.
  40800. */
  40801. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40802. private _forceWireframe;
  40803. /**
  40804. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40805. */
  40806. set forceWireframe(value: boolean);
  40807. get forceWireframe(): boolean;
  40808. private _skipFrustumClipping;
  40809. /**
  40810. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40811. */
  40812. set skipFrustumClipping(value: boolean);
  40813. get skipFrustumClipping(): boolean;
  40814. private _forcePointsCloud;
  40815. /**
  40816. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40817. */
  40818. set forcePointsCloud(value: boolean);
  40819. get forcePointsCloud(): boolean;
  40820. /**
  40821. * Gets or sets the active clipplane 1
  40822. */
  40823. clipPlane: Nullable<Plane>;
  40824. /**
  40825. * Gets or sets the active clipplane 2
  40826. */
  40827. clipPlane2: Nullable<Plane>;
  40828. /**
  40829. * Gets or sets the active clipplane 3
  40830. */
  40831. clipPlane3: Nullable<Plane>;
  40832. /**
  40833. * Gets or sets the active clipplane 4
  40834. */
  40835. clipPlane4: Nullable<Plane>;
  40836. /**
  40837. * Gets or sets the active clipplane 5
  40838. */
  40839. clipPlane5: Nullable<Plane>;
  40840. /**
  40841. * Gets or sets the active clipplane 6
  40842. */
  40843. clipPlane6: Nullable<Plane>;
  40844. /**
  40845. * Gets or sets a boolean indicating if animations are enabled
  40846. */
  40847. animationsEnabled: boolean;
  40848. private _animationPropertiesOverride;
  40849. /**
  40850. * Gets or sets the animation properties override
  40851. */
  40852. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40853. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40854. /**
  40855. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40856. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40857. */
  40858. useConstantAnimationDeltaTime: boolean;
  40859. /**
  40860. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40861. * Please note that it requires to run a ray cast through the scene on every frame
  40862. */
  40863. constantlyUpdateMeshUnderPointer: boolean;
  40864. /**
  40865. * Defines the HTML cursor to use when hovering over interactive elements
  40866. */
  40867. hoverCursor: string;
  40868. /**
  40869. * Defines the HTML default cursor to use (empty by default)
  40870. */
  40871. defaultCursor: string;
  40872. /**
  40873. * Defines whether cursors are handled by the scene.
  40874. */
  40875. doNotHandleCursors: boolean;
  40876. /**
  40877. * This is used to call preventDefault() on pointer down
  40878. * in order to block unwanted artifacts like system double clicks
  40879. */
  40880. preventDefaultOnPointerDown: boolean;
  40881. /**
  40882. * This is used to call preventDefault() on pointer up
  40883. * in order to block unwanted artifacts like system double clicks
  40884. */
  40885. preventDefaultOnPointerUp: boolean;
  40886. /**
  40887. * Gets or sets user defined metadata
  40888. */
  40889. metadata: any;
  40890. /**
  40891. * For internal use only. Please do not use.
  40892. */
  40893. reservedDataStore: any;
  40894. /**
  40895. * Gets the name of the plugin used to load this scene (null by default)
  40896. */
  40897. loadingPluginName: string;
  40898. /**
  40899. * Use this array to add regular expressions used to disable offline support for specific urls
  40900. */
  40901. disableOfflineSupportExceptionRules: RegExp[];
  40902. /**
  40903. * An event triggered when the scene is disposed.
  40904. */
  40905. onDisposeObservable: Observable<Scene>;
  40906. private _onDisposeObserver;
  40907. /** Sets a function to be executed when this scene is disposed. */
  40908. set onDispose(callback: () => void);
  40909. /**
  40910. * An event triggered before rendering the scene (right after animations and physics)
  40911. */
  40912. onBeforeRenderObservable: Observable<Scene>;
  40913. private _onBeforeRenderObserver;
  40914. /** Sets a function to be executed before rendering this scene */
  40915. set beforeRender(callback: Nullable<() => void>);
  40916. /**
  40917. * An event triggered after rendering the scene
  40918. */
  40919. onAfterRenderObservable: Observable<Scene>;
  40920. /**
  40921. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40922. */
  40923. onAfterRenderCameraObservable: Observable<Camera>;
  40924. private _onAfterRenderObserver;
  40925. /** Sets a function to be executed after rendering this scene */
  40926. set afterRender(callback: Nullable<() => void>);
  40927. /**
  40928. * An event triggered before animating the scene
  40929. */
  40930. onBeforeAnimationsObservable: Observable<Scene>;
  40931. /**
  40932. * An event triggered after animations processing
  40933. */
  40934. onAfterAnimationsObservable: Observable<Scene>;
  40935. /**
  40936. * An event triggered before draw calls are ready to be sent
  40937. */
  40938. onBeforeDrawPhaseObservable: Observable<Scene>;
  40939. /**
  40940. * An event triggered after draw calls have been sent
  40941. */
  40942. onAfterDrawPhaseObservable: Observable<Scene>;
  40943. /**
  40944. * An event triggered when the scene is ready
  40945. */
  40946. onReadyObservable: Observable<Scene>;
  40947. /**
  40948. * An event triggered before rendering a camera
  40949. */
  40950. onBeforeCameraRenderObservable: Observable<Camera>;
  40951. private _onBeforeCameraRenderObserver;
  40952. /** Sets a function to be executed before rendering a camera*/
  40953. set beforeCameraRender(callback: () => void);
  40954. /**
  40955. * An event triggered after rendering a camera
  40956. */
  40957. onAfterCameraRenderObservable: Observable<Camera>;
  40958. private _onAfterCameraRenderObserver;
  40959. /** Sets a function to be executed after rendering a camera*/
  40960. set afterCameraRender(callback: () => void);
  40961. /**
  40962. * An event triggered when active meshes evaluation is about to start
  40963. */
  40964. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40965. /**
  40966. * An event triggered when active meshes evaluation is done
  40967. */
  40968. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40969. /**
  40970. * An event triggered when particles rendering is about to start
  40971. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40972. */
  40973. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40974. /**
  40975. * An event triggered when particles rendering is done
  40976. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40977. */
  40978. onAfterParticlesRenderingObservable: Observable<Scene>;
  40979. /**
  40980. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40981. */
  40982. onDataLoadedObservable: Observable<Scene>;
  40983. /**
  40984. * An event triggered when a camera is created
  40985. */
  40986. onNewCameraAddedObservable: Observable<Camera>;
  40987. /**
  40988. * An event triggered when a camera is removed
  40989. */
  40990. onCameraRemovedObservable: Observable<Camera>;
  40991. /**
  40992. * An event triggered when a light is created
  40993. */
  40994. onNewLightAddedObservable: Observable<Light>;
  40995. /**
  40996. * An event triggered when a light is removed
  40997. */
  40998. onLightRemovedObservable: Observable<Light>;
  40999. /**
  41000. * An event triggered when a geometry is created
  41001. */
  41002. onNewGeometryAddedObservable: Observable<Geometry>;
  41003. /**
  41004. * An event triggered when a geometry is removed
  41005. */
  41006. onGeometryRemovedObservable: Observable<Geometry>;
  41007. /**
  41008. * An event triggered when a transform node is created
  41009. */
  41010. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41011. /**
  41012. * An event triggered when a transform node is removed
  41013. */
  41014. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41015. /**
  41016. * An event triggered when a mesh is created
  41017. */
  41018. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41019. /**
  41020. * An event triggered when a mesh is removed
  41021. */
  41022. onMeshRemovedObservable: Observable<AbstractMesh>;
  41023. /**
  41024. * An event triggered when a skeleton is created
  41025. */
  41026. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41027. /**
  41028. * An event triggered when a skeleton is removed
  41029. */
  41030. onSkeletonRemovedObservable: Observable<Skeleton>;
  41031. /**
  41032. * An event triggered when a material is created
  41033. */
  41034. onNewMaterialAddedObservable: Observable<Material>;
  41035. /**
  41036. * An event triggered when a material is removed
  41037. */
  41038. onMaterialRemovedObservable: Observable<Material>;
  41039. /**
  41040. * An event triggered when a texture is created
  41041. */
  41042. onNewTextureAddedObservable: Observable<BaseTexture>;
  41043. /**
  41044. * An event triggered when a texture is removed
  41045. */
  41046. onTextureRemovedObservable: Observable<BaseTexture>;
  41047. /**
  41048. * An event triggered when render targets are about to be rendered
  41049. * Can happen multiple times per frame.
  41050. */
  41051. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41052. /**
  41053. * An event triggered when render targets were rendered.
  41054. * Can happen multiple times per frame.
  41055. */
  41056. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41057. /**
  41058. * An event triggered before calculating deterministic simulation step
  41059. */
  41060. onBeforeStepObservable: Observable<Scene>;
  41061. /**
  41062. * An event triggered after calculating deterministic simulation step
  41063. */
  41064. onAfterStepObservable: Observable<Scene>;
  41065. /**
  41066. * An event triggered when the activeCamera property is updated
  41067. */
  41068. onActiveCameraChanged: Observable<Scene>;
  41069. /**
  41070. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41071. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41072. * 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)
  41073. */
  41074. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41075. /**
  41076. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41077. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41078. * 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)
  41079. */
  41080. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41081. /**
  41082. * This Observable will when a mesh has been imported into the scene.
  41083. */
  41084. onMeshImportedObservable: Observable<AbstractMesh>;
  41085. /**
  41086. * This Observable will when an animation file has been imported into the scene.
  41087. */
  41088. onAnimationFileImportedObservable: Observable<Scene>;
  41089. /**
  41090. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41091. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41092. */
  41093. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41094. /** @hidden */
  41095. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41096. /**
  41097. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41098. */
  41099. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41100. /**
  41101. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41102. */
  41103. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41104. /**
  41105. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41106. */
  41107. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41108. /** Callback called when a pointer move is detected */
  41109. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41110. /** Callback called when a pointer down is detected */
  41111. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41112. /** Callback called when a pointer up is detected */
  41113. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41114. /** Callback called when a pointer pick is detected */
  41115. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41116. /**
  41117. * 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).
  41118. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41119. */
  41120. onPrePointerObservable: Observable<PointerInfoPre>;
  41121. /**
  41122. * Observable event triggered each time an input event is received from the rendering canvas
  41123. */
  41124. onPointerObservable: Observable<PointerInfo>;
  41125. /**
  41126. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41127. */
  41128. get unTranslatedPointer(): Vector2;
  41129. /**
  41130. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41131. */
  41132. static get DragMovementThreshold(): number;
  41133. static set DragMovementThreshold(value: number);
  41134. /**
  41135. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41136. */
  41137. static get LongPressDelay(): number;
  41138. static set LongPressDelay(value: number);
  41139. /**
  41140. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41141. */
  41142. static get DoubleClickDelay(): number;
  41143. static set DoubleClickDelay(value: number);
  41144. /** If you need to check double click without raising a single click at first click, enable this flag */
  41145. static get ExclusiveDoubleClickMode(): boolean;
  41146. static set ExclusiveDoubleClickMode(value: boolean);
  41147. /** @hidden */
  41148. _mirroredCameraPosition: Nullable<Vector3>;
  41149. /**
  41150. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41151. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41152. */
  41153. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41154. /**
  41155. * Observable event triggered each time an keyboard event is received from the hosting window
  41156. */
  41157. onKeyboardObservable: Observable<KeyboardInfo>;
  41158. private _useRightHandedSystem;
  41159. /**
  41160. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41161. */
  41162. set useRightHandedSystem(value: boolean);
  41163. get useRightHandedSystem(): boolean;
  41164. private _timeAccumulator;
  41165. private _currentStepId;
  41166. private _currentInternalStep;
  41167. /**
  41168. * Sets the step Id used by deterministic lock step
  41169. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41170. * @param newStepId defines the step Id
  41171. */
  41172. setStepId(newStepId: number): void;
  41173. /**
  41174. * Gets the step Id used by deterministic lock step
  41175. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41176. * @returns the step Id
  41177. */
  41178. getStepId(): number;
  41179. /**
  41180. * Gets the internal step used by deterministic lock step
  41181. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41182. * @returns the internal step
  41183. */
  41184. getInternalStep(): number;
  41185. private _fogEnabled;
  41186. /**
  41187. * Gets or sets a boolean indicating if fog is enabled on this scene
  41188. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41189. * (Default is true)
  41190. */
  41191. set fogEnabled(value: boolean);
  41192. get fogEnabled(): boolean;
  41193. private _fogMode;
  41194. /**
  41195. * Gets or sets the fog mode to use
  41196. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41197. * | mode | value |
  41198. * | --- | --- |
  41199. * | FOGMODE_NONE | 0 |
  41200. * | FOGMODE_EXP | 1 |
  41201. * | FOGMODE_EXP2 | 2 |
  41202. * | FOGMODE_LINEAR | 3 |
  41203. */
  41204. set fogMode(value: number);
  41205. get fogMode(): number;
  41206. /**
  41207. * Gets or sets the fog color to use
  41208. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41209. * (Default is Color3(0.2, 0.2, 0.3))
  41210. */
  41211. fogColor: Color3;
  41212. /**
  41213. * Gets or sets the fog density to use
  41214. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41215. * (Default is 0.1)
  41216. */
  41217. fogDensity: number;
  41218. /**
  41219. * Gets or sets the fog start distance to use
  41220. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41221. * (Default is 0)
  41222. */
  41223. fogStart: number;
  41224. /**
  41225. * Gets or sets the fog end distance to use
  41226. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41227. * (Default is 1000)
  41228. */
  41229. fogEnd: number;
  41230. /**
  41231. * Flag indicating that the frame buffer binding is handled by another component
  41232. */
  41233. prePass: boolean;
  41234. private _shadowsEnabled;
  41235. /**
  41236. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41237. */
  41238. set shadowsEnabled(value: boolean);
  41239. get shadowsEnabled(): boolean;
  41240. private _lightsEnabled;
  41241. /**
  41242. * Gets or sets a boolean indicating if lights are enabled on this scene
  41243. */
  41244. set lightsEnabled(value: boolean);
  41245. get lightsEnabled(): boolean;
  41246. /** All of the active cameras added to this scene. */
  41247. activeCameras: Camera[];
  41248. /** @hidden */
  41249. _activeCamera: Nullable<Camera>;
  41250. /** Gets or sets the current active camera */
  41251. get activeCamera(): Nullable<Camera>;
  41252. set activeCamera(value: Nullable<Camera>);
  41253. private _defaultMaterial;
  41254. /** The default material used on meshes when no material is affected */
  41255. get defaultMaterial(): Material;
  41256. /** The default material used on meshes when no material is affected */
  41257. set defaultMaterial(value: Material);
  41258. private _texturesEnabled;
  41259. /**
  41260. * Gets or sets a boolean indicating if textures are enabled on this scene
  41261. */
  41262. set texturesEnabled(value: boolean);
  41263. get texturesEnabled(): boolean;
  41264. /**
  41265. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41266. */
  41267. physicsEnabled: boolean;
  41268. /**
  41269. * Gets or sets a boolean indicating if particles are enabled on this scene
  41270. */
  41271. particlesEnabled: boolean;
  41272. /**
  41273. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41274. */
  41275. spritesEnabled: boolean;
  41276. private _skeletonsEnabled;
  41277. /**
  41278. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41279. */
  41280. set skeletonsEnabled(value: boolean);
  41281. get skeletonsEnabled(): boolean;
  41282. /**
  41283. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41284. */
  41285. lensFlaresEnabled: boolean;
  41286. /**
  41287. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41288. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41289. */
  41290. collisionsEnabled: boolean;
  41291. private _collisionCoordinator;
  41292. /** @hidden */
  41293. get collisionCoordinator(): ICollisionCoordinator;
  41294. /**
  41295. * Defines the gravity applied to this scene (used only for collisions)
  41296. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41297. */
  41298. gravity: Vector3;
  41299. /**
  41300. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41301. */
  41302. postProcessesEnabled: boolean;
  41303. /**
  41304. * Gets the current postprocess manager
  41305. */
  41306. postProcessManager: PostProcessManager;
  41307. /**
  41308. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41309. */
  41310. renderTargetsEnabled: boolean;
  41311. /**
  41312. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41313. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41314. */
  41315. dumpNextRenderTargets: boolean;
  41316. /**
  41317. * The list of user defined render targets added to the scene
  41318. */
  41319. customRenderTargets: RenderTargetTexture[];
  41320. /**
  41321. * Defines if texture loading must be delayed
  41322. * If true, textures will only be loaded when they need to be rendered
  41323. */
  41324. useDelayedTextureLoading: boolean;
  41325. /**
  41326. * Gets the list of meshes imported to the scene through SceneLoader
  41327. */
  41328. importedMeshesFiles: String[];
  41329. /**
  41330. * Gets or sets a boolean indicating if probes are enabled on this scene
  41331. */
  41332. probesEnabled: boolean;
  41333. /**
  41334. * Gets or sets the current offline provider to use to store scene data
  41335. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41336. */
  41337. offlineProvider: IOfflineProvider;
  41338. /**
  41339. * Gets or sets the action manager associated with the scene
  41340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41341. */
  41342. actionManager: AbstractActionManager;
  41343. private _meshesForIntersections;
  41344. /**
  41345. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41346. */
  41347. proceduralTexturesEnabled: boolean;
  41348. private _engine;
  41349. private _totalVertices;
  41350. /** @hidden */
  41351. _activeIndices: PerfCounter;
  41352. /** @hidden */
  41353. _activeParticles: PerfCounter;
  41354. /** @hidden */
  41355. _activeBones: PerfCounter;
  41356. private _animationRatio;
  41357. /** @hidden */
  41358. _animationTimeLast: number;
  41359. /** @hidden */
  41360. _animationTime: number;
  41361. /**
  41362. * Gets or sets a general scale for animation speed
  41363. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41364. */
  41365. animationTimeScale: number;
  41366. /** @hidden */
  41367. _cachedMaterial: Nullable<Material>;
  41368. /** @hidden */
  41369. _cachedEffect: Nullable<Effect>;
  41370. /** @hidden */
  41371. _cachedVisibility: Nullable<number>;
  41372. private _renderId;
  41373. private _frameId;
  41374. private _executeWhenReadyTimeoutId;
  41375. private _intermediateRendering;
  41376. private _viewUpdateFlag;
  41377. private _projectionUpdateFlag;
  41378. /** @hidden */
  41379. _toBeDisposed: Nullable<IDisposable>[];
  41380. private _activeRequests;
  41381. /** @hidden */
  41382. _pendingData: any[];
  41383. private _isDisposed;
  41384. /**
  41385. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41386. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41387. */
  41388. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41389. private _activeMeshes;
  41390. private _processedMaterials;
  41391. private _renderTargets;
  41392. /** @hidden */
  41393. _activeParticleSystems: SmartArray<IParticleSystem>;
  41394. private _activeSkeletons;
  41395. private _softwareSkinnedMeshes;
  41396. private _renderingManager;
  41397. /** @hidden */
  41398. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41399. private _transformMatrix;
  41400. private _sceneUbo;
  41401. /** @hidden */
  41402. _viewMatrix: Matrix;
  41403. private _projectionMatrix;
  41404. /** @hidden */
  41405. _forcedViewPosition: Nullable<Vector3>;
  41406. /** @hidden */
  41407. _frustumPlanes: Plane[];
  41408. /**
  41409. * Gets the list of frustum planes (built from the active camera)
  41410. */
  41411. get frustumPlanes(): Plane[];
  41412. /**
  41413. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41414. * This is useful if there are more lights that the maximum simulteanous authorized
  41415. */
  41416. requireLightSorting: boolean;
  41417. /** @hidden */
  41418. readonly useMaterialMeshMap: boolean;
  41419. /** @hidden */
  41420. readonly useClonedMeshMap: boolean;
  41421. private _externalData;
  41422. private _uid;
  41423. /**
  41424. * @hidden
  41425. * Backing store of defined scene components.
  41426. */
  41427. _components: ISceneComponent[];
  41428. /**
  41429. * @hidden
  41430. * Backing store of defined scene components.
  41431. */
  41432. _serializableComponents: ISceneSerializableComponent[];
  41433. /**
  41434. * List of components to register on the next registration step.
  41435. */
  41436. private _transientComponents;
  41437. /**
  41438. * Registers the transient components if needed.
  41439. */
  41440. private _registerTransientComponents;
  41441. /**
  41442. * @hidden
  41443. * Add a component to the scene.
  41444. * Note that the ccomponent could be registered on th next frame if this is called after
  41445. * the register component stage.
  41446. * @param component Defines the component to add to the scene
  41447. */
  41448. _addComponent(component: ISceneComponent): void;
  41449. /**
  41450. * @hidden
  41451. * Gets a component from the scene.
  41452. * @param name defines the name of the component to retrieve
  41453. * @returns the component or null if not present
  41454. */
  41455. _getComponent(name: string): Nullable<ISceneComponent>;
  41456. /**
  41457. * @hidden
  41458. * Defines the actions happening before camera updates.
  41459. */
  41460. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41461. /**
  41462. * @hidden
  41463. * Defines the actions happening before clear the canvas.
  41464. */
  41465. _beforeClearStage: Stage<SimpleStageAction>;
  41466. /**
  41467. * @hidden
  41468. * Defines the actions when collecting render targets for the frame.
  41469. */
  41470. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41471. /**
  41472. * @hidden
  41473. * Defines the actions happening for one camera in the frame.
  41474. */
  41475. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41476. /**
  41477. * @hidden
  41478. * Defines the actions happening during the per mesh ready checks.
  41479. */
  41480. _isReadyForMeshStage: Stage<MeshStageAction>;
  41481. /**
  41482. * @hidden
  41483. * Defines the actions happening before evaluate active mesh checks.
  41484. */
  41485. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41486. /**
  41487. * @hidden
  41488. * Defines the actions happening during the evaluate sub mesh checks.
  41489. */
  41490. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41491. /**
  41492. * @hidden
  41493. * Defines the actions happening during the active mesh stage.
  41494. */
  41495. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41496. /**
  41497. * @hidden
  41498. * Defines the actions happening during the per camera render target step.
  41499. */
  41500. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41501. /**
  41502. * @hidden
  41503. * Defines the actions happening just before the active camera is drawing.
  41504. */
  41505. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41506. /**
  41507. * @hidden
  41508. * Defines the actions happening just before a render target is drawing.
  41509. */
  41510. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41511. /**
  41512. * @hidden
  41513. * Defines the actions happening just before a rendering group is drawing.
  41514. */
  41515. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41516. /**
  41517. * @hidden
  41518. * Defines the actions happening just before a mesh is drawing.
  41519. */
  41520. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41521. /**
  41522. * @hidden
  41523. * Defines the actions happening just after a mesh has been drawn.
  41524. */
  41525. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41526. /**
  41527. * @hidden
  41528. * Defines the actions happening just after a rendering group has been drawn.
  41529. */
  41530. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41531. /**
  41532. * @hidden
  41533. * Defines the actions happening just after the active camera has been drawn.
  41534. */
  41535. _afterCameraDrawStage: Stage<CameraStageAction>;
  41536. /**
  41537. * @hidden
  41538. * Defines the actions happening just after a render target has been drawn.
  41539. */
  41540. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41541. /**
  41542. * @hidden
  41543. * Defines the actions happening just after rendering all cameras and computing intersections.
  41544. */
  41545. _afterRenderStage: Stage<SimpleStageAction>;
  41546. /**
  41547. * @hidden
  41548. * Defines the actions happening when a pointer move event happens.
  41549. */
  41550. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41551. /**
  41552. * @hidden
  41553. * Defines the actions happening when a pointer down event happens.
  41554. */
  41555. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41556. /**
  41557. * @hidden
  41558. * Defines the actions happening when a pointer up event happens.
  41559. */
  41560. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41561. /**
  41562. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41563. */
  41564. private geometriesByUniqueId;
  41565. /**
  41566. * Creates a new Scene
  41567. * @param engine defines the engine to use to render this scene
  41568. * @param options defines the scene options
  41569. */
  41570. constructor(engine: Engine, options?: SceneOptions);
  41571. /**
  41572. * Gets a string identifying the name of the class
  41573. * @returns "Scene" string
  41574. */
  41575. getClassName(): string;
  41576. private _defaultMeshCandidates;
  41577. /**
  41578. * @hidden
  41579. */
  41580. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41581. private _defaultSubMeshCandidates;
  41582. /**
  41583. * @hidden
  41584. */
  41585. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41586. /**
  41587. * Sets the default candidate providers for the scene.
  41588. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41589. * and getCollidingSubMeshCandidates to their default function
  41590. */
  41591. setDefaultCandidateProviders(): void;
  41592. /**
  41593. * Gets the mesh that is currently under the pointer
  41594. */
  41595. get meshUnderPointer(): Nullable<AbstractMesh>;
  41596. /**
  41597. * Gets or sets the current on-screen X position of the pointer
  41598. */
  41599. get pointerX(): number;
  41600. set pointerX(value: number);
  41601. /**
  41602. * Gets or sets the current on-screen Y position of the pointer
  41603. */
  41604. get pointerY(): number;
  41605. set pointerY(value: number);
  41606. /**
  41607. * Gets the cached material (ie. the latest rendered one)
  41608. * @returns the cached material
  41609. */
  41610. getCachedMaterial(): Nullable<Material>;
  41611. /**
  41612. * Gets the cached effect (ie. the latest rendered one)
  41613. * @returns the cached effect
  41614. */
  41615. getCachedEffect(): Nullable<Effect>;
  41616. /**
  41617. * Gets the cached visibility state (ie. the latest rendered one)
  41618. * @returns the cached visibility state
  41619. */
  41620. getCachedVisibility(): Nullable<number>;
  41621. /**
  41622. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41623. * @param material defines the current material
  41624. * @param effect defines the current effect
  41625. * @param visibility defines the current visibility state
  41626. * @returns true if one parameter is not cached
  41627. */
  41628. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41629. /**
  41630. * Gets the engine associated with the scene
  41631. * @returns an Engine
  41632. */
  41633. getEngine(): Engine;
  41634. /**
  41635. * Gets the total number of vertices rendered per frame
  41636. * @returns the total number of vertices rendered per frame
  41637. */
  41638. getTotalVertices(): number;
  41639. /**
  41640. * Gets the performance counter for total vertices
  41641. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41642. */
  41643. get totalVerticesPerfCounter(): PerfCounter;
  41644. /**
  41645. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41646. * @returns the total number of active indices rendered per frame
  41647. */
  41648. getActiveIndices(): number;
  41649. /**
  41650. * Gets the performance counter for active indices
  41651. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41652. */
  41653. get totalActiveIndicesPerfCounter(): PerfCounter;
  41654. /**
  41655. * Gets the total number of active particles rendered per frame
  41656. * @returns the total number of active particles rendered per frame
  41657. */
  41658. getActiveParticles(): number;
  41659. /**
  41660. * Gets the performance counter for active particles
  41661. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41662. */
  41663. get activeParticlesPerfCounter(): PerfCounter;
  41664. /**
  41665. * Gets the total number of active bones rendered per frame
  41666. * @returns the total number of active bones rendered per frame
  41667. */
  41668. getActiveBones(): number;
  41669. /**
  41670. * Gets the performance counter for active bones
  41671. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41672. */
  41673. get activeBonesPerfCounter(): PerfCounter;
  41674. /**
  41675. * Gets the array of active meshes
  41676. * @returns an array of AbstractMesh
  41677. */
  41678. getActiveMeshes(): SmartArray<AbstractMesh>;
  41679. /**
  41680. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41681. * @returns a number
  41682. */
  41683. getAnimationRatio(): number;
  41684. /**
  41685. * Gets an unique Id for the current render phase
  41686. * @returns a number
  41687. */
  41688. getRenderId(): number;
  41689. /**
  41690. * Gets an unique Id for the current frame
  41691. * @returns a number
  41692. */
  41693. getFrameId(): number;
  41694. /** Call this function if you want to manually increment the render Id*/
  41695. incrementRenderId(): void;
  41696. private _createUbo;
  41697. /**
  41698. * Use this method to simulate a pointer move on a mesh
  41699. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41700. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41701. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41702. * @returns the current scene
  41703. */
  41704. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41705. /**
  41706. * Use this method to simulate a pointer down on a mesh
  41707. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41708. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41709. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41710. * @returns the current scene
  41711. */
  41712. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41713. /**
  41714. * Use this method to simulate a pointer up on a mesh
  41715. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41716. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41717. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41718. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41719. * @returns the current scene
  41720. */
  41721. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41722. /**
  41723. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41724. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41725. * @returns true if the pointer was captured
  41726. */
  41727. isPointerCaptured(pointerId?: number): boolean;
  41728. /**
  41729. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41730. * @param attachUp defines if you want to attach events to pointerup
  41731. * @param attachDown defines if you want to attach events to pointerdown
  41732. * @param attachMove defines if you want to attach events to pointermove
  41733. */
  41734. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41735. /** Detaches all event handlers*/
  41736. detachControl(): void;
  41737. /**
  41738. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41739. * Delay loaded resources are not taking in account
  41740. * @return true if all required resources are ready
  41741. */
  41742. isReady(): boolean;
  41743. /** Resets all cached information relative to material (including effect and visibility) */
  41744. resetCachedMaterial(): void;
  41745. /**
  41746. * Registers a function to be called before every frame render
  41747. * @param func defines the function to register
  41748. */
  41749. registerBeforeRender(func: () => void): void;
  41750. /**
  41751. * Unregisters a function called before every frame render
  41752. * @param func defines the function to unregister
  41753. */
  41754. unregisterBeforeRender(func: () => void): void;
  41755. /**
  41756. * Registers a function to be called after every frame render
  41757. * @param func defines the function to register
  41758. */
  41759. registerAfterRender(func: () => void): void;
  41760. /**
  41761. * Unregisters a function called after every frame render
  41762. * @param func defines the function to unregister
  41763. */
  41764. unregisterAfterRender(func: () => void): void;
  41765. private _executeOnceBeforeRender;
  41766. /**
  41767. * The provided function will run before render once and will be disposed afterwards.
  41768. * A timeout delay can be provided so that the function will be executed in N ms.
  41769. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41770. * @param func The function to be executed.
  41771. * @param timeout optional delay in ms
  41772. */
  41773. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41774. /** @hidden */
  41775. _addPendingData(data: any): void;
  41776. /** @hidden */
  41777. _removePendingData(data: any): void;
  41778. /**
  41779. * Returns the number of items waiting to be loaded
  41780. * @returns the number of items waiting to be loaded
  41781. */
  41782. getWaitingItemsCount(): number;
  41783. /**
  41784. * Returns a boolean indicating if the scene is still loading data
  41785. */
  41786. get isLoading(): boolean;
  41787. /**
  41788. * Registers a function to be executed when the scene is ready
  41789. * @param {Function} func - the function to be executed
  41790. */
  41791. executeWhenReady(func: () => void): void;
  41792. /**
  41793. * Returns a promise that resolves when the scene is ready
  41794. * @returns A promise that resolves when the scene is ready
  41795. */
  41796. whenReadyAsync(): Promise<void>;
  41797. /** @hidden */
  41798. _checkIsReady(): void;
  41799. /**
  41800. * Gets all animatable attached to the scene
  41801. */
  41802. get animatables(): Animatable[];
  41803. /**
  41804. * Resets the last animation time frame.
  41805. * Useful to override when animations start running when loading a scene for the first time.
  41806. */
  41807. resetLastAnimationTimeFrame(): void;
  41808. /**
  41809. * Gets the current view matrix
  41810. * @returns a Matrix
  41811. */
  41812. getViewMatrix(): Matrix;
  41813. /**
  41814. * Gets the current projection matrix
  41815. * @returns a Matrix
  41816. */
  41817. getProjectionMatrix(): Matrix;
  41818. /**
  41819. * Gets the current transform matrix
  41820. * @returns a Matrix made of View * Projection
  41821. */
  41822. getTransformMatrix(): Matrix;
  41823. /**
  41824. * Sets the current transform matrix
  41825. * @param viewL defines the View matrix to use
  41826. * @param projectionL defines the Projection matrix to use
  41827. * @param viewR defines the right View matrix to use (if provided)
  41828. * @param projectionR defines the right Projection matrix to use (if provided)
  41829. */
  41830. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41831. /**
  41832. * Gets the uniform buffer used to store scene data
  41833. * @returns a UniformBuffer
  41834. */
  41835. getSceneUniformBuffer(): UniformBuffer;
  41836. /**
  41837. * Gets an unique (relatively to the current scene) Id
  41838. * @returns an unique number for the scene
  41839. */
  41840. getUniqueId(): number;
  41841. /**
  41842. * Add a mesh to the list of scene's meshes
  41843. * @param newMesh defines the mesh to add
  41844. * @param recursive if all child meshes should also be added to the scene
  41845. */
  41846. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41847. /**
  41848. * Remove a mesh for the list of scene's meshes
  41849. * @param toRemove defines the mesh to remove
  41850. * @param recursive if all child meshes should also be removed from the scene
  41851. * @returns the index where the mesh was in the mesh list
  41852. */
  41853. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41854. /**
  41855. * Add a transform node to the list of scene's transform nodes
  41856. * @param newTransformNode defines the transform node to add
  41857. */
  41858. addTransformNode(newTransformNode: TransformNode): void;
  41859. /**
  41860. * Remove a transform node for the list of scene's transform nodes
  41861. * @param toRemove defines the transform node to remove
  41862. * @returns the index where the transform node was in the transform node list
  41863. */
  41864. removeTransformNode(toRemove: TransformNode): number;
  41865. /**
  41866. * Remove a skeleton for the list of scene's skeletons
  41867. * @param toRemove defines the skeleton to remove
  41868. * @returns the index where the skeleton was in the skeleton list
  41869. */
  41870. removeSkeleton(toRemove: Skeleton): number;
  41871. /**
  41872. * Remove a morph target for the list of scene's morph targets
  41873. * @param toRemove defines the morph target to remove
  41874. * @returns the index where the morph target was in the morph target list
  41875. */
  41876. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41877. /**
  41878. * Remove a light for the list of scene's lights
  41879. * @param toRemove defines the light to remove
  41880. * @returns the index where the light was in the light list
  41881. */
  41882. removeLight(toRemove: Light): number;
  41883. /**
  41884. * Remove a camera for the list of scene's cameras
  41885. * @param toRemove defines the camera to remove
  41886. * @returns the index where the camera was in the camera list
  41887. */
  41888. removeCamera(toRemove: Camera): number;
  41889. /**
  41890. * Remove a particle system for the list of scene's particle systems
  41891. * @param toRemove defines the particle system to remove
  41892. * @returns the index where the particle system was in the particle system list
  41893. */
  41894. removeParticleSystem(toRemove: IParticleSystem): number;
  41895. /**
  41896. * Remove a animation for the list of scene's animations
  41897. * @param toRemove defines the animation to remove
  41898. * @returns the index where the animation was in the animation list
  41899. */
  41900. removeAnimation(toRemove: Animation): number;
  41901. /**
  41902. * Will stop the animation of the given target
  41903. * @param target - the target
  41904. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41905. * @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)
  41906. */
  41907. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41908. /**
  41909. * Removes the given animation group from this scene.
  41910. * @param toRemove The animation group to remove
  41911. * @returns The index of the removed animation group
  41912. */
  41913. removeAnimationGroup(toRemove: AnimationGroup): number;
  41914. /**
  41915. * Removes the given multi-material from this scene.
  41916. * @param toRemove The multi-material to remove
  41917. * @returns The index of the removed multi-material
  41918. */
  41919. removeMultiMaterial(toRemove: MultiMaterial): number;
  41920. /**
  41921. * Removes the given material from this scene.
  41922. * @param toRemove The material to remove
  41923. * @returns The index of the removed material
  41924. */
  41925. removeMaterial(toRemove: Material): number;
  41926. /**
  41927. * Removes the given action manager from this scene.
  41928. * @param toRemove The action manager to remove
  41929. * @returns The index of the removed action manager
  41930. */
  41931. removeActionManager(toRemove: AbstractActionManager): number;
  41932. /**
  41933. * Removes the given texture from this scene.
  41934. * @param toRemove The texture to remove
  41935. * @returns The index of the removed texture
  41936. */
  41937. removeTexture(toRemove: BaseTexture): number;
  41938. /**
  41939. * Adds the given light to this scene
  41940. * @param newLight The light to add
  41941. */
  41942. addLight(newLight: Light): void;
  41943. /**
  41944. * Sorts the list list based on light priorities
  41945. */
  41946. sortLightsByPriority(): void;
  41947. /**
  41948. * Adds the given camera to this scene
  41949. * @param newCamera The camera to add
  41950. */
  41951. addCamera(newCamera: Camera): void;
  41952. /**
  41953. * Adds the given skeleton to this scene
  41954. * @param newSkeleton The skeleton to add
  41955. */
  41956. addSkeleton(newSkeleton: Skeleton): void;
  41957. /**
  41958. * Adds the given particle system to this scene
  41959. * @param newParticleSystem The particle system to add
  41960. */
  41961. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41962. /**
  41963. * Adds the given animation to this scene
  41964. * @param newAnimation The animation to add
  41965. */
  41966. addAnimation(newAnimation: Animation): void;
  41967. /**
  41968. * Adds the given animation group to this scene.
  41969. * @param newAnimationGroup The animation group to add
  41970. */
  41971. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41972. /**
  41973. * Adds the given multi-material to this scene
  41974. * @param newMultiMaterial The multi-material to add
  41975. */
  41976. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41977. /**
  41978. * Adds the given material to this scene
  41979. * @param newMaterial The material to add
  41980. */
  41981. addMaterial(newMaterial: Material): void;
  41982. /**
  41983. * Adds the given morph target to this scene
  41984. * @param newMorphTargetManager The morph target to add
  41985. */
  41986. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41987. /**
  41988. * Adds the given geometry to this scene
  41989. * @param newGeometry The geometry to add
  41990. */
  41991. addGeometry(newGeometry: Geometry): void;
  41992. /**
  41993. * Adds the given action manager to this scene
  41994. * @param newActionManager The action manager to add
  41995. */
  41996. addActionManager(newActionManager: AbstractActionManager): void;
  41997. /**
  41998. * Adds the given texture to this scene.
  41999. * @param newTexture The texture to add
  42000. */
  42001. addTexture(newTexture: BaseTexture): void;
  42002. /**
  42003. * Switch active camera
  42004. * @param newCamera defines the new active camera
  42005. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42006. */
  42007. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42008. /**
  42009. * sets the active camera of the scene using its ID
  42010. * @param id defines the camera's ID
  42011. * @return the new active camera or null if none found.
  42012. */
  42013. setActiveCameraByID(id: string): Nullable<Camera>;
  42014. /**
  42015. * sets the active camera of the scene using its name
  42016. * @param name defines the camera's name
  42017. * @returns the new active camera or null if none found.
  42018. */
  42019. setActiveCameraByName(name: string): Nullable<Camera>;
  42020. /**
  42021. * get an animation group using its name
  42022. * @param name defines the material's name
  42023. * @return the animation group or null if none found.
  42024. */
  42025. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42026. /**
  42027. * Get a material using its unique id
  42028. * @param uniqueId defines the material's unique id
  42029. * @return the material or null if none found.
  42030. */
  42031. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42032. /**
  42033. * get a material using its id
  42034. * @param id defines the material's ID
  42035. * @return the material or null if none found.
  42036. */
  42037. getMaterialByID(id: string): Nullable<Material>;
  42038. /**
  42039. * Gets a the last added material using a given id
  42040. * @param id defines the material's ID
  42041. * @return the last material with the given id or null if none found.
  42042. */
  42043. getLastMaterialByID(id: string): Nullable<Material>;
  42044. /**
  42045. * Gets a material using its name
  42046. * @param name defines the material's name
  42047. * @return the material or null if none found.
  42048. */
  42049. getMaterialByName(name: string): Nullable<Material>;
  42050. /**
  42051. * Get a texture using its unique id
  42052. * @param uniqueId defines the texture's unique id
  42053. * @return the texture or null if none found.
  42054. */
  42055. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42056. /**
  42057. * Gets a camera using its id
  42058. * @param id defines the id to look for
  42059. * @returns the camera or null if not found
  42060. */
  42061. getCameraByID(id: string): Nullable<Camera>;
  42062. /**
  42063. * Gets a camera using its unique id
  42064. * @param uniqueId defines the unique id to look for
  42065. * @returns the camera or null if not found
  42066. */
  42067. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42068. /**
  42069. * Gets a camera using its name
  42070. * @param name defines the camera's name
  42071. * @return the camera or null if none found.
  42072. */
  42073. getCameraByName(name: string): Nullable<Camera>;
  42074. /**
  42075. * Gets a bone using its id
  42076. * @param id defines the bone's id
  42077. * @return the bone or null if not found
  42078. */
  42079. getBoneByID(id: string): Nullable<Bone>;
  42080. /**
  42081. * Gets a bone using its id
  42082. * @param name defines the bone's name
  42083. * @return the bone or null if not found
  42084. */
  42085. getBoneByName(name: string): Nullable<Bone>;
  42086. /**
  42087. * Gets a light node using its name
  42088. * @param name defines the the light's name
  42089. * @return the light or null if none found.
  42090. */
  42091. getLightByName(name: string): Nullable<Light>;
  42092. /**
  42093. * Gets a light node using its id
  42094. * @param id defines the light's id
  42095. * @return the light or null if none found.
  42096. */
  42097. getLightByID(id: string): Nullable<Light>;
  42098. /**
  42099. * Gets a light node using its scene-generated unique ID
  42100. * @param uniqueId defines the light's unique id
  42101. * @return the light or null if none found.
  42102. */
  42103. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42104. /**
  42105. * Gets a particle system by id
  42106. * @param id defines the particle system id
  42107. * @return the corresponding system or null if none found
  42108. */
  42109. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42110. /**
  42111. * Gets a geometry using its ID
  42112. * @param id defines the geometry's id
  42113. * @return the geometry or null if none found.
  42114. */
  42115. getGeometryByID(id: string): Nullable<Geometry>;
  42116. private _getGeometryByUniqueID;
  42117. /**
  42118. * Add a new geometry to this scene
  42119. * @param geometry defines the geometry to be added to the scene.
  42120. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42121. * @return a boolean defining if the geometry was added or not
  42122. */
  42123. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42124. /**
  42125. * Removes an existing geometry
  42126. * @param geometry defines the geometry to be removed from the scene
  42127. * @return a boolean defining if the geometry was removed or not
  42128. */
  42129. removeGeometry(geometry: Geometry): boolean;
  42130. /**
  42131. * Gets the list of geometries attached to the scene
  42132. * @returns an array of Geometry
  42133. */
  42134. getGeometries(): Geometry[];
  42135. /**
  42136. * Gets the first added mesh found of a given ID
  42137. * @param id defines the id to search for
  42138. * @return the mesh found or null if not found at all
  42139. */
  42140. getMeshByID(id: string): Nullable<AbstractMesh>;
  42141. /**
  42142. * Gets a list of meshes using their id
  42143. * @param id defines the id to search for
  42144. * @returns a list of meshes
  42145. */
  42146. getMeshesByID(id: string): Array<AbstractMesh>;
  42147. /**
  42148. * Gets the first added transform node found of a given ID
  42149. * @param id defines the id to search for
  42150. * @return the found transform node or null if not found at all.
  42151. */
  42152. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42153. /**
  42154. * Gets a transform node with its auto-generated unique id
  42155. * @param uniqueId efines the unique id to search for
  42156. * @return the found transform node or null if not found at all.
  42157. */
  42158. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42159. /**
  42160. * Gets a list of transform nodes using their id
  42161. * @param id defines the id to search for
  42162. * @returns a list of transform nodes
  42163. */
  42164. getTransformNodesByID(id: string): Array<TransformNode>;
  42165. /**
  42166. * Gets a mesh with its auto-generated unique id
  42167. * @param uniqueId defines the unique id to search for
  42168. * @return the found mesh or null if not found at all.
  42169. */
  42170. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42171. /**
  42172. * Gets a the last added mesh using a given id
  42173. * @param id defines the id to search for
  42174. * @return the found mesh or null if not found at all.
  42175. */
  42176. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42177. /**
  42178. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42179. * @param id defines the id to search for
  42180. * @return the found node or null if not found at all
  42181. */
  42182. getLastEntryByID(id: string): Nullable<Node>;
  42183. /**
  42184. * Gets a node (Mesh, Camera, Light) using a given id
  42185. * @param id defines the id to search for
  42186. * @return the found node or null if not found at all
  42187. */
  42188. getNodeByID(id: string): Nullable<Node>;
  42189. /**
  42190. * Gets a node (Mesh, Camera, Light) using a given name
  42191. * @param name defines the name to search for
  42192. * @return the found node or null if not found at all.
  42193. */
  42194. getNodeByName(name: string): Nullable<Node>;
  42195. /**
  42196. * Gets a mesh using a given name
  42197. * @param name defines the name to search for
  42198. * @return the found mesh or null if not found at all.
  42199. */
  42200. getMeshByName(name: string): Nullable<AbstractMesh>;
  42201. /**
  42202. * Gets a transform node using a given name
  42203. * @param name defines the name to search for
  42204. * @return the found transform node or null if not found at all.
  42205. */
  42206. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42207. /**
  42208. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42209. * @param id defines the id to search for
  42210. * @return the found skeleton or null if not found at all.
  42211. */
  42212. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42213. /**
  42214. * Gets a skeleton using a given auto generated unique id
  42215. * @param uniqueId defines the unique id to search for
  42216. * @return the found skeleton or null if not found at all.
  42217. */
  42218. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42219. /**
  42220. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42221. * @param id defines the id to search for
  42222. * @return the found skeleton or null if not found at all.
  42223. */
  42224. getSkeletonById(id: string): Nullable<Skeleton>;
  42225. /**
  42226. * Gets a skeleton using a given name
  42227. * @param name defines the name to search for
  42228. * @return the found skeleton or null if not found at all.
  42229. */
  42230. getSkeletonByName(name: string): Nullable<Skeleton>;
  42231. /**
  42232. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42233. * @param id defines the id to search for
  42234. * @return the found morph target manager or null if not found at all.
  42235. */
  42236. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42237. /**
  42238. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42239. * @param id defines the id to search for
  42240. * @return the found morph target or null if not found at all.
  42241. */
  42242. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42243. /**
  42244. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42245. * @param name defines the name to search for
  42246. * @return the found morph target or null if not found at all.
  42247. */
  42248. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42249. /**
  42250. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42251. * @param name defines the name to search for
  42252. * @return the found post process or null if not found at all.
  42253. */
  42254. getPostProcessByName(name: string): Nullable<PostProcess>;
  42255. /**
  42256. * Gets a boolean indicating if the given mesh is active
  42257. * @param mesh defines the mesh to look for
  42258. * @returns true if the mesh is in the active list
  42259. */
  42260. isActiveMesh(mesh: AbstractMesh): boolean;
  42261. /**
  42262. * Return a unique id as a string which can serve as an identifier for the scene
  42263. */
  42264. get uid(): string;
  42265. /**
  42266. * Add an externaly attached data from its key.
  42267. * This method call will fail and return false, if such key already exists.
  42268. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42269. * @param key the unique key that identifies the data
  42270. * @param data the data object to associate to the key for this Engine instance
  42271. * @return true if no such key were already present and the data was added successfully, false otherwise
  42272. */
  42273. addExternalData<T>(key: string, data: T): boolean;
  42274. /**
  42275. * Get an externaly attached data from its key
  42276. * @param key the unique key that identifies the data
  42277. * @return the associated data, if present (can be null), or undefined if not present
  42278. */
  42279. getExternalData<T>(key: string): Nullable<T>;
  42280. /**
  42281. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42282. * @param key the unique key that identifies the data
  42283. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42284. * @return the associated data, can be null if the factory returned null.
  42285. */
  42286. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42287. /**
  42288. * Remove an externaly attached data from the Engine instance
  42289. * @param key the unique key that identifies the data
  42290. * @return true if the data was successfully removed, false if it doesn't exist
  42291. */
  42292. removeExternalData(key: string): boolean;
  42293. private _evaluateSubMesh;
  42294. /**
  42295. * Clear the processed materials smart array preventing retention point in material dispose.
  42296. */
  42297. freeProcessedMaterials(): void;
  42298. private _preventFreeActiveMeshesAndRenderingGroups;
  42299. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42300. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42301. * when disposing several meshes in a row or a hierarchy of meshes.
  42302. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42303. */
  42304. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42305. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42306. /**
  42307. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42308. */
  42309. freeActiveMeshes(): void;
  42310. /**
  42311. * Clear the info related to rendering groups preventing retention points during dispose.
  42312. */
  42313. freeRenderingGroups(): void;
  42314. /** @hidden */
  42315. _isInIntermediateRendering(): boolean;
  42316. /**
  42317. * Lambda returning the list of potentially active meshes.
  42318. */
  42319. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42320. /**
  42321. * Lambda returning the list of potentially active sub meshes.
  42322. */
  42323. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42324. /**
  42325. * Lambda returning the list of potentially intersecting sub meshes.
  42326. */
  42327. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42328. /**
  42329. * Lambda returning the list of potentially colliding sub meshes.
  42330. */
  42331. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42332. private _activeMeshesFrozen;
  42333. private _skipEvaluateActiveMeshesCompletely;
  42334. /**
  42335. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42336. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42337. * @returns the current scene
  42338. */
  42339. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42340. /**
  42341. * Use this function to restart evaluating active meshes on every frame
  42342. * @returns the current scene
  42343. */
  42344. unfreezeActiveMeshes(): Scene;
  42345. private _evaluateActiveMeshes;
  42346. private _activeMesh;
  42347. /**
  42348. * Update the transform matrix to update from the current active camera
  42349. * @param force defines a boolean used to force the update even if cache is up to date
  42350. */
  42351. updateTransformMatrix(force?: boolean): void;
  42352. private _bindFrameBuffer;
  42353. /** @hidden */
  42354. _allowPostProcessClearColor: boolean;
  42355. /** @hidden */
  42356. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42357. private _processSubCameras;
  42358. private _checkIntersections;
  42359. /** @hidden */
  42360. _advancePhysicsEngineStep(step: number): void;
  42361. /**
  42362. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42363. */
  42364. getDeterministicFrameTime: () => number;
  42365. /** @hidden */
  42366. _animate(): void;
  42367. /** Execute all animations (for a frame) */
  42368. animate(): void;
  42369. /**
  42370. * Render the scene
  42371. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42372. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42373. */
  42374. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42375. /**
  42376. * Freeze all materials
  42377. * A frozen material will not be updatable but should be faster to render
  42378. */
  42379. freezeMaterials(): void;
  42380. /**
  42381. * Unfreeze all materials
  42382. * A frozen material will not be updatable but should be faster to render
  42383. */
  42384. unfreezeMaterials(): void;
  42385. /**
  42386. * Releases all held ressources
  42387. */
  42388. dispose(): void;
  42389. /**
  42390. * Gets if the scene is already disposed
  42391. */
  42392. get isDisposed(): boolean;
  42393. /**
  42394. * Call this function to reduce memory footprint of the scene.
  42395. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42396. */
  42397. clearCachedVertexData(): void;
  42398. /**
  42399. * This function will remove the local cached buffer data from texture.
  42400. * It will save memory but will prevent the texture from being rebuilt
  42401. */
  42402. cleanCachedTextureBuffer(): void;
  42403. /**
  42404. * Get the world extend vectors with an optional filter
  42405. *
  42406. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42407. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42408. */
  42409. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42410. min: Vector3;
  42411. max: Vector3;
  42412. };
  42413. /**
  42414. * Creates a ray that can be used to pick in the scene
  42415. * @param x defines the x coordinate of the origin (on-screen)
  42416. * @param y defines the y coordinate of the origin (on-screen)
  42417. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42418. * @param camera defines the camera to use for the picking
  42419. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42420. * @returns a Ray
  42421. */
  42422. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42423. /**
  42424. * Creates a ray that can be used to pick in the scene
  42425. * @param x defines the x coordinate of the origin (on-screen)
  42426. * @param y defines the y coordinate of the origin (on-screen)
  42427. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42428. * @param result defines the ray where to store the picking ray
  42429. * @param camera defines the camera to use for the picking
  42430. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42431. * @returns the current scene
  42432. */
  42433. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42434. /**
  42435. * Creates a ray that can be used to pick in the scene
  42436. * @param x defines the x coordinate of the origin (on-screen)
  42437. * @param y defines the y coordinate of the origin (on-screen)
  42438. * @param camera defines the camera to use for the picking
  42439. * @returns a Ray
  42440. */
  42441. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42442. /**
  42443. * Creates a ray that can be used to pick in the scene
  42444. * @param x defines the x coordinate of the origin (on-screen)
  42445. * @param y defines the y coordinate of the origin (on-screen)
  42446. * @param result defines the ray where to store the picking ray
  42447. * @param camera defines the camera to use for the picking
  42448. * @returns the current scene
  42449. */
  42450. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42451. /** Launch a ray to try to pick a mesh in the scene
  42452. * @param x position on screen
  42453. * @param y position on screen
  42454. * @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
  42455. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42456. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42458. * @returns a PickingInfo
  42459. */
  42460. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42461. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42462. * @param x position on screen
  42463. * @param y position on screen
  42464. * @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
  42465. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42466. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42467. * @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)
  42468. */
  42469. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42470. /** Use the given ray to pick a mesh in the scene
  42471. * @param ray The ray to use to pick meshes
  42472. * @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
  42473. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42475. * @returns a PickingInfo
  42476. */
  42477. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42478. /**
  42479. * Launch a ray to try to pick a mesh in the scene
  42480. * @param x X position on screen
  42481. * @param y Y position on screen
  42482. * @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
  42483. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42485. * @returns an array of PickingInfo
  42486. */
  42487. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42488. /**
  42489. * Launch a ray to try to pick a mesh in the scene
  42490. * @param ray Ray to use
  42491. * @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
  42492. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42493. * @returns an array of PickingInfo
  42494. */
  42495. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42496. /**
  42497. * Force the value of meshUnderPointer
  42498. * @param mesh defines the mesh to use
  42499. * @param pointerId optional pointer id when using more than one pointer
  42500. */
  42501. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42502. /**
  42503. * Gets the mesh under the pointer
  42504. * @returns a Mesh or null if no mesh is under the pointer
  42505. */
  42506. getPointerOverMesh(): Nullable<AbstractMesh>;
  42507. /** @hidden */
  42508. _rebuildGeometries(): void;
  42509. /** @hidden */
  42510. _rebuildTextures(): void;
  42511. private _getByTags;
  42512. /**
  42513. * Get a list of meshes by tags
  42514. * @param tagsQuery defines the tags query to use
  42515. * @param forEach defines a predicate used to filter results
  42516. * @returns an array of Mesh
  42517. */
  42518. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42519. /**
  42520. * Get a list of cameras by tags
  42521. * @param tagsQuery defines the tags query to use
  42522. * @param forEach defines a predicate used to filter results
  42523. * @returns an array of Camera
  42524. */
  42525. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42526. /**
  42527. * Get a list of lights by tags
  42528. * @param tagsQuery defines the tags query to use
  42529. * @param forEach defines a predicate used to filter results
  42530. * @returns an array of Light
  42531. */
  42532. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42533. /**
  42534. * Get a list of materials by tags
  42535. * @param tagsQuery defines the tags query to use
  42536. * @param forEach defines a predicate used to filter results
  42537. * @returns an array of Material
  42538. */
  42539. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42540. /**
  42541. * Get a list of transform nodes by tags
  42542. * @param tagsQuery defines the tags query to use
  42543. * @param forEach defines a predicate used to filter results
  42544. * @returns an array of TransformNode
  42545. */
  42546. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42547. /**
  42548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42549. * This allowed control for front to back rendering or reversly depending of the special needs.
  42550. *
  42551. * @param renderingGroupId The rendering group id corresponding to its index
  42552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42555. */
  42556. 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;
  42557. /**
  42558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42559. *
  42560. * @param renderingGroupId The rendering group id corresponding to its index
  42561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42562. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42563. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42564. */
  42565. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42566. /**
  42567. * Gets the current auto clear configuration for one rendering group of the rendering
  42568. * manager.
  42569. * @param index the rendering group index to get the information for
  42570. * @returns The auto clear setup for the requested rendering group
  42571. */
  42572. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42573. private _blockMaterialDirtyMechanism;
  42574. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42575. get blockMaterialDirtyMechanism(): boolean;
  42576. set blockMaterialDirtyMechanism(value: boolean);
  42577. /**
  42578. * Will flag all materials as dirty to trigger new shader compilation
  42579. * @param flag defines the flag used to specify which material part must be marked as dirty
  42580. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42581. */
  42582. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42583. /** @hidden */
  42584. _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;
  42585. /** @hidden */
  42586. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42587. /** @hidden */
  42588. _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;
  42589. /** @hidden */
  42590. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42591. /** @hidden */
  42592. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42593. /** @hidden */
  42594. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42595. }
  42596. }
  42597. declare module "babylonjs/assetContainer" {
  42598. import { AbstractScene } from "babylonjs/abstractScene";
  42599. import { Scene } from "babylonjs/scene";
  42600. import { Mesh } from "babylonjs/Meshes/mesh";
  42601. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42602. import { Skeleton } from "babylonjs/Bones/skeleton";
  42603. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42604. import { Animatable } from "babylonjs/Animations/animatable";
  42605. import { Nullable } from "babylonjs/types";
  42606. import { Node } from "babylonjs/node";
  42607. /**
  42608. * Set of assets to keep when moving a scene into an asset container.
  42609. */
  42610. export class KeepAssets extends AbstractScene {
  42611. }
  42612. /**
  42613. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42614. */
  42615. export class InstantiatedEntries {
  42616. /**
  42617. * List of new root nodes (eg. nodes with no parent)
  42618. */
  42619. rootNodes: TransformNode[];
  42620. /**
  42621. * List of new skeletons
  42622. */
  42623. skeletons: Skeleton[];
  42624. /**
  42625. * List of new animation groups
  42626. */
  42627. animationGroups: AnimationGroup[];
  42628. }
  42629. /**
  42630. * Container with a set of assets that can be added or removed from a scene.
  42631. */
  42632. export class AssetContainer extends AbstractScene {
  42633. private _wasAddedToScene;
  42634. /**
  42635. * The scene the AssetContainer belongs to.
  42636. */
  42637. scene: Scene;
  42638. /**
  42639. * Instantiates an AssetContainer.
  42640. * @param scene The scene the AssetContainer belongs to.
  42641. */
  42642. constructor(scene: Scene);
  42643. /**
  42644. * Instantiate or clone all meshes and add the new ones to the scene.
  42645. * Skeletons and animation groups will all be cloned
  42646. * @param nameFunction defines an optional function used to get new names for clones
  42647. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42648. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42649. */
  42650. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42651. /**
  42652. * Adds all the assets from the container to the scene.
  42653. */
  42654. addAllToScene(): void;
  42655. /**
  42656. * Removes all the assets in the container from the scene
  42657. */
  42658. removeAllFromScene(): void;
  42659. /**
  42660. * Disposes all the assets in the container
  42661. */
  42662. dispose(): void;
  42663. private _moveAssets;
  42664. /**
  42665. * Removes all the assets contained in the scene and adds them to the container.
  42666. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42667. */
  42668. moveAllFromScene(keepAssets?: KeepAssets): void;
  42669. /**
  42670. * 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.
  42671. * @returns the root mesh
  42672. */
  42673. createRootMesh(): Mesh;
  42674. /**
  42675. * Merge animations (direct and animation groups) from this asset container into a scene
  42676. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42677. * @param animatables set of animatables to retarget to a node from the scene
  42678. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42679. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42680. */
  42681. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42682. }
  42683. }
  42684. declare module "babylonjs/abstractScene" {
  42685. import { Scene } from "babylonjs/scene";
  42686. import { Nullable } from "babylonjs/types";
  42687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42688. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42689. import { Geometry } from "babylonjs/Meshes/geometry";
  42690. import { Skeleton } from "babylonjs/Bones/skeleton";
  42691. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42692. import { AssetContainer } from "babylonjs/assetContainer";
  42693. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42694. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42696. import { Material } from "babylonjs/Materials/material";
  42697. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42698. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42699. import { Camera } from "babylonjs/Cameras/camera";
  42700. import { Light } from "babylonjs/Lights/light";
  42701. import { Node } from "babylonjs/node";
  42702. import { Animation } from "babylonjs/Animations/animation";
  42703. /**
  42704. * Defines how the parser contract is defined.
  42705. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42706. */
  42707. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42708. /**
  42709. * Defines how the individual parser contract is defined.
  42710. * These parser can parse an individual asset
  42711. */
  42712. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42713. /**
  42714. * Base class of the scene acting as a container for the different elements composing a scene.
  42715. * This class is dynamically extended by the different components of the scene increasing
  42716. * flexibility and reducing coupling
  42717. */
  42718. export abstract class AbstractScene {
  42719. /**
  42720. * Stores the list of available parsers in the application.
  42721. */
  42722. private static _BabylonFileParsers;
  42723. /**
  42724. * Stores the list of available individual parsers in the application.
  42725. */
  42726. private static _IndividualBabylonFileParsers;
  42727. /**
  42728. * Adds a parser in the list of available ones
  42729. * @param name Defines the name of the parser
  42730. * @param parser Defines the parser to add
  42731. */
  42732. static AddParser(name: string, parser: BabylonFileParser): void;
  42733. /**
  42734. * Gets a general parser from the list of avaialble ones
  42735. * @param name Defines the name of the parser
  42736. * @returns the requested parser or null
  42737. */
  42738. static GetParser(name: string): Nullable<BabylonFileParser>;
  42739. /**
  42740. * Adds n individual parser in the list of available ones
  42741. * @param name Defines the name of the parser
  42742. * @param parser Defines the parser to add
  42743. */
  42744. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42745. /**
  42746. * Gets an individual parser from the list of avaialble ones
  42747. * @param name Defines the name of the parser
  42748. * @returns the requested parser or null
  42749. */
  42750. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42751. /**
  42752. * Parser json data and populate both a scene and its associated container object
  42753. * @param jsonData Defines the data to parse
  42754. * @param scene Defines the scene to parse the data for
  42755. * @param container Defines the container attached to the parsing sequence
  42756. * @param rootUrl Defines the root url of the data
  42757. */
  42758. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42759. /**
  42760. * Gets the list of root nodes (ie. nodes with no parent)
  42761. */
  42762. rootNodes: Node[];
  42763. /** All of the cameras added to this scene
  42764. * @see https://doc.babylonjs.com/babylon101/cameras
  42765. */
  42766. cameras: Camera[];
  42767. /**
  42768. * All of the lights added to this scene
  42769. * @see https://doc.babylonjs.com/babylon101/lights
  42770. */
  42771. lights: Light[];
  42772. /**
  42773. * All of the (abstract) meshes added to this scene
  42774. */
  42775. meshes: AbstractMesh[];
  42776. /**
  42777. * The list of skeletons added to the scene
  42778. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42779. */
  42780. skeletons: Skeleton[];
  42781. /**
  42782. * All of the particle systems added to this scene
  42783. * @see https://doc.babylonjs.com/babylon101/particles
  42784. */
  42785. particleSystems: IParticleSystem[];
  42786. /**
  42787. * Gets a list of Animations associated with the scene
  42788. */
  42789. animations: Animation[];
  42790. /**
  42791. * All of the animation groups added to this scene
  42792. * @see https://doc.babylonjs.com/how_to/group
  42793. */
  42794. animationGroups: AnimationGroup[];
  42795. /**
  42796. * All of the multi-materials added to this scene
  42797. * @see https://doc.babylonjs.com/how_to/multi_materials
  42798. */
  42799. multiMaterials: MultiMaterial[];
  42800. /**
  42801. * All of the materials added to this scene
  42802. * In the context of a Scene, it is not supposed to be modified manually.
  42803. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42804. * Note also that the order of the Material within the array is not significant and might change.
  42805. * @see https://doc.babylonjs.com/babylon101/materials
  42806. */
  42807. materials: Material[];
  42808. /**
  42809. * The list of morph target managers added to the scene
  42810. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42811. */
  42812. morphTargetManagers: MorphTargetManager[];
  42813. /**
  42814. * The list of geometries used in the scene.
  42815. */
  42816. geometries: Geometry[];
  42817. /**
  42818. * All of the tranform nodes added to this scene
  42819. * In the context of a Scene, it is not supposed to be modified manually.
  42820. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42821. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42822. * @see https://doc.babylonjs.com/how_to/transformnode
  42823. */
  42824. transformNodes: TransformNode[];
  42825. /**
  42826. * ActionManagers available on the scene.
  42827. */
  42828. actionManagers: AbstractActionManager[];
  42829. /**
  42830. * Textures to keep.
  42831. */
  42832. textures: BaseTexture[];
  42833. /** @hidden */
  42834. protected _environmentTexture: Nullable<BaseTexture>;
  42835. /**
  42836. * Texture used in all pbr material as the reflection texture.
  42837. * As in the majority of the scene they are the same (exception for multi room and so on),
  42838. * this is easier to reference from here than from all the materials.
  42839. */
  42840. get environmentTexture(): Nullable<BaseTexture>;
  42841. set environmentTexture(value: Nullable<BaseTexture>);
  42842. /**
  42843. * The list of postprocesses added to the scene
  42844. */
  42845. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42846. /**
  42847. * @returns all meshes, lights, cameras, transformNodes and bones
  42848. */
  42849. getNodes(): Array<Node>;
  42850. }
  42851. }
  42852. declare module "babylonjs/Audio/sound" {
  42853. import { Observable } from "babylonjs/Misc/observable";
  42854. import { Vector3 } from "babylonjs/Maths/math.vector";
  42855. import { Nullable } from "babylonjs/types";
  42856. import { Scene } from "babylonjs/scene";
  42857. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42858. /**
  42859. * Interface used to define options for Sound class
  42860. */
  42861. export interface ISoundOptions {
  42862. /**
  42863. * Does the sound autoplay once loaded.
  42864. */
  42865. autoplay?: boolean;
  42866. /**
  42867. * Does the sound loop after it finishes playing once.
  42868. */
  42869. loop?: boolean;
  42870. /**
  42871. * Sound's volume
  42872. */
  42873. volume?: number;
  42874. /**
  42875. * Is it a spatial sound?
  42876. */
  42877. spatialSound?: boolean;
  42878. /**
  42879. * Maximum distance to hear that sound
  42880. */
  42881. maxDistance?: number;
  42882. /**
  42883. * Uses user defined attenuation function
  42884. */
  42885. useCustomAttenuation?: boolean;
  42886. /**
  42887. * Define the roll off factor of spatial sounds.
  42888. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42889. */
  42890. rolloffFactor?: number;
  42891. /**
  42892. * Define the reference distance the sound should be heard perfectly.
  42893. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42894. */
  42895. refDistance?: number;
  42896. /**
  42897. * Define the distance attenuation model the sound will follow.
  42898. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42899. */
  42900. distanceModel?: string;
  42901. /**
  42902. * Defines the playback speed (1 by default)
  42903. */
  42904. playbackRate?: number;
  42905. /**
  42906. * Defines if the sound is from a streaming source
  42907. */
  42908. streaming?: boolean;
  42909. /**
  42910. * Defines an optional length (in seconds) inside the sound file
  42911. */
  42912. length?: number;
  42913. /**
  42914. * Defines an optional offset (in seconds) inside the sound file
  42915. */
  42916. offset?: number;
  42917. /**
  42918. * If true, URLs will not be required to state the audio file codec to use.
  42919. */
  42920. skipCodecCheck?: boolean;
  42921. }
  42922. /**
  42923. * Defines a sound that can be played in the application.
  42924. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42925. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42926. */
  42927. export class Sound {
  42928. /**
  42929. * The name of the sound in the scene.
  42930. */
  42931. name: string;
  42932. /**
  42933. * Does the sound autoplay once loaded.
  42934. */
  42935. autoplay: boolean;
  42936. /**
  42937. * Does the sound loop after it finishes playing once.
  42938. */
  42939. loop: boolean;
  42940. /**
  42941. * Does the sound use a custom attenuation curve to simulate the falloff
  42942. * happening when the source gets further away from the camera.
  42943. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42944. */
  42945. useCustomAttenuation: boolean;
  42946. /**
  42947. * The sound track id this sound belongs to.
  42948. */
  42949. soundTrackId: number;
  42950. /**
  42951. * Is this sound currently played.
  42952. */
  42953. isPlaying: boolean;
  42954. /**
  42955. * Is this sound currently paused.
  42956. */
  42957. isPaused: boolean;
  42958. /**
  42959. * Does this sound enables spatial sound.
  42960. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42961. */
  42962. spatialSound: boolean;
  42963. /**
  42964. * Define the reference distance the sound should be heard perfectly.
  42965. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42966. */
  42967. refDistance: number;
  42968. /**
  42969. * Define the roll off factor of spatial sounds.
  42970. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42971. */
  42972. rolloffFactor: number;
  42973. /**
  42974. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42976. */
  42977. maxDistance: number;
  42978. /**
  42979. * Define the distance attenuation model the sound will follow.
  42980. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42981. */
  42982. distanceModel: string;
  42983. /**
  42984. * @hidden
  42985. * Back Compat
  42986. **/
  42987. onended: () => any;
  42988. /**
  42989. * Gets or sets an object used to store user defined information for the sound.
  42990. */
  42991. metadata: any;
  42992. /**
  42993. * Observable event when the current playing sound finishes.
  42994. */
  42995. onEndedObservable: Observable<Sound>;
  42996. private _panningModel;
  42997. private _playbackRate;
  42998. private _streaming;
  42999. private _startTime;
  43000. private _startOffset;
  43001. private _position;
  43002. /** @hidden */
  43003. _positionInEmitterSpace: boolean;
  43004. private _localDirection;
  43005. private _volume;
  43006. private _isReadyToPlay;
  43007. private _isDirectional;
  43008. private _readyToPlayCallback;
  43009. private _audioBuffer;
  43010. private _soundSource;
  43011. private _streamingSource;
  43012. private _soundPanner;
  43013. private _soundGain;
  43014. private _inputAudioNode;
  43015. private _outputAudioNode;
  43016. private _coneInnerAngle;
  43017. private _coneOuterAngle;
  43018. private _coneOuterGain;
  43019. private _scene;
  43020. private _connectedTransformNode;
  43021. private _customAttenuationFunction;
  43022. private _registerFunc;
  43023. private _isOutputConnected;
  43024. private _htmlAudioElement;
  43025. private _urlType;
  43026. private _length?;
  43027. private _offset?;
  43028. /** @hidden */
  43029. static _SceneComponentInitialization: (scene: Scene) => void;
  43030. /**
  43031. * Create a sound and attach it to a scene
  43032. * @param name Name of your sound
  43033. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43034. * @param scene defines the scene the sound belongs to
  43035. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43036. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43037. */
  43038. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43039. /**
  43040. * Release the sound and its associated resources
  43041. */
  43042. dispose(): void;
  43043. /**
  43044. * Gets if the sounds is ready to be played or not.
  43045. * @returns true if ready, otherwise false
  43046. */
  43047. isReady(): boolean;
  43048. private _soundLoaded;
  43049. /**
  43050. * Sets the data of the sound from an audiobuffer
  43051. * @param audioBuffer The audioBuffer containing the data
  43052. */
  43053. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43054. /**
  43055. * Updates the current sounds options such as maxdistance, loop...
  43056. * @param options A JSON object containing values named as the object properties
  43057. */
  43058. updateOptions(options: ISoundOptions): void;
  43059. private _createSpatialParameters;
  43060. private _updateSpatialParameters;
  43061. /**
  43062. * Switch the panning model to HRTF:
  43063. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43064. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43065. */
  43066. switchPanningModelToHRTF(): void;
  43067. /**
  43068. * Switch the panning model to Equal Power:
  43069. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43071. */
  43072. switchPanningModelToEqualPower(): void;
  43073. private _switchPanningModel;
  43074. /**
  43075. * Connect this sound to a sound track audio node like gain...
  43076. * @param soundTrackAudioNode the sound track audio node to connect to
  43077. */
  43078. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43079. /**
  43080. * Transform this sound into a directional source
  43081. * @param coneInnerAngle Size of the inner cone in degree
  43082. * @param coneOuterAngle Size of the outer cone in degree
  43083. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43084. */
  43085. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43086. /**
  43087. * Gets or sets the inner angle for the directional cone.
  43088. */
  43089. get directionalConeInnerAngle(): number;
  43090. /**
  43091. * Gets or sets the inner angle for the directional cone.
  43092. */
  43093. set directionalConeInnerAngle(value: number);
  43094. /**
  43095. * Gets or sets the outer angle for the directional cone.
  43096. */
  43097. get directionalConeOuterAngle(): number;
  43098. /**
  43099. * Gets or sets the outer angle for the directional cone.
  43100. */
  43101. set directionalConeOuterAngle(value: number);
  43102. /**
  43103. * Sets the position of the emitter if spatial sound is enabled
  43104. * @param newPosition Defines the new posisiton
  43105. */
  43106. setPosition(newPosition: Vector3): void;
  43107. /**
  43108. * Sets the local direction of the emitter if spatial sound is enabled
  43109. * @param newLocalDirection Defines the new local direction
  43110. */
  43111. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43112. private _updateDirection;
  43113. /** @hidden */
  43114. updateDistanceFromListener(): void;
  43115. /**
  43116. * Sets a new custom attenuation function for the sound.
  43117. * @param callback Defines the function used for the attenuation
  43118. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43119. */
  43120. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43121. /**
  43122. * Play the sound
  43123. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43124. * @param offset (optional) Start the sound at a specific time in seconds
  43125. * @param length (optional) Sound duration (in seconds)
  43126. */
  43127. play(time?: number, offset?: number, length?: number): void;
  43128. private _onended;
  43129. /**
  43130. * Stop the sound
  43131. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43132. */
  43133. stop(time?: number): void;
  43134. /**
  43135. * Put the sound in pause
  43136. */
  43137. pause(): void;
  43138. /**
  43139. * Sets a dedicated volume for this sounds
  43140. * @param newVolume Define the new volume of the sound
  43141. * @param time Define time for gradual change to new volume
  43142. */
  43143. setVolume(newVolume: number, time?: number): void;
  43144. /**
  43145. * Set the sound play back rate
  43146. * @param newPlaybackRate Define the playback rate the sound should be played at
  43147. */
  43148. setPlaybackRate(newPlaybackRate: number): void;
  43149. /**
  43150. * Gets the volume of the sound.
  43151. * @returns the volume of the sound
  43152. */
  43153. getVolume(): number;
  43154. /**
  43155. * Attach the sound to a dedicated mesh
  43156. * @param transformNode The transform node to connect the sound with
  43157. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43158. */
  43159. attachToMesh(transformNode: TransformNode): void;
  43160. /**
  43161. * Detach the sound from the previously attached mesh
  43162. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43163. */
  43164. detachFromMesh(): void;
  43165. private _onRegisterAfterWorldMatrixUpdate;
  43166. /**
  43167. * Clone the current sound in the scene.
  43168. * @returns the new sound clone
  43169. */
  43170. clone(): Nullable<Sound>;
  43171. /**
  43172. * Gets the current underlying audio buffer containing the data
  43173. * @returns the audio buffer
  43174. */
  43175. getAudioBuffer(): Nullable<AudioBuffer>;
  43176. /**
  43177. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43178. * @returns the source node
  43179. */
  43180. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43181. /**
  43182. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43183. * @returns the gain node
  43184. */
  43185. getSoundGain(): Nullable<GainNode>;
  43186. /**
  43187. * Serializes the Sound in a JSON representation
  43188. * @returns the JSON representation of the sound
  43189. */
  43190. serialize(): any;
  43191. /**
  43192. * Parse a JSON representation of a sound to innstantiate in a given scene
  43193. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43194. * @param scene Define the scene the new parsed sound should be created in
  43195. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43196. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43197. * @returns the newly parsed sound
  43198. */
  43199. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43200. }
  43201. }
  43202. declare module "babylonjs/Actions/directAudioActions" {
  43203. import { Action } from "babylonjs/Actions/action";
  43204. import { Condition } from "babylonjs/Actions/condition";
  43205. import { Sound } from "babylonjs/Audio/sound";
  43206. /**
  43207. * This defines an action helpful to play a defined sound on a triggered action.
  43208. */
  43209. export class PlaySoundAction extends Action {
  43210. private _sound;
  43211. /**
  43212. * Instantiate the action
  43213. * @param triggerOptions defines the trigger options
  43214. * @param sound defines the sound to play
  43215. * @param condition defines the trigger related conditions
  43216. */
  43217. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43218. /** @hidden */
  43219. _prepare(): void;
  43220. /**
  43221. * Execute the action and play the sound.
  43222. */
  43223. execute(): void;
  43224. /**
  43225. * Serializes the actions and its related information.
  43226. * @param parent defines the object to serialize in
  43227. * @returns the serialized object
  43228. */
  43229. serialize(parent: any): any;
  43230. }
  43231. /**
  43232. * This defines an action helpful to stop a defined sound on a triggered action.
  43233. */
  43234. export class StopSoundAction extends Action {
  43235. private _sound;
  43236. /**
  43237. * Instantiate the action
  43238. * @param triggerOptions defines the trigger options
  43239. * @param sound defines the sound to stop
  43240. * @param condition defines the trigger related conditions
  43241. */
  43242. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43243. /** @hidden */
  43244. _prepare(): void;
  43245. /**
  43246. * Execute the action and stop the sound.
  43247. */
  43248. execute(): void;
  43249. /**
  43250. * Serializes the actions and its related information.
  43251. * @param parent defines the object to serialize in
  43252. * @returns the serialized object
  43253. */
  43254. serialize(parent: any): any;
  43255. }
  43256. }
  43257. declare module "babylonjs/Actions/interpolateValueAction" {
  43258. import { Action } from "babylonjs/Actions/action";
  43259. import { Condition } from "babylonjs/Actions/condition";
  43260. import { Observable } from "babylonjs/Misc/observable";
  43261. /**
  43262. * This defines an action responsible to change the value of a property
  43263. * by interpolating between its current value and the newly set one once triggered.
  43264. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43265. */
  43266. export class InterpolateValueAction extends Action {
  43267. /**
  43268. * Defines the path of the property where the value should be interpolated
  43269. */
  43270. propertyPath: string;
  43271. /**
  43272. * Defines the target value at the end of the interpolation.
  43273. */
  43274. value: any;
  43275. /**
  43276. * Defines the time it will take for the property to interpolate to the value.
  43277. */
  43278. duration: number;
  43279. /**
  43280. * Defines if the other scene animations should be stopped when the action has been triggered
  43281. */
  43282. stopOtherAnimations?: boolean;
  43283. /**
  43284. * Defines a callback raised once the interpolation animation has been done.
  43285. */
  43286. onInterpolationDone?: () => void;
  43287. /**
  43288. * Observable triggered once the interpolation animation has been done.
  43289. */
  43290. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43291. private _target;
  43292. private _effectiveTarget;
  43293. private _property;
  43294. /**
  43295. * Instantiate the action
  43296. * @param triggerOptions defines the trigger options
  43297. * @param target defines the object containing the value to interpolate
  43298. * @param propertyPath defines the path to the property in the target object
  43299. * @param value defines the target value at the end of the interpolation
  43300. * @param duration deines the time it will take for the property to interpolate to the value.
  43301. * @param condition defines the trigger related conditions
  43302. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43303. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43304. */
  43305. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43306. /** @hidden */
  43307. _prepare(): void;
  43308. /**
  43309. * Execute the action starts the value interpolation.
  43310. */
  43311. execute(): void;
  43312. /**
  43313. * Serializes the actions and its related information.
  43314. * @param parent defines the object to serialize in
  43315. * @returns the serialized object
  43316. */
  43317. serialize(parent: any): any;
  43318. }
  43319. }
  43320. declare module "babylonjs/Actions/index" {
  43321. export * from "babylonjs/Actions/abstractActionManager";
  43322. export * from "babylonjs/Actions/action";
  43323. export * from "babylonjs/Actions/actionEvent";
  43324. export * from "babylonjs/Actions/actionManager";
  43325. export * from "babylonjs/Actions/condition";
  43326. export * from "babylonjs/Actions/directActions";
  43327. export * from "babylonjs/Actions/directAudioActions";
  43328. export * from "babylonjs/Actions/interpolateValueAction";
  43329. }
  43330. declare module "babylonjs/Animations/index" {
  43331. export * from "babylonjs/Animations/animatable";
  43332. export * from "babylonjs/Animations/animation";
  43333. export * from "babylonjs/Animations/animationGroup";
  43334. export * from "babylonjs/Animations/animationPropertiesOverride";
  43335. export * from "babylonjs/Animations/easing";
  43336. export * from "babylonjs/Animations/runtimeAnimation";
  43337. export * from "babylonjs/Animations/animationEvent";
  43338. export * from "babylonjs/Animations/animationGroup";
  43339. export * from "babylonjs/Animations/animationKey";
  43340. export * from "babylonjs/Animations/animationRange";
  43341. export * from "babylonjs/Animations/animatable.interface";
  43342. }
  43343. declare module "babylonjs/Audio/soundTrack" {
  43344. import { Sound } from "babylonjs/Audio/sound";
  43345. import { Analyser } from "babylonjs/Audio/analyser";
  43346. import { Scene } from "babylonjs/scene";
  43347. /**
  43348. * Options allowed during the creation of a sound track.
  43349. */
  43350. export interface ISoundTrackOptions {
  43351. /**
  43352. * The volume the sound track should take during creation
  43353. */
  43354. volume?: number;
  43355. /**
  43356. * Define if the sound track is the main sound track of the scene
  43357. */
  43358. mainTrack?: boolean;
  43359. }
  43360. /**
  43361. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43362. * It will be also used in a future release to apply effects on a specific track.
  43363. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43364. */
  43365. export class SoundTrack {
  43366. /**
  43367. * The unique identifier of the sound track in the scene.
  43368. */
  43369. id: number;
  43370. /**
  43371. * The list of sounds included in the sound track.
  43372. */
  43373. soundCollection: Array<Sound>;
  43374. private _outputAudioNode;
  43375. private _scene;
  43376. private _connectedAnalyser;
  43377. private _options;
  43378. private _isInitialized;
  43379. /**
  43380. * Creates a new sound track.
  43381. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43382. * @param scene Define the scene the sound track belongs to
  43383. * @param options
  43384. */
  43385. constructor(scene: Scene, options?: ISoundTrackOptions);
  43386. private _initializeSoundTrackAudioGraph;
  43387. /**
  43388. * Release the sound track and its associated resources
  43389. */
  43390. dispose(): void;
  43391. /**
  43392. * Adds a sound to this sound track
  43393. * @param sound define the cound to add
  43394. * @ignoreNaming
  43395. */
  43396. AddSound(sound: Sound): void;
  43397. /**
  43398. * Removes a sound to this sound track
  43399. * @param sound define the cound to remove
  43400. * @ignoreNaming
  43401. */
  43402. RemoveSound(sound: Sound): void;
  43403. /**
  43404. * Set a global volume for the full sound track.
  43405. * @param newVolume Define the new volume of the sound track
  43406. */
  43407. setVolume(newVolume: number): void;
  43408. /**
  43409. * Switch the panning model to HRTF:
  43410. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43411. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43412. */
  43413. switchPanningModelToHRTF(): void;
  43414. /**
  43415. * Switch the panning model to Equal Power:
  43416. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43418. */
  43419. switchPanningModelToEqualPower(): void;
  43420. /**
  43421. * Connect the sound track to an audio analyser allowing some amazing
  43422. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43423. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43424. * @param analyser The analyser to connect to the engine
  43425. */
  43426. connectToAnalyser(analyser: Analyser): void;
  43427. }
  43428. }
  43429. declare module "babylonjs/Audio/audioSceneComponent" {
  43430. import { Sound } from "babylonjs/Audio/sound";
  43431. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43432. import { Nullable } from "babylonjs/types";
  43433. import { Vector3 } from "babylonjs/Maths/math.vector";
  43434. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43435. import { Scene } from "babylonjs/scene";
  43436. import { AbstractScene } from "babylonjs/abstractScene";
  43437. import "babylonjs/Audio/audioEngine";
  43438. module "babylonjs/abstractScene" {
  43439. interface AbstractScene {
  43440. /**
  43441. * The list of sounds used in the scene.
  43442. */
  43443. sounds: Nullable<Array<Sound>>;
  43444. }
  43445. }
  43446. module "babylonjs/scene" {
  43447. interface Scene {
  43448. /**
  43449. * @hidden
  43450. * Backing field
  43451. */
  43452. _mainSoundTrack: SoundTrack;
  43453. /**
  43454. * The main sound track played by the scene.
  43455. * It cotains your primary collection of sounds.
  43456. */
  43457. mainSoundTrack: SoundTrack;
  43458. /**
  43459. * The list of sound tracks added to the scene
  43460. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43461. */
  43462. soundTracks: Nullable<Array<SoundTrack>>;
  43463. /**
  43464. * Gets a sound using a given name
  43465. * @param name defines the name to search for
  43466. * @return the found sound or null if not found at all.
  43467. */
  43468. getSoundByName(name: string): Nullable<Sound>;
  43469. /**
  43470. * Gets or sets if audio support is enabled
  43471. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43472. */
  43473. audioEnabled: boolean;
  43474. /**
  43475. * Gets or sets if audio will be output to headphones
  43476. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43477. */
  43478. headphone: boolean;
  43479. /**
  43480. * Gets or sets custom audio listener position provider
  43481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43482. */
  43483. audioListenerPositionProvider: Nullable<() => Vector3>;
  43484. /**
  43485. * Gets or sets a refresh rate when using 3D audio positioning
  43486. */
  43487. audioPositioningRefreshRate: number;
  43488. }
  43489. }
  43490. /**
  43491. * Defines the sound scene component responsible to manage any sounds
  43492. * in a given scene.
  43493. */
  43494. export class AudioSceneComponent implements ISceneSerializableComponent {
  43495. private static _CameraDirectionLH;
  43496. private static _CameraDirectionRH;
  43497. /**
  43498. * The component name helpfull to identify the component in the list of scene components.
  43499. */
  43500. readonly name: string;
  43501. /**
  43502. * The scene the component belongs to.
  43503. */
  43504. scene: Scene;
  43505. private _audioEnabled;
  43506. /**
  43507. * Gets whether audio is enabled or not.
  43508. * Please use related enable/disable method to switch state.
  43509. */
  43510. get audioEnabled(): boolean;
  43511. private _headphone;
  43512. /**
  43513. * Gets whether audio is outputing to headphone or not.
  43514. * Please use the according Switch methods to change output.
  43515. */
  43516. get headphone(): boolean;
  43517. /**
  43518. * Gets or sets a refresh rate when using 3D audio positioning
  43519. */
  43520. audioPositioningRefreshRate: number;
  43521. private _audioListenerPositionProvider;
  43522. /**
  43523. * Gets the current audio listener position provider
  43524. */
  43525. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43526. /**
  43527. * Sets a custom listener position for all sounds in the scene
  43528. * By default, this is the position of the first active camera
  43529. */
  43530. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43531. /**
  43532. * Creates a new instance of the component for the given scene
  43533. * @param scene Defines the scene to register the component in
  43534. */
  43535. constructor(scene: Scene);
  43536. /**
  43537. * Registers the component in a given scene
  43538. */
  43539. register(): void;
  43540. /**
  43541. * Rebuilds the elements related to this component in case of
  43542. * context lost for instance.
  43543. */
  43544. rebuild(): void;
  43545. /**
  43546. * Serializes the component data to the specified json object
  43547. * @param serializationObject The object to serialize to
  43548. */
  43549. serialize(serializationObject: any): void;
  43550. /**
  43551. * Adds all the elements from the container to the scene
  43552. * @param container the container holding the elements
  43553. */
  43554. addFromContainer(container: AbstractScene): void;
  43555. /**
  43556. * Removes all the elements in the container from the scene
  43557. * @param container contains the elements to remove
  43558. * @param dispose if the removed element should be disposed (default: false)
  43559. */
  43560. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43561. /**
  43562. * Disposes the component and the associated ressources.
  43563. */
  43564. dispose(): void;
  43565. /**
  43566. * Disables audio in the associated scene.
  43567. */
  43568. disableAudio(): void;
  43569. /**
  43570. * Enables audio in the associated scene.
  43571. */
  43572. enableAudio(): void;
  43573. /**
  43574. * Switch audio to headphone output.
  43575. */
  43576. switchAudioModeForHeadphones(): void;
  43577. /**
  43578. * Switch audio to normal speakers.
  43579. */
  43580. switchAudioModeForNormalSpeakers(): void;
  43581. private _cachedCameraDirection;
  43582. private _cachedCameraPosition;
  43583. private _lastCheck;
  43584. private _afterRender;
  43585. }
  43586. }
  43587. declare module "babylonjs/Audio/weightedsound" {
  43588. import { Sound } from "babylonjs/Audio/sound";
  43589. /**
  43590. * Wraps one or more Sound objects and selects one with random weight for playback.
  43591. */
  43592. export class WeightedSound {
  43593. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43594. loop: boolean;
  43595. private _coneInnerAngle;
  43596. private _coneOuterAngle;
  43597. private _volume;
  43598. /** A Sound is currently playing. */
  43599. isPlaying: boolean;
  43600. /** A Sound is currently paused. */
  43601. isPaused: boolean;
  43602. private _sounds;
  43603. private _weights;
  43604. private _currentIndex?;
  43605. /**
  43606. * Creates a new WeightedSound from the list of sounds given.
  43607. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43608. * @param sounds Array of Sounds that will be selected from.
  43609. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43610. */
  43611. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43612. /**
  43613. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43614. */
  43615. get directionalConeInnerAngle(): number;
  43616. /**
  43617. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43618. */
  43619. set directionalConeInnerAngle(value: number);
  43620. /**
  43621. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43622. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43623. */
  43624. get directionalConeOuterAngle(): number;
  43625. /**
  43626. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43627. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43628. */
  43629. set directionalConeOuterAngle(value: number);
  43630. /**
  43631. * Playback volume.
  43632. */
  43633. get volume(): number;
  43634. /**
  43635. * Playback volume.
  43636. */
  43637. set volume(value: number);
  43638. private _onended;
  43639. /**
  43640. * Suspend playback
  43641. */
  43642. pause(): void;
  43643. /**
  43644. * Stop playback
  43645. */
  43646. stop(): void;
  43647. /**
  43648. * Start playback.
  43649. * @param startOffset Position the clip head at a specific time in seconds.
  43650. */
  43651. play(startOffset?: number): void;
  43652. }
  43653. }
  43654. declare module "babylonjs/Audio/index" {
  43655. export * from "babylonjs/Audio/analyser";
  43656. export * from "babylonjs/Audio/audioEngine";
  43657. export * from "babylonjs/Audio/audioSceneComponent";
  43658. export * from "babylonjs/Audio/sound";
  43659. export * from "babylonjs/Audio/soundTrack";
  43660. export * from "babylonjs/Audio/weightedsound";
  43661. }
  43662. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43663. import { Behavior } from "babylonjs/Behaviors/behavior";
  43664. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43665. import { BackEase } from "babylonjs/Animations/easing";
  43666. /**
  43667. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43668. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43669. */
  43670. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43671. /**
  43672. * Gets the name of the behavior.
  43673. */
  43674. get name(): string;
  43675. /**
  43676. * The easing function used by animations
  43677. */
  43678. static EasingFunction: BackEase;
  43679. /**
  43680. * The easing mode used by animations
  43681. */
  43682. static EasingMode: number;
  43683. /**
  43684. * The duration of the animation, in milliseconds
  43685. */
  43686. transitionDuration: number;
  43687. /**
  43688. * Length of the distance animated by the transition when lower radius is reached
  43689. */
  43690. lowerRadiusTransitionRange: number;
  43691. /**
  43692. * Length of the distance animated by the transition when upper radius is reached
  43693. */
  43694. upperRadiusTransitionRange: number;
  43695. private _autoTransitionRange;
  43696. /**
  43697. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43698. */
  43699. get autoTransitionRange(): boolean;
  43700. /**
  43701. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43702. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43703. */
  43704. set autoTransitionRange(value: boolean);
  43705. private _attachedCamera;
  43706. private _onAfterCheckInputsObserver;
  43707. private _onMeshTargetChangedObserver;
  43708. /**
  43709. * Initializes the behavior.
  43710. */
  43711. init(): void;
  43712. /**
  43713. * Attaches the behavior to its arc rotate camera.
  43714. * @param camera Defines the camera to attach the behavior to
  43715. */
  43716. attach(camera: ArcRotateCamera): void;
  43717. /**
  43718. * Detaches the behavior from its current arc rotate camera.
  43719. */
  43720. detach(): void;
  43721. private _radiusIsAnimating;
  43722. private _radiusBounceTransition;
  43723. private _animatables;
  43724. private _cachedWheelPrecision;
  43725. /**
  43726. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43727. * @param radiusLimit The limit to check against.
  43728. * @return Bool to indicate if at limit.
  43729. */
  43730. private _isRadiusAtLimit;
  43731. /**
  43732. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43733. * @param radiusDelta The delta by which to animate to. Can be negative.
  43734. */
  43735. private _applyBoundRadiusAnimation;
  43736. /**
  43737. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43738. */
  43739. protected _clearAnimationLocks(): void;
  43740. /**
  43741. * Stops and removes all animations that have been applied to the camera
  43742. */
  43743. stopAllAnimations(): void;
  43744. }
  43745. }
  43746. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43747. import { Behavior } from "babylonjs/Behaviors/behavior";
  43748. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43749. import { ExponentialEase } from "babylonjs/Animations/easing";
  43750. import { Nullable } from "babylonjs/types";
  43751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43752. import { Vector3 } from "babylonjs/Maths/math.vector";
  43753. /**
  43754. * 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.
  43755. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43756. */
  43757. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43758. /**
  43759. * Gets the name of the behavior.
  43760. */
  43761. get name(): string;
  43762. private _mode;
  43763. private _radiusScale;
  43764. private _positionScale;
  43765. private _defaultElevation;
  43766. private _elevationReturnTime;
  43767. private _elevationReturnWaitTime;
  43768. private _zoomStopsAnimation;
  43769. private _framingTime;
  43770. /**
  43771. * The easing function used by animations
  43772. */
  43773. static EasingFunction: ExponentialEase;
  43774. /**
  43775. * The easing mode used by animations
  43776. */
  43777. static EasingMode: number;
  43778. /**
  43779. * Sets the current mode used by the behavior
  43780. */
  43781. set mode(mode: number);
  43782. /**
  43783. * Gets current mode used by the behavior.
  43784. */
  43785. get mode(): number;
  43786. /**
  43787. * Sets the scale applied to the radius (1 by default)
  43788. */
  43789. set radiusScale(radius: number);
  43790. /**
  43791. * Gets the scale applied to the radius
  43792. */
  43793. get radiusScale(): number;
  43794. /**
  43795. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43796. */
  43797. set positionScale(scale: number);
  43798. /**
  43799. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43800. */
  43801. get positionScale(): number;
  43802. /**
  43803. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43804. * behaviour is triggered, in radians.
  43805. */
  43806. set defaultElevation(elevation: number);
  43807. /**
  43808. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43809. * behaviour is triggered, in radians.
  43810. */
  43811. get defaultElevation(): number;
  43812. /**
  43813. * Sets the time (in milliseconds) taken to return to the default beta position.
  43814. * Negative value indicates camera should not return to default.
  43815. */
  43816. set elevationReturnTime(speed: number);
  43817. /**
  43818. * Gets the time (in milliseconds) taken to return to the default beta position.
  43819. * Negative value indicates camera should not return to default.
  43820. */
  43821. get elevationReturnTime(): number;
  43822. /**
  43823. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43824. */
  43825. set elevationReturnWaitTime(time: number);
  43826. /**
  43827. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43828. */
  43829. get elevationReturnWaitTime(): number;
  43830. /**
  43831. * Sets the flag that indicates if user zooming should stop animation.
  43832. */
  43833. set zoomStopsAnimation(flag: boolean);
  43834. /**
  43835. * Gets the flag that indicates if user zooming should stop animation.
  43836. */
  43837. get zoomStopsAnimation(): boolean;
  43838. /**
  43839. * Sets the transition time when framing the mesh, in milliseconds
  43840. */
  43841. set framingTime(time: number);
  43842. /**
  43843. * Gets the transition time when framing the mesh, in milliseconds
  43844. */
  43845. get framingTime(): number;
  43846. /**
  43847. * Define if the behavior should automatically change the configured
  43848. * camera limits and sensibilities.
  43849. */
  43850. autoCorrectCameraLimitsAndSensibility: boolean;
  43851. private _onPrePointerObservableObserver;
  43852. private _onAfterCheckInputsObserver;
  43853. private _onMeshTargetChangedObserver;
  43854. private _attachedCamera;
  43855. private _isPointerDown;
  43856. private _lastInteractionTime;
  43857. /**
  43858. * Initializes the behavior.
  43859. */
  43860. init(): void;
  43861. /**
  43862. * Attaches the behavior to its arc rotate camera.
  43863. * @param camera Defines the camera to attach the behavior to
  43864. */
  43865. attach(camera: ArcRotateCamera): void;
  43866. /**
  43867. * Detaches the behavior from its current arc rotate camera.
  43868. */
  43869. detach(): void;
  43870. private _animatables;
  43871. private _betaIsAnimating;
  43872. private _betaTransition;
  43873. private _radiusTransition;
  43874. private _vectorTransition;
  43875. /**
  43876. * Targets the given mesh and updates zoom level accordingly.
  43877. * @param mesh The mesh to target.
  43878. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43879. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43880. */
  43881. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43882. /**
  43883. * Targets the given mesh with its children and updates zoom level accordingly.
  43884. * @param mesh The mesh to target.
  43885. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43886. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43887. */
  43888. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43889. /**
  43890. * Targets the given meshes with their children and updates zoom level accordingly.
  43891. * @param meshes The mesh to target.
  43892. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43893. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43894. */
  43895. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43896. /**
  43897. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43898. * @param minimumWorld Determines the smaller position of the bounding box extend
  43899. * @param maximumWorld Determines the bigger position of the bounding box extend
  43900. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43901. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43902. */
  43903. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43904. /**
  43905. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43906. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43907. * frustum width.
  43908. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43909. * to fully enclose the mesh in the viewing frustum.
  43910. */
  43911. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43912. /**
  43913. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43914. * is automatically returned to its default position (expected to be above ground plane).
  43915. */
  43916. private _maintainCameraAboveGround;
  43917. /**
  43918. * Returns the frustum slope based on the canvas ratio and camera FOV
  43919. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43920. */
  43921. private _getFrustumSlope;
  43922. /**
  43923. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43924. */
  43925. private _clearAnimationLocks;
  43926. /**
  43927. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43928. */
  43929. private _applyUserInteraction;
  43930. /**
  43931. * Stops and removes all animations that have been applied to the camera
  43932. */
  43933. stopAllAnimations(): void;
  43934. /**
  43935. * Gets a value indicating if the user is moving the camera
  43936. */
  43937. get isUserIsMoving(): boolean;
  43938. /**
  43939. * The camera can move all the way towards the mesh.
  43940. */
  43941. static IgnoreBoundsSizeMode: number;
  43942. /**
  43943. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43944. */
  43945. static FitFrustumSidesMode: number;
  43946. }
  43947. }
  43948. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43949. import { Nullable } from "babylonjs/types";
  43950. import { Camera } from "babylonjs/Cameras/camera";
  43951. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43952. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43953. /**
  43954. * Base class for Camera Pointer Inputs.
  43955. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43956. * for example usage.
  43957. */
  43958. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43959. /**
  43960. * Defines the camera the input is attached to.
  43961. */
  43962. abstract camera: Camera;
  43963. /**
  43964. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43965. */
  43966. protected _altKey: boolean;
  43967. protected _ctrlKey: boolean;
  43968. protected _metaKey: boolean;
  43969. protected _shiftKey: boolean;
  43970. /**
  43971. * Which mouse buttons were pressed at time of last mouse event.
  43972. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43973. */
  43974. protected _buttonsPressed: number;
  43975. /**
  43976. * Defines the buttons associated with the input to handle camera move.
  43977. */
  43978. buttons: number[];
  43979. /**
  43980. * Attach the input controls to a specific dom element to get the input from.
  43981. * @param element Defines the element the controls should be listened from
  43982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43983. */
  43984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43985. /**
  43986. * Detach the current controls from the specified dom element.
  43987. * @param element Defines the element to stop listening the inputs from
  43988. */
  43989. detachControl(element: Nullable<HTMLElement>): void;
  43990. /**
  43991. * Gets the class name of the current input.
  43992. * @returns the class name
  43993. */
  43994. getClassName(): string;
  43995. /**
  43996. * Get the friendly name associated with the input class.
  43997. * @returns the input friendly name
  43998. */
  43999. getSimpleName(): string;
  44000. /**
  44001. * Called on pointer POINTERDOUBLETAP event.
  44002. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44003. */
  44004. protected onDoubleTap(type: string): void;
  44005. /**
  44006. * Called on pointer POINTERMOVE event if only a single touch is active.
  44007. * Override this method to provide functionality.
  44008. */
  44009. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44010. /**
  44011. * Called on pointer POINTERMOVE event if multiple touches are active.
  44012. * Override this method to provide functionality.
  44013. */
  44014. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44015. /**
  44016. * Called on JS contextmenu event.
  44017. * Override this method to provide functionality.
  44018. */
  44019. protected onContextMenu(evt: PointerEvent): void;
  44020. /**
  44021. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44022. * press.
  44023. * Override this method to provide functionality.
  44024. */
  44025. protected onButtonDown(evt: PointerEvent): void;
  44026. /**
  44027. * Called each time a new POINTERUP event occurs. Ie, for each button
  44028. * release.
  44029. * Override this method to provide functionality.
  44030. */
  44031. protected onButtonUp(evt: PointerEvent): void;
  44032. /**
  44033. * Called when window becomes inactive.
  44034. * Override this method to provide functionality.
  44035. */
  44036. protected onLostFocus(): void;
  44037. private _pointerInput;
  44038. private _observer;
  44039. private _onLostFocus;
  44040. private pointA;
  44041. private pointB;
  44042. }
  44043. }
  44044. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44045. import { Nullable } from "babylonjs/types";
  44046. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44047. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44048. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44049. /**
  44050. * Manage the pointers inputs to control an arc rotate camera.
  44051. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44052. */
  44053. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44054. /**
  44055. * Defines the camera the input is attached to.
  44056. */
  44057. camera: ArcRotateCamera;
  44058. /**
  44059. * Gets the class name of the current input.
  44060. * @returns the class name
  44061. */
  44062. getClassName(): string;
  44063. /**
  44064. * Defines the buttons associated with the input to handle camera move.
  44065. */
  44066. buttons: number[];
  44067. /**
  44068. * Defines the pointer angular sensibility along the X axis or how fast is
  44069. * the camera rotating.
  44070. */
  44071. angularSensibilityX: number;
  44072. /**
  44073. * Defines the pointer angular sensibility along the Y axis or how fast is
  44074. * the camera rotating.
  44075. */
  44076. angularSensibilityY: number;
  44077. /**
  44078. * Defines the pointer pinch precision or how fast is the camera zooming.
  44079. */
  44080. pinchPrecision: number;
  44081. /**
  44082. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44083. * from 0.
  44084. * It defines the percentage of current camera.radius to use as delta when
  44085. * pinch zoom is used.
  44086. */
  44087. pinchDeltaPercentage: number;
  44088. /**
  44089. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44090. * that any object in the plane at the camera's target point will scale
  44091. * perfectly with finger motion.
  44092. * Overrides pinchDeltaPercentage and pinchPrecision.
  44093. */
  44094. useNaturalPinchZoom: boolean;
  44095. /**
  44096. * Defines the pointer panning sensibility or how fast is the camera moving.
  44097. */
  44098. panningSensibility: number;
  44099. /**
  44100. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44101. */
  44102. multiTouchPanning: boolean;
  44103. /**
  44104. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44105. * zoom (pinch) through multitouch.
  44106. */
  44107. multiTouchPanAndZoom: boolean;
  44108. /**
  44109. * Revers pinch action direction.
  44110. */
  44111. pinchInwards: boolean;
  44112. private _isPanClick;
  44113. private _twoFingerActivityCount;
  44114. private _isPinching;
  44115. /**
  44116. * Called on pointer POINTERMOVE event if only a single touch is active.
  44117. */
  44118. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44119. /**
  44120. * Called on pointer POINTERDOUBLETAP event.
  44121. */
  44122. protected onDoubleTap(type: string): void;
  44123. /**
  44124. * Called on pointer POINTERMOVE event if multiple touches are active.
  44125. */
  44126. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44127. /**
  44128. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44129. * press.
  44130. */
  44131. protected onButtonDown(evt: PointerEvent): void;
  44132. /**
  44133. * Called each time a new POINTERUP event occurs. Ie, for each button
  44134. * release.
  44135. */
  44136. protected onButtonUp(evt: PointerEvent): void;
  44137. /**
  44138. * Called when window becomes inactive.
  44139. */
  44140. protected onLostFocus(): void;
  44141. }
  44142. }
  44143. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44144. import { Nullable } from "babylonjs/types";
  44145. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44146. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44147. /**
  44148. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44149. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44150. */
  44151. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44152. /**
  44153. * Defines the camera the input is attached to.
  44154. */
  44155. camera: ArcRotateCamera;
  44156. /**
  44157. * Defines the list of key codes associated with the up action (increase alpha)
  44158. */
  44159. keysUp: number[];
  44160. /**
  44161. * Defines the list of key codes associated with the down action (decrease alpha)
  44162. */
  44163. keysDown: number[];
  44164. /**
  44165. * Defines the list of key codes associated with the left action (increase beta)
  44166. */
  44167. keysLeft: number[];
  44168. /**
  44169. * Defines the list of key codes associated with the right action (decrease beta)
  44170. */
  44171. keysRight: number[];
  44172. /**
  44173. * Defines the list of key codes associated with the reset action.
  44174. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44175. */
  44176. keysReset: number[];
  44177. /**
  44178. * Defines the panning sensibility of the inputs.
  44179. * (How fast is the camera panning)
  44180. */
  44181. panningSensibility: number;
  44182. /**
  44183. * Defines the zooming sensibility of the inputs.
  44184. * (How fast is the camera zooming)
  44185. */
  44186. zoomingSensibility: number;
  44187. /**
  44188. * Defines whether maintaining the alt key down switch the movement mode from
  44189. * orientation to zoom.
  44190. */
  44191. useAltToZoom: boolean;
  44192. /**
  44193. * Rotation speed of the camera
  44194. */
  44195. angularSpeed: number;
  44196. private _keys;
  44197. private _ctrlPressed;
  44198. private _altPressed;
  44199. private _onCanvasBlurObserver;
  44200. private _onKeyboardObserver;
  44201. private _engine;
  44202. private _scene;
  44203. /**
  44204. * Attach the input controls to a specific dom element to get the input from.
  44205. * @param element Defines the element the controls should be listened from
  44206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44207. */
  44208. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44209. /**
  44210. * Detach the current controls from the specified dom element.
  44211. * @param element Defines the element to stop listening the inputs from
  44212. */
  44213. detachControl(element: Nullable<HTMLElement>): void;
  44214. /**
  44215. * Update the current camera state depending on the inputs that have been used this frame.
  44216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44217. */
  44218. checkInputs(): void;
  44219. /**
  44220. * Gets the class name of the current intput.
  44221. * @returns the class name
  44222. */
  44223. getClassName(): string;
  44224. /**
  44225. * Get the friendly name associated with the input class.
  44226. * @returns the input friendly name
  44227. */
  44228. getSimpleName(): string;
  44229. }
  44230. }
  44231. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44232. import { Nullable } from "babylonjs/types";
  44233. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44234. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44235. /**
  44236. * Manage the mouse wheel inputs to control an arc rotate camera.
  44237. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44238. */
  44239. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44240. /**
  44241. * Defines the camera the input is attached to.
  44242. */
  44243. camera: ArcRotateCamera;
  44244. /**
  44245. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44246. */
  44247. wheelPrecision: number;
  44248. /**
  44249. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44250. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44251. */
  44252. wheelDeltaPercentage: number;
  44253. private _wheel;
  44254. private _observer;
  44255. private computeDeltaFromMouseWheelLegacyEvent;
  44256. /**
  44257. * Attach the input controls to a specific dom element to get the input from.
  44258. * @param element Defines the element the controls should be listened from
  44259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44260. */
  44261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44262. /**
  44263. * Detach the current controls from the specified dom element.
  44264. * @param element Defines the element to stop listening the inputs from
  44265. */
  44266. detachControl(element: Nullable<HTMLElement>): void;
  44267. /**
  44268. * Gets the class name of the current intput.
  44269. * @returns the class name
  44270. */
  44271. getClassName(): string;
  44272. /**
  44273. * Get the friendly name associated with the input class.
  44274. * @returns the input friendly name
  44275. */
  44276. getSimpleName(): string;
  44277. }
  44278. }
  44279. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44280. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44281. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44282. /**
  44283. * Default Inputs manager for the ArcRotateCamera.
  44284. * It groups all the default supported inputs for ease of use.
  44285. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44286. */
  44287. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44288. /**
  44289. * Instantiates a new ArcRotateCameraInputsManager.
  44290. * @param camera Defines the camera the inputs belong to
  44291. */
  44292. constructor(camera: ArcRotateCamera);
  44293. /**
  44294. * Add mouse wheel input support to the input manager.
  44295. * @returns the current input manager
  44296. */
  44297. addMouseWheel(): ArcRotateCameraInputsManager;
  44298. /**
  44299. * Add pointers input support to the input manager.
  44300. * @returns the current input manager
  44301. */
  44302. addPointers(): ArcRotateCameraInputsManager;
  44303. /**
  44304. * Add keyboard input support to the input manager.
  44305. * @returns the current input manager
  44306. */
  44307. addKeyboard(): ArcRotateCameraInputsManager;
  44308. }
  44309. }
  44310. declare module "babylonjs/Cameras/arcRotateCamera" {
  44311. import { Observable } from "babylonjs/Misc/observable";
  44312. import { Nullable } from "babylonjs/types";
  44313. import { Scene } from "babylonjs/scene";
  44314. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44316. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44317. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44318. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44319. import { Camera } from "babylonjs/Cameras/camera";
  44320. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44321. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44322. import { Collider } from "babylonjs/Collisions/collider";
  44323. /**
  44324. * This represents an orbital type of camera.
  44325. *
  44326. * 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.
  44327. * 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.
  44328. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44329. */
  44330. export class ArcRotateCamera extends TargetCamera {
  44331. /**
  44332. * Defines the rotation angle of the camera along the longitudinal axis.
  44333. */
  44334. alpha: number;
  44335. /**
  44336. * Defines the rotation angle of the camera along the latitudinal axis.
  44337. */
  44338. beta: number;
  44339. /**
  44340. * Defines the radius of the camera from it s target point.
  44341. */
  44342. radius: number;
  44343. protected _target: Vector3;
  44344. protected _targetHost: Nullable<AbstractMesh>;
  44345. /**
  44346. * Defines the target point of the camera.
  44347. * The camera looks towards it form the radius distance.
  44348. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44349. */
  44350. get target(): Vector3;
  44351. set target(value: Vector3);
  44352. /**
  44353. * Define the current local position of the camera in the scene
  44354. */
  44355. get position(): Vector3;
  44356. set position(newPosition: Vector3);
  44357. protected _upToYMatrix: Matrix;
  44358. protected _YToUpMatrix: Matrix;
  44359. /**
  44360. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44361. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44362. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44363. */
  44364. set upVector(vec: Vector3);
  44365. get upVector(): Vector3;
  44366. /**
  44367. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44368. */
  44369. setMatUp(): void;
  44370. /**
  44371. * Current inertia value on the longitudinal axis.
  44372. * The bigger this number the longer it will take for the camera to stop.
  44373. */
  44374. inertialAlphaOffset: number;
  44375. /**
  44376. * Current inertia value on the latitudinal axis.
  44377. * The bigger this number the longer it will take for the camera to stop.
  44378. */
  44379. inertialBetaOffset: number;
  44380. /**
  44381. * Current inertia value on the radius axis.
  44382. * The bigger this number the longer it will take for the camera to stop.
  44383. */
  44384. inertialRadiusOffset: number;
  44385. /**
  44386. * Minimum allowed angle on the longitudinal axis.
  44387. * This can help limiting how the Camera is able to move in the scene.
  44388. */
  44389. lowerAlphaLimit: Nullable<number>;
  44390. /**
  44391. * Maximum allowed angle on the longitudinal axis.
  44392. * This can help limiting how the Camera is able to move in the scene.
  44393. */
  44394. upperAlphaLimit: Nullable<number>;
  44395. /**
  44396. * Minimum allowed angle on the latitudinal axis.
  44397. * This can help limiting how the Camera is able to move in the scene.
  44398. */
  44399. lowerBetaLimit: number;
  44400. /**
  44401. * Maximum allowed angle on the latitudinal axis.
  44402. * This can help limiting how the Camera is able to move in the scene.
  44403. */
  44404. upperBetaLimit: number;
  44405. /**
  44406. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44407. * This can help limiting how the Camera is able to move in the scene.
  44408. */
  44409. lowerRadiusLimit: Nullable<number>;
  44410. /**
  44411. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44412. * This can help limiting how the Camera is able to move in the scene.
  44413. */
  44414. upperRadiusLimit: Nullable<number>;
  44415. /**
  44416. * Defines the current inertia value used during panning of the camera along the X axis.
  44417. */
  44418. inertialPanningX: number;
  44419. /**
  44420. * Defines the current inertia value used during panning of the camera along the Y axis.
  44421. */
  44422. inertialPanningY: number;
  44423. /**
  44424. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44425. * Basically if your fingers moves away from more than this distance you will be considered
  44426. * in pinch mode.
  44427. */
  44428. pinchToPanMaxDistance: number;
  44429. /**
  44430. * Defines the maximum distance the camera can pan.
  44431. * This could help keeping the cammera always in your scene.
  44432. */
  44433. panningDistanceLimit: Nullable<number>;
  44434. /**
  44435. * Defines the target of the camera before paning.
  44436. */
  44437. panningOriginTarget: Vector3;
  44438. /**
  44439. * Defines the value of the inertia used during panning.
  44440. * 0 would mean stop inertia and one would mean no decelleration at all.
  44441. */
  44442. panningInertia: number;
  44443. /**
  44444. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44445. */
  44446. get angularSensibilityX(): number;
  44447. set angularSensibilityX(value: number);
  44448. /**
  44449. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44450. */
  44451. get angularSensibilityY(): number;
  44452. set angularSensibilityY(value: number);
  44453. /**
  44454. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44455. */
  44456. get pinchPrecision(): number;
  44457. set pinchPrecision(value: number);
  44458. /**
  44459. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44460. * It will be used instead of pinchDeltaPrecision if different from 0.
  44461. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44462. */
  44463. get pinchDeltaPercentage(): number;
  44464. set pinchDeltaPercentage(value: number);
  44465. /**
  44466. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44467. * and pinch delta percentage.
  44468. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44469. * that any object in the plane at the camera's target point will scale
  44470. * perfectly with finger motion.
  44471. */
  44472. get useNaturalPinchZoom(): boolean;
  44473. set useNaturalPinchZoom(value: boolean);
  44474. /**
  44475. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44476. */
  44477. get panningSensibility(): number;
  44478. set panningSensibility(value: number);
  44479. /**
  44480. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44481. */
  44482. get keysUp(): number[];
  44483. set keysUp(value: number[]);
  44484. /**
  44485. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44486. */
  44487. get keysDown(): number[];
  44488. set keysDown(value: number[]);
  44489. /**
  44490. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44491. */
  44492. get keysLeft(): number[];
  44493. set keysLeft(value: number[]);
  44494. /**
  44495. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44496. */
  44497. get keysRight(): number[];
  44498. set keysRight(value: number[]);
  44499. /**
  44500. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44501. */
  44502. get wheelPrecision(): number;
  44503. set wheelPrecision(value: number);
  44504. /**
  44505. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44506. * It will be used instead of pinchDeltaPrecision if different from 0.
  44507. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44508. */
  44509. get wheelDeltaPercentage(): number;
  44510. set wheelDeltaPercentage(value: number);
  44511. /**
  44512. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44513. */
  44514. zoomOnFactor: number;
  44515. /**
  44516. * Defines a screen offset for the camera position.
  44517. */
  44518. targetScreenOffset: Vector2;
  44519. /**
  44520. * Allows the camera to be completely reversed.
  44521. * If false the camera can not arrive upside down.
  44522. */
  44523. allowUpsideDown: boolean;
  44524. /**
  44525. * Define if double tap/click is used to restore the previously saved state of the camera.
  44526. */
  44527. useInputToRestoreState: boolean;
  44528. /** @hidden */
  44529. _viewMatrix: Matrix;
  44530. /** @hidden */
  44531. _useCtrlForPanning: boolean;
  44532. /** @hidden */
  44533. _panningMouseButton: number;
  44534. /**
  44535. * Defines the input associated to the camera.
  44536. */
  44537. inputs: ArcRotateCameraInputsManager;
  44538. /** @hidden */
  44539. _reset: () => void;
  44540. /**
  44541. * Defines the allowed panning axis.
  44542. */
  44543. panningAxis: Vector3;
  44544. protected _localDirection: Vector3;
  44545. protected _transformedDirection: Vector3;
  44546. private _bouncingBehavior;
  44547. /**
  44548. * Gets the bouncing behavior of the camera if it has been enabled.
  44549. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44550. */
  44551. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44552. /**
  44553. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44554. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44555. */
  44556. get useBouncingBehavior(): boolean;
  44557. set useBouncingBehavior(value: boolean);
  44558. private _framingBehavior;
  44559. /**
  44560. * Gets the framing behavior of the camera if it has been enabled.
  44561. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44562. */
  44563. get framingBehavior(): Nullable<FramingBehavior>;
  44564. /**
  44565. * Defines if the framing behavior of the camera is enabled on the camera.
  44566. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44567. */
  44568. get useFramingBehavior(): boolean;
  44569. set useFramingBehavior(value: boolean);
  44570. private _autoRotationBehavior;
  44571. /**
  44572. * Gets the auto rotation behavior of the camera if it has been enabled.
  44573. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44574. */
  44575. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44576. /**
  44577. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44578. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44579. */
  44580. get useAutoRotationBehavior(): boolean;
  44581. set useAutoRotationBehavior(value: boolean);
  44582. /**
  44583. * Observable triggered when the mesh target has been changed on the camera.
  44584. */
  44585. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44586. /**
  44587. * Event raised when the camera is colliding with a mesh.
  44588. */
  44589. onCollide: (collidedMesh: AbstractMesh) => void;
  44590. /**
  44591. * Defines whether the camera should check collision with the objects oh the scene.
  44592. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44593. */
  44594. checkCollisions: boolean;
  44595. /**
  44596. * Defines the collision radius of the camera.
  44597. * This simulates a sphere around the camera.
  44598. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44599. */
  44600. collisionRadius: Vector3;
  44601. protected _collider: Collider;
  44602. protected _previousPosition: Vector3;
  44603. protected _collisionVelocity: Vector3;
  44604. protected _newPosition: Vector3;
  44605. protected _previousAlpha: number;
  44606. protected _previousBeta: number;
  44607. protected _previousRadius: number;
  44608. protected _collisionTriggered: boolean;
  44609. protected _targetBoundingCenter: Nullable<Vector3>;
  44610. private _computationVector;
  44611. /**
  44612. * Instantiates a new ArcRotateCamera in a given scene
  44613. * @param name Defines the name of the camera
  44614. * @param alpha Defines the camera rotation along the logitudinal axis
  44615. * @param beta Defines the camera rotation along the latitudinal axis
  44616. * @param radius Defines the camera distance from its target
  44617. * @param target Defines the camera target
  44618. * @param scene Defines the scene the camera belongs to
  44619. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44620. */
  44621. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44622. /** @hidden */
  44623. _initCache(): void;
  44624. /** @hidden */
  44625. _updateCache(ignoreParentClass?: boolean): void;
  44626. protected _getTargetPosition(): Vector3;
  44627. private _storedAlpha;
  44628. private _storedBeta;
  44629. private _storedRadius;
  44630. private _storedTarget;
  44631. private _storedTargetScreenOffset;
  44632. /**
  44633. * Stores the current state of the camera (alpha, beta, radius and target)
  44634. * @returns the camera itself
  44635. */
  44636. storeState(): Camera;
  44637. /**
  44638. * @hidden
  44639. * Restored camera state. You must call storeState() first
  44640. */
  44641. _restoreStateValues(): boolean;
  44642. /** @hidden */
  44643. _isSynchronizedViewMatrix(): boolean;
  44644. /**
  44645. * Attached controls to the current camera.
  44646. * @param element Defines the element the controls should be listened from
  44647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44648. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44649. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44650. */
  44651. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44652. /**
  44653. * Detach the current controls from the camera.
  44654. * The camera will stop reacting to inputs.
  44655. * @param element Defines the element to stop listening the inputs from
  44656. */
  44657. detachControl(element: HTMLElement): void;
  44658. /** @hidden */
  44659. _checkInputs(): void;
  44660. protected _checkLimits(): void;
  44661. /**
  44662. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44663. */
  44664. rebuildAnglesAndRadius(): void;
  44665. /**
  44666. * Use a position to define the current camera related information like alpha, beta and radius
  44667. * @param position Defines the position to set the camera at
  44668. */
  44669. setPosition(position: Vector3): void;
  44670. /**
  44671. * Defines the target the camera should look at.
  44672. * This will automatically adapt alpha beta and radius to fit within the new target.
  44673. * @param target Defines the new target as a Vector or a mesh
  44674. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44675. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44676. */
  44677. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44678. /** @hidden */
  44679. _getViewMatrix(): Matrix;
  44680. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44681. /**
  44682. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44683. * @param meshes Defines the mesh to zoom on
  44684. * @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)
  44685. */
  44686. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44687. /**
  44688. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44689. * The target will be changed but the radius
  44690. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44691. * @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)
  44692. */
  44693. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44694. min: Vector3;
  44695. max: Vector3;
  44696. distance: number;
  44697. }, doNotUpdateMaxZ?: boolean): void;
  44698. /**
  44699. * @override
  44700. * Override Camera.createRigCamera
  44701. */
  44702. createRigCamera(name: string, cameraIndex: number): Camera;
  44703. /**
  44704. * @hidden
  44705. * @override
  44706. * Override Camera._updateRigCameras
  44707. */
  44708. _updateRigCameras(): void;
  44709. /**
  44710. * Destroy the camera and release the current resources hold by it.
  44711. */
  44712. dispose(): void;
  44713. /**
  44714. * Gets the current object class name.
  44715. * @return the class name
  44716. */
  44717. getClassName(): string;
  44718. }
  44719. }
  44720. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44721. import { Behavior } from "babylonjs/Behaviors/behavior";
  44722. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44723. /**
  44724. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44725. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44726. */
  44727. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44728. /**
  44729. * Gets the name of the behavior.
  44730. */
  44731. get name(): string;
  44732. private _zoomStopsAnimation;
  44733. private _idleRotationSpeed;
  44734. private _idleRotationWaitTime;
  44735. private _idleRotationSpinupTime;
  44736. /**
  44737. * Sets the flag that indicates if user zooming should stop animation.
  44738. */
  44739. set zoomStopsAnimation(flag: boolean);
  44740. /**
  44741. * Gets the flag that indicates if user zooming should stop animation.
  44742. */
  44743. get zoomStopsAnimation(): boolean;
  44744. /**
  44745. * Sets the default speed at which the camera rotates around the model.
  44746. */
  44747. set idleRotationSpeed(speed: number);
  44748. /**
  44749. * Gets the default speed at which the camera rotates around the model.
  44750. */
  44751. get idleRotationSpeed(): number;
  44752. /**
  44753. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44754. */
  44755. set idleRotationWaitTime(time: number);
  44756. /**
  44757. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44758. */
  44759. get idleRotationWaitTime(): number;
  44760. /**
  44761. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44762. */
  44763. set idleRotationSpinupTime(time: number);
  44764. /**
  44765. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44766. */
  44767. get idleRotationSpinupTime(): number;
  44768. /**
  44769. * Gets a value indicating if the camera is currently rotating because of this behavior
  44770. */
  44771. get rotationInProgress(): boolean;
  44772. private _onPrePointerObservableObserver;
  44773. private _onAfterCheckInputsObserver;
  44774. private _attachedCamera;
  44775. private _isPointerDown;
  44776. private _lastFrameTime;
  44777. private _lastInteractionTime;
  44778. private _cameraRotationSpeed;
  44779. /**
  44780. * Initializes the behavior.
  44781. */
  44782. init(): void;
  44783. /**
  44784. * Attaches the behavior to its arc rotate camera.
  44785. * @param camera Defines the camera to attach the behavior to
  44786. */
  44787. attach(camera: ArcRotateCamera): void;
  44788. /**
  44789. * Detaches the behavior from its current arc rotate camera.
  44790. */
  44791. detach(): void;
  44792. /**
  44793. * Returns true if user is scrolling.
  44794. * @return true if user is scrolling.
  44795. */
  44796. private _userIsZooming;
  44797. private _lastFrameRadius;
  44798. private _shouldAnimationStopForInteraction;
  44799. /**
  44800. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44801. */
  44802. private _applyUserInteraction;
  44803. private _userIsMoving;
  44804. }
  44805. }
  44806. declare module "babylonjs/Behaviors/Cameras/index" {
  44807. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44808. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44809. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44810. }
  44811. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44812. import { Mesh } from "babylonjs/Meshes/mesh";
  44813. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44814. import { Behavior } from "babylonjs/Behaviors/behavior";
  44815. /**
  44816. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44817. */
  44818. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44819. private ui;
  44820. /**
  44821. * The name of the behavior
  44822. */
  44823. name: string;
  44824. /**
  44825. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44826. */
  44827. distanceAwayFromFace: number;
  44828. /**
  44829. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44830. */
  44831. distanceAwayFromBottomOfFace: number;
  44832. private _faceVectors;
  44833. private _target;
  44834. private _scene;
  44835. private _onRenderObserver;
  44836. private _tmpMatrix;
  44837. private _tmpVector;
  44838. /**
  44839. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44840. * @param ui The transform node that should be attched to the mesh
  44841. */
  44842. constructor(ui: TransformNode);
  44843. /**
  44844. * Initializes the behavior
  44845. */
  44846. init(): void;
  44847. private _closestFace;
  44848. private _zeroVector;
  44849. private _lookAtTmpMatrix;
  44850. private _lookAtToRef;
  44851. /**
  44852. * Attaches the AttachToBoxBehavior to the passed in mesh
  44853. * @param target The mesh that the specified node will be attached to
  44854. */
  44855. attach(target: Mesh): void;
  44856. /**
  44857. * Detaches the behavior from the mesh
  44858. */
  44859. detach(): void;
  44860. }
  44861. }
  44862. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44863. import { Behavior } from "babylonjs/Behaviors/behavior";
  44864. import { Mesh } from "babylonjs/Meshes/mesh";
  44865. /**
  44866. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44867. */
  44868. export class FadeInOutBehavior implements Behavior<Mesh> {
  44869. /**
  44870. * Time in milliseconds to delay before fading in (Default: 0)
  44871. */
  44872. delay: number;
  44873. /**
  44874. * Time in milliseconds for the mesh to fade in (Default: 300)
  44875. */
  44876. fadeInTime: number;
  44877. private _millisecondsPerFrame;
  44878. private _hovered;
  44879. private _hoverValue;
  44880. private _ownerNode;
  44881. /**
  44882. * Instatiates the FadeInOutBehavior
  44883. */
  44884. constructor();
  44885. /**
  44886. * The name of the behavior
  44887. */
  44888. get name(): string;
  44889. /**
  44890. * Initializes the behavior
  44891. */
  44892. init(): void;
  44893. /**
  44894. * Attaches the fade behavior on the passed in mesh
  44895. * @param ownerNode The mesh that will be faded in/out once attached
  44896. */
  44897. attach(ownerNode: Mesh): void;
  44898. /**
  44899. * Detaches the behavior from the mesh
  44900. */
  44901. detach(): void;
  44902. /**
  44903. * Triggers the mesh to begin fading in or out
  44904. * @param value if the object should fade in or out (true to fade in)
  44905. */
  44906. fadeIn(value: boolean): void;
  44907. private _update;
  44908. private _setAllVisibility;
  44909. }
  44910. }
  44911. declare module "babylonjs/Misc/pivotTools" {
  44912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44913. /**
  44914. * Class containing a set of static utilities functions for managing Pivots
  44915. * @hidden
  44916. */
  44917. export class PivotTools {
  44918. private static _PivotCached;
  44919. private static _OldPivotPoint;
  44920. private static _PivotTranslation;
  44921. private static _PivotTmpVector;
  44922. private static _PivotPostMultiplyPivotMatrix;
  44923. /** @hidden */
  44924. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44925. /** @hidden */
  44926. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44927. }
  44928. }
  44929. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44930. import { Scene } from "babylonjs/scene";
  44931. import { Vector4 } from "babylonjs/Maths/math.vector";
  44932. import { Mesh } from "babylonjs/Meshes/mesh";
  44933. import { Nullable } from "babylonjs/types";
  44934. import { Plane } from "babylonjs/Maths/math.plane";
  44935. /**
  44936. * Class containing static functions to help procedurally build meshes
  44937. */
  44938. export class PlaneBuilder {
  44939. /**
  44940. * Creates a plane mesh
  44941. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44942. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44943. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44947. * @param name defines the name of the mesh
  44948. * @param options defines the options used to create the mesh
  44949. * @param scene defines the hosting scene
  44950. * @returns the plane mesh
  44951. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44952. */
  44953. static CreatePlane(name: string, options: {
  44954. size?: number;
  44955. width?: number;
  44956. height?: number;
  44957. sideOrientation?: number;
  44958. frontUVs?: Vector4;
  44959. backUVs?: Vector4;
  44960. updatable?: boolean;
  44961. sourcePlane?: Plane;
  44962. }, scene?: Nullable<Scene>): Mesh;
  44963. }
  44964. }
  44965. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44966. import { Behavior } from "babylonjs/Behaviors/behavior";
  44967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44968. import { Observable } from "babylonjs/Misc/observable";
  44969. import { Vector3 } from "babylonjs/Maths/math.vector";
  44970. import { Ray } from "babylonjs/Culling/ray";
  44971. import "babylonjs/Meshes/Builders/planeBuilder";
  44972. /**
  44973. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44974. */
  44975. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44976. private static _AnyMouseID;
  44977. /**
  44978. * Abstract mesh the behavior is set on
  44979. */
  44980. attachedNode: AbstractMesh;
  44981. private _dragPlane;
  44982. private _scene;
  44983. private _pointerObserver;
  44984. private _beforeRenderObserver;
  44985. private static _planeScene;
  44986. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44987. /**
  44988. * 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)
  44989. */
  44990. maxDragAngle: number;
  44991. /**
  44992. * @hidden
  44993. */
  44994. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44995. /**
  44996. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44997. */
  44998. currentDraggingPointerID: number;
  44999. /**
  45000. * The last position where the pointer hit the drag plane in world space
  45001. */
  45002. lastDragPosition: Vector3;
  45003. /**
  45004. * If the behavior is currently in a dragging state
  45005. */
  45006. dragging: boolean;
  45007. /**
  45008. * 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)
  45009. */
  45010. dragDeltaRatio: number;
  45011. /**
  45012. * If the drag plane orientation should be updated during the dragging (Default: true)
  45013. */
  45014. updateDragPlane: boolean;
  45015. private _debugMode;
  45016. private _moving;
  45017. /**
  45018. * Fires each time the attached mesh is dragged with the pointer
  45019. * * delta between last drag position and current drag position in world space
  45020. * * dragDistance along the drag axis
  45021. * * dragPlaneNormal normal of the current drag plane used during the drag
  45022. * * dragPlanePoint in world space where the drag intersects the drag plane
  45023. */
  45024. onDragObservable: Observable<{
  45025. delta: Vector3;
  45026. dragPlanePoint: Vector3;
  45027. dragPlaneNormal: Vector3;
  45028. dragDistance: number;
  45029. pointerId: number;
  45030. }>;
  45031. /**
  45032. * Fires each time a drag begins (eg. mouse down on mesh)
  45033. */
  45034. onDragStartObservable: Observable<{
  45035. dragPlanePoint: Vector3;
  45036. pointerId: number;
  45037. }>;
  45038. /**
  45039. * Fires each time a drag ends (eg. mouse release after drag)
  45040. */
  45041. onDragEndObservable: Observable<{
  45042. dragPlanePoint: Vector3;
  45043. pointerId: number;
  45044. }>;
  45045. /**
  45046. * If the attached mesh should be moved when dragged
  45047. */
  45048. moveAttached: boolean;
  45049. /**
  45050. * If the drag behavior will react to drag events (Default: true)
  45051. */
  45052. enabled: boolean;
  45053. /**
  45054. * If pointer events should start and release the drag (Default: true)
  45055. */
  45056. startAndReleaseDragOnPointerEvents: boolean;
  45057. /**
  45058. * If camera controls should be detached during the drag
  45059. */
  45060. detachCameraControls: boolean;
  45061. /**
  45062. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45063. */
  45064. useObjectOrientationForDragging: boolean;
  45065. private _options;
  45066. /**
  45067. * Gets the options used by the behavior
  45068. */
  45069. get options(): {
  45070. dragAxis?: Vector3;
  45071. dragPlaneNormal?: Vector3;
  45072. };
  45073. /**
  45074. * Sets the options used by the behavior
  45075. */
  45076. set options(options: {
  45077. dragAxis?: Vector3;
  45078. dragPlaneNormal?: Vector3;
  45079. });
  45080. /**
  45081. * Creates a pointer drag behavior that can be attached to a mesh
  45082. * @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)
  45083. */
  45084. constructor(options?: {
  45085. dragAxis?: Vector3;
  45086. dragPlaneNormal?: Vector3;
  45087. });
  45088. /**
  45089. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45090. */
  45091. validateDrag: (targetPosition: Vector3) => boolean;
  45092. /**
  45093. * The name of the behavior
  45094. */
  45095. get name(): string;
  45096. /**
  45097. * Initializes the behavior
  45098. */
  45099. init(): void;
  45100. private _tmpVector;
  45101. private _alternatePickedPoint;
  45102. private _worldDragAxis;
  45103. private _targetPosition;
  45104. private _attachedElement;
  45105. /**
  45106. * Attaches the drag behavior the passed in mesh
  45107. * @param ownerNode The mesh that will be dragged around once attached
  45108. * @param predicate Predicate to use for pick filtering
  45109. */
  45110. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45111. /**
  45112. * Force relase the drag action by code.
  45113. */
  45114. releaseDrag(): void;
  45115. private _startDragRay;
  45116. private _lastPointerRay;
  45117. /**
  45118. * Simulates the start of a pointer drag event on the behavior
  45119. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45120. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45121. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45122. */
  45123. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45124. private _startDrag;
  45125. private _dragDelta;
  45126. private _moveDrag;
  45127. private _pickWithRayOnDragPlane;
  45128. private _pointA;
  45129. private _pointC;
  45130. private _localAxis;
  45131. private _lookAt;
  45132. private _updateDragPlanePosition;
  45133. /**
  45134. * Detaches the behavior from the mesh
  45135. */
  45136. detach(): void;
  45137. }
  45138. }
  45139. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45140. import { Mesh } from "babylonjs/Meshes/mesh";
  45141. import { Behavior } from "babylonjs/Behaviors/behavior";
  45142. /**
  45143. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45144. */
  45145. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45146. private _dragBehaviorA;
  45147. private _dragBehaviorB;
  45148. private _startDistance;
  45149. private _initialScale;
  45150. private _targetScale;
  45151. private _ownerNode;
  45152. private _sceneRenderObserver;
  45153. /**
  45154. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45155. */
  45156. constructor();
  45157. /**
  45158. * The name of the behavior
  45159. */
  45160. get name(): string;
  45161. /**
  45162. * Initializes the behavior
  45163. */
  45164. init(): void;
  45165. private _getCurrentDistance;
  45166. /**
  45167. * Attaches the scale behavior the passed in mesh
  45168. * @param ownerNode The mesh that will be scaled around once attached
  45169. */
  45170. attach(ownerNode: Mesh): void;
  45171. /**
  45172. * Detaches the behavior from the mesh
  45173. */
  45174. detach(): void;
  45175. }
  45176. }
  45177. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45178. import { Behavior } from "babylonjs/Behaviors/behavior";
  45179. import { Mesh } from "babylonjs/Meshes/mesh";
  45180. import { Observable } from "babylonjs/Misc/observable";
  45181. /**
  45182. * 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
  45183. */
  45184. export class SixDofDragBehavior implements Behavior<Mesh> {
  45185. private static _virtualScene;
  45186. private _ownerNode;
  45187. private _sceneRenderObserver;
  45188. private _scene;
  45189. private _targetPosition;
  45190. private _virtualOriginMesh;
  45191. private _virtualDragMesh;
  45192. private _pointerObserver;
  45193. private _moving;
  45194. private _startingOrientation;
  45195. private _attachedElement;
  45196. /**
  45197. * 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)
  45198. */
  45199. private zDragFactor;
  45200. /**
  45201. * If the object should rotate to face the drag origin
  45202. */
  45203. rotateDraggedObject: boolean;
  45204. /**
  45205. * If the behavior is currently in a dragging state
  45206. */
  45207. dragging: boolean;
  45208. /**
  45209. * 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)
  45210. */
  45211. dragDeltaRatio: number;
  45212. /**
  45213. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45214. */
  45215. currentDraggingPointerID: number;
  45216. /**
  45217. * If camera controls should be detached during the drag
  45218. */
  45219. detachCameraControls: boolean;
  45220. /**
  45221. * Fires each time a drag starts
  45222. */
  45223. onDragStartObservable: Observable<{}>;
  45224. /**
  45225. * Fires each time a drag ends (eg. mouse release after drag)
  45226. */
  45227. onDragEndObservable: Observable<{}>;
  45228. /**
  45229. * 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
  45230. */
  45231. constructor();
  45232. /**
  45233. * The name of the behavior
  45234. */
  45235. get name(): string;
  45236. /**
  45237. * Initializes the behavior
  45238. */
  45239. init(): void;
  45240. /**
  45241. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45242. */
  45243. private get _pointerCamera();
  45244. /**
  45245. * Attaches the scale behavior the passed in mesh
  45246. * @param ownerNode The mesh that will be scaled around once attached
  45247. */
  45248. attach(ownerNode: Mesh): void;
  45249. /**
  45250. * Detaches the behavior from the mesh
  45251. */
  45252. detach(): void;
  45253. }
  45254. }
  45255. declare module "babylonjs/Behaviors/Meshes/index" {
  45256. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45257. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45258. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45259. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45260. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45261. }
  45262. declare module "babylonjs/Behaviors/index" {
  45263. export * from "babylonjs/Behaviors/behavior";
  45264. export * from "babylonjs/Behaviors/Cameras/index";
  45265. export * from "babylonjs/Behaviors/Meshes/index";
  45266. }
  45267. declare module "babylonjs/Bones/boneIKController" {
  45268. import { Bone } from "babylonjs/Bones/bone";
  45269. import { Vector3 } from "babylonjs/Maths/math.vector";
  45270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45271. import { Nullable } from "babylonjs/types";
  45272. /**
  45273. * Class used to apply inverse kinematics to bones
  45274. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45275. */
  45276. export class BoneIKController {
  45277. private static _tmpVecs;
  45278. private static _tmpQuat;
  45279. private static _tmpMats;
  45280. /**
  45281. * Gets or sets the target mesh
  45282. */
  45283. targetMesh: AbstractMesh;
  45284. /** Gets or sets the mesh used as pole */
  45285. poleTargetMesh: AbstractMesh;
  45286. /**
  45287. * Gets or sets the bone used as pole
  45288. */
  45289. poleTargetBone: Nullable<Bone>;
  45290. /**
  45291. * Gets or sets the target position
  45292. */
  45293. targetPosition: Vector3;
  45294. /**
  45295. * Gets or sets the pole target position
  45296. */
  45297. poleTargetPosition: Vector3;
  45298. /**
  45299. * Gets or sets the pole target local offset
  45300. */
  45301. poleTargetLocalOffset: Vector3;
  45302. /**
  45303. * Gets or sets the pole angle
  45304. */
  45305. poleAngle: number;
  45306. /**
  45307. * Gets or sets the mesh associated with the controller
  45308. */
  45309. mesh: AbstractMesh;
  45310. /**
  45311. * 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)
  45312. */
  45313. slerpAmount: number;
  45314. private _bone1Quat;
  45315. private _bone1Mat;
  45316. private _bone2Ang;
  45317. private _bone1;
  45318. private _bone2;
  45319. private _bone1Length;
  45320. private _bone2Length;
  45321. private _maxAngle;
  45322. private _maxReach;
  45323. private _rightHandedSystem;
  45324. private _bendAxis;
  45325. private _slerping;
  45326. private _adjustRoll;
  45327. /**
  45328. * Gets or sets maximum allowed angle
  45329. */
  45330. get maxAngle(): number;
  45331. set maxAngle(value: number);
  45332. /**
  45333. * Creates a new BoneIKController
  45334. * @param mesh defines the mesh to control
  45335. * @param bone defines the bone to control
  45336. * @param options defines options to set up the controller
  45337. */
  45338. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45339. targetMesh?: AbstractMesh;
  45340. poleTargetMesh?: AbstractMesh;
  45341. poleTargetBone?: Bone;
  45342. poleTargetLocalOffset?: Vector3;
  45343. poleAngle?: number;
  45344. bendAxis?: Vector3;
  45345. maxAngle?: number;
  45346. slerpAmount?: number;
  45347. });
  45348. private _setMaxAngle;
  45349. /**
  45350. * Force the controller to update the bones
  45351. */
  45352. update(): void;
  45353. }
  45354. }
  45355. declare module "babylonjs/Bones/boneLookController" {
  45356. import { Vector3 } from "babylonjs/Maths/math.vector";
  45357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45358. import { Bone } from "babylonjs/Bones/bone";
  45359. import { Space } from "babylonjs/Maths/math.axis";
  45360. /**
  45361. * Class used to make a bone look toward a point in space
  45362. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45363. */
  45364. export class BoneLookController {
  45365. private static _tmpVecs;
  45366. private static _tmpQuat;
  45367. private static _tmpMats;
  45368. /**
  45369. * The target Vector3 that the bone will look at
  45370. */
  45371. target: Vector3;
  45372. /**
  45373. * The mesh that the bone is attached to
  45374. */
  45375. mesh: AbstractMesh;
  45376. /**
  45377. * The bone that will be looking to the target
  45378. */
  45379. bone: Bone;
  45380. /**
  45381. * The up axis of the coordinate system that is used when the bone is rotated
  45382. */
  45383. upAxis: Vector3;
  45384. /**
  45385. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45386. */
  45387. upAxisSpace: Space;
  45388. /**
  45389. * Used to make an adjustment to the yaw of the bone
  45390. */
  45391. adjustYaw: number;
  45392. /**
  45393. * Used to make an adjustment to the pitch of the bone
  45394. */
  45395. adjustPitch: number;
  45396. /**
  45397. * Used to make an adjustment to the roll of the bone
  45398. */
  45399. adjustRoll: number;
  45400. /**
  45401. * 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)
  45402. */
  45403. slerpAmount: number;
  45404. private _minYaw;
  45405. private _maxYaw;
  45406. private _minPitch;
  45407. private _maxPitch;
  45408. private _minYawSin;
  45409. private _minYawCos;
  45410. private _maxYawSin;
  45411. private _maxYawCos;
  45412. private _midYawConstraint;
  45413. private _minPitchTan;
  45414. private _maxPitchTan;
  45415. private _boneQuat;
  45416. private _slerping;
  45417. private _transformYawPitch;
  45418. private _transformYawPitchInv;
  45419. private _firstFrameSkipped;
  45420. private _yawRange;
  45421. private _fowardAxis;
  45422. /**
  45423. * Gets or sets the minimum yaw angle that the bone can look to
  45424. */
  45425. get minYaw(): number;
  45426. set minYaw(value: number);
  45427. /**
  45428. * Gets or sets the maximum yaw angle that the bone can look to
  45429. */
  45430. get maxYaw(): number;
  45431. set maxYaw(value: number);
  45432. /**
  45433. * Gets or sets the minimum pitch angle that the bone can look to
  45434. */
  45435. get minPitch(): number;
  45436. set minPitch(value: number);
  45437. /**
  45438. * Gets or sets the maximum pitch angle that the bone can look to
  45439. */
  45440. get maxPitch(): number;
  45441. set maxPitch(value: number);
  45442. /**
  45443. * Create a BoneLookController
  45444. * @param mesh the mesh that the bone belongs to
  45445. * @param bone the bone that will be looking to the target
  45446. * @param target the target Vector3 to look at
  45447. * @param options optional settings:
  45448. * * maxYaw: the maximum angle the bone will yaw to
  45449. * * minYaw: the minimum angle the bone will yaw to
  45450. * * maxPitch: the maximum angle the bone will pitch to
  45451. * * minPitch: the minimum angle the bone will yaw to
  45452. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45453. * * upAxis: the up axis of the coordinate system
  45454. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45455. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45456. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45457. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45458. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45459. * * adjustRoll: used to make an adjustment to the roll of the bone
  45460. **/
  45461. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45462. maxYaw?: number;
  45463. minYaw?: number;
  45464. maxPitch?: number;
  45465. minPitch?: number;
  45466. slerpAmount?: number;
  45467. upAxis?: Vector3;
  45468. upAxisSpace?: Space;
  45469. yawAxis?: Vector3;
  45470. pitchAxis?: Vector3;
  45471. adjustYaw?: number;
  45472. adjustPitch?: number;
  45473. adjustRoll?: number;
  45474. });
  45475. /**
  45476. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45477. */
  45478. update(): void;
  45479. private _getAngleDiff;
  45480. private _getAngleBetween;
  45481. private _isAngleBetween;
  45482. }
  45483. }
  45484. declare module "babylonjs/Bones/index" {
  45485. export * from "babylonjs/Bones/bone";
  45486. export * from "babylonjs/Bones/boneIKController";
  45487. export * from "babylonjs/Bones/boneLookController";
  45488. export * from "babylonjs/Bones/skeleton";
  45489. }
  45490. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45491. import { Nullable } from "babylonjs/types";
  45492. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45493. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45494. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45495. /**
  45496. * Manage the gamepad inputs to control an arc rotate camera.
  45497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45498. */
  45499. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45500. /**
  45501. * Defines the camera the input is attached to.
  45502. */
  45503. camera: ArcRotateCamera;
  45504. /**
  45505. * Defines the gamepad the input is gathering event from.
  45506. */
  45507. gamepad: Nullable<Gamepad>;
  45508. /**
  45509. * Defines the gamepad rotation sensiblity.
  45510. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45511. */
  45512. gamepadRotationSensibility: number;
  45513. /**
  45514. * Defines the gamepad move sensiblity.
  45515. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45516. */
  45517. gamepadMoveSensibility: number;
  45518. private _yAxisScale;
  45519. /**
  45520. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45521. */
  45522. get invertYAxis(): boolean;
  45523. set invertYAxis(value: boolean);
  45524. private _onGamepadConnectedObserver;
  45525. private _onGamepadDisconnectedObserver;
  45526. /**
  45527. * Attach the input controls to a specific dom element to get the input from.
  45528. * @param element Defines the element the controls should be listened from
  45529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45530. */
  45531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45532. /**
  45533. * Detach the current controls from the specified dom element.
  45534. * @param element Defines the element to stop listening the inputs from
  45535. */
  45536. detachControl(element: Nullable<HTMLElement>): void;
  45537. /**
  45538. * Update the current camera state depending on the inputs that have been used this frame.
  45539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45540. */
  45541. checkInputs(): void;
  45542. /**
  45543. * Gets the class name of the current intput.
  45544. * @returns the class name
  45545. */
  45546. getClassName(): string;
  45547. /**
  45548. * Get the friendly name associated with the input class.
  45549. * @returns the input friendly name
  45550. */
  45551. getSimpleName(): string;
  45552. }
  45553. }
  45554. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45555. import { Nullable } from "babylonjs/types";
  45556. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45557. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45558. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45559. interface ArcRotateCameraInputsManager {
  45560. /**
  45561. * Add orientation input support to the input manager.
  45562. * @returns the current input manager
  45563. */
  45564. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45565. }
  45566. }
  45567. /**
  45568. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45570. */
  45571. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45572. /**
  45573. * Defines the camera the input is attached to.
  45574. */
  45575. camera: ArcRotateCamera;
  45576. /**
  45577. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45578. */
  45579. alphaCorrection: number;
  45580. /**
  45581. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45582. */
  45583. gammaCorrection: number;
  45584. private _alpha;
  45585. private _gamma;
  45586. private _dirty;
  45587. private _deviceOrientationHandler;
  45588. /**
  45589. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45590. */
  45591. constructor();
  45592. /**
  45593. * Attach the input controls to a specific dom element to get the input from.
  45594. * @param element Defines the element the controls should be listened from
  45595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45596. */
  45597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45598. /** @hidden */
  45599. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45600. /**
  45601. * Update the current camera state depending on the inputs that have been used this frame.
  45602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45603. */
  45604. checkInputs(): void;
  45605. /**
  45606. * Detach the current controls from the specified dom element.
  45607. * @param element Defines the element to stop listening the inputs from
  45608. */
  45609. detachControl(element: Nullable<HTMLElement>): void;
  45610. /**
  45611. * Gets the class name of the current intput.
  45612. * @returns the class name
  45613. */
  45614. getClassName(): string;
  45615. /**
  45616. * Get the friendly name associated with the input class.
  45617. * @returns the input friendly name
  45618. */
  45619. getSimpleName(): string;
  45620. }
  45621. }
  45622. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45623. import { Nullable } from "babylonjs/types";
  45624. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45625. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45626. /**
  45627. * Listen to mouse events to control the camera.
  45628. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45629. */
  45630. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45631. /**
  45632. * Defines the camera the input is attached to.
  45633. */
  45634. camera: FlyCamera;
  45635. /**
  45636. * Defines if touch is enabled. (Default is true.)
  45637. */
  45638. touchEnabled: boolean;
  45639. /**
  45640. * Defines the buttons associated with the input to handle camera rotation.
  45641. */
  45642. buttons: number[];
  45643. /**
  45644. * Assign buttons for Yaw control.
  45645. */
  45646. buttonsYaw: number[];
  45647. /**
  45648. * Assign buttons for Pitch control.
  45649. */
  45650. buttonsPitch: number[];
  45651. /**
  45652. * Assign buttons for Roll control.
  45653. */
  45654. buttonsRoll: number[];
  45655. /**
  45656. * Detect if any button is being pressed while mouse is moved.
  45657. * -1 = Mouse locked.
  45658. * 0 = Left button.
  45659. * 1 = Middle Button.
  45660. * 2 = Right Button.
  45661. */
  45662. activeButton: number;
  45663. /**
  45664. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45665. * Higher values reduce its sensitivity.
  45666. */
  45667. angularSensibility: number;
  45668. private _mousemoveCallback;
  45669. private _observer;
  45670. private _rollObserver;
  45671. private previousPosition;
  45672. private noPreventDefault;
  45673. private element;
  45674. /**
  45675. * Listen to mouse events to control the camera.
  45676. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45677. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45678. */
  45679. constructor(touchEnabled?: boolean);
  45680. /**
  45681. * Attach the mouse control to the HTML DOM element.
  45682. * @param element Defines the element that listens to the input events.
  45683. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45684. */
  45685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45686. /**
  45687. * Detach the current controls from the specified dom element.
  45688. * @param element Defines the element to stop listening the inputs from
  45689. */
  45690. detachControl(element: Nullable<HTMLElement>): void;
  45691. /**
  45692. * Gets the class name of the current input.
  45693. * @returns the class name.
  45694. */
  45695. getClassName(): string;
  45696. /**
  45697. * Get the friendly name associated with the input class.
  45698. * @returns the input's friendly name.
  45699. */
  45700. getSimpleName(): string;
  45701. private _pointerInput;
  45702. private _onMouseMove;
  45703. /**
  45704. * Rotate camera by mouse offset.
  45705. */
  45706. private rotateCamera;
  45707. }
  45708. }
  45709. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45710. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45711. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45712. /**
  45713. * Default Inputs manager for the FlyCamera.
  45714. * It groups all the default supported inputs for ease of use.
  45715. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45716. */
  45717. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45718. /**
  45719. * Instantiates a new FlyCameraInputsManager.
  45720. * @param camera Defines the camera the inputs belong to.
  45721. */
  45722. constructor(camera: FlyCamera);
  45723. /**
  45724. * Add keyboard input support to the input manager.
  45725. * @returns the new FlyCameraKeyboardMoveInput().
  45726. */
  45727. addKeyboard(): FlyCameraInputsManager;
  45728. /**
  45729. * Add mouse input support to the input manager.
  45730. * @param touchEnabled Enable touch screen support.
  45731. * @returns the new FlyCameraMouseInput().
  45732. */
  45733. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45734. }
  45735. }
  45736. declare module "babylonjs/Cameras/flyCamera" {
  45737. import { Scene } from "babylonjs/scene";
  45738. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45740. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45741. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45742. /**
  45743. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45744. * such as in a 3D Space Shooter or a Flight Simulator.
  45745. */
  45746. export class FlyCamera extends TargetCamera {
  45747. /**
  45748. * Define the collision ellipsoid of the camera.
  45749. * This is helpful for simulating a camera body, like a player's body.
  45750. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45751. */
  45752. ellipsoid: Vector3;
  45753. /**
  45754. * Define an offset for the position of the ellipsoid around the camera.
  45755. * This can be helpful if the camera is attached away from the player's body center,
  45756. * such as at its head.
  45757. */
  45758. ellipsoidOffset: Vector3;
  45759. /**
  45760. * Enable or disable collisions of the camera with the rest of the scene objects.
  45761. */
  45762. checkCollisions: boolean;
  45763. /**
  45764. * Enable or disable gravity on the camera.
  45765. */
  45766. applyGravity: boolean;
  45767. /**
  45768. * Define the current direction the camera is moving to.
  45769. */
  45770. cameraDirection: Vector3;
  45771. /**
  45772. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45773. * This overrides and empties cameraRotation.
  45774. */
  45775. rotationQuaternion: Quaternion;
  45776. /**
  45777. * Track Roll to maintain the wanted Rolling when looking around.
  45778. */
  45779. _trackRoll: number;
  45780. /**
  45781. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45782. */
  45783. rollCorrect: number;
  45784. /**
  45785. * Mimic a banked turn, Rolling the camera when Yawing.
  45786. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45787. */
  45788. bankedTurn: boolean;
  45789. /**
  45790. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45791. */
  45792. bankedTurnLimit: number;
  45793. /**
  45794. * Value of 0 disables the banked Roll.
  45795. * Value of 1 is equal to the Yaw angle in radians.
  45796. */
  45797. bankedTurnMultiplier: number;
  45798. /**
  45799. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45800. */
  45801. inputs: FlyCameraInputsManager;
  45802. /**
  45803. * Gets the input sensibility for mouse input.
  45804. * Higher values reduce sensitivity.
  45805. */
  45806. get angularSensibility(): number;
  45807. /**
  45808. * Sets the input sensibility for a mouse input.
  45809. * Higher values reduce sensitivity.
  45810. */
  45811. set angularSensibility(value: number);
  45812. /**
  45813. * Get the keys for camera movement forward.
  45814. */
  45815. get keysForward(): number[];
  45816. /**
  45817. * Set the keys for camera movement forward.
  45818. */
  45819. set keysForward(value: number[]);
  45820. /**
  45821. * Get the keys for camera movement backward.
  45822. */
  45823. get keysBackward(): number[];
  45824. set keysBackward(value: number[]);
  45825. /**
  45826. * Get the keys for camera movement up.
  45827. */
  45828. get keysUp(): number[];
  45829. /**
  45830. * Set the keys for camera movement up.
  45831. */
  45832. set keysUp(value: number[]);
  45833. /**
  45834. * Get the keys for camera movement down.
  45835. */
  45836. get keysDown(): number[];
  45837. /**
  45838. * Set the keys for camera movement down.
  45839. */
  45840. set keysDown(value: number[]);
  45841. /**
  45842. * Get the keys for camera movement left.
  45843. */
  45844. get keysLeft(): number[];
  45845. /**
  45846. * Set the keys for camera movement left.
  45847. */
  45848. set keysLeft(value: number[]);
  45849. /**
  45850. * Set the keys for camera movement right.
  45851. */
  45852. get keysRight(): number[];
  45853. /**
  45854. * Set the keys for camera movement right.
  45855. */
  45856. set keysRight(value: number[]);
  45857. /**
  45858. * Event raised when the camera collides with a mesh in the scene.
  45859. */
  45860. onCollide: (collidedMesh: AbstractMesh) => void;
  45861. private _collider;
  45862. private _needMoveForGravity;
  45863. private _oldPosition;
  45864. private _diffPosition;
  45865. private _newPosition;
  45866. /** @hidden */
  45867. _localDirection: Vector3;
  45868. /** @hidden */
  45869. _transformedDirection: Vector3;
  45870. /**
  45871. * Instantiates a FlyCamera.
  45872. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45873. * such as in a 3D Space Shooter or a Flight Simulator.
  45874. * @param name Define the name of the camera in the scene.
  45875. * @param position Define the starting position of the camera in the scene.
  45876. * @param scene Define the scene the camera belongs to.
  45877. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45878. */
  45879. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45880. /**
  45881. * Attach a control to the HTML DOM element.
  45882. * @param element Defines the element that listens to the input events.
  45883. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45884. */
  45885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45886. /**
  45887. * Detach a control from the HTML DOM element.
  45888. * The camera will stop reacting to that input.
  45889. * @param element Defines the element that listens to the input events.
  45890. */
  45891. detachControl(element: HTMLElement): void;
  45892. private _collisionMask;
  45893. /**
  45894. * Get the mask that the camera ignores in collision events.
  45895. */
  45896. get collisionMask(): number;
  45897. /**
  45898. * Set the mask that the camera ignores in collision events.
  45899. */
  45900. set collisionMask(mask: number);
  45901. /** @hidden */
  45902. _collideWithWorld(displacement: Vector3): void;
  45903. /** @hidden */
  45904. private _onCollisionPositionChange;
  45905. /** @hidden */
  45906. _checkInputs(): void;
  45907. /** @hidden */
  45908. _decideIfNeedsToMove(): boolean;
  45909. /** @hidden */
  45910. _updatePosition(): void;
  45911. /**
  45912. * Restore the Roll to its target value at the rate specified.
  45913. * @param rate - Higher means slower restoring.
  45914. * @hidden
  45915. */
  45916. restoreRoll(rate: number): void;
  45917. /**
  45918. * Destroy the camera and release the current resources held by it.
  45919. */
  45920. dispose(): void;
  45921. /**
  45922. * Get the current object class name.
  45923. * @returns the class name.
  45924. */
  45925. getClassName(): string;
  45926. }
  45927. }
  45928. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45929. import { Nullable } from "babylonjs/types";
  45930. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45931. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45932. /**
  45933. * Listen to keyboard events to control the camera.
  45934. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45935. */
  45936. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45937. /**
  45938. * Defines the camera the input is attached to.
  45939. */
  45940. camera: FlyCamera;
  45941. /**
  45942. * The list of keyboard keys used to control the forward move of the camera.
  45943. */
  45944. keysForward: number[];
  45945. /**
  45946. * The list of keyboard keys used to control the backward move of the camera.
  45947. */
  45948. keysBackward: number[];
  45949. /**
  45950. * The list of keyboard keys used to control the forward move of the camera.
  45951. */
  45952. keysUp: number[];
  45953. /**
  45954. * The list of keyboard keys used to control the backward move of the camera.
  45955. */
  45956. keysDown: number[];
  45957. /**
  45958. * The list of keyboard keys used to control the right strafe move of the camera.
  45959. */
  45960. keysRight: number[];
  45961. /**
  45962. * The list of keyboard keys used to control the left strafe move of the camera.
  45963. */
  45964. keysLeft: number[];
  45965. private _keys;
  45966. private _onCanvasBlurObserver;
  45967. private _onKeyboardObserver;
  45968. private _engine;
  45969. private _scene;
  45970. /**
  45971. * Attach the input controls to a specific dom element to get the input from.
  45972. * @param element Defines the element the controls should be listened from
  45973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45974. */
  45975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45976. /**
  45977. * Detach the current controls from the specified dom element.
  45978. * @param element Defines the element to stop listening the inputs from
  45979. */
  45980. detachControl(element: Nullable<HTMLElement>): void;
  45981. /**
  45982. * Gets the class name of the current intput.
  45983. * @returns the class name
  45984. */
  45985. getClassName(): string;
  45986. /** @hidden */
  45987. _onLostFocus(e: FocusEvent): void;
  45988. /**
  45989. * Get the friendly name associated with the input class.
  45990. * @returns the input friendly name
  45991. */
  45992. getSimpleName(): string;
  45993. /**
  45994. * Update the current camera state depending on the inputs that have been used this frame.
  45995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45996. */
  45997. checkInputs(): void;
  45998. }
  45999. }
  46000. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46001. import { Nullable } from "babylonjs/types";
  46002. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46003. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46004. /**
  46005. * Manage the mouse wheel inputs to control a follow camera.
  46006. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46007. */
  46008. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46009. /**
  46010. * Defines the camera the input is attached to.
  46011. */
  46012. camera: FollowCamera;
  46013. /**
  46014. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46015. */
  46016. axisControlRadius: boolean;
  46017. /**
  46018. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46019. */
  46020. axisControlHeight: boolean;
  46021. /**
  46022. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46023. */
  46024. axisControlRotation: boolean;
  46025. /**
  46026. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46027. * relation to mouseWheel events.
  46028. */
  46029. wheelPrecision: number;
  46030. /**
  46031. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46032. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46033. */
  46034. wheelDeltaPercentage: number;
  46035. private _wheel;
  46036. private _observer;
  46037. /**
  46038. * Attach the input controls to a specific dom element to get the input from.
  46039. * @param element Defines the element the controls should be listened from
  46040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46041. */
  46042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46043. /**
  46044. * Detach the current controls from the specified dom element.
  46045. * @param element Defines the element to stop listening the inputs from
  46046. */
  46047. detachControl(element: Nullable<HTMLElement>): void;
  46048. /**
  46049. * Gets the class name of the current intput.
  46050. * @returns the class name
  46051. */
  46052. getClassName(): string;
  46053. /**
  46054. * Get the friendly name associated with the input class.
  46055. * @returns the input friendly name
  46056. */
  46057. getSimpleName(): string;
  46058. }
  46059. }
  46060. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46061. import { Nullable } from "babylonjs/types";
  46062. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46063. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46064. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46065. /**
  46066. * Manage the pointers inputs to control an follow camera.
  46067. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46068. */
  46069. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46070. /**
  46071. * Defines the camera the input is attached to.
  46072. */
  46073. camera: FollowCamera;
  46074. /**
  46075. * Gets the class name of the current input.
  46076. * @returns the class name
  46077. */
  46078. getClassName(): string;
  46079. /**
  46080. * Defines the pointer angular sensibility along the X axis or how fast is
  46081. * the camera rotating.
  46082. * A negative number will reverse the axis direction.
  46083. */
  46084. angularSensibilityX: number;
  46085. /**
  46086. * Defines the pointer angular sensibility along the Y axis or how fast is
  46087. * the camera rotating.
  46088. * A negative number will reverse the axis direction.
  46089. */
  46090. angularSensibilityY: number;
  46091. /**
  46092. * Defines the pointer pinch precision or how fast is the camera zooming.
  46093. * A negative number will reverse the axis direction.
  46094. */
  46095. pinchPrecision: number;
  46096. /**
  46097. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46098. * from 0.
  46099. * It defines the percentage of current camera.radius to use as delta when
  46100. * pinch zoom is used.
  46101. */
  46102. pinchDeltaPercentage: number;
  46103. /**
  46104. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46105. */
  46106. axisXControlRadius: boolean;
  46107. /**
  46108. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46109. */
  46110. axisXControlHeight: boolean;
  46111. /**
  46112. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46113. */
  46114. axisXControlRotation: boolean;
  46115. /**
  46116. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46117. */
  46118. axisYControlRadius: boolean;
  46119. /**
  46120. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46121. */
  46122. axisYControlHeight: boolean;
  46123. /**
  46124. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46125. */
  46126. axisYControlRotation: boolean;
  46127. /**
  46128. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46129. */
  46130. axisPinchControlRadius: boolean;
  46131. /**
  46132. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46133. */
  46134. axisPinchControlHeight: boolean;
  46135. /**
  46136. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46137. */
  46138. axisPinchControlRotation: boolean;
  46139. /**
  46140. * Log error messages if basic misconfiguration has occurred.
  46141. */
  46142. warningEnable: boolean;
  46143. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46144. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46145. private _warningCounter;
  46146. private _warning;
  46147. }
  46148. }
  46149. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46150. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46151. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46152. /**
  46153. * Default Inputs manager for the FollowCamera.
  46154. * It groups all the default supported inputs for ease of use.
  46155. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46156. */
  46157. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46158. /**
  46159. * Instantiates a new FollowCameraInputsManager.
  46160. * @param camera Defines the camera the inputs belong to
  46161. */
  46162. constructor(camera: FollowCamera);
  46163. /**
  46164. * Add keyboard input support to the input manager.
  46165. * @returns the current input manager
  46166. */
  46167. addKeyboard(): FollowCameraInputsManager;
  46168. /**
  46169. * Add mouse wheel input support to the input manager.
  46170. * @returns the current input manager
  46171. */
  46172. addMouseWheel(): FollowCameraInputsManager;
  46173. /**
  46174. * Add pointers input support to the input manager.
  46175. * @returns the current input manager
  46176. */
  46177. addPointers(): FollowCameraInputsManager;
  46178. /**
  46179. * Add orientation input support to the input manager.
  46180. * @returns the current input manager
  46181. */
  46182. addVRDeviceOrientation(): FollowCameraInputsManager;
  46183. }
  46184. }
  46185. declare module "babylonjs/Cameras/followCamera" {
  46186. import { Nullable } from "babylonjs/types";
  46187. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46188. import { Scene } from "babylonjs/scene";
  46189. import { Vector3 } from "babylonjs/Maths/math.vector";
  46190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46191. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46192. /**
  46193. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46194. * an arc rotate version arcFollowCamera are available.
  46195. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46196. */
  46197. export class FollowCamera extends TargetCamera {
  46198. /**
  46199. * Distance the follow camera should follow an object at
  46200. */
  46201. radius: number;
  46202. /**
  46203. * Minimum allowed distance of the camera to the axis of rotation
  46204. * (The camera can not get closer).
  46205. * This can help limiting how the Camera is able to move in the scene.
  46206. */
  46207. lowerRadiusLimit: Nullable<number>;
  46208. /**
  46209. * Maximum allowed distance of the camera to the axis of rotation
  46210. * (The camera can not get further).
  46211. * This can help limiting how the Camera is able to move in the scene.
  46212. */
  46213. upperRadiusLimit: Nullable<number>;
  46214. /**
  46215. * Define a rotation offset between the camera and the object it follows
  46216. */
  46217. rotationOffset: number;
  46218. /**
  46219. * Minimum allowed angle to camera position relative to target object.
  46220. * This can help limiting how the Camera is able to move in the scene.
  46221. */
  46222. lowerRotationOffsetLimit: Nullable<number>;
  46223. /**
  46224. * Maximum allowed angle to camera position relative to target object.
  46225. * This can help limiting how the Camera is able to move in the scene.
  46226. */
  46227. upperRotationOffsetLimit: Nullable<number>;
  46228. /**
  46229. * Define a height offset between the camera and the object it follows.
  46230. * It can help following an object from the top (like a car chaing a plane)
  46231. */
  46232. heightOffset: number;
  46233. /**
  46234. * Minimum allowed height of camera position relative to target object.
  46235. * This can help limiting how the Camera is able to move in the scene.
  46236. */
  46237. lowerHeightOffsetLimit: Nullable<number>;
  46238. /**
  46239. * Maximum allowed height of camera position relative to target object.
  46240. * This can help limiting how the Camera is able to move in the scene.
  46241. */
  46242. upperHeightOffsetLimit: Nullable<number>;
  46243. /**
  46244. * Define how fast the camera can accelerate to follow it s target.
  46245. */
  46246. cameraAcceleration: number;
  46247. /**
  46248. * Define the speed limit of the camera following an object.
  46249. */
  46250. maxCameraSpeed: number;
  46251. /**
  46252. * Define the target of the camera.
  46253. */
  46254. lockedTarget: Nullable<AbstractMesh>;
  46255. /**
  46256. * Defines the input associated with the camera.
  46257. */
  46258. inputs: FollowCameraInputsManager;
  46259. /**
  46260. * Instantiates the follow camera.
  46261. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46262. * @param name Define the name of the camera in the scene
  46263. * @param position Define the position of the camera
  46264. * @param scene Define the scene the camera belong to
  46265. * @param lockedTarget Define the target of the camera
  46266. */
  46267. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46268. private _follow;
  46269. /**
  46270. * Attached controls to the current camera.
  46271. * @param element Defines the element the controls should be listened from
  46272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46273. */
  46274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46275. /**
  46276. * Detach the current controls from the camera.
  46277. * The camera will stop reacting to inputs.
  46278. * @param element Defines the element to stop listening the inputs from
  46279. */
  46280. detachControl(element: HTMLElement): void;
  46281. /** @hidden */
  46282. _checkInputs(): void;
  46283. private _checkLimits;
  46284. /**
  46285. * Gets the camera class name.
  46286. * @returns the class name
  46287. */
  46288. getClassName(): string;
  46289. }
  46290. /**
  46291. * Arc Rotate version of the follow camera.
  46292. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46293. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46294. */
  46295. export class ArcFollowCamera extends TargetCamera {
  46296. /** The longitudinal angle of the camera */
  46297. alpha: number;
  46298. /** The latitudinal angle of the camera */
  46299. beta: number;
  46300. /** The radius of the camera from its target */
  46301. radius: number;
  46302. private _cartesianCoordinates;
  46303. /** Define the camera target (the mesh it should follow) */
  46304. private _meshTarget;
  46305. /**
  46306. * Instantiates a new ArcFollowCamera
  46307. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46308. * @param name Define the name of the camera
  46309. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46310. * @param beta Define the rotation angle of the camera around the elevation axis
  46311. * @param radius Define the radius of the camera from its target point
  46312. * @param target Define the target of the camera
  46313. * @param scene Define the scene the camera belongs to
  46314. */
  46315. constructor(name: string,
  46316. /** The longitudinal angle of the camera */
  46317. alpha: number,
  46318. /** The latitudinal angle of the camera */
  46319. beta: number,
  46320. /** The radius of the camera from its target */
  46321. radius: number,
  46322. /** Define the camera target (the mesh it should follow) */
  46323. target: Nullable<AbstractMesh>, scene: Scene);
  46324. private _follow;
  46325. /** @hidden */
  46326. _checkInputs(): void;
  46327. /**
  46328. * Returns the class name of the object.
  46329. * It is mostly used internally for serialization purposes.
  46330. */
  46331. getClassName(): string;
  46332. }
  46333. }
  46334. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46335. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46336. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46337. import { Nullable } from "babylonjs/types";
  46338. /**
  46339. * Manage the keyboard inputs to control the movement of a follow camera.
  46340. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46341. */
  46342. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46343. /**
  46344. * Defines the camera the input is attached to.
  46345. */
  46346. camera: FollowCamera;
  46347. /**
  46348. * Defines the list of key codes associated with the up action (increase heightOffset)
  46349. */
  46350. keysHeightOffsetIncr: number[];
  46351. /**
  46352. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46353. */
  46354. keysHeightOffsetDecr: number[];
  46355. /**
  46356. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46357. */
  46358. keysHeightOffsetModifierAlt: boolean;
  46359. /**
  46360. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46361. */
  46362. keysHeightOffsetModifierCtrl: boolean;
  46363. /**
  46364. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46365. */
  46366. keysHeightOffsetModifierShift: boolean;
  46367. /**
  46368. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46369. */
  46370. keysRotationOffsetIncr: number[];
  46371. /**
  46372. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46373. */
  46374. keysRotationOffsetDecr: number[];
  46375. /**
  46376. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46377. */
  46378. keysRotationOffsetModifierAlt: boolean;
  46379. /**
  46380. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46381. */
  46382. keysRotationOffsetModifierCtrl: boolean;
  46383. /**
  46384. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46385. */
  46386. keysRotationOffsetModifierShift: boolean;
  46387. /**
  46388. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46389. */
  46390. keysRadiusIncr: number[];
  46391. /**
  46392. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46393. */
  46394. keysRadiusDecr: number[];
  46395. /**
  46396. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46397. */
  46398. keysRadiusModifierAlt: boolean;
  46399. /**
  46400. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46401. */
  46402. keysRadiusModifierCtrl: boolean;
  46403. /**
  46404. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46405. */
  46406. keysRadiusModifierShift: boolean;
  46407. /**
  46408. * Defines the rate of change of heightOffset.
  46409. */
  46410. heightSensibility: number;
  46411. /**
  46412. * Defines the rate of change of rotationOffset.
  46413. */
  46414. rotationSensibility: number;
  46415. /**
  46416. * Defines the rate of change of radius.
  46417. */
  46418. radiusSensibility: number;
  46419. private _keys;
  46420. private _ctrlPressed;
  46421. private _altPressed;
  46422. private _shiftPressed;
  46423. private _onCanvasBlurObserver;
  46424. private _onKeyboardObserver;
  46425. private _engine;
  46426. private _scene;
  46427. /**
  46428. * Attach the input controls to a specific dom element to get the input from.
  46429. * @param element Defines the element the controls should be listened from
  46430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46431. */
  46432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46433. /**
  46434. * Detach the current controls from the specified dom element.
  46435. * @param element Defines the element to stop listening the inputs from
  46436. */
  46437. detachControl(element: Nullable<HTMLElement>): void;
  46438. /**
  46439. * Update the current camera state depending on the inputs that have been used this frame.
  46440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46441. */
  46442. checkInputs(): void;
  46443. /**
  46444. * Gets the class name of the current input.
  46445. * @returns the class name
  46446. */
  46447. getClassName(): string;
  46448. /**
  46449. * Get the friendly name associated with the input class.
  46450. * @returns the input friendly name
  46451. */
  46452. getSimpleName(): string;
  46453. /**
  46454. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46455. * allow modification of the heightOffset value.
  46456. */
  46457. private _modifierHeightOffset;
  46458. /**
  46459. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46460. * allow modification of the rotationOffset value.
  46461. */
  46462. private _modifierRotationOffset;
  46463. /**
  46464. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46465. * allow modification of the radius value.
  46466. */
  46467. private _modifierRadius;
  46468. }
  46469. }
  46470. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46471. import { Nullable } from "babylonjs/types";
  46472. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46473. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46474. import { Observable } from "babylonjs/Misc/observable";
  46475. module "babylonjs/Cameras/freeCameraInputsManager" {
  46476. interface FreeCameraInputsManager {
  46477. /**
  46478. * @hidden
  46479. */
  46480. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46481. /**
  46482. * Add orientation input support to the input manager.
  46483. * @returns the current input manager
  46484. */
  46485. addDeviceOrientation(): FreeCameraInputsManager;
  46486. }
  46487. }
  46488. /**
  46489. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46490. * Screen rotation is taken into account.
  46491. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46492. */
  46493. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46494. private _camera;
  46495. private _screenOrientationAngle;
  46496. private _constantTranform;
  46497. private _screenQuaternion;
  46498. private _alpha;
  46499. private _beta;
  46500. private _gamma;
  46501. /**
  46502. * Can be used to detect if a device orientation sensor is available on a device
  46503. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46504. * @returns a promise that will resolve on orientation change
  46505. */
  46506. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46507. /**
  46508. * @hidden
  46509. */
  46510. _onDeviceOrientationChangedObservable: Observable<void>;
  46511. /**
  46512. * Instantiates a new input
  46513. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46514. */
  46515. constructor();
  46516. /**
  46517. * Define the camera controlled by the input.
  46518. */
  46519. get camera(): FreeCamera;
  46520. set camera(camera: FreeCamera);
  46521. /**
  46522. * Attach the input controls to a specific dom element to get the input from.
  46523. * @param element Defines the element the controls should be listened from
  46524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46525. */
  46526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46527. private _orientationChanged;
  46528. private _deviceOrientation;
  46529. /**
  46530. * Detach the current controls from the specified dom element.
  46531. * @param element Defines the element to stop listening the inputs from
  46532. */
  46533. detachControl(element: Nullable<HTMLElement>): void;
  46534. /**
  46535. * Update the current camera state depending on the inputs that have been used this frame.
  46536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46537. */
  46538. checkInputs(): void;
  46539. /**
  46540. * Gets the class name of the current intput.
  46541. * @returns the class name
  46542. */
  46543. getClassName(): string;
  46544. /**
  46545. * Get the friendly name associated with the input class.
  46546. * @returns the input friendly name
  46547. */
  46548. getSimpleName(): string;
  46549. }
  46550. }
  46551. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46552. import { Nullable } from "babylonjs/types";
  46553. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46554. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46555. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46556. /**
  46557. * Manage the gamepad inputs to control a free camera.
  46558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46559. */
  46560. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46561. /**
  46562. * Define the camera the input is attached to.
  46563. */
  46564. camera: FreeCamera;
  46565. /**
  46566. * Define the Gamepad controlling the input
  46567. */
  46568. gamepad: Nullable<Gamepad>;
  46569. /**
  46570. * Defines the gamepad rotation sensiblity.
  46571. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46572. */
  46573. gamepadAngularSensibility: number;
  46574. /**
  46575. * Defines the gamepad move sensiblity.
  46576. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46577. */
  46578. gamepadMoveSensibility: number;
  46579. private _yAxisScale;
  46580. /**
  46581. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46582. */
  46583. get invertYAxis(): boolean;
  46584. set invertYAxis(value: boolean);
  46585. private _onGamepadConnectedObserver;
  46586. private _onGamepadDisconnectedObserver;
  46587. private _cameraTransform;
  46588. private _deltaTransform;
  46589. private _vector3;
  46590. private _vector2;
  46591. /**
  46592. * Attach the input controls to a specific dom element to get the input from.
  46593. * @param element Defines the element the controls should be listened from
  46594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46595. */
  46596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46597. /**
  46598. * Detach the current controls from the specified dom element.
  46599. * @param element Defines the element to stop listening the inputs from
  46600. */
  46601. detachControl(element: Nullable<HTMLElement>): void;
  46602. /**
  46603. * Update the current camera state depending on the inputs that have been used this frame.
  46604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46605. */
  46606. checkInputs(): void;
  46607. /**
  46608. * Gets the class name of the current intput.
  46609. * @returns the class name
  46610. */
  46611. getClassName(): string;
  46612. /**
  46613. * Get the friendly name associated with the input class.
  46614. * @returns the input friendly name
  46615. */
  46616. getSimpleName(): string;
  46617. }
  46618. }
  46619. declare module "babylonjs/Misc/virtualJoystick" {
  46620. import { Nullable } from "babylonjs/types";
  46621. import { Vector3 } from "babylonjs/Maths/math.vector";
  46622. /**
  46623. * Defines the potential axis of a Joystick
  46624. */
  46625. export enum JoystickAxis {
  46626. /** X axis */
  46627. X = 0,
  46628. /** Y axis */
  46629. Y = 1,
  46630. /** Z axis */
  46631. Z = 2
  46632. }
  46633. /**
  46634. * Represents the different customization options available
  46635. * for VirtualJoystick
  46636. */
  46637. interface VirtualJoystickCustomizations {
  46638. /**
  46639. * Size of the joystick's puck
  46640. */
  46641. puckSize: number;
  46642. /**
  46643. * Size of the joystick's container
  46644. */
  46645. containerSize: number;
  46646. /**
  46647. * Color of the joystick && puck
  46648. */
  46649. color: string;
  46650. /**
  46651. * Image URL for the joystick's puck
  46652. */
  46653. puckImage?: string;
  46654. /**
  46655. * Image URL for the joystick's container
  46656. */
  46657. containerImage?: string;
  46658. /**
  46659. * Defines the unmoving position of the joystick container
  46660. */
  46661. position?: {
  46662. x: number;
  46663. y: number;
  46664. };
  46665. /**
  46666. * Defines whether or not the joystick container is always visible
  46667. */
  46668. alwaysVisible: boolean;
  46669. /**
  46670. * Defines whether or not to limit the movement of the puck to the joystick's container
  46671. */
  46672. limitToContainer: boolean;
  46673. }
  46674. /**
  46675. * Class used to define virtual joystick (used in touch mode)
  46676. */
  46677. export class VirtualJoystick {
  46678. /**
  46679. * Gets or sets a boolean indicating that left and right values must be inverted
  46680. */
  46681. reverseLeftRight: boolean;
  46682. /**
  46683. * Gets or sets a boolean indicating that up and down values must be inverted
  46684. */
  46685. reverseUpDown: boolean;
  46686. /**
  46687. * Gets the offset value for the position (ie. the change of the position value)
  46688. */
  46689. deltaPosition: Vector3;
  46690. /**
  46691. * Gets a boolean indicating if the virtual joystick was pressed
  46692. */
  46693. pressed: boolean;
  46694. /**
  46695. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46696. */
  46697. static Canvas: Nullable<HTMLCanvasElement>;
  46698. /**
  46699. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46700. */
  46701. limitToContainer: boolean;
  46702. private static _globalJoystickIndex;
  46703. private static _alwaysVisibleSticks;
  46704. private static vjCanvasContext;
  46705. private static vjCanvasWidth;
  46706. private static vjCanvasHeight;
  46707. private static halfWidth;
  46708. private static _GetDefaultOptions;
  46709. private _action;
  46710. private _axisTargetedByLeftAndRight;
  46711. private _axisTargetedByUpAndDown;
  46712. private _joystickSensibility;
  46713. private _inversedSensibility;
  46714. private _joystickPointerID;
  46715. private _joystickColor;
  46716. private _joystickPointerPos;
  46717. private _joystickPreviousPointerPos;
  46718. private _joystickPointerStartPos;
  46719. private _deltaJoystickVector;
  46720. private _leftJoystick;
  46721. private _touches;
  46722. private _joystickPosition;
  46723. private _alwaysVisible;
  46724. private _puckImage;
  46725. private _containerImage;
  46726. private _joystickPuckSize;
  46727. private _joystickContainerSize;
  46728. private _clearPuckSize;
  46729. private _clearContainerSize;
  46730. private _clearPuckSizeOffset;
  46731. private _clearContainerSizeOffset;
  46732. private _onPointerDownHandlerRef;
  46733. private _onPointerMoveHandlerRef;
  46734. private _onPointerUpHandlerRef;
  46735. private _onResize;
  46736. /**
  46737. * Creates a new virtual joystick
  46738. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46739. * @param customizations Defines the options we want to customize the VirtualJoystick
  46740. */
  46741. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46742. /**
  46743. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46744. * @param newJoystickSensibility defines the new sensibility
  46745. */
  46746. setJoystickSensibility(newJoystickSensibility: number): void;
  46747. private _onPointerDown;
  46748. private _onPointerMove;
  46749. private _onPointerUp;
  46750. /**
  46751. * Change the color of the virtual joystick
  46752. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46753. */
  46754. setJoystickColor(newColor: string): void;
  46755. /**
  46756. * Size of the joystick's container
  46757. */
  46758. set containerSize(newSize: number);
  46759. get containerSize(): number;
  46760. /**
  46761. * Size of the joystick's puck
  46762. */
  46763. set puckSize(newSize: number);
  46764. get puckSize(): number;
  46765. /**
  46766. * Clears the set position of the joystick
  46767. */
  46768. clearPosition(): void;
  46769. /**
  46770. * Defines whether or not the joystick container is always visible
  46771. */
  46772. set alwaysVisible(value: boolean);
  46773. get alwaysVisible(): boolean;
  46774. /**
  46775. * Sets the constant position of the Joystick container
  46776. * @param x X axis coordinate
  46777. * @param y Y axis coordinate
  46778. */
  46779. setPosition(x: number, y: number): void;
  46780. /**
  46781. * Defines a callback to call when the joystick is touched
  46782. * @param action defines the callback
  46783. */
  46784. setActionOnTouch(action: () => any): void;
  46785. /**
  46786. * Defines which axis you'd like to control for left & right
  46787. * @param axis defines the axis to use
  46788. */
  46789. setAxisForLeftRight(axis: JoystickAxis): void;
  46790. /**
  46791. * Defines which axis you'd like to control for up & down
  46792. * @param axis defines the axis to use
  46793. */
  46794. setAxisForUpDown(axis: JoystickAxis): void;
  46795. /**
  46796. * Clears the canvas from the previous puck / container draw
  46797. */
  46798. private _clearPreviousDraw;
  46799. /**
  46800. * Loads `urlPath` to be used for the container's image
  46801. * @param urlPath defines the urlPath of an image to use
  46802. */
  46803. setContainerImage(urlPath: string): void;
  46804. /**
  46805. * Loads `urlPath` to be used for the puck's image
  46806. * @param urlPath defines the urlPath of an image to use
  46807. */
  46808. setPuckImage(urlPath: string): void;
  46809. /**
  46810. * Draws the Virtual Joystick's container
  46811. */
  46812. private _drawContainer;
  46813. /**
  46814. * Draws the Virtual Joystick's puck
  46815. */
  46816. private _drawPuck;
  46817. private _drawVirtualJoystick;
  46818. /**
  46819. * Release internal HTML canvas
  46820. */
  46821. releaseCanvas(): void;
  46822. }
  46823. }
  46824. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46825. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46826. import { Nullable } from "babylonjs/types";
  46827. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46828. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46829. module "babylonjs/Cameras/freeCameraInputsManager" {
  46830. interface FreeCameraInputsManager {
  46831. /**
  46832. * Add virtual joystick input support to the input manager.
  46833. * @returns the current input manager
  46834. */
  46835. addVirtualJoystick(): FreeCameraInputsManager;
  46836. }
  46837. }
  46838. /**
  46839. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46840. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46841. */
  46842. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46843. /**
  46844. * Defines the camera the input is attached to.
  46845. */
  46846. camera: FreeCamera;
  46847. private _leftjoystick;
  46848. private _rightjoystick;
  46849. /**
  46850. * Gets the left stick of the virtual joystick.
  46851. * @returns The virtual Joystick
  46852. */
  46853. getLeftJoystick(): VirtualJoystick;
  46854. /**
  46855. * Gets the right stick of the virtual joystick.
  46856. * @returns The virtual Joystick
  46857. */
  46858. getRightJoystick(): VirtualJoystick;
  46859. /**
  46860. * Update the current camera state depending on the inputs that have been used this frame.
  46861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46862. */
  46863. checkInputs(): void;
  46864. /**
  46865. * Attach the input controls to a specific dom element to get the input from.
  46866. * @param element Defines the element the controls should be listened from
  46867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46868. */
  46869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46870. /**
  46871. * Detach the current controls from the specified dom element.
  46872. * @param element Defines the element to stop listening the inputs from
  46873. */
  46874. detachControl(element: Nullable<HTMLElement>): void;
  46875. /**
  46876. * Gets the class name of the current intput.
  46877. * @returns the class name
  46878. */
  46879. getClassName(): string;
  46880. /**
  46881. * Get the friendly name associated with the input class.
  46882. * @returns the input friendly name
  46883. */
  46884. getSimpleName(): string;
  46885. }
  46886. }
  46887. declare module "babylonjs/Cameras/Inputs/index" {
  46888. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46889. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46890. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46891. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46892. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46893. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46894. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46895. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46896. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46897. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46898. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46899. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46900. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46901. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46902. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46903. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46904. }
  46905. declare module "babylonjs/Cameras/touchCamera" {
  46906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46907. import { Scene } from "babylonjs/scene";
  46908. import { Vector3 } from "babylonjs/Maths/math.vector";
  46909. /**
  46910. * This represents a FPS type of camera controlled by touch.
  46911. * This is like a universal camera minus the Gamepad controls.
  46912. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46913. */
  46914. export class TouchCamera extends FreeCamera {
  46915. /**
  46916. * Defines the touch sensibility for rotation.
  46917. * The higher the faster.
  46918. */
  46919. get touchAngularSensibility(): number;
  46920. set touchAngularSensibility(value: number);
  46921. /**
  46922. * Defines the touch sensibility for move.
  46923. * The higher the faster.
  46924. */
  46925. get touchMoveSensibility(): number;
  46926. set touchMoveSensibility(value: number);
  46927. /**
  46928. * Instantiates a new touch camera.
  46929. * This represents a FPS type of camera controlled by touch.
  46930. * This is like a universal camera minus the Gamepad controls.
  46931. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46932. * @param name Define the name of the camera in the scene
  46933. * @param position Define the start position of the camera in the scene
  46934. * @param scene Define the scene the camera belongs to
  46935. */
  46936. constructor(name: string, position: Vector3, scene: Scene);
  46937. /**
  46938. * Gets the current object class name.
  46939. * @return the class name
  46940. */
  46941. getClassName(): string;
  46942. /** @hidden */
  46943. _setupInputs(): void;
  46944. }
  46945. }
  46946. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46947. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46948. import { Scene } from "babylonjs/scene";
  46949. import { Vector3 } from "babylonjs/Maths/math.vector";
  46950. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46951. import { Axis } from "babylonjs/Maths/math.axis";
  46952. /**
  46953. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46954. * being tilted forward or back and left or right.
  46955. */
  46956. export class DeviceOrientationCamera extends FreeCamera {
  46957. private _initialQuaternion;
  46958. private _quaternionCache;
  46959. private _tmpDragQuaternion;
  46960. private _disablePointerInputWhenUsingDeviceOrientation;
  46961. /**
  46962. * Creates a new device orientation camera
  46963. * @param name The name of the camera
  46964. * @param position The start position camera
  46965. * @param scene The scene the camera belongs to
  46966. */
  46967. constructor(name: string, position: Vector3, scene: Scene);
  46968. /**
  46969. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46970. */
  46971. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46972. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46973. private _dragFactor;
  46974. /**
  46975. * Enabled turning on the y axis when the orientation sensor is active
  46976. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46977. */
  46978. enableHorizontalDragging(dragFactor?: number): void;
  46979. /**
  46980. * Gets the current instance class name ("DeviceOrientationCamera").
  46981. * This helps avoiding instanceof at run time.
  46982. * @returns the class name
  46983. */
  46984. getClassName(): string;
  46985. /**
  46986. * @hidden
  46987. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46988. */
  46989. _checkInputs(): void;
  46990. /**
  46991. * Reset the camera to its default orientation on the specified axis only.
  46992. * @param axis The axis to reset
  46993. */
  46994. resetToCurrentRotation(axis?: Axis): void;
  46995. }
  46996. }
  46997. declare module "babylonjs/Gamepads/xboxGamepad" {
  46998. import { Observable } from "babylonjs/Misc/observable";
  46999. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47000. /**
  47001. * Defines supported buttons for XBox360 compatible gamepads
  47002. */
  47003. export enum Xbox360Button {
  47004. /** A */
  47005. A = 0,
  47006. /** B */
  47007. B = 1,
  47008. /** X */
  47009. X = 2,
  47010. /** Y */
  47011. Y = 3,
  47012. /** Left button */
  47013. LB = 4,
  47014. /** Right button */
  47015. RB = 5,
  47016. /** Back */
  47017. Back = 8,
  47018. /** Start */
  47019. Start = 9,
  47020. /** Left stick */
  47021. LeftStick = 10,
  47022. /** Right stick */
  47023. RightStick = 11
  47024. }
  47025. /** Defines values for XBox360 DPad */
  47026. export enum Xbox360Dpad {
  47027. /** Up */
  47028. Up = 12,
  47029. /** Down */
  47030. Down = 13,
  47031. /** Left */
  47032. Left = 14,
  47033. /** Right */
  47034. Right = 15
  47035. }
  47036. /**
  47037. * Defines a XBox360 gamepad
  47038. */
  47039. export class Xbox360Pad extends Gamepad {
  47040. private _leftTrigger;
  47041. private _rightTrigger;
  47042. private _onlefttriggerchanged;
  47043. private _onrighttriggerchanged;
  47044. private _onbuttondown;
  47045. private _onbuttonup;
  47046. private _ondpaddown;
  47047. private _ondpadup;
  47048. /** Observable raised when a button is pressed */
  47049. onButtonDownObservable: Observable<Xbox360Button>;
  47050. /** Observable raised when a button is released */
  47051. onButtonUpObservable: Observable<Xbox360Button>;
  47052. /** Observable raised when a pad is pressed */
  47053. onPadDownObservable: Observable<Xbox360Dpad>;
  47054. /** Observable raised when a pad is released */
  47055. onPadUpObservable: Observable<Xbox360Dpad>;
  47056. private _buttonA;
  47057. private _buttonB;
  47058. private _buttonX;
  47059. private _buttonY;
  47060. private _buttonBack;
  47061. private _buttonStart;
  47062. private _buttonLB;
  47063. private _buttonRB;
  47064. private _buttonLeftStick;
  47065. private _buttonRightStick;
  47066. private _dPadUp;
  47067. private _dPadDown;
  47068. private _dPadLeft;
  47069. private _dPadRight;
  47070. private _isXboxOnePad;
  47071. /**
  47072. * Creates a new XBox360 gamepad object
  47073. * @param id defines the id of this gamepad
  47074. * @param index defines its index
  47075. * @param gamepad defines the internal HTML gamepad object
  47076. * @param xboxOne defines if it is a XBox One gamepad
  47077. */
  47078. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47079. /**
  47080. * Defines the callback to call when left trigger is pressed
  47081. * @param callback defines the callback to use
  47082. */
  47083. onlefttriggerchanged(callback: (value: number) => void): void;
  47084. /**
  47085. * Defines the callback to call when right trigger is pressed
  47086. * @param callback defines the callback to use
  47087. */
  47088. onrighttriggerchanged(callback: (value: number) => void): void;
  47089. /**
  47090. * Gets the left trigger value
  47091. */
  47092. get leftTrigger(): number;
  47093. /**
  47094. * Sets the left trigger value
  47095. */
  47096. set leftTrigger(newValue: number);
  47097. /**
  47098. * Gets the right trigger value
  47099. */
  47100. get rightTrigger(): number;
  47101. /**
  47102. * Sets the right trigger value
  47103. */
  47104. set rightTrigger(newValue: number);
  47105. /**
  47106. * Defines the callback to call when a button is pressed
  47107. * @param callback defines the callback to use
  47108. */
  47109. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47110. /**
  47111. * Defines the callback to call when a button is released
  47112. * @param callback defines the callback to use
  47113. */
  47114. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47115. /**
  47116. * Defines the callback to call when a pad is pressed
  47117. * @param callback defines the callback to use
  47118. */
  47119. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47120. /**
  47121. * Defines the callback to call when a pad is released
  47122. * @param callback defines the callback to use
  47123. */
  47124. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47125. private _setButtonValue;
  47126. private _setDPadValue;
  47127. /**
  47128. * Gets the value of the `A` button
  47129. */
  47130. get buttonA(): number;
  47131. /**
  47132. * Sets the value of the `A` button
  47133. */
  47134. set buttonA(value: number);
  47135. /**
  47136. * Gets the value of the `B` button
  47137. */
  47138. get buttonB(): number;
  47139. /**
  47140. * Sets the value of the `B` button
  47141. */
  47142. set buttonB(value: number);
  47143. /**
  47144. * Gets the value of the `X` button
  47145. */
  47146. get buttonX(): number;
  47147. /**
  47148. * Sets the value of the `X` button
  47149. */
  47150. set buttonX(value: number);
  47151. /**
  47152. * Gets the value of the `Y` button
  47153. */
  47154. get buttonY(): number;
  47155. /**
  47156. * Sets the value of the `Y` button
  47157. */
  47158. set buttonY(value: number);
  47159. /**
  47160. * Gets the value of the `Start` button
  47161. */
  47162. get buttonStart(): number;
  47163. /**
  47164. * Sets the value of the `Start` button
  47165. */
  47166. set buttonStart(value: number);
  47167. /**
  47168. * Gets the value of the `Back` button
  47169. */
  47170. get buttonBack(): number;
  47171. /**
  47172. * Sets the value of the `Back` button
  47173. */
  47174. set buttonBack(value: number);
  47175. /**
  47176. * Gets the value of the `Left` button
  47177. */
  47178. get buttonLB(): number;
  47179. /**
  47180. * Sets the value of the `Left` button
  47181. */
  47182. set buttonLB(value: number);
  47183. /**
  47184. * Gets the value of the `Right` button
  47185. */
  47186. get buttonRB(): number;
  47187. /**
  47188. * Sets the value of the `Right` button
  47189. */
  47190. set buttonRB(value: number);
  47191. /**
  47192. * Gets the value of the Left joystick
  47193. */
  47194. get buttonLeftStick(): number;
  47195. /**
  47196. * Sets the value of the Left joystick
  47197. */
  47198. set buttonLeftStick(value: number);
  47199. /**
  47200. * Gets the value of the Right joystick
  47201. */
  47202. get buttonRightStick(): number;
  47203. /**
  47204. * Sets the value of the Right joystick
  47205. */
  47206. set buttonRightStick(value: number);
  47207. /**
  47208. * Gets the value of D-pad up
  47209. */
  47210. get dPadUp(): number;
  47211. /**
  47212. * Sets the value of D-pad up
  47213. */
  47214. set dPadUp(value: number);
  47215. /**
  47216. * Gets the value of D-pad down
  47217. */
  47218. get dPadDown(): number;
  47219. /**
  47220. * Sets the value of D-pad down
  47221. */
  47222. set dPadDown(value: number);
  47223. /**
  47224. * Gets the value of D-pad left
  47225. */
  47226. get dPadLeft(): number;
  47227. /**
  47228. * Sets the value of D-pad left
  47229. */
  47230. set dPadLeft(value: number);
  47231. /**
  47232. * Gets the value of D-pad right
  47233. */
  47234. get dPadRight(): number;
  47235. /**
  47236. * Sets the value of D-pad right
  47237. */
  47238. set dPadRight(value: number);
  47239. /**
  47240. * Force the gamepad to synchronize with device values
  47241. */
  47242. update(): void;
  47243. /**
  47244. * Disposes the gamepad
  47245. */
  47246. dispose(): void;
  47247. }
  47248. }
  47249. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47250. import { Observable } from "babylonjs/Misc/observable";
  47251. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47252. /**
  47253. * Defines supported buttons for DualShock compatible gamepads
  47254. */
  47255. export enum DualShockButton {
  47256. /** Cross */
  47257. Cross = 0,
  47258. /** Circle */
  47259. Circle = 1,
  47260. /** Square */
  47261. Square = 2,
  47262. /** Triangle */
  47263. Triangle = 3,
  47264. /** L1 */
  47265. L1 = 4,
  47266. /** R1 */
  47267. R1 = 5,
  47268. /** Share */
  47269. Share = 8,
  47270. /** Options */
  47271. Options = 9,
  47272. /** Left stick */
  47273. LeftStick = 10,
  47274. /** Right stick */
  47275. RightStick = 11
  47276. }
  47277. /** Defines values for DualShock DPad */
  47278. export enum DualShockDpad {
  47279. /** Up */
  47280. Up = 12,
  47281. /** Down */
  47282. Down = 13,
  47283. /** Left */
  47284. Left = 14,
  47285. /** Right */
  47286. Right = 15
  47287. }
  47288. /**
  47289. * Defines a DualShock gamepad
  47290. */
  47291. export class DualShockPad extends Gamepad {
  47292. private _leftTrigger;
  47293. private _rightTrigger;
  47294. private _onlefttriggerchanged;
  47295. private _onrighttriggerchanged;
  47296. private _onbuttondown;
  47297. private _onbuttonup;
  47298. private _ondpaddown;
  47299. private _ondpadup;
  47300. /** Observable raised when a button is pressed */
  47301. onButtonDownObservable: Observable<DualShockButton>;
  47302. /** Observable raised when a button is released */
  47303. onButtonUpObservable: Observable<DualShockButton>;
  47304. /** Observable raised when a pad is pressed */
  47305. onPadDownObservable: Observable<DualShockDpad>;
  47306. /** Observable raised when a pad is released */
  47307. onPadUpObservable: Observable<DualShockDpad>;
  47308. private _buttonCross;
  47309. private _buttonCircle;
  47310. private _buttonSquare;
  47311. private _buttonTriangle;
  47312. private _buttonShare;
  47313. private _buttonOptions;
  47314. private _buttonL1;
  47315. private _buttonR1;
  47316. private _buttonLeftStick;
  47317. private _buttonRightStick;
  47318. private _dPadUp;
  47319. private _dPadDown;
  47320. private _dPadLeft;
  47321. private _dPadRight;
  47322. /**
  47323. * Creates a new DualShock gamepad object
  47324. * @param id defines the id of this gamepad
  47325. * @param index defines its index
  47326. * @param gamepad defines the internal HTML gamepad object
  47327. */
  47328. constructor(id: string, index: number, gamepad: any);
  47329. /**
  47330. * Defines the callback to call when left trigger is pressed
  47331. * @param callback defines the callback to use
  47332. */
  47333. onlefttriggerchanged(callback: (value: number) => void): void;
  47334. /**
  47335. * Defines the callback to call when right trigger is pressed
  47336. * @param callback defines the callback to use
  47337. */
  47338. onrighttriggerchanged(callback: (value: number) => void): void;
  47339. /**
  47340. * Gets the left trigger value
  47341. */
  47342. get leftTrigger(): number;
  47343. /**
  47344. * Sets the left trigger value
  47345. */
  47346. set leftTrigger(newValue: number);
  47347. /**
  47348. * Gets the right trigger value
  47349. */
  47350. get rightTrigger(): number;
  47351. /**
  47352. * Sets the right trigger value
  47353. */
  47354. set rightTrigger(newValue: number);
  47355. /**
  47356. * Defines the callback to call when a button is pressed
  47357. * @param callback defines the callback to use
  47358. */
  47359. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47360. /**
  47361. * Defines the callback to call when a button is released
  47362. * @param callback defines the callback to use
  47363. */
  47364. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47365. /**
  47366. * Defines the callback to call when a pad is pressed
  47367. * @param callback defines the callback to use
  47368. */
  47369. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47370. /**
  47371. * Defines the callback to call when a pad is released
  47372. * @param callback defines the callback to use
  47373. */
  47374. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47375. private _setButtonValue;
  47376. private _setDPadValue;
  47377. /**
  47378. * Gets the value of the `Cross` button
  47379. */
  47380. get buttonCross(): number;
  47381. /**
  47382. * Sets the value of the `Cross` button
  47383. */
  47384. set buttonCross(value: number);
  47385. /**
  47386. * Gets the value of the `Circle` button
  47387. */
  47388. get buttonCircle(): number;
  47389. /**
  47390. * Sets the value of the `Circle` button
  47391. */
  47392. set buttonCircle(value: number);
  47393. /**
  47394. * Gets the value of the `Square` button
  47395. */
  47396. get buttonSquare(): number;
  47397. /**
  47398. * Sets the value of the `Square` button
  47399. */
  47400. set buttonSquare(value: number);
  47401. /**
  47402. * Gets the value of the `Triangle` button
  47403. */
  47404. get buttonTriangle(): number;
  47405. /**
  47406. * Sets the value of the `Triangle` button
  47407. */
  47408. set buttonTriangle(value: number);
  47409. /**
  47410. * Gets the value of the `Options` button
  47411. */
  47412. get buttonOptions(): number;
  47413. /**
  47414. * Sets the value of the `Options` button
  47415. */
  47416. set buttonOptions(value: number);
  47417. /**
  47418. * Gets the value of the `Share` button
  47419. */
  47420. get buttonShare(): number;
  47421. /**
  47422. * Sets the value of the `Share` button
  47423. */
  47424. set buttonShare(value: number);
  47425. /**
  47426. * Gets the value of the `L1` button
  47427. */
  47428. get buttonL1(): number;
  47429. /**
  47430. * Sets the value of the `L1` button
  47431. */
  47432. set buttonL1(value: number);
  47433. /**
  47434. * Gets the value of the `R1` button
  47435. */
  47436. get buttonR1(): number;
  47437. /**
  47438. * Sets the value of the `R1` button
  47439. */
  47440. set buttonR1(value: number);
  47441. /**
  47442. * Gets the value of the Left joystick
  47443. */
  47444. get buttonLeftStick(): number;
  47445. /**
  47446. * Sets the value of the Left joystick
  47447. */
  47448. set buttonLeftStick(value: number);
  47449. /**
  47450. * Gets the value of the Right joystick
  47451. */
  47452. get buttonRightStick(): number;
  47453. /**
  47454. * Sets the value of the Right joystick
  47455. */
  47456. set buttonRightStick(value: number);
  47457. /**
  47458. * Gets the value of D-pad up
  47459. */
  47460. get dPadUp(): number;
  47461. /**
  47462. * Sets the value of D-pad up
  47463. */
  47464. set dPadUp(value: number);
  47465. /**
  47466. * Gets the value of D-pad down
  47467. */
  47468. get dPadDown(): number;
  47469. /**
  47470. * Sets the value of D-pad down
  47471. */
  47472. set dPadDown(value: number);
  47473. /**
  47474. * Gets the value of D-pad left
  47475. */
  47476. get dPadLeft(): number;
  47477. /**
  47478. * Sets the value of D-pad left
  47479. */
  47480. set dPadLeft(value: number);
  47481. /**
  47482. * Gets the value of D-pad right
  47483. */
  47484. get dPadRight(): number;
  47485. /**
  47486. * Sets the value of D-pad right
  47487. */
  47488. set dPadRight(value: number);
  47489. /**
  47490. * Force the gamepad to synchronize with device values
  47491. */
  47492. update(): void;
  47493. /**
  47494. * Disposes the gamepad
  47495. */
  47496. dispose(): void;
  47497. }
  47498. }
  47499. declare module "babylonjs/Gamepads/gamepadManager" {
  47500. import { Observable } from "babylonjs/Misc/observable";
  47501. import { Nullable } from "babylonjs/types";
  47502. import { Scene } from "babylonjs/scene";
  47503. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47504. /**
  47505. * Manager for handling gamepads
  47506. */
  47507. export class GamepadManager {
  47508. private _scene?;
  47509. private _babylonGamepads;
  47510. private _oneGamepadConnected;
  47511. /** @hidden */
  47512. _isMonitoring: boolean;
  47513. private _gamepadEventSupported;
  47514. private _gamepadSupport?;
  47515. /**
  47516. * observable to be triggered when the gamepad controller has been connected
  47517. */
  47518. onGamepadConnectedObservable: Observable<Gamepad>;
  47519. /**
  47520. * observable to be triggered when the gamepad controller has been disconnected
  47521. */
  47522. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47523. private _onGamepadConnectedEvent;
  47524. private _onGamepadDisconnectedEvent;
  47525. /**
  47526. * Initializes the gamepad manager
  47527. * @param _scene BabylonJS scene
  47528. */
  47529. constructor(_scene?: Scene | undefined);
  47530. /**
  47531. * The gamepads in the game pad manager
  47532. */
  47533. get gamepads(): Gamepad[];
  47534. /**
  47535. * Get the gamepad controllers based on type
  47536. * @param type The type of gamepad controller
  47537. * @returns Nullable gamepad
  47538. */
  47539. getGamepadByType(type?: number): Nullable<Gamepad>;
  47540. /**
  47541. * Disposes the gamepad manager
  47542. */
  47543. dispose(): void;
  47544. private _addNewGamepad;
  47545. private _startMonitoringGamepads;
  47546. private _stopMonitoringGamepads;
  47547. /** @hidden */
  47548. _checkGamepadsStatus(): void;
  47549. private _updateGamepadObjects;
  47550. }
  47551. }
  47552. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47553. import { Nullable } from "babylonjs/types";
  47554. import { Scene } from "babylonjs/scene";
  47555. import { ISceneComponent } from "babylonjs/sceneComponent";
  47556. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47557. module "babylonjs/scene" {
  47558. interface Scene {
  47559. /** @hidden */
  47560. _gamepadManager: Nullable<GamepadManager>;
  47561. /**
  47562. * Gets the gamepad manager associated with the scene
  47563. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47564. */
  47565. gamepadManager: GamepadManager;
  47566. }
  47567. }
  47568. module "babylonjs/Cameras/freeCameraInputsManager" {
  47569. /**
  47570. * Interface representing a free camera inputs manager
  47571. */
  47572. interface FreeCameraInputsManager {
  47573. /**
  47574. * Adds gamepad input support to the FreeCameraInputsManager.
  47575. * @returns the FreeCameraInputsManager
  47576. */
  47577. addGamepad(): FreeCameraInputsManager;
  47578. }
  47579. }
  47580. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47581. /**
  47582. * Interface representing an arc rotate camera inputs manager
  47583. */
  47584. interface ArcRotateCameraInputsManager {
  47585. /**
  47586. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47587. * @returns the camera inputs manager
  47588. */
  47589. addGamepad(): ArcRotateCameraInputsManager;
  47590. }
  47591. }
  47592. /**
  47593. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47594. */
  47595. export class GamepadSystemSceneComponent implements ISceneComponent {
  47596. /**
  47597. * The component name helpfull to identify the component in the list of scene components.
  47598. */
  47599. readonly name: string;
  47600. /**
  47601. * The scene the component belongs to.
  47602. */
  47603. scene: Scene;
  47604. /**
  47605. * Creates a new instance of the component for the given scene
  47606. * @param scene Defines the scene to register the component in
  47607. */
  47608. constructor(scene: Scene);
  47609. /**
  47610. * Registers the component in a given scene
  47611. */
  47612. register(): void;
  47613. /**
  47614. * Rebuilds the elements related to this component in case of
  47615. * context lost for instance.
  47616. */
  47617. rebuild(): void;
  47618. /**
  47619. * Disposes the component and the associated ressources
  47620. */
  47621. dispose(): void;
  47622. private _beforeCameraUpdate;
  47623. }
  47624. }
  47625. declare module "babylonjs/Cameras/universalCamera" {
  47626. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47627. import { Scene } from "babylonjs/scene";
  47628. import { Vector3 } from "babylonjs/Maths/math.vector";
  47629. import "babylonjs/Gamepads/gamepadSceneComponent";
  47630. /**
  47631. * 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,
  47632. * which still works and will still be found in many Playgrounds.
  47633. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47634. */
  47635. export class UniversalCamera extends TouchCamera {
  47636. /**
  47637. * Defines the gamepad rotation sensiblity.
  47638. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47639. */
  47640. get gamepadAngularSensibility(): number;
  47641. set gamepadAngularSensibility(value: number);
  47642. /**
  47643. * Defines the gamepad move sensiblity.
  47644. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47645. */
  47646. get gamepadMoveSensibility(): number;
  47647. set gamepadMoveSensibility(value: number);
  47648. /**
  47649. * 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,
  47650. * which still works and will still be found in many Playgrounds.
  47651. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47652. * @param name Define the name of the camera in the scene
  47653. * @param position Define the start position of the camera in the scene
  47654. * @param scene Define the scene the camera belongs to
  47655. */
  47656. constructor(name: string, position: Vector3, scene: Scene);
  47657. /**
  47658. * Gets the current object class name.
  47659. * @return the class name
  47660. */
  47661. getClassName(): string;
  47662. }
  47663. }
  47664. declare module "babylonjs/Cameras/gamepadCamera" {
  47665. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47666. import { Scene } from "babylonjs/scene";
  47667. import { Vector3 } from "babylonjs/Maths/math.vector";
  47668. /**
  47669. * This represents a FPS type of camera. This is only here for back compat purpose.
  47670. * Please use the UniversalCamera instead as both are identical.
  47671. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47672. */
  47673. export class GamepadCamera extends UniversalCamera {
  47674. /**
  47675. * Instantiates a new Gamepad Camera
  47676. * This represents a FPS type of camera. This is only here for back compat purpose.
  47677. * Please use the UniversalCamera instead as both are identical.
  47678. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47679. * @param name Define the name of the camera in the scene
  47680. * @param position Define the start position of the camera in the scene
  47681. * @param scene Define the scene the camera belongs to
  47682. */
  47683. constructor(name: string, position: Vector3, scene: Scene);
  47684. /**
  47685. * Gets the current object class name.
  47686. * @return the class name
  47687. */
  47688. getClassName(): string;
  47689. }
  47690. }
  47691. declare module "babylonjs/Shaders/pass.fragment" {
  47692. /** @hidden */
  47693. export var passPixelShader: {
  47694. name: string;
  47695. shader: string;
  47696. };
  47697. }
  47698. declare module "babylonjs/Shaders/passCube.fragment" {
  47699. /** @hidden */
  47700. export var passCubePixelShader: {
  47701. name: string;
  47702. shader: string;
  47703. };
  47704. }
  47705. declare module "babylonjs/PostProcesses/passPostProcess" {
  47706. import { Nullable } from "babylonjs/types";
  47707. import { Camera } from "babylonjs/Cameras/camera";
  47708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47709. import { Engine } from "babylonjs/Engines/engine";
  47710. import "babylonjs/Shaders/pass.fragment";
  47711. import "babylonjs/Shaders/passCube.fragment";
  47712. import { Scene } from "babylonjs/scene";
  47713. /**
  47714. * PassPostProcess which produces an output the same as it's input
  47715. */
  47716. export class PassPostProcess extends PostProcess {
  47717. /**
  47718. * Gets a string identifying the name of the class
  47719. * @returns "PassPostProcess" string
  47720. */
  47721. getClassName(): string;
  47722. /**
  47723. * Creates the PassPostProcess
  47724. * @param name The name of the effect.
  47725. * @param options The required width/height ratio to downsize to before computing the render pass.
  47726. * @param camera The camera to apply the render pass to.
  47727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47728. * @param engine The engine which the post process will be applied. (default: current engine)
  47729. * @param reusable If the post process can be reused on the same frame. (default: false)
  47730. * @param textureType The type of texture to be used when performing the post processing.
  47731. * @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)
  47732. */
  47733. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47734. /** @hidden */
  47735. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47736. }
  47737. /**
  47738. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47739. */
  47740. export class PassCubePostProcess extends PostProcess {
  47741. private _face;
  47742. /**
  47743. * Gets or sets the cube face to display.
  47744. * * 0 is +X
  47745. * * 1 is -X
  47746. * * 2 is +Y
  47747. * * 3 is -Y
  47748. * * 4 is +Z
  47749. * * 5 is -Z
  47750. */
  47751. get face(): number;
  47752. set face(value: number);
  47753. /**
  47754. * Gets a string identifying the name of the class
  47755. * @returns "PassCubePostProcess" string
  47756. */
  47757. getClassName(): string;
  47758. /**
  47759. * Creates the PassCubePostProcess
  47760. * @param name The name of the effect.
  47761. * @param options The required width/height ratio to downsize to before computing the render pass.
  47762. * @param camera The camera to apply the render pass to.
  47763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47764. * @param engine The engine which the post process will be applied. (default: current engine)
  47765. * @param reusable If the post process can be reused on the same frame. (default: false)
  47766. * @param textureType The type of texture to be used when performing the post processing.
  47767. * @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)
  47768. */
  47769. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47770. /** @hidden */
  47771. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47772. }
  47773. }
  47774. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47775. /** @hidden */
  47776. export var anaglyphPixelShader: {
  47777. name: string;
  47778. shader: string;
  47779. };
  47780. }
  47781. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47782. import { Engine } from "babylonjs/Engines/engine";
  47783. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47784. import { Camera } from "babylonjs/Cameras/camera";
  47785. import "babylonjs/Shaders/anaglyph.fragment";
  47786. /**
  47787. * Postprocess used to generate anaglyphic rendering
  47788. */
  47789. export class AnaglyphPostProcess extends PostProcess {
  47790. private _passedProcess;
  47791. /**
  47792. * Gets a string identifying the name of the class
  47793. * @returns "AnaglyphPostProcess" string
  47794. */
  47795. getClassName(): string;
  47796. /**
  47797. * Creates a new AnaglyphPostProcess
  47798. * @param name defines postprocess name
  47799. * @param options defines creation options or target ratio scale
  47800. * @param rigCameras defines cameras using this postprocess
  47801. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47802. * @param engine defines hosting engine
  47803. * @param reusable defines if the postprocess will be reused multiple times per frame
  47804. */
  47805. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47806. }
  47807. }
  47808. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47809. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47810. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47811. import { Scene } from "babylonjs/scene";
  47812. import { Vector3 } from "babylonjs/Maths/math.vector";
  47813. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47814. /**
  47815. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47816. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47817. */
  47818. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47819. /**
  47820. * Creates a new AnaglyphArcRotateCamera
  47821. * @param name defines camera name
  47822. * @param alpha defines alpha angle (in radians)
  47823. * @param beta defines beta angle (in radians)
  47824. * @param radius defines radius
  47825. * @param target defines camera target
  47826. * @param interaxialDistance defines distance between each color axis
  47827. * @param scene defines the hosting scene
  47828. */
  47829. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47830. /**
  47831. * Gets camera class name
  47832. * @returns AnaglyphArcRotateCamera
  47833. */
  47834. getClassName(): string;
  47835. }
  47836. }
  47837. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47838. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47839. import { Scene } from "babylonjs/scene";
  47840. import { Vector3 } from "babylonjs/Maths/math.vector";
  47841. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47842. /**
  47843. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47844. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47845. */
  47846. export class AnaglyphFreeCamera extends FreeCamera {
  47847. /**
  47848. * Creates a new AnaglyphFreeCamera
  47849. * @param name defines camera name
  47850. * @param position defines initial position
  47851. * @param interaxialDistance defines distance between each color axis
  47852. * @param scene defines the hosting scene
  47853. */
  47854. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47855. /**
  47856. * Gets camera class name
  47857. * @returns AnaglyphFreeCamera
  47858. */
  47859. getClassName(): string;
  47860. }
  47861. }
  47862. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47863. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47864. import { Scene } from "babylonjs/scene";
  47865. import { Vector3 } from "babylonjs/Maths/math.vector";
  47866. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47867. /**
  47868. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47869. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47870. */
  47871. export class AnaglyphGamepadCamera extends GamepadCamera {
  47872. /**
  47873. * Creates a new AnaglyphGamepadCamera
  47874. * @param name defines camera name
  47875. * @param position defines initial position
  47876. * @param interaxialDistance defines distance between each color axis
  47877. * @param scene defines the hosting scene
  47878. */
  47879. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47880. /**
  47881. * Gets camera class name
  47882. * @returns AnaglyphGamepadCamera
  47883. */
  47884. getClassName(): string;
  47885. }
  47886. }
  47887. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47888. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47889. import { Scene } from "babylonjs/scene";
  47890. import { Vector3 } from "babylonjs/Maths/math.vector";
  47891. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47892. /**
  47893. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47894. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47895. */
  47896. export class AnaglyphUniversalCamera extends UniversalCamera {
  47897. /**
  47898. * Creates a new AnaglyphUniversalCamera
  47899. * @param name defines camera name
  47900. * @param position defines initial position
  47901. * @param interaxialDistance defines distance between each color axis
  47902. * @param scene defines the hosting scene
  47903. */
  47904. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47905. /**
  47906. * Gets camera class name
  47907. * @returns AnaglyphUniversalCamera
  47908. */
  47909. getClassName(): string;
  47910. }
  47911. }
  47912. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47913. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47914. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47915. import { Scene } from "babylonjs/scene";
  47916. import { Vector3 } from "babylonjs/Maths/math.vector";
  47917. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47918. /**
  47919. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47920. * @see https://doc.babylonjs.com/features/cameras
  47921. */
  47922. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47923. /**
  47924. * Creates a new StereoscopicArcRotateCamera
  47925. * @param name defines camera name
  47926. * @param alpha defines alpha angle (in radians)
  47927. * @param beta defines beta angle (in radians)
  47928. * @param radius defines radius
  47929. * @param target defines camera target
  47930. * @param interaxialDistance defines distance between each color axis
  47931. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47932. * @param scene defines the hosting scene
  47933. */
  47934. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47935. /**
  47936. * Gets camera class name
  47937. * @returns StereoscopicArcRotateCamera
  47938. */
  47939. getClassName(): string;
  47940. }
  47941. }
  47942. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47943. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47944. import { Scene } from "babylonjs/scene";
  47945. import { Vector3 } from "babylonjs/Maths/math.vector";
  47946. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47947. /**
  47948. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47949. * @see https://doc.babylonjs.com/features/cameras
  47950. */
  47951. export class StereoscopicFreeCamera extends FreeCamera {
  47952. /**
  47953. * Creates a new StereoscopicFreeCamera
  47954. * @param name defines camera name
  47955. * @param position defines initial position
  47956. * @param interaxialDistance defines distance between each color axis
  47957. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47958. * @param scene defines the hosting scene
  47959. */
  47960. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47961. /**
  47962. * Gets camera class name
  47963. * @returns StereoscopicFreeCamera
  47964. */
  47965. getClassName(): string;
  47966. }
  47967. }
  47968. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47969. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47970. import { Scene } from "babylonjs/scene";
  47971. import { Vector3 } from "babylonjs/Maths/math.vector";
  47972. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47973. /**
  47974. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47975. * @see https://doc.babylonjs.com/features/cameras
  47976. */
  47977. export class StereoscopicGamepadCamera extends GamepadCamera {
  47978. /**
  47979. * Creates a new StereoscopicGamepadCamera
  47980. * @param name defines camera name
  47981. * @param position defines initial position
  47982. * @param interaxialDistance defines distance between each color axis
  47983. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47984. * @param scene defines the hosting scene
  47985. */
  47986. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47987. /**
  47988. * Gets camera class name
  47989. * @returns StereoscopicGamepadCamera
  47990. */
  47991. getClassName(): string;
  47992. }
  47993. }
  47994. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47995. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47996. import { Scene } from "babylonjs/scene";
  47997. import { Vector3 } from "babylonjs/Maths/math.vector";
  47998. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47999. /**
  48000. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48001. * @see https://doc.babylonjs.com/features/cameras
  48002. */
  48003. export class StereoscopicUniversalCamera extends UniversalCamera {
  48004. /**
  48005. * Creates a new StereoscopicUniversalCamera
  48006. * @param name defines camera name
  48007. * @param position defines initial position
  48008. * @param interaxialDistance defines distance between each color axis
  48009. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48010. * @param scene defines the hosting scene
  48011. */
  48012. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48013. /**
  48014. * Gets camera class name
  48015. * @returns StereoscopicUniversalCamera
  48016. */
  48017. getClassName(): string;
  48018. }
  48019. }
  48020. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48021. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48022. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48023. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48024. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48025. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48026. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48027. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48028. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48029. }
  48030. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48031. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48032. import { Scene } from "babylonjs/scene";
  48033. import { Vector3 } from "babylonjs/Maths/math.vector";
  48034. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48035. /**
  48036. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48037. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48038. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48039. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48040. */
  48041. export class VirtualJoysticksCamera extends FreeCamera {
  48042. /**
  48043. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48044. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48045. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48046. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48047. * @param name Define the name of the camera in the scene
  48048. * @param position Define the start position of the camera in the scene
  48049. * @param scene Define the scene the camera belongs to
  48050. */
  48051. constructor(name: string, position: Vector3, scene: Scene);
  48052. /**
  48053. * Gets the current object class name.
  48054. * @return the class name
  48055. */
  48056. getClassName(): string;
  48057. }
  48058. }
  48059. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48060. import { Matrix } from "babylonjs/Maths/math.vector";
  48061. /**
  48062. * This represents all the required metrics to create a VR camera.
  48063. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48064. */
  48065. export class VRCameraMetrics {
  48066. /**
  48067. * Define the horizontal resolution off the screen.
  48068. */
  48069. hResolution: number;
  48070. /**
  48071. * Define the vertical resolution off the screen.
  48072. */
  48073. vResolution: number;
  48074. /**
  48075. * Define the horizontal screen size.
  48076. */
  48077. hScreenSize: number;
  48078. /**
  48079. * Define the vertical screen size.
  48080. */
  48081. vScreenSize: number;
  48082. /**
  48083. * Define the vertical screen center position.
  48084. */
  48085. vScreenCenter: number;
  48086. /**
  48087. * Define the distance of the eyes to the screen.
  48088. */
  48089. eyeToScreenDistance: number;
  48090. /**
  48091. * Define the distance between both lenses
  48092. */
  48093. lensSeparationDistance: number;
  48094. /**
  48095. * Define the distance between both viewer's eyes.
  48096. */
  48097. interpupillaryDistance: number;
  48098. /**
  48099. * Define the distortion factor of the VR postprocess.
  48100. * Please, touch with care.
  48101. */
  48102. distortionK: number[];
  48103. /**
  48104. * Define the chromatic aberration correction factors for the VR post process.
  48105. */
  48106. chromaAbCorrection: number[];
  48107. /**
  48108. * Define the scale factor of the post process.
  48109. * The smaller the better but the slower.
  48110. */
  48111. postProcessScaleFactor: number;
  48112. /**
  48113. * Define an offset for the lens center.
  48114. */
  48115. lensCenterOffset: number;
  48116. /**
  48117. * Define if the current vr camera should compensate the distortion of the lense or not.
  48118. */
  48119. compensateDistortion: boolean;
  48120. /**
  48121. * Defines if multiview should be enabled when rendering (Default: false)
  48122. */
  48123. multiviewEnabled: boolean;
  48124. /**
  48125. * Gets the rendering aspect ratio based on the provided resolutions.
  48126. */
  48127. get aspectRatio(): number;
  48128. /**
  48129. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48130. */
  48131. get aspectRatioFov(): number;
  48132. /**
  48133. * @hidden
  48134. */
  48135. get leftHMatrix(): Matrix;
  48136. /**
  48137. * @hidden
  48138. */
  48139. get rightHMatrix(): Matrix;
  48140. /**
  48141. * @hidden
  48142. */
  48143. get leftPreViewMatrix(): Matrix;
  48144. /**
  48145. * @hidden
  48146. */
  48147. get rightPreViewMatrix(): Matrix;
  48148. /**
  48149. * Get the default VRMetrics based on the most generic setup.
  48150. * @returns the default vr metrics
  48151. */
  48152. static GetDefault(): VRCameraMetrics;
  48153. }
  48154. }
  48155. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48156. /** @hidden */
  48157. export var vrDistortionCorrectionPixelShader: {
  48158. name: string;
  48159. shader: string;
  48160. };
  48161. }
  48162. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48163. import { Camera } from "babylonjs/Cameras/camera";
  48164. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48165. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48166. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48167. /**
  48168. * VRDistortionCorrectionPostProcess used for mobile VR
  48169. */
  48170. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48171. private _isRightEye;
  48172. private _distortionFactors;
  48173. private _postProcessScaleFactor;
  48174. private _lensCenterOffset;
  48175. private _scaleIn;
  48176. private _scaleFactor;
  48177. private _lensCenter;
  48178. /**
  48179. * Gets a string identifying the name of the class
  48180. * @returns "VRDistortionCorrectionPostProcess" string
  48181. */
  48182. getClassName(): string;
  48183. /**
  48184. * Initializes the VRDistortionCorrectionPostProcess
  48185. * @param name The name of the effect.
  48186. * @param camera The camera to apply the render pass to.
  48187. * @param isRightEye If this is for the right eye distortion
  48188. * @param vrMetrics All the required metrics for the VR camera
  48189. */
  48190. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48191. }
  48192. }
  48193. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48194. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48195. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48196. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48197. import { Scene } from "babylonjs/scene";
  48198. import { Vector3 } from "babylonjs/Maths/math.vector";
  48199. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48200. import "babylonjs/Cameras/RigModes/vrRigMode";
  48201. /**
  48202. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48203. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48204. */
  48205. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48206. /**
  48207. * Creates a new VRDeviceOrientationArcRotateCamera
  48208. * @param name defines camera name
  48209. * @param alpha defines the camera rotation along the logitudinal axis
  48210. * @param beta defines the camera rotation along the latitudinal axis
  48211. * @param radius defines the camera distance from its target
  48212. * @param target defines the camera target
  48213. * @param scene defines the scene the camera belongs to
  48214. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48215. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48216. */
  48217. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48218. /**
  48219. * Gets camera class name
  48220. * @returns VRDeviceOrientationArcRotateCamera
  48221. */
  48222. getClassName(): string;
  48223. }
  48224. }
  48225. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48226. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48227. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48228. import { Scene } from "babylonjs/scene";
  48229. import { Vector3 } from "babylonjs/Maths/math.vector";
  48230. import "babylonjs/Cameras/RigModes/vrRigMode";
  48231. /**
  48232. * Camera used to simulate VR rendering (based on FreeCamera)
  48233. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48234. */
  48235. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48236. /**
  48237. * Creates a new VRDeviceOrientationFreeCamera
  48238. * @param name defines camera name
  48239. * @param position defines the start position of the camera
  48240. * @param scene defines the scene the camera belongs to
  48241. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48242. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48243. */
  48244. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48245. /**
  48246. * Gets camera class name
  48247. * @returns VRDeviceOrientationFreeCamera
  48248. */
  48249. getClassName(): string;
  48250. }
  48251. }
  48252. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48253. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48254. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48255. import { Scene } from "babylonjs/scene";
  48256. import { Vector3 } from "babylonjs/Maths/math.vector";
  48257. import "babylonjs/Gamepads/gamepadSceneComponent";
  48258. /**
  48259. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48260. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48261. */
  48262. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48263. /**
  48264. * Creates a new VRDeviceOrientationGamepadCamera
  48265. * @param name defines camera name
  48266. * @param position defines the start position of the camera
  48267. * @param scene defines the scene the camera belongs to
  48268. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48269. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48270. */
  48271. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48272. /**
  48273. * Gets camera class name
  48274. * @returns VRDeviceOrientationGamepadCamera
  48275. */
  48276. getClassName(): string;
  48277. }
  48278. }
  48279. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48280. import { Scene } from "babylonjs/scene";
  48281. import { Texture } from "babylonjs/Materials/Textures/texture";
  48282. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48283. /**
  48284. * A class extending Texture allowing drawing on a texture
  48285. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48286. */
  48287. export class DynamicTexture extends Texture {
  48288. private _generateMipMaps;
  48289. private _canvas;
  48290. private _context;
  48291. /**
  48292. * Creates a DynamicTexture
  48293. * @param name defines the name of the texture
  48294. * @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
  48295. * @param scene defines the scene where you want the texture
  48296. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48297. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48298. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48299. */
  48300. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48301. /**
  48302. * Get the current class name of the texture useful for serialization or dynamic coding.
  48303. * @returns "DynamicTexture"
  48304. */
  48305. getClassName(): string;
  48306. /**
  48307. * Gets the current state of canRescale
  48308. */
  48309. get canRescale(): boolean;
  48310. private _recreate;
  48311. /**
  48312. * Scales the texture
  48313. * @param ratio the scale factor to apply to both width and height
  48314. */
  48315. scale(ratio: number): void;
  48316. /**
  48317. * Resizes the texture
  48318. * @param width the new width
  48319. * @param height the new height
  48320. */
  48321. scaleTo(width: number, height: number): void;
  48322. /**
  48323. * Gets the context of the canvas used by the texture
  48324. * @returns the canvas context of the dynamic texture
  48325. */
  48326. getContext(): CanvasRenderingContext2D;
  48327. /**
  48328. * Clears the texture
  48329. */
  48330. clear(): void;
  48331. /**
  48332. * Updates the texture
  48333. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48334. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48335. */
  48336. update(invertY?: boolean, premulAlpha?: boolean): void;
  48337. /**
  48338. * Draws text onto the texture
  48339. * @param text defines the text to be drawn
  48340. * @param x defines the placement of the text from the left
  48341. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48342. * @param font defines the font to be used with font-style, font-size, font-name
  48343. * @param color defines the color used for the text
  48344. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48345. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48346. * @param update defines whether texture is immediately update (default is true)
  48347. */
  48348. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48349. /**
  48350. * Clones the texture
  48351. * @returns the clone of the texture.
  48352. */
  48353. clone(): DynamicTexture;
  48354. /**
  48355. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48356. * @returns a serialized dynamic texture object
  48357. */
  48358. serialize(): any;
  48359. private _IsCanvasElement;
  48360. /** @hidden */
  48361. _rebuild(): void;
  48362. }
  48363. }
  48364. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48365. import { Scene } from "babylonjs/scene";
  48366. import { Color3 } from "babylonjs/Maths/math.color";
  48367. import { Mesh } from "babylonjs/Meshes/mesh";
  48368. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48369. import { Nullable } from "babylonjs/types";
  48370. /**
  48371. * Class containing static functions to help procedurally build meshes
  48372. */
  48373. export class GroundBuilder {
  48374. /**
  48375. * Creates a ground mesh
  48376. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48377. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48379. * @param name defines the name of the mesh
  48380. * @param options defines the options used to create the mesh
  48381. * @param scene defines the hosting scene
  48382. * @returns the ground mesh
  48383. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48384. */
  48385. static CreateGround(name: string, options: {
  48386. width?: number;
  48387. height?: number;
  48388. subdivisions?: number;
  48389. subdivisionsX?: number;
  48390. subdivisionsY?: number;
  48391. updatable?: boolean;
  48392. }, scene: any): Mesh;
  48393. /**
  48394. * Creates a tiled ground mesh
  48395. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48396. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48397. * * 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
  48398. * * 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
  48399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48400. * @param name defines the name of the mesh
  48401. * @param options defines the options used to create the mesh
  48402. * @param scene defines the hosting scene
  48403. * @returns the tiled ground mesh
  48404. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48405. */
  48406. static CreateTiledGround(name: string, options: {
  48407. xmin: number;
  48408. zmin: number;
  48409. xmax: number;
  48410. zmax: number;
  48411. subdivisions?: {
  48412. w: number;
  48413. h: number;
  48414. };
  48415. precision?: {
  48416. w: number;
  48417. h: number;
  48418. };
  48419. updatable?: boolean;
  48420. }, scene?: Nullable<Scene>): Mesh;
  48421. /**
  48422. * Creates a ground mesh from a height map
  48423. * * The parameter `url` sets the URL of the height map image resource.
  48424. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48425. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48426. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48427. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48428. * * 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.
  48429. * * 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).
  48430. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48432. * @param name defines the name of the mesh
  48433. * @param url defines the url to the height map
  48434. * @param options defines the options used to create the mesh
  48435. * @param scene defines the hosting scene
  48436. * @returns the ground mesh
  48437. * @see https://doc.babylonjs.com/babylon101/height_map
  48438. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48439. */
  48440. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48441. width?: number;
  48442. height?: number;
  48443. subdivisions?: number;
  48444. minHeight?: number;
  48445. maxHeight?: number;
  48446. colorFilter?: Color3;
  48447. alphaFilter?: number;
  48448. updatable?: boolean;
  48449. onReady?: (mesh: GroundMesh) => void;
  48450. }, scene?: Nullable<Scene>): GroundMesh;
  48451. }
  48452. }
  48453. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48454. import { Vector4 } from "babylonjs/Maths/math.vector";
  48455. import { Mesh } from "babylonjs/Meshes/mesh";
  48456. /**
  48457. * Class containing static functions to help procedurally build meshes
  48458. */
  48459. export class TorusBuilder {
  48460. /**
  48461. * Creates a torus mesh
  48462. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48463. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48464. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48468. * @param name defines the name of the mesh
  48469. * @param options defines the options used to create the mesh
  48470. * @param scene defines the hosting scene
  48471. * @returns the torus mesh
  48472. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48473. */
  48474. static CreateTorus(name: string, options: {
  48475. diameter?: number;
  48476. thickness?: number;
  48477. tessellation?: number;
  48478. updatable?: boolean;
  48479. sideOrientation?: number;
  48480. frontUVs?: Vector4;
  48481. backUVs?: Vector4;
  48482. }, scene: any): Mesh;
  48483. }
  48484. }
  48485. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48486. import { Vector4 } from "babylonjs/Maths/math.vector";
  48487. import { Color4 } from "babylonjs/Maths/math.color";
  48488. import { Mesh } from "babylonjs/Meshes/mesh";
  48489. /**
  48490. * Class containing static functions to help procedurally build meshes
  48491. */
  48492. export class CylinderBuilder {
  48493. /**
  48494. * Creates a cylinder or a cone mesh
  48495. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48496. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48497. * * 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.
  48498. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48499. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48500. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48501. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48502. * * 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).
  48503. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48504. * * 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).
  48505. * * 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
  48506. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48507. * * 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
  48508. * * 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.
  48509. * * If `enclose` is false, a ring surface is one element.
  48510. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48511. * * 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
  48512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48515. * @param name defines the name of the mesh
  48516. * @param options defines the options used to create the mesh
  48517. * @param scene defines the hosting scene
  48518. * @returns the cylinder mesh
  48519. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48520. */
  48521. static CreateCylinder(name: string, options: {
  48522. height?: number;
  48523. diameterTop?: number;
  48524. diameterBottom?: number;
  48525. diameter?: number;
  48526. tessellation?: number;
  48527. subdivisions?: number;
  48528. arc?: number;
  48529. faceColors?: Color4[];
  48530. faceUV?: Vector4[];
  48531. updatable?: boolean;
  48532. hasRings?: boolean;
  48533. enclose?: boolean;
  48534. cap?: number;
  48535. sideOrientation?: number;
  48536. frontUVs?: Vector4;
  48537. backUVs?: Vector4;
  48538. }, scene: any): Mesh;
  48539. }
  48540. }
  48541. declare module "babylonjs/XR/webXRTypes" {
  48542. import { Nullable } from "babylonjs/types";
  48543. import { IDisposable } from "babylonjs/scene";
  48544. /**
  48545. * States of the webXR experience
  48546. */
  48547. export enum WebXRState {
  48548. /**
  48549. * Transitioning to being in XR mode
  48550. */
  48551. ENTERING_XR = 0,
  48552. /**
  48553. * Transitioning to non XR mode
  48554. */
  48555. EXITING_XR = 1,
  48556. /**
  48557. * In XR mode and presenting
  48558. */
  48559. IN_XR = 2,
  48560. /**
  48561. * Not entered XR mode
  48562. */
  48563. NOT_IN_XR = 3
  48564. }
  48565. /**
  48566. * Abstraction of the XR render target
  48567. */
  48568. export interface WebXRRenderTarget extends IDisposable {
  48569. /**
  48570. * xrpresent context of the canvas which can be used to display/mirror xr content
  48571. */
  48572. canvasContext: WebGLRenderingContext;
  48573. /**
  48574. * xr layer for the canvas
  48575. */
  48576. xrLayer: Nullable<XRWebGLLayer>;
  48577. /**
  48578. * Initializes the xr layer for the session
  48579. * @param xrSession xr session
  48580. * @returns a promise that will resolve once the XR Layer has been created
  48581. */
  48582. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48583. }
  48584. }
  48585. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48586. import { Nullable } from "babylonjs/types";
  48587. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48588. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48589. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48590. import { Observable } from "babylonjs/Misc/observable";
  48591. /**
  48592. * COnfiguration object for WebXR output canvas
  48593. */
  48594. export class WebXRManagedOutputCanvasOptions {
  48595. /**
  48596. * An optional canvas in case you wish to create it yourself and provide it here.
  48597. * If not provided, a new canvas will be created
  48598. */
  48599. canvasElement?: HTMLCanvasElement;
  48600. /**
  48601. * Options for this XR Layer output
  48602. */
  48603. canvasOptions?: XRWebGLLayerOptions;
  48604. /**
  48605. * CSS styling for a newly created canvas (if not provided)
  48606. */
  48607. newCanvasCssStyle?: string;
  48608. /**
  48609. * Get the default values of the configuration object
  48610. * @param engine defines the engine to use (can be null)
  48611. * @returns default values of this configuration object
  48612. */
  48613. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48614. }
  48615. /**
  48616. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48617. */
  48618. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48619. private _options;
  48620. private _canvas;
  48621. private _engine;
  48622. private _originalCanvasSize;
  48623. /**
  48624. * Rendering context of the canvas which can be used to display/mirror xr content
  48625. */
  48626. canvasContext: WebGLRenderingContext;
  48627. /**
  48628. * xr layer for the canvas
  48629. */
  48630. xrLayer: Nullable<XRWebGLLayer>;
  48631. /**
  48632. * Obseervers registered here will be triggered when the xr layer was initialized
  48633. */
  48634. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48635. /**
  48636. * Initializes the canvas to be added/removed upon entering/exiting xr
  48637. * @param _xrSessionManager The XR Session manager
  48638. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48639. */
  48640. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48641. /**
  48642. * Disposes of the object
  48643. */
  48644. dispose(): void;
  48645. /**
  48646. * Initializes the xr layer for the session
  48647. * @param xrSession xr session
  48648. * @returns a promise that will resolve once the XR Layer has been created
  48649. */
  48650. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48651. private _addCanvas;
  48652. private _removeCanvas;
  48653. private _setCanvasSize;
  48654. private _setManagedOutputCanvas;
  48655. }
  48656. }
  48657. declare module "babylonjs/XR/webXRSessionManager" {
  48658. import { Observable } from "babylonjs/Misc/observable";
  48659. import { Nullable } from "babylonjs/types";
  48660. import { IDisposable, Scene } from "babylonjs/scene";
  48661. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48662. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48663. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48664. /**
  48665. * Manages an XRSession to work with Babylon's engine
  48666. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48667. */
  48668. export class WebXRSessionManager implements IDisposable {
  48669. /** The scene which the session should be created for */
  48670. scene: Scene;
  48671. private _referenceSpace;
  48672. private _rttProvider;
  48673. private _sessionEnded;
  48674. private _xrNavigator;
  48675. private baseLayer;
  48676. /**
  48677. * The base reference space from which the session started. good if you want to reset your
  48678. * reference space
  48679. */
  48680. baseReferenceSpace: XRReferenceSpace;
  48681. /**
  48682. * Current XR frame
  48683. */
  48684. currentFrame: Nullable<XRFrame>;
  48685. /** WebXR timestamp updated every frame */
  48686. currentTimestamp: number;
  48687. /**
  48688. * Used just in case of a failure to initialize an immersive session.
  48689. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48690. */
  48691. defaultHeightCompensation: number;
  48692. /**
  48693. * Fires every time a new xrFrame arrives which can be used to update the camera
  48694. */
  48695. onXRFrameObservable: Observable<XRFrame>;
  48696. /**
  48697. * Fires when the reference space changed
  48698. */
  48699. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48700. /**
  48701. * Fires when the xr session is ended either by the device or manually done
  48702. */
  48703. onXRSessionEnded: Observable<any>;
  48704. /**
  48705. * Fires when the xr session is ended either by the device or manually done
  48706. */
  48707. onXRSessionInit: Observable<XRSession>;
  48708. /**
  48709. * Underlying xr session
  48710. */
  48711. session: XRSession;
  48712. /**
  48713. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48714. * or get the offset the player is currently at.
  48715. */
  48716. viewerReferenceSpace: XRReferenceSpace;
  48717. /**
  48718. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48719. * @param scene The scene which the session should be created for
  48720. */
  48721. constructor(
  48722. /** The scene which the session should be created for */
  48723. scene: Scene);
  48724. /**
  48725. * The current reference space used in this session. This reference space can constantly change!
  48726. * It is mainly used to offset the camera's position.
  48727. */
  48728. get referenceSpace(): XRReferenceSpace;
  48729. /**
  48730. * Set a new reference space and triggers the observable
  48731. */
  48732. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48733. /**
  48734. * Disposes of the session manager
  48735. */
  48736. dispose(): void;
  48737. /**
  48738. * Stops the xrSession and restores the render loop
  48739. * @returns Promise which resolves after it exits XR
  48740. */
  48741. exitXRAsync(): Promise<void>;
  48742. /**
  48743. * Gets the correct render target texture to be rendered this frame for this eye
  48744. * @param eye the eye for which to get the render target
  48745. * @returns the render target for the specified eye
  48746. */
  48747. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48748. /**
  48749. * Creates a WebXRRenderTarget object for the XR session
  48750. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48751. * @param options optional options to provide when creating a new render target
  48752. * @returns a WebXR render target to which the session can render
  48753. */
  48754. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48755. /**
  48756. * Initializes the manager
  48757. * After initialization enterXR can be called to start an XR session
  48758. * @returns Promise which resolves after it is initialized
  48759. */
  48760. initializeAsync(): Promise<void>;
  48761. /**
  48762. * Initializes an xr session
  48763. * @param xrSessionMode mode to initialize
  48764. * @param xrSessionInit defines optional and required values to pass to the session builder
  48765. * @returns a promise which will resolve once the session has been initialized
  48766. */
  48767. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48768. /**
  48769. * Checks if a session would be supported for the creation options specified
  48770. * @param sessionMode session mode to check if supported eg. immersive-vr
  48771. * @returns A Promise that resolves to true if supported and false if not
  48772. */
  48773. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48774. /**
  48775. * Resets the reference space to the one started the session
  48776. */
  48777. resetReferenceSpace(): void;
  48778. /**
  48779. * Starts rendering to the xr layer
  48780. */
  48781. runXRRenderLoop(): void;
  48782. /**
  48783. * Sets the reference space on the xr session
  48784. * @param referenceSpaceType space to set
  48785. * @returns a promise that will resolve once the reference space has been set
  48786. */
  48787. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48788. /**
  48789. * Updates the render state of the session
  48790. * @param state state to set
  48791. * @returns a promise that resolves once the render state has been updated
  48792. */
  48793. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48794. /**
  48795. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48796. * @param sessionMode defines the session to test
  48797. * @returns a promise with boolean as final value
  48798. */
  48799. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48800. private _createRenderTargetTexture;
  48801. }
  48802. }
  48803. declare module "babylonjs/XR/webXRCamera" {
  48804. import { Vector3 } from "babylonjs/Maths/math.vector";
  48805. import { Scene } from "babylonjs/scene";
  48806. import { Camera } from "babylonjs/Cameras/camera";
  48807. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48808. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48809. import { Observable } from "babylonjs/Misc/observable";
  48810. /**
  48811. * WebXR Camera which holds the views for the xrSession
  48812. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48813. */
  48814. export class WebXRCamera extends FreeCamera {
  48815. private _xrSessionManager;
  48816. private _firstFrame;
  48817. private _referenceQuaternion;
  48818. private _referencedPosition;
  48819. private _xrInvPositionCache;
  48820. private _xrInvQuaternionCache;
  48821. /**
  48822. * Observable raised before camera teleportation
  48823. */
  48824. onBeforeCameraTeleport: Observable<Vector3>;
  48825. /**
  48826. * Observable raised after camera teleportation
  48827. */
  48828. onAfterCameraTeleport: Observable<Vector3>;
  48829. /**
  48830. * Should position compensation execute on first frame.
  48831. * This is used when copying the position from a native (non XR) camera
  48832. */
  48833. compensateOnFirstFrame: boolean;
  48834. /**
  48835. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48836. * @param name the name of the camera
  48837. * @param scene the scene to add the camera to
  48838. * @param _xrSessionManager a constructed xr session manager
  48839. */
  48840. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48841. /**
  48842. * Return the user's height, unrelated to the current ground.
  48843. * This will be the y position of this camera, when ground level is 0.
  48844. */
  48845. get realWorldHeight(): number;
  48846. /** @hidden */
  48847. _updateForDualEyeDebugging(): void;
  48848. /**
  48849. * Sets this camera's transformation based on a non-vr camera
  48850. * @param otherCamera the non-vr camera to copy the transformation from
  48851. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48852. */
  48853. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48854. /**
  48855. * Gets the current instance class name ("WebXRCamera").
  48856. * @returns the class name
  48857. */
  48858. getClassName(): string;
  48859. private _rotate180;
  48860. private _updateFromXRSession;
  48861. private _updateNumberOfRigCameras;
  48862. private _updateReferenceSpace;
  48863. private _updateReferenceSpaceOffset;
  48864. }
  48865. }
  48866. declare module "babylonjs/XR/webXRFeaturesManager" {
  48867. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48868. import { IDisposable } from "babylonjs/scene";
  48869. /**
  48870. * Defining the interface required for a (webxr) feature
  48871. */
  48872. export interface IWebXRFeature extends IDisposable {
  48873. /**
  48874. * Is this feature attached
  48875. */
  48876. attached: boolean;
  48877. /**
  48878. * Should auto-attach be disabled?
  48879. */
  48880. disableAutoAttach: boolean;
  48881. /**
  48882. * Attach the feature to the session
  48883. * Will usually be called by the features manager
  48884. *
  48885. * @param force should attachment be forced (even when already attached)
  48886. * @returns true if successful.
  48887. */
  48888. attach(force?: boolean): boolean;
  48889. /**
  48890. * Detach the feature from the session
  48891. * Will usually be called by the features manager
  48892. *
  48893. * @returns true if successful.
  48894. */
  48895. detach(): boolean;
  48896. /**
  48897. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48898. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48899. *
  48900. * @returns whether or not the feature is compatible in this environment
  48901. */
  48902. isCompatible(): boolean;
  48903. /**
  48904. * Was this feature disposed;
  48905. */
  48906. isDisposed: boolean;
  48907. /**
  48908. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48909. */
  48910. xrNativeFeatureName?: string;
  48911. /**
  48912. * A list of (Babylon WebXR) features this feature depends on
  48913. */
  48914. dependsOn?: string[];
  48915. }
  48916. /**
  48917. * A list of the currently available features without referencing them
  48918. */
  48919. export class WebXRFeatureName {
  48920. /**
  48921. * The name of the anchor system feature
  48922. */
  48923. static readonly ANCHOR_SYSTEM: string;
  48924. /**
  48925. * The name of the background remover feature
  48926. */
  48927. static readonly BACKGROUND_REMOVER: string;
  48928. /**
  48929. * The name of the hit test feature
  48930. */
  48931. static readonly HIT_TEST: string;
  48932. /**
  48933. * physics impostors for xr controllers feature
  48934. */
  48935. static readonly PHYSICS_CONTROLLERS: string;
  48936. /**
  48937. * The name of the plane detection feature
  48938. */
  48939. static readonly PLANE_DETECTION: string;
  48940. /**
  48941. * The name of the pointer selection feature
  48942. */
  48943. static readonly POINTER_SELECTION: string;
  48944. /**
  48945. * The name of the teleportation feature
  48946. */
  48947. static readonly TELEPORTATION: string;
  48948. /**
  48949. * The name of the feature points feature.
  48950. */
  48951. static readonly FEATURE_POINTS: string;
  48952. /**
  48953. * The name of the hand tracking feature.
  48954. */
  48955. static readonly HAND_TRACKING: string;
  48956. }
  48957. /**
  48958. * Defining the constructor of a feature. Used to register the modules.
  48959. */
  48960. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48961. /**
  48962. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48963. * It is mainly used in AR sessions.
  48964. *
  48965. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48966. */
  48967. export class WebXRFeaturesManager implements IDisposable {
  48968. private _xrSessionManager;
  48969. private static readonly _AvailableFeatures;
  48970. private _features;
  48971. /**
  48972. * constructs a new features manages.
  48973. *
  48974. * @param _xrSessionManager an instance of WebXRSessionManager
  48975. */
  48976. constructor(_xrSessionManager: WebXRSessionManager);
  48977. /**
  48978. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48979. * Mainly used internally.
  48980. *
  48981. * @param featureName the name of the feature to register
  48982. * @param constructorFunction the function used to construct the module
  48983. * @param version the (babylon) version of the module
  48984. * @param stable is that a stable version of this module
  48985. */
  48986. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48987. /**
  48988. * Returns a constructor of a specific feature.
  48989. *
  48990. * @param featureName the name of the feature to construct
  48991. * @param version the version of the feature to load
  48992. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48993. * @param options optional options provided to the module.
  48994. * @returns a function that, when called, will return a new instance of this feature
  48995. */
  48996. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48997. /**
  48998. * Can be used to return the list of features currently registered
  48999. *
  49000. * @returns an Array of available features
  49001. */
  49002. static GetAvailableFeatures(): string[];
  49003. /**
  49004. * Gets the versions available for a specific feature
  49005. * @param featureName the name of the feature
  49006. * @returns an array with the available versions
  49007. */
  49008. static GetAvailableVersions(featureName: string): string[];
  49009. /**
  49010. * Return the latest unstable version of this feature
  49011. * @param featureName the name of the feature to search
  49012. * @returns the version number. if not found will return -1
  49013. */
  49014. static GetLatestVersionOfFeature(featureName: string): number;
  49015. /**
  49016. * Return the latest stable version of this feature
  49017. * @param featureName the name of the feature to search
  49018. * @returns the version number. if not found will return -1
  49019. */
  49020. static GetStableVersionOfFeature(featureName: string): number;
  49021. /**
  49022. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49023. * Can be used during a session to start a feature
  49024. * @param featureName the name of feature to attach
  49025. */
  49026. attachFeature(featureName: string): void;
  49027. /**
  49028. * Can be used inside a session or when the session ends to detach a specific feature
  49029. * @param featureName the name of the feature to detach
  49030. */
  49031. detachFeature(featureName: string): void;
  49032. /**
  49033. * Used to disable an already-enabled feature
  49034. * The feature will be disposed and will be recreated once enabled.
  49035. * @param featureName the feature to disable
  49036. * @returns true if disable was successful
  49037. */
  49038. disableFeature(featureName: string | {
  49039. Name: string;
  49040. }): boolean;
  49041. /**
  49042. * dispose this features manager
  49043. */
  49044. dispose(): void;
  49045. /**
  49046. * 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.
  49047. * 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.
  49048. *
  49049. * @param featureName the name of the feature to load or the class of the feature
  49050. * @param version optional version to load. if not provided the latest version will be enabled
  49051. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49052. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49053. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49054. * @returns a new constructed feature or throws an error if feature not found.
  49055. */
  49056. enableFeature(featureName: string | {
  49057. Name: string;
  49058. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49059. /**
  49060. * get the implementation of an enabled feature.
  49061. * @param featureName the name of the feature to load
  49062. * @returns the feature class, if found
  49063. */
  49064. getEnabledFeature(featureName: string): IWebXRFeature;
  49065. /**
  49066. * Get the list of enabled features
  49067. * @returns an array of enabled features
  49068. */
  49069. getEnabledFeatures(): string[];
  49070. /**
  49071. * This function will exten the session creation configuration object with enabled features.
  49072. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49073. * according to the defined "required" variable, provided during enableFeature call
  49074. * @param xrSessionInit the xr Session init object to extend
  49075. *
  49076. * @returns an extended XRSessionInit object
  49077. */
  49078. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49079. }
  49080. }
  49081. declare module "babylonjs/XR/webXRExperienceHelper" {
  49082. import { Observable } from "babylonjs/Misc/observable";
  49083. import { IDisposable, Scene } from "babylonjs/scene";
  49084. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49085. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49086. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49087. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49088. /**
  49089. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49090. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49091. */
  49092. export class WebXRExperienceHelper implements IDisposable {
  49093. private scene;
  49094. private _nonVRCamera;
  49095. private _originalSceneAutoClear;
  49096. private _supported;
  49097. /**
  49098. * Camera used to render xr content
  49099. */
  49100. camera: WebXRCamera;
  49101. /** A features manager for this xr session */
  49102. featuresManager: WebXRFeaturesManager;
  49103. /**
  49104. * Observers registered here will be triggered after the camera's initial transformation is set
  49105. * This can be used to set a different ground level or an extra rotation.
  49106. *
  49107. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49108. * to the position set after this observable is done executing.
  49109. */
  49110. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49111. /**
  49112. * Fires when the state of the experience helper has changed
  49113. */
  49114. onStateChangedObservable: Observable<WebXRState>;
  49115. /** Session manager used to keep track of xr session */
  49116. sessionManager: WebXRSessionManager;
  49117. /**
  49118. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49119. */
  49120. state: WebXRState;
  49121. /**
  49122. * Creates a WebXRExperienceHelper
  49123. * @param scene The scene the helper should be created in
  49124. */
  49125. private constructor();
  49126. /**
  49127. * Creates the experience helper
  49128. * @param scene the scene to attach the experience helper to
  49129. * @returns a promise for the experience helper
  49130. */
  49131. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49132. /**
  49133. * Disposes of the experience helper
  49134. */
  49135. dispose(): void;
  49136. /**
  49137. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49138. * @param sessionMode options for the XR session
  49139. * @param referenceSpaceType frame of reference of the XR session
  49140. * @param renderTarget the output canvas that will be used to enter XR mode
  49141. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49142. * @returns promise that resolves after xr mode has entered
  49143. */
  49144. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49145. /**
  49146. * Exits XR mode and returns the scene to its original state
  49147. * @returns promise that resolves after xr mode has exited
  49148. */
  49149. exitXRAsync(): Promise<void>;
  49150. private _nonXRToXRCamera;
  49151. private _setState;
  49152. }
  49153. }
  49154. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49155. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49156. import { Observable } from "babylonjs/Misc/observable";
  49157. import { IDisposable } from "babylonjs/scene";
  49158. /**
  49159. * X-Y values for axes in WebXR
  49160. */
  49161. export interface IWebXRMotionControllerAxesValue {
  49162. /**
  49163. * The value of the x axis
  49164. */
  49165. x: number;
  49166. /**
  49167. * The value of the y-axis
  49168. */
  49169. y: number;
  49170. }
  49171. /**
  49172. * changed / previous values for the values of this component
  49173. */
  49174. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49175. /**
  49176. * current (this frame) value
  49177. */
  49178. current: T;
  49179. /**
  49180. * previous (last change) value
  49181. */
  49182. previous: T;
  49183. }
  49184. /**
  49185. * Represents changes in the component between current frame and last values recorded
  49186. */
  49187. export interface IWebXRMotionControllerComponentChanges {
  49188. /**
  49189. * will be populated with previous and current values if axes changed
  49190. */
  49191. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49192. /**
  49193. * will be populated with previous and current values if pressed changed
  49194. */
  49195. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49196. /**
  49197. * will be populated with previous and current values if touched changed
  49198. */
  49199. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49200. /**
  49201. * will be populated with previous and current values if value changed
  49202. */
  49203. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49204. }
  49205. /**
  49206. * This class represents a single component (for example button or thumbstick) of a motion controller
  49207. */
  49208. export class WebXRControllerComponent implements IDisposable {
  49209. /**
  49210. * the id of this component
  49211. */
  49212. id: string;
  49213. /**
  49214. * the type of the component
  49215. */
  49216. type: MotionControllerComponentType;
  49217. private _buttonIndex;
  49218. private _axesIndices;
  49219. private _axes;
  49220. private _changes;
  49221. private _currentValue;
  49222. private _hasChanges;
  49223. private _pressed;
  49224. private _touched;
  49225. /**
  49226. * button component type
  49227. */
  49228. static BUTTON_TYPE: MotionControllerComponentType;
  49229. /**
  49230. * squeeze component type
  49231. */
  49232. static SQUEEZE_TYPE: MotionControllerComponentType;
  49233. /**
  49234. * Thumbstick component type
  49235. */
  49236. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49237. /**
  49238. * Touchpad component type
  49239. */
  49240. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49241. /**
  49242. * trigger component type
  49243. */
  49244. static TRIGGER_TYPE: MotionControllerComponentType;
  49245. /**
  49246. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49247. * the axes data changes
  49248. */
  49249. onAxisValueChangedObservable: Observable<{
  49250. x: number;
  49251. y: number;
  49252. }>;
  49253. /**
  49254. * Observers registered here will be triggered when the state of a button changes
  49255. * State change is either pressed / touched / value
  49256. */
  49257. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49258. /**
  49259. * Creates a new component for a motion controller.
  49260. * It is created by the motion controller itself
  49261. *
  49262. * @param id the id of this component
  49263. * @param type the type of the component
  49264. * @param _buttonIndex index in the buttons array of the gamepad
  49265. * @param _axesIndices indices of the values in the axes array of the gamepad
  49266. */
  49267. constructor(
  49268. /**
  49269. * the id of this component
  49270. */
  49271. id: string,
  49272. /**
  49273. * the type of the component
  49274. */
  49275. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49276. /**
  49277. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49278. */
  49279. get axes(): IWebXRMotionControllerAxesValue;
  49280. /**
  49281. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49282. */
  49283. get changes(): IWebXRMotionControllerComponentChanges;
  49284. /**
  49285. * Return whether or not the component changed the last frame
  49286. */
  49287. get hasChanges(): boolean;
  49288. /**
  49289. * is the button currently pressed
  49290. */
  49291. get pressed(): boolean;
  49292. /**
  49293. * is the button currently touched
  49294. */
  49295. get touched(): boolean;
  49296. /**
  49297. * Get the current value of this component
  49298. */
  49299. get value(): number;
  49300. /**
  49301. * Dispose this component
  49302. */
  49303. dispose(): void;
  49304. /**
  49305. * Are there axes correlating to this component
  49306. * @return true is axes data is available
  49307. */
  49308. isAxes(): boolean;
  49309. /**
  49310. * Is this component a button (hence - pressable)
  49311. * @returns true if can be pressed
  49312. */
  49313. isButton(): boolean;
  49314. /**
  49315. * update this component using the gamepad object it is in. Called on every frame
  49316. * @param nativeController the native gamepad controller object
  49317. */
  49318. update(nativeController: IMinimalMotionControllerObject): void;
  49319. }
  49320. }
  49321. declare module "babylonjs/Loading/sceneLoader" {
  49322. import { Observable } from "babylonjs/Misc/observable";
  49323. import { Nullable } from "babylonjs/types";
  49324. import { Scene } from "babylonjs/scene";
  49325. import { Engine } from "babylonjs/Engines/engine";
  49326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49327. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49328. import { AssetContainer } from "babylonjs/assetContainer";
  49329. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49330. import { Skeleton } from "babylonjs/Bones/skeleton";
  49331. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49332. import { WebRequest } from "babylonjs/Misc/webRequest";
  49333. /**
  49334. * Interface used to represent data loading progression
  49335. */
  49336. export interface ISceneLoaderProgressEvent {
  49337. /**
  49338. * Defines if data length to load can be evaluated
  49339. */
  49340. readonly lengthComputable: boolean;
  49341. /**
  49342. * Defines the loaded data length
  49343. */
  49344. readonly loaded: number;
  49345. /**
  49346. * Defines the data length to load
  49347. */
  49348. readonly total: number;
  49349. }
  49350. /**
  49351. * Interface used by SceneLoader plugins to define supported file extensions
  49352. */
  49353. export interface ISceneLoaderPluginExtensions {
  49354. /**
  49355. * Defines the list of supported extensions
  49356. */
  49357. [extension: string]: {
  49358. isBinary: boolean;
  49359. };
  49360. }
  49361. /**
  49362. * Interface used by SceneLoader plugin factory
  49363. */
  49364. export interface ISceneLoaderPluginFactory {
  49365. /**
  49366. * Defines the name of the factory
  49367. */
  49368. name: string;
  49369. /**
  49370. * Function called to create a new plugin
  49371. * @return the new plugin
  49372. */
  49373. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49374. /**
  49375. * The callback that returns true if the data can be directly loaded.
  49376. * @param data string containing the file data
  49377. * @returns if the data can be loaded directly
  49378. */
  49379. canDirectLoad?(data: string): boolean;
  49380. }
  49381. /**
  49382. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49383. */
  49384. export interface ISceneLoaderPluginBase {
  49385. /**
  49386. * The friendly name of this plugin.
  49387. */
  49388. name: string;
  49389. /**
  49390. * The file extensions supported by this plugin.
  49391. */
  49392. extensions: string | ISceneLoaderPluginExtensions;
  49393. /**
  49394. * The callback called when loading from a url.
  49395. * @param scene scene loading this url
  49396. * @param url url to load
  49397. * @param onSuccess callback called when the file successfully loads
  49398. * @param onProgress callback called while file is loading (if the server supports this mode)
  49399. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49400. * @param onError callback called when the file fails to load
  49401. * @returns a file request object
  49402. */
  49403. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49404. /**
  49405. * The callback called when loading from a file object.
  49406. * @param scene scene loading this file
  49407. * @param file defines the file to load
  49408. * @param onSuccess defines the callback to call when data is loaded
  49409. * @param onProgress defines the callback to call during loading process
  49410. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49411. * @param onError defines the callback to call when an error occurs
  49412. * @returns a file request object
  49413. */
  49414. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49415. /**
  49416. * The callback that returns true if the data can be directly loaded.
  49417. * @param data string containing the file data
  49418. * @returns if the data can be loaded directly
  49419. */
  49420. canDirectLoad?(data: string): boolean;
  49421. /**
  49422. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49423. * @param scene scene loading this data
  49424. * @param data string containing the data
  49425. * @returns data to pass to the plugin
  49426. */
  49427. directLoad?(scene: Scene, data: string): any;
  49428. /**
  49429. * The callback that allows custom handling of the root url based on the response url.
  49430. * @param rootUrl the original root url
  49431. * @param responseURL the response url if available
  49432. * @returns the new root url
  49433. */
  49434. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49435. }
  49436. /**
  49437. * Interface used to define a SceneLoader plugin
  49438. */
  49439. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49440. /**
  49441. * Import meshes into a scene.
  49442. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49443. * @param scene The scene to import into
  49444. * @param data The data to import
  49445. * @param rootUrl The root url for scene and resources
  49446. * @param meshes The meshes array to import into
  49447. * @param particleSystems The particle systems array to import into
  49448. * @param skeletons The skeletons array to import into
  49449. * @param onError The callback when import fails
  49450. * @returns True if successful or false otherwise
  49451. */
  49452. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49453. /**
  49454. * Load into a scene.
  49455. * @param scene The scene to load into
  49456. * @param data The data to import
  49457. * @param rootUrl The root url for scene and resources
  49458. * @param onError The callback when import fails
  49459. * @returns True if successful or false otherwise
  49460. */
  49461. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49462. /**
  49463. * Load into an asset container.
  49464. * @param scene The scene to load into
  49465. * @param data The data to import
  49466. * @param rootUrl The root url for scene and resources
  49467. * @param onError The callback when import fails
  49468. * @returns The loaded asset container
  49469. */
  49470. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49471. }
  49472. /**
  49473. * Interface used to define an async SceneLoader plugin
  49474. */
  49475. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49476. /**
  49477. * Import meshes into a scene.
  49478. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49479. * @param scene The scene to import into
  49480. * @param data The data to import
  49481. * @param rootUrl The root url for scene and resources
  49482. * @param onProgress The callback when the load progresses
  49483. * @param fileName Defines the name of the file to load
  49484. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49485. */
  49486. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49487. meshes: AbstractMesh[];
  49488. particleSystems: IParticleSystem[];
  49489. skeletons: Skeleton[];
  49490. animationGroups: AnimationGroup[];
  49491. }>;
  49492. /**
  49493. * Load into a scene.
  49494. * @param scene The scene to load into
  49495. * @param data The data to import
  49496. * @param rootUrl The root url for scene and resources
  49497. * @param onProgress The callback when the load progresses
  49498. * @param fileName Defines the name of the file to load
  49499. * @returns Nothing
  49500. */
  49501. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49502. /**
  49503. * Load into an asset container.
  49504. * @param scene The scene to load into
  49505. * @param data The data to import
  49506. * @param rootUrl The root url for scene and resources
  49507. * @param onProgress The callback when the load progresses
  49508. * @param fileName Defines the name of the file to load
  49509. * @returns The loaded asset container
  49510. */
  49511. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49512. }
  49513. /**
  49514. * Mode that determines how to handle old animation groups before loading new ones.
  49515. */
  49516. export enum SceneLoaderAnimationGroupLoadingMode {
  49517. /**
  49518. * Reset all old animations to initial state then dispose them.
  49519. */
  49520. Clean = 0,
  49521. /**
  49522. * Stop all old animations.
  49523. */
  49524. Stop = 1,
  49525. /**
  49526. * Restart old animations from first frame.
  49527. */
  49528. Sync = 2,
  49529. /**
  49530. * Old animations remains untouched.
  49531. */
  49532. NoSync = 3
  49533. }
  49534. /**
  49535. * Defines a plugin registered by the SceneLoader
  49536. */
  49537. interface IRegisteredPlugin {
  49538. /**
  49539. * Defines the plugin to use
  49540. */
  49541. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49542. /**
  49543. * Defines if the plugin supports binary data
  49544. */
  49545. isBinary: boolean;
  49546. }
  49547. /**
  49548. * Class used to load scene from various file formats using registered plugins
  49549. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49550. */
  49551. export class SceneLoader {
  49552. /**
  49553. * No logging while loading
  49554. */
  49555. static readonly NO_LOGGING: number;
  49556. /**
  49557. * Minimal logging while loading
  49558. */
  49559. static readonly MINIMAL_LOGGING: number;
  49560. /**
  49561. * Summary logging while loading
  49562. */
  49563. static readonly SUMMARY_LOGGING: number;
  49564. /**
  49565. * Detailled logging while loading
  49566. */
  49567. static readonly DETAILED_LOGGING: number;
  49568. /**
  49569. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49570. */
  49571. static get ForceFullSceneLoadingForIncremental(): boolean;
  49572. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49573. /**
  49574. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49575. */
  49576. static get ShowLoadingScreen(): boolean;
  49577. static set ShowLoadingScreen(value: boolean);
  49578. /**
  49579. * Defines the current logging level (while loading the scene)
  49580. * @ignorenaming
  49581. */
  49582. static get loggingLevel(): number;
  49583. static set loggingLevel(value: number);
  49584. /**
  49585. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49586. */
  49587. static get CleanBoneMatrixWeights(): boolean;
  49588. static set CleanBoneMatrixWeights(value: boolean);
  49589. /**
  49590. * Event raised when a plugin is used to load a scene
  49591. */
  49592. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49593. private static _registeredPlugins;
  49594. private static _showingLoadingScreen;
  49595. /**
  49596. * Gets the default plugin (used to load Babylon files)
  49597. * @returns the .babylon plugin
  49598. */
  49599. static GetDefaultPlugin(): IRegisteredPlugin;
  49600. private static _GetPluginForExtension;
  49601. private static _GetPluginForDirectLoad;
  49602. private static _GetPluginForFilename;
  49603. private static _GetDirectLoad;
  49604. private static _LoadData;
  49605. private static _GetFileInfo;
  49606. /**
  49607. * Gets a plugin that can load the given extension
  49608. * @param extension defines the extension to load
  49609. * @returns a plugin or null if none works
  49610. */
  49611. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49612. /**
  49613. * Gets a boolean indicating that the given extension can be loaded
  49614. * @param extension defines the extension to load
  49615. * @returns true if the extension is supported
  49616. */
  49617. static IsPluginForExtensionAvailable(extension: string): boolean;
  49618. /**
  49619. * Adds a new plugin to the list of registered plugins
  49620. * @param plugin defines the plugin to add
  49621. */
  49622. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49623. /**
  49624. * Import meshes into a scene
  49625. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49626. * @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)
  49627. * @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)
  49628. * @param scene the instance of BABYLON.Scene to append to
  49629. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49630. * @param onProgress a callback with a progress event for each file being loaded
  49631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49632. * @param pluginExtension the extension used to determine the plugin
  49633. * @returns The loaded plugin
  49634. */
  49635. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49636. /**
  49637. * Import meshes into a scene
  49638. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49639. * @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)
  49640. * @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)
  49641. * @param scene the instance of BABYLON.Scene to append to
  49642. * @param onProgress a callback with a progress event for each file being loaded
  49643. * @param pluginExtension the extension used to determine the plugin
  49644. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49645. */
  49646. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49647. meshes: AbstractMesh[];
  49648. particleSystems: IParticleSystem[];
  49649. skeletons: Skeleton[];
  49650. animationGroups: AnimationGroup[];
  49651. }>;
  49652. /**
  49653. * Load a scene
  49654. * @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)
  49655. * @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)
  49656. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49657. * @param onSuccess a callback with the scene when import succeeds
  49658. * @param onProgress a callback with a progress event for each file being loaded
  49659. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49660. * @param pluginExtension the extension used to determine the plugin
  49661. * @returns The loaded plugin
  49662. */
  49663. 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>;
  49664. /**
  49665. * Load a scene
  49666. * @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)
  49667. * @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)
  49668. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49669. * @param onProgress a callback with a progress event for each file being loaded
  49670. * @param pluginExtension the extension used to determine the plugin
  49671. * @returns The loaded scene
  49672. */
  49673. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49674. /**
  49675. * Append a scene
  49676. * @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)
  49677. * @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)
  49678. * @param scene is the instance of BABYLON.Scene to append to
  49679. * @param onSuccess a callback with the scene when import succeeds
  49680. * @param onProgress a callback with a progress event for each file being loaded
  49681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49682. * @param pluginExtension the extension used to determine the plugin
  49683. * @returns The loaded plugin
  49684. */
  49685. 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>;
  49686. /**
  49687. * Append a scene
  49688. * @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)
  49689. * @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)
  49690. * @param scene is the instance of BABYLON.Scene to append to
  49691. * @param onProgress a callback with a progress event for each file being loaded
  49692. * @param pluginExtension the extension used to determine the plugin
  49693. * @returns The given scene
  49694. */
  49695. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49696. /**
  49697. * Load a scene into an asset container
  49698. * @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)
  49699. * @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)
  49700. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49701. * @param onSuccess a callback with the scene when import succeeds
  49702. * @param onProgress a callback with a progress event for each file being loaded
  49703. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49704. * @param pluginExtension the extension used to determine the plugin
  49705. * @returns The loaded plugin
  49706. */
  49707. 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>;
  49708. /**
  49709. * Load a scene into an asset container
  49710. * @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)
  49711. * @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)
  49712. * @param scene is the instance of Scene to append to
  49713. * @param onProgress a callback with a progress event for each file being loaded
  49714. * @param pluginExtension the extension used to determine the plugin
  49715. * @returns The loaded asset container
  49716. */
  49717. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49718. /**
  49719. * Import animations from a file into a scene
  49720. * @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)
  49721. * @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)
  49722. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49723. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49724. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49725. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49726. * @param onSuccess a callback with the scene when import succeeds
  49727. * @param onProgress a callback with a progress event for each file being loaded
  49728. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49729. * @param pluginExtension the extension used to determine the plugin
  49730. */
  49731. 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;
  49732. /**
  49733. * Import animations from a file into a scene
  49734. * @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)
  49735. * @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)
  49736. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49737. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49738. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49739. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49740. * @param onSuccess a callback with the scene when import succeeds
  49741. * @param onProgress a callback with a progress event for each file being loaded
  49742. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49743. * @param pluginExtension the extension used to determine the plugin
  49744. * @returns the updated scene with imported animations
  49745. */
  49746. 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>;
  49747. }
  49748. }
  49749. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49750. import { IDisposable, Scene } from "babylonjs/scene";
  49751. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49752. import { Observable } from "babylonjs/Misc/observable";
  49753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49754. import { Nullable } from "babylonjs/types";
  49755. /**
  49756. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49757. */
  49758. export type MotionControllerHandedness = "none" | "left" | "right";
  49759. /**
  49760. * The type of components available in motion controllers.
  49761. * This is not the name of the component.
  49762. */
  49763. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49764. /**
  49765. * The state of a controller component
  49766. */
  49767. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49768. /**
  49769. * The schema of motion controller layout.
  49770. * No object will be initialized using this interface
  49771. * This is used just to define the profile.
  49772. */
  49773. export interface IMotionControllerLayout {
  49774. /**
  49775. * Path to load the assets. Usually relative to the base path
  49776. */
  49777. assetPath: string;
  49778. /**
  49779. * Available components (unsorted)
  49780. */
  49781. components: {
  49782. /**
  49783. * A map of component Ids
  49784. */
  49785. [componentId: string]: {
  49786. /**
  49787. * The type of input the component outputs
  49788. */
  49789. type: MotionControllerComponentType;
  49790. /**
  49791. * The indices of this component in the gamepad object
  49792. */
  49793. gamepadIndices: {
  49794. /**
  49795. * Index of button
  49796. */
  49797. button?: number;
  49798. /**
  49799. * If available, index of x-axis
  49800. */
  49801. xAxis?: number;
  49802. /**
  49803. * If available, index of y-axis
  49804. */
  49805. yAxis?: number;
  49806. };
  49807. /**
  49808. * The mesh's root node name
  49809. */
  49810. rootNodeName: string;
  49811. /**
  49812. * Animation definitions for this model
  49813. */
  49814. visualResponses: {
  49815. [stateKey: string]: {
  49816. /**
  49817. * What property will be animated
  49818. */
  49819. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49820. /**
  49821. * What states influence this visual response
  49822. */
  49823. states: MotionControllerComponentStateType[];
  49824. /**
  49825. * Type of animation - movement or visibility
  49826. */
  49827. valueNodeProperty: "transform" | "visibility";
  49828. /**
  49829. * Base node name to move. Its position will be calculated according to the min and max nodes
  49830. */
  49831. valueNodeName?: string;
  49832. /**
  49833. * Minimum movement node
  49834. */
  49835. minNodeName?: string;
  49836. /**
  49837. * Max movement node
  49838. */
  49839. maxNodeName?: string;
  49840. };
  49841. };
  49842. /**
  49843. * If touch enabled, what is the name of node to display user feedback
  49844. */
  49845. touchPointNodeName?: string;
  49846. };
  49847. };
  49848. /**
  49849. * Is it xr standard mapping or not
  49850. */
  49851. gamepadMapping: "" | "xr-standard";
  49852. /**
  49853. * Base root node of this entire model
  49854. */
  49855. rootNodeName: string;
  49856. /**
  49857. * Defines the main button component id
  49858. */
  49859. selectComponentId: string;
  49860. }
  49861. /**
  49862. * A definition for the layout map in the input profile
  49863. */
  49864. export interface IMotionControllerLayoutMap {
  49865. /**
  49866. * Layouts with handedness type as a key
  49867. */
  49868. [handedness: string]: IMotionControllerLayout;
  49869. }
  49870. /**
  49871. * The XR Input profile schema
  49872. * Profiles can be found here:
  49873. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49874. */
  49875. export interface IMotionControllerProfile {
  49876. /**
  49877. * fallback profiles for this profileId
  49878. */
  49879. fallbackProfileIds: string[];
  49880. /**
  49881. * The layout map, with handedness as key
  49882. */
  49883. layouts: IMotionControllerLayoutMap;
  49884. /**
  49885. * The id of this profile
  49886. * correlates to the profile(s) in the xrInput.profiles array
  49887. */
  49888. profileId: string;
  49889. }
  49890. /**
  49891. * A helper-interface for the 3 meshes needed for controller button animation
  49892. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49893. */
  49894. export interface IMotionControllerButtonMeshMap {
  49895. /**
  49896. * the mesh that defines the pressed value mesh position.
  49897. * This is used to find the max-position of this button
  49898. */
  49899. pressedMesh: AbstractMesh;
  49900. /**
  49901. * the mesh that defines the unpressed value mesh position.
  49902. * This is used to find the min (or initial) position of this button
  49903. */
  49904. unpressedMesh: AbstractMesh;
  49905. /**
  49906. * The mesh that will be changed when value changes
  49907. */
  49908. valueMesh: AbstractMesh;
  49909. }
  49910. /**
  49911. * A helper-interface for the 3 meshes needed for controller axis animation.
  49912. * This will be expanded when touchpad animations are fully supported
  49913. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49914. */
  49915. export interface IMotionControllerMeshMap {
  49916. /**
  49917. * the mesh that defines the maximum value mesh position.
  49918. */
  49919. maxMesh?: AbstractMesh;
  49920. /**
  49921. * the mesh that defines the minimum value mesh position.
  49922. */
  49923. minMesh?: AbstractMesh;
  49924. /**
  49925. * The mesh that will be changed when axis value changes
  49926. */
  49927. valueMesh?: AbstractMesh;
  49928. }
  49929. /**
  49930. * The elements needed for change-detection of the gamepad objects in motion controllers
  49931. */
  49932. export interface IMinimalMotionControllerObject {
  49933. /**
  49934. * Available axes of this controller
  49935. */
  49936. axes: number[];
  49937. /**
  49938. * An array of available buttons
  49939. */
  49940. buttons: Array<{
  49941. /**
  49942. * Value of the button/trigger
  49943. */
  49944. value: number;
  49945. /**
  49946. * If the button/trigger is currently touched
  49947. */
  49948. touched: boolean;
  49949. /**
  49950. * If the button/trigger is currently pressed
  49951. */
  49952. pressed: boolean;
  49953. }>;
  49954. /**
  49955. * EXPERIMENTAL haptic support.
  49956. */
  49957. hapticActuators?: Array<{
  49958. pulse: (value: number, duration: number) => Promise<boolean>;
  49959. }>;
  49960. }
  49961. /**
  49962. * An Abstract Motion controller
  49963. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49964. * Each component has an observable to check for changes in value and state
  49965. */
  49966. export abstract class WebXRAbstractMotionController implements IDisposable {
  49967. protected scene: Scene;
  49968. protected layout: IMotionControllerLayout;
  49969. /**
  49970. * The gamepad object correlating to this controller
  49971. */
  49972. gamepadObject: IMinimalMotionControllerObject;
  49973. /**
  49974. * handedness (left/right/none) of this controller
  49975. */
  49976. handedness: MotionControllerHandedness;
  49977. private _initComponent;
  49978. private _modelReady;
  49979. /**
  49980. * A map of components (WebXRControllerComponent) in this motion controller
  49981. * Components have a ComponentType and can also have both button and axis definitions
  49982. */
  49983. readonly components: {
  49984. [id: string]: WebXRControllerComponent;
  49985. };
  49986. /**
  49987. * Disable the model's animation. Can be set at any time.
  49988. */
  49989. disableAnimation: boolean;
  49990. /**
  49991. * Observers registered here will be triggered when the model of this controller is done loading
  49992. */
  49993. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49994. /**
  49995. * The profile id of this motion controller
  49996. */
  49997. abstract profileId: string;
  49998. /**
  49999. * The root mesh of the model. It is null if the model was not yet initialized
  50000. */
  50001. rootMesh: Nullable<AbstractMesh>;
  50002. /**
  50003. * constructs a new abstract motion controller
  50004. * @param scene the scene to which the model of the controller will be added
  50005. * @param layout The profile layout to load
  50006. * @param gamepadObject The gamepad object correlating to this controller
  50007. * @param handedness handedness (left/right/none) of this controller
  50008. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50009. */
  50010. constructor(scene: Scene, layout: IMotionControllerLayout,
  50011. /**
  50012. * The gamepad object correlating to this controller
  50013. */
  50014. gamepadObject: IMinimalMotionControllerObject,
  50015. /**
  50016. * handedness (left/right/none) of this controller
  50017. */
  50018. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50019. /**
  50020. * Dispose this controller, the model mesh and all its components
  50021. */
  50022. dispose(): void;
  50023. /**
  50024. * Returns all components of specific type
  50025. * @param type the type to search for
  50026. * @return an array of components with this type
  50027. */
  50028. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50029. /**
  50030. * get a component based an its component id as defined in layout.components
  50031. * @param id the id of the component
  50032. * @returns the component correlates to the id or undefined if not found
  50033. */
  50034. getComponent(id: string): WebXRControllerComponent;
  50035. /**
  50036. * Get the list of components available in this motion controller
  50037. * @returns an array of strings correlating to available components
  50038. */
  50039. getComponentIds(): string[];
  50040. /**
  50041. * Get the first component of specific type
  50042. * @param type type of component to find
  50043. * @return a controller component or null if not found
  50044. */
  50045. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50046. /**
  50047. * Get the main (Select) component of this controller as defined in the layout
  50048. * @returns the main component of this controller
  50049. */
  50050. getMainComponent(): WebXRControllerComponent;
  50051. /**
  50052. * Loads the model correlating to this controller
  50053. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50054. * @returns A promise fulfilled with the result of the model loading
  50055. */
  50056. loadModel(): Promise<boolean>;
  50057. /**
  50058. * Update this model using the current XRFrame
  50059. * @param xrFrame the current xr frame to use and update the model
  50060. */
  50061. updateFromXRFrame(xrFrame: XRFrame): void;
  50062. /**
  50063. * Backwards compatibility due to a deeply-integrated typo
  50064. */
  50065. get handness(): XREye;
  50066. /**
  50067. * Pulse (vibrate) this controller
  50068. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50069. * Consecutive calls to this function will cancel the last pulse call
  50070. *
  50071. * @param value the strength of the pulse in 0.0...1.0 range
  50072. * @param duration Duration of the pulse in milliseconds
  50073. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50074. * @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
  50075. */
  50076. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50077. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50078. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50079. /**
  50080. * Moves the axis on the controller mesh based on its current state
  50081. * @param axis the index of the axis
  50082. * @param axisValue the value of the axis which determines the meshes new position
  50083. * @hidden
  50084. */
  50085. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50086. /**
  50087. * Update the model itself with the current frame data
  50088. * @param xrFrame the frame to use for updating the model mesh
  50089. */
  50090. protected updateModel(xrFrame: XRFrame): void;
  50091. /**
  50092. * Get the filename and path for this controller's model
  50093. * @returns a map of filename and path
  50094. */
  50095. protected abstract _getFilenameAndPath(): {
  50096. filename: string;
  50097. path: string;
  50098. };
  50099. /**
  50100. * This function is called before the mesh is loaded. It checks for loading constraints.
  50101. * For example, this function can check if the GLB loader is available
  50102. * If this function returns false, the generic controller will be loaded instead
  50103. * @returns Is the client ready to load the mesh
  50104. */
  50105. protected abstract _getModelLoadingConstraints(): boolean;
  50106. /**
  50107. * This function will be called after the model was successfully loaded and can be used
  50108. * for mesh transformations before it is available for the user
  50109. * @param meshes the loaded meshes
  50110. */
  50111. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50112. /**
  50113. * Set the root mesh for this controller. Important for the WebXR controller class
  50114. * @param meshes the loaded meshes
  50115. */
  50116. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50117. /**
  50118. * A function executed each frame that updates the mesh (if needed)
  50119. * @param xrFrame the current xrFrame
  50120. */
  50121. protected abstract _updateModel(xrFrame: XRFrame): void;
  50122. private _getGenericFilenameAndPath;
  50123. private _getGenericParentMesh;
  50124. }
  50125. }
  50126. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50127. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50129. import { Scene } from "babylonjs/scene";
  50130. /**
  50131. * A generic trigger-only motion controller for WebXR
  50132. */
  50133. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50134. /**
  50135. * Static version of the profile id of this controller
  50136. */
  50137. static ProfileId: string;
  50138. profileId: string;
  50139. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50140. protected _getFilenameAndPath(): {
  50141. filename: string;
  50142. path: string;
  50143. };
  50144. protected _getModelLoadingConstraints(): boolean;
  50145. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50146. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50147. protected _updateModel(): void;
  50148. }
  50149. }
  50150. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50151. import { Vector4 } from "babylonjs/Maths/math.vector";
  50152. import { Mesh } from "babylonjs/Meshes/mesh";
  50153. import { Scene } from "babylonjs/scene";
  50154. import { Nullable } from "babylonjs/types";
  50155. /**
  50156. * Class containing static functions to help procedurally build meshes
  50157. */
  50158. export class SphereBuilder {
  50159. /**
  50160. * Creates a sphere mesh
  50161. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50162. * * 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`)
  50163. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50164. * * 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
  50165. * * 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)
  50166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50169. * @param name defines the name of the mesh
  50170. * @param options defines the options used to create the mesh
  50171. * @param scene defines the hosting scene
  50172. * @returns the sphere mesh
  50173. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50174. */
  50175. static CreateSphere(name: string, options: {
  50176. segments?: number;
  50177. diameter?: number;
  50178. diameterX?: number;
  50179. diameterY?: number;
  50180. diameterZ?: number;
  50181. arc?: number;
  50182. slice?: number;
  50183. sideOrientation?: number;
  50184. frontUVs?: Vector4;
  50185. backUVs?: Vector4;
  50186. updatable?: boolean;
  50187. }, scene?: Nullable<Scene>): Mesh;
  50188. }
  50189. }
  50190. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50192. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50193. import { Scene } from "babylonjs/scene";
  50194. /**
  50195. * A profiled motion controller has its profile loaded from an online repository.
  50196. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50197. */
  50198. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50199. private _repositoryUrl;
  50200. private _buttonMeshMapping;
  50201. private _touchDots;
  50202. /**
  50203. * The profile ID of this controller. Will be populated when the controller initializes.
  50204. */
  50205. profileId: string;
  50206. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50207. dispose(): void;
  50208. protected _getFilenameAndPath(): {
  50209. filename: string;
  50210. path: string;
  50211. };
  50212. protected _getModelLoadingConstraints(): boolean;
  50213. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50214. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50215. protected _updateModel(_xrFrame: XRFrame): void;
  50216. }
  50217. }
  50218. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50219. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50220. import { Scene } from "babylonjs/scene";
  50221. /**
  50222. * A construction function type to create a new controller based on an xrInput object
  50223. */
  50224. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50225. /**
  50226. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50227. *
  50228. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50229. * it should be replaced with auto-loaded controllers.
  50230. *
  50231. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50232. */
  50233. export class WebXRMotionControllerManager {
  50234. private static _AvailableControllers;
  50235. private static _Fallbacks;
  50236. private static _ProfileLoadingPromises;
  50237. private static _ProfilesList;
  50238. /**
  50239. * The base URL of the online controller repository. Can be changed at any time.
  50240. */
  50241. static BaseRepositoryUrl: string;
  50242. /**
  50243. * Which repository gets priority - local or online
  50244. */
  50245. static PrioritizeOnlineRepository: boolean;
  50246. /**
  50247. * Use the online repository, or use only locally-defined controllers
  50248. */
  50249. static UseOnlineRepository: boolean;
  50250. /**
  50251. * Clear the cache used for profile loading and reload when requested again
  50252. */
  50253. static ClearProfilesCache(): void;
  50254. /**
  50255. * Register the default fallbacks.
  50256. * This function is called automatically when this file is imported.
  50257. */
  50258. static DefaultFallbacks(): void;
  50259. /**
  50260. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50261. * @param profileId the profile to which a fallback needs to be found
  50262. * @return an array with corresponding fallback profiles
  50263. */
  50264. static FindFallbackWithProfileId(profileId: string): string[];
  50265. /**
  50266. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50267. * The order of search:
  50268. *
  50269. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50270. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50271. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50272. * 4) return the generic trigger controller if none were found
  50273. *
  50274. * @param xrInput the xrInput to which a new controller is initialized
  50275. * @param scene the scene to which the model will be added
  50276. * @param forceProfile force a certain profile for this controller
  50277. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50278. */
  50279. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50280. /**
  50281. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50282. *
  50283. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50284. *
  50285. * @param type the profile type to register
  50286. * @param constructFunction the function to be called when loading this profile
  50287. */
  50288. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50289. /**
  50290. * Register a fallback to a specific profile.
  50291. * @param profileId the profileId that will receive the fallbacks
  50292. * @param fallbacks A list of fallback profiles
  50293. */
  50294. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50295. /**
  50296. * Will update the list of profiles available in the repository
  50297. * @return a promise that resolves to a map of profiles available online
  50298. */
  50299. static UpdateProfilesList(): Promise<{
  50300. [profile: string]: string;
  50301. }>;
  50302. private static _LoadProfileFromRepository;
  50303. private static _LoadProfilesFromAvailableControllers;
  50304. }
  50305. }
  50306. declare module "babylonjs/XR/webXRInputSource" {
  50307. import { Observable } from "babylonjs/Misc/observable";
  50308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50309. import { Ray } from "babylonjs/Culling/ray";
  50310. import { Scene } from "babylonjs/scene";
  50311. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50312. /**
  50313. * Configuration options for the WebXR controller creation
  50314. */
  50315. export interface IWebXRControllerOptions {
  50316. /**
  50317. * Should the controller mesh be animated when a user interacts with it
  50318. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50319. */
  50320. disableMotionControllerAnimation?: boolean;
  50321. /**
  50322. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50323. */
  50324. doNotLoadControllerMesh?: boolean;
  50325. /**
  50326. * Force a specific controller type for this controller.
  50327. * This can be used when creating your own profile or when testing different controllers
  50328. */
  50329. forceControllerProfile?: string;
  50330. /**
  50331. * Defines a rendering group ID for meshes that will be loaded.
  50332. * This is for the default controllers only.
  50333. */
  50334. renderingGroupId?: number;
  50335. }
  50336. /**
  50337. * Represents an XR controller
  50338. */
  50339. export class WebXRInputSource {
  50340. private _scene;
  50341. /** The underlying input source for the controller */
  50342. inputSource: XRInputSource;
  50343. private _options;
  50344. private _tmpVector;
  50345. private _uniqueId;
  50346. private _disposed;
  50347. /**
  50348. * 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
  50349. */
  50350. grip?: AbstractMesh;
  50351. /**
  50352. * If available, this is the gamepad object related to this controller.
  50353. * Using this object it is possible to get click events and trackpad changes of the
  50354. * webxr controller that is currently being used.
  50355. */
  50356. motionController?: WebXRAbstractMotionController;
  50357. /**
  50358. * Event that fires when the controller is removed/disposed.
  50359. * The object provided as event data is this controller, after associated assets were disposed.
  50360. * uniqueId is still available.
  50361. */
  50362. onDisposeObservable: Observable<WebXRInputSource>;
  50363. /**
  50364. * Will be triggered when the mesh associated with the motion controller is done loading.
  50365. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50366. * A shortened version of controller -> motion controller -> on mesh loaded.
  50367. */
  50368. onMeshLoadedObservable: Observable<AbstractMesh>;
  50369. /**
  50370. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50371. */
  50372. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50373. /**
  50374. * Pointer which can be used to select objects or attach a visible laser to
  50375. */
  50376. pointer: AbstractMesh;
  50377. /**
  50378. * Creates the input source object
  50379. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50380. * @param _scene the scene which the controller should be associated to
  50381. * @param inputSource the underlying input source for the controller
  50382. * @param _options options for this controller creation
  50383. */
  50384. constructor(_scene: Scene,
  50385. /** The underlying input source for the controller */
  50386. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50387. /**
  50388. * Get this controllers unique id
  50389. */
  50390. get uniqueId(): string;
  50391. /**
  50392. * Disposes of the object
  50393. */
  50394. dispose(): void;
  50395. /**
  50396. * Gets a world space ray coming from the pointer or grip
  50397. * @param result the resulting ray
  50398. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50399. */
  50400. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50401. /**
  50402. * Updates the controller pose based on the given XRFrame
  50403. * @param xrFrame xr frame to update the pose with
  50404. * @param referenceSpace reference space to use
  50405. */
  50406. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50407. }
  50408. }
  50409. declare module "babylonjs/XR/webXRInput" {
  50410. import { Observable } from "babylonjs/Misc/observable";
  50411. import { IDisposable } from "babylonjs/scene";
  50412. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50413. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50414. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50415. /**
  50416. * The schema for initialization options of the XR Input class
  50417. */
  50418. export interface IWebXRInputOptions {
  50419. /**
  50420. * If set to true no model will be automatically loaded
  50421. */
  50422. doNotLoadControllerMeshes?: boolean;
  50423. /**
  50424. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50425. * If not found, the xr input profile data will be used.
  50426. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50427. */
  50428. forceInputProfile?: string;
  50429. /**
  50430. * Do not send a request to the controller repository to load the profile.
  50431. *
  50432. * Instead, use the controllers available in babylon itself.
  50433. */
  50434. disableOnlineControllerRepository?: boolean;
  50435. /**
  50436. * A custom URL for the controllers repository
  50437. */
  50438. customControllersRepositoryURL?: string;
  50439. /**
  50440. * Should the controller model's components not move according to the user input
  50441. */
  50442. disableControllerAnimation?: boolean;
  50443. /**
  50444. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50445. */
  50446. controllerOptions?: IWebXRControllerOptions;
  50447. }
  50448. /**
  50449. * XR input used to track XR inputs such as controllers/rays
  50450. */
  50451. export class WebXRInput implements IDisposable {
  50452. /**
  50453. * the xr session manager for this session
  50454. */
  50455. xrSessionManager: WebXRSessionManager;
  50456. /**
  50457. * the WebXR camera for this session. Mainly used for teleportation
  50458. */
  50459. xrCamera: WebXRCamera;
  50460. private readonly options;
  50461. /**
  50462. * XR controllers being tracked
  50463. */
  50464. controllers: Array<WebXRInputSource>;
  50465. private _frameObserver;
  50466. private _sessionEndedObserver;
  50467. private _sessionInitObserver;
  50468. /**
  50469. * Event when a controller has been connected/added
  50470. */
  50471. onControllerAddedObservable: Observable<WebXRInputSource>;
  50472. /**
  50473. * Event when a controller has been removed/disconnected
  50474. */
  50475. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50476. /**
  50477. * Initializes the WebXRInput
  50478. * @param xrSessionManager the xr session manager for this session
  50479. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50480. * @param options = initialization options for this xr input
  50481. */
  50482. constructor(
  50483. /**
  50484. * the xr session manager for this session
  50485. */
  50486. xrSessionManager: WebXRSessionManager,
  50487. /**
  50488. * the WebXR camera for this session. Mainly used for teleportation
  50489. */
  50490. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50491. private _onInputSourcesChange;
  50492. private _addAndRemoveControllers;
  50493. /**
  50494. * Disposes of the object
  50495. */
  50496. dispose(): void;
  50497. }
  50498. }
  50499. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50500. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50501. import { Observable, EventState } from "babylonjs/Misc/observable";
  50502. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50503. /**
  50504. * This is the base class for all WebXR features.
  50505. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50506. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50507. */
  50508. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50509. protected _xrSessionManager: WebXRSessionManager;
  50510. private _attached;
  50511. private _removeOnDetach;
  50512. /**
  50513. * Is this feature disposed?
  50514. */
  50515. isDisposed: boolean;
  50516. /**
  50517. * Should auto-attach be disabled?
  50518. */
  50519. disableAutoAttach: boolean;
  50520. /**
  50521. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50522. */
  50523. xrNativeFeatureName: string;
  50524. /**
  50525. * Construct a new (abstract) WebXR feature
  50526. * @param _xrSessionManager the xr session manager for this feature
  50527. */
  50528. constructor(_xrSessionManager: WebXRSessionManager);
  50529. /**
  50530. * Is this feature attached
  50531. */
  50532. get attached(): boolean;
  50533. /**
  50534. * attach this feature
  50535. *
  50536. * @param force should attachment be forced (even when already attached)
  50537. * @returns true if successful, false is failed or already attached
  50538. */
  50539. attach(force?: boolean): boolean;
  50540. /**
  50541. * detach this feature.
  50542. *
  50543. * @returns true if successful, false if failed or already detached
  50544. */
  50545. detach(): boolean;
  50546. /**
  50547. * Dispose this feature and all of the resources attached
  50548. */
  50549. dispose(): void;
  50550. /**
  50551. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50552. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50553. *
  50554. * @returns whether or not the feature is compatible in this environment
  50555. */
  50556. isCompatible(): boolean;
  50557. /**
  50558. * This is used to register callbacks that will automatically be removed when detach is called.
  50559. * @param observable the observable to which the observer will be attached
  50560. * @param callback the callback to register
  50561. */
  50562. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50563. /**
  50564. * Code in this function will be executed on each xrFrame received from the browser.
  50565. * This function will not execute after the feature is detached.
  50566. * @param _xrFrame the current frame
  50567. */
  50568. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50569. }
  50570. }
  50571. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50572. import { IDisposable, Scene } from "babylonjs/scene";
  50573. import { Nullable } from "babylonjs/types";
  50574. import { Observable } from "babylonjs/Misc/observable";
  50575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50576. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50577. import { Camera } from "babylonjs/Cameras/camera";
  50578. /**
  50579. * Renders a layer on top of an existing scene
  50580. */
  50581. export class UtilityLayerRenderer implements IDisposable {
  50582. /** the original scene that will be rendered on top of */
  50583. originalScene: Scene;
  50584. private _pointerCaptures;
  50585. private _lastPointerEvents;
  50586. private static _DefaultUtilityLayer;
  50587. private static _DefaultKeepDepthUtilityLayer;
  50588. private _sharedGizmoLight;
  50589. private _renderCamera;
  50590. /**
  50591. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50592. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50593. * @returns the camera that is used when rendering the utility layer
  50594. */
  50595. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50596. /**
  50597. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50598. * @param cam the camera that should be used when rendering the utility layer
  50599. */
  50600. setRenderCamera(cam: Nullable<Camera>): void;
  50601. /**
  50602. * @hidden
  50603. * Light which used by gizmos to get light shading
  50604. */
  50605. _getSharedGizmoLight(): HemisphericLight;
  50606. /**
  50607. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50608. */
  50609. pickUtilitySceneFirst: boolean;
  50610. /**
  50611. * 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)
  50612. */
  50613. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50614. /**
  50615. * 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)
  50616. */
  50617. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50618. /**
  50619. * The scene that is rendered on top of the original scene
  50620. */
  50621. utilityLayerScene: Scene;
  50622. /**
  50623. * If the utility layer should automatically be rendered on top of existing scene
  50624. */
  50625. shouldRender: boolean;
  50626. /**
  50627. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50628. */
  50629. onlyCheckPointerDownEvents: boolean;
  50630. /**
  50631. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50632. */
  50633. processAllEvents: boolean;
  50634. /**
  50635. * Observable raised when the pointer move from the utility layer scene to the main scene
  50636. */
  50637. onPointerOutObservable: Observable<number>;
  50638. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50639. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50640. private _afterRenderObserver;
  50641. private _sceneDisposeObserver;
  50642. private _originalPointerObserver;
  50643. /**
  50644. * Instantiates a UtilityLayerRenderer
  50645. * @param originalScene the original scene that will be rendered on top of
  50646. * @param handleEvents boolean indicating if the utility layer should handle events
  50647. */
  50648. constructor(
  50649. /** the original scene that will be rendered on top of */
  50650. originalScene: Scene, handleEvents?: boolean);
  50651. private _notifyObservers;
  50652. /**
  50653. * Renders the utility layers scene on top of the original scene
  50654. */
  50655. render(): void;
  50656. /**
  50657. * Disposes of the renderer
  50658. */
  50659. dispose(): void;
  50660. private _updateCamera;
  50661. }
  50662. }
  50663. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50664. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50666. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50667. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50668. import { Scene } from "babylonjs/scene";
  50669. import { Nullable } from "babylonjs/types";
  50670. import { Color3 } from "babylonjs/Maths/math.color";
  50671. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50672. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50673. /**
  50674. * Options interface for the pointer selection module
  50675. */
  50676. export interface IWebXRControllerPointerSelectionOptions {
  50677. /**
  50678. * if provided, this scene will be used to render meshes.
  50679. */
  50680. customUtilityLayerScene?: Scene;
  50681. /**
  50682. * 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)
  50683. * If not disabled, the last picked point will be used to execute a pointer up event
  50684. * If disabled, pointer up event will be triggered right after the pointer down event.
  50685. * Used in screen and gaze target ray mode only
  50686. */
  50687. disablePointerUpOnTouchOut: boolean;
  50688. /**
  50689. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50690. */
  50691. forceGazeMode: boolean;
  50692. /**
  50693. * 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
  50694. * to start a new countdown to the pointer down event.
  50695. * Defaults to 1.
  50696. */
  50697. gazeModePointerMovedFactor?: number;
  50698. /**
  50699. * Different button type to use instead of the main component
  50700. */
  50701. overrideButtonId?: string;
  50702. /**
  50703. * use this rendering group id for the meshes (optional)
  50704. */
  50705. renderingGroupId?: number;
  50706. /**
  50707. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50708. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50709. * 3000 means 3 seconds between pointing at something and selecting it
  50710. */
  50711. timeToSelect?: number;
  50712. /**
  50713. * Should meshes created here be added to a utility layer or the main scene
  50714. */
  50715. useUtilityLayer?: boolean;
  50716. /**
  50717. * Optional WebXR camera to be used for gaze selection
  50718. */
  50719. gazeCamera?: WebXRCamera;
  50720. /**
  50721. * the xr input to use with this pointer selection
  50722. */
  50723. xrInput: WebXRInput;
  50724. }
  50725. /**
  50726. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50727. */
  50728. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50729. private readonly _options;
  50730. private static _idCounter;
  50731. private _attachController;
  50732. private _controllers;
  50733. private _scene;
  50734. private _tmpVectorForPickCompare;
  50735. /**
  50736. * The module's name
  50737. */
  50738. static readonly Name: string;
  50739. /**
  50740. * The (Babylon) version of this module.
  50741. * This is an integer representing the implementation version.
  50742. * This number does not correspond to the WebXR specs version
  50743. */
  50744. static readonly Version: number;
  50745. /**
  50746. * Disable lighting on the laser pointer (so it will always be visible)
  50747. */
  50748. disablePointerLighting: boolean;
  50749. /**
  50750. * Disable lighting on the selection mesh (so it will always be visible)
  50751. */
  50752. disableSelectionMeshLighting: boolean;
  50753. /**
  50754. * Should the laser pointer be displayed
  50755. */
  50756. displayLaserPointer: boolean;
  50757. /**
  50758. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50759. */
  50760. displaySelectionMesh: boolean;
  50761. /**
  50762. * This color will be set to the laser pointer when selection is triggered
  50763. */
  50764. laserPointerPickedColor: Color3;
  50765. /**
  50766. * Default color of the laser pointer
  50767. */
  50768. laserPointerDefaultColor: Color3;
  50769. /**
  50770. * default color of the selection ring
  50771. */
  50772. selectionMeshDefaultColor: Color3;
  50773. /**
  50774. * This color will be applied to the selection ring when selection is triggered
  50775. */
  50776. selectionMeshPickedColor: Color3;
  50777. /**
  50778. * Optional filter to be used for ray selection. This predicate shares behavior with
  50779. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50780. */
  50781. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50782. /**
  50783. * constructs a new background remover module
  50784. * @param _xrSessionManager the session manager for this module
  50785. * @param _options read-only options to be used in this module
  50786. */
  50787. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50788. /**
  50789. * attach this feature
  50790. * Will usually be called by the features manager
  50791. *
  50792. * @returns true if successful.
  50793. */
  50794. attach(): boolean;
  50795. /**
  50796. * detach this feature.
  50797. * Will usually be called by the features manager
  50798. *
  50799. * @returns true if successful.
  50800. */
  50801. detach(): boolean;
  50802. /**
  50803. * Will get the mesh under a specific pointer.
  50804. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50805. * @param controllerId the controllerId to check
  50806. * @returns The mesh under pointer or null if no mesh is under the pointer
  50807. */
  50808. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50809. /**
  50810. * Get the xr controller that correlates to the pointer id in the pointer event
  50811. *
  50812. * @param id the pointer id to search for
  50813. * @returns the controller that correlates to this id or null if not found
  50814. */
  50815. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50816. protected _onXRFrame(_xrFrame: XRFrame): void;
  50817. private _attachGazeMode;
  50818. private _attachScreenRayMode;
  50819. private _attachTrackedPointerRayMode;
  50820. private _convertNormalToDirectionOfRay;
  50821. private _detachController;
  50822. private _generateNewMeshPair;
  50823. private _pickingMoved;
  50824. private _updatePointerDistance;
  50825. /** @hidden */
  50826. get lasterPointerDefaultColor(): Color3;
  50827. }
  50828. }
  50829. declare module "babylonjs/XR/webXREnterExitUI" {
  50830. import { Nullable } from "babylonjs/types";
  50831. import { Observable } from "babylonjs/Misc/observable";
  50832. import { IDisposable, Scene } from "babylonjs/scene";
  50833. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50834. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50835. /**
  50836. * Button which can be used to enter a different mode of XR
  50837. */
  50838. export class WebXREnterExitUIButton {
  50839. /** button element */
  50840. element: HTMLElement;
  50841. /** XR initialization options for the button */
  50842. sessionMode: XRSessionMode;
  50843. /** Reference space type */
  50844. referenceSpaceType: XRReferenceSpaceType;
  50845. /**
  50846. * Creates a WebXREnterExitUIButton
  50847. * @param element button element
  50848. * @param sessionMode XR initialization session mode
  50849. * @param referenceSpaceType the type of reference space to be used
  50850. */
  50851. constructor(
  50852. /** button element */
  50853. element: HTMLElement,
  50854. /** XR initialization options for the button */
  50855. sessionMode: XRSessionMode,
  50856. /** Reference space type */
  50857. referenceSpaceType: XRReferenceSpaceType);
  50858. /**
  50859. * Extendable function which can be used to update the button's visuals when the state changes
  50860. * @param activeButton the current active button in the UI
  50861. */
  50862. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50863. }
  50864. /**
  50865. * Options to create the webXR UI
  50866. */
  50867. export class WebXREnterExitUIOptions {
  50868. /**
  50869. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50870. */
  50871. customButtons?: Array<WebXREnterExitUIButton>;
  50872. /**
  50873. * A reference space type to use when creating the default button.
  50874. * Default is local-floor
  50875. */
  50876. referenceSpaceType?: XRReferenceSpaceType;
  50877. /**
  50878. * Context to enter xr with
  50879. */
  50880. renderTarget?: Nullable<WebXRRenderTarget>;
  50881. /**
  50882. * A session mode to use when creating the default button.
  50883. * Default is immersive-vr
  50884. */
  50885. sessionMode?: XRSessionMode;
  50886. /**
  50887. * A list of optional features to init the session with
  50888. */
  50889. optionalFeatures?: string[];
  50890. /**
  50891. * A list of optional features to init the session with
  50892. */
  50893. requiredFeatures?: string[];
  50894. }
  50895. /**
  50896. * UI to allow the user to enter/exit XR mode
  50897. */
  50898. export class WebXREnterExitUI implements IDisposable {
  50899. private scene;
  50900. /** version of the options passed to this UI */
  50901. options: WebXREnterExitUIOptions;
  50902. private _activeButton;
  50903. private _buttons;
  50904. /**
  50905. * The HTML Div Element to which buttons are added.
  50906. */
  50907. readonly overlay: HTMLDivElement;
  50908. /**
  50909. * Fired every time the active button is changed.
  50910. *
  50911. * When xr is entered via a button that launches xr that button will be the callback parameter
  50912. *
  50913. * When exiting xr the callback parameter will be null)
  50914. */
  50915. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50916. /**
  50917. *
  50918. * @param scene babylon scene object to use
  50919. * @param options (read-only) version of the options passed to this UI
  50920. */
  50921. private constructor();
  50922. /**
  50923. * Creates UI to allow the user to enter/exit XR mode
  50924. * @param scene the scene to add the ui to
  50925. * @param helper the xr experience helper to enter/exit xr with
  50926. * @param options options to configure the UI
  50927. * @returns the created ui
  50928. */
  50929. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50930. /**
  50931. * Disposes of the XR UI component
  50932. */
  50933. dispose(): void;
  50934. private _updateButtons;
  50935. }
  50936. }
  50937. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50938. import { Vector3 } from "babylonjs/Maths/math.vector";
  50939. import { Color4 } from "babylonjs/Maths/math.color";
  50940. import { Nullable } from "babylonjs/types";
  50941. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50942. import { Scene } from "babylonjs/scene";
  50943. /**
  50944. * Class containing static functions to help procedurally build meshes
  50945. */
  50946. export class LinesBuilder {
  50947. /**
  50948. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50949. * * 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
  50950. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50951. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50952. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50953. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50954. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50955. * * 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
  50956. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50959. * @param name defines the name of the new line system
  50960. * @param options defines the options used to create the line system
  50961. * @param scene defines the hosting scene
  50962. * @returns a new line system mesh
  50963. */
  50964. static CreateLineSystem(name: string, options: {
  50965. lines: Vector3[][];
  50966. updatable?: boolean;
  50967. instance?: Nullable<LinesMesh>;
  50968. colors?: Nullable<Color4[][]>;
  50969. useVertexAlpha?: boolean;
  50970. }, scene: Nullable<Scene>): LinesMesh;
  50971. /**
  50972. * Creates a line mesh
  50973. * 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
  50974. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50975. * * The parameter `points` is an array successive Vector3
  50976. * * 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
  50977. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50978. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50979. * * When updating an instance, remember that only point positions can change, not the number of points
  50980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50982. * @param name defines the name of the new line system
  50983. * @param options defines the options used to create the line system
  50984. * @param scene defines the hosting scene
  50985. * @returns a new line mesh
  50986. */
  50987. static CreateLines(name: string, options: {
  50988. points: Vector3[];
  50989. updatable?: boolean;
  50990. instance?: Nullable<LinesMesh>;
  50991. colors?: Color4[];
  50992. useVertexAlpha?: boolean;
  50993. }, scene?: Nullable<Scene>): LinesMesh;
  50994. /**
  50995. * Creates a dashed line mesh
  50996. * * 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
  50997. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50998. * * The parameter `points` is an array successive Vector3
  50999. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51000. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51001. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51002. * * 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
  51003. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51004. * * When updating an instance, remember that only point positions can change, not the number of points
  51005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51006. * @param name defines the name of the mesh
  51007. * @param options defines the options used to create the mesh
  51008. * @param scene defines the hosting scene
  51009. * @returns the dashed line mesh
  51010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51011. */
  51012. static CreateDashedLines(name: string, options: {
  51013. points: Vector3[];
  51014. dashSize?: number;
  51015. gapSize?: number;
  51016. dashNb?: number;
  51017. updatable?: boolean;
  51018. instance?: LinesMesh;
  51019. useVertexAlpha?: boolean;
  51020. }, scene?: Nullable<Scene>): LinesMesh;
  51021. }
  51022. }
  51023. declare module "babylonjs/Misc/timer" {
  51024. import { Observable, Observer } from "babylonjs/Misc/observable";
  51025. import { Nullable } from "babylonjs/types";
  51026. import { IDisposable } from "babylonjs/scene";
  51027. /**
  51028. * Construction options for a timer
  51029. */
  51030. export interface ITimerOptions<T> {
  51031. /**
  51032. * Time-to-end
  51033. */
  51034. timeout: number;
  51035. /**
  51036. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51037. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51038. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51039. */
  51040. contextObservable: Observable<T>;
  51041. /**
  51042. * Optional parameters when adding an observer to the observable
  51043. */
  51044. observableParameters?: {
  51045. mask?: number;
  51046. insertFirst?: boolean;
  51047. scope?: any;
  51048. };
  51049. /**
  51050. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51051. */
  51052. breakCondition?: (data?: ITimerData<T>) => boolean;
  51053. /**
  51054. * Will be triggered when the time condition has met
  51055. */
  51056. onEnded?: (data: ITimerData<any>) => void;
  51057. /**
  51058. * Will be triggered when the break condition has met (prematurely ended)
  51059. */
  51060. onAborted?: (data: ITimerData<any>) => void;
  51061. /**
  51062. * Optional function to execute on each tick (or count)
  51063. */
  51064. onTick?: (data: ITimerData<any>) => void;
  51065. }
  51066. /**
  51067. * An interface defining the data sent by the timer
  51068. */
  51069. export interface ITimerData<T> {
  51070. /**
  51071. * When did it start
  51072. */
  51073. startTime: number;
  51074. /**
  51075. * Time now
  51076. */
  51077. currentTime: number;
  51078. /**
  51079. * Time passed since started
  51080. */
  51081. deltaTime: number;
  51082. /**
  51083. * How much is completed, in [0.0...1.0].
  51084. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51085. */
  51086. completeRate: number;
  51087. /**
  51088. * What the registered observable sent in the last count
  51089. */
  51090. payload: T;
  51091. }
  51092. /**
  51093. * The current state of the timer
  51094. */
  51095. export enum TimerState {
  51096. /**
  51097. * Timer initialized, not yet started
  51098. */
  51099. INIT = 0,
  51100. /**
  51101. * Timer started and counting
  51102. */
  51103. STARTED = 1,
  51104. /**
  51105. * Timer ended (whether aborted or time reached)
  51106. */
  51107. ENDED = 2
  51108. }
  51109. /**
  51110. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51111. *
  51112. * @param options options with which to initialize this timer
  51113. */
  51114. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51115. /**
  51116. * An advanced implementation of a timer class
  51117. */
  51118. export class AdvancedTimer<T = any> implements IDisposable {
  51119. /**
  51120. * Will notify each time the timer calculates the remaining time
  51121. */
  51122. onEachCountObservable: Observable<ITimerData<T>>;
  51123. /**
  51124. * Will trigger when the timer was aborted due to the break condition
  51125. */
  51126. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51127. /**
  51128. * Will trigger when the timer ended successfully
  51129. */
  51130. onTimerEndedObservable: Observable<ITimerData<T>>;
  51131. /**
  51132. * Will trigger when the timer state has changed
  51133. */
  51134. onStateChangedObservable: Observable<TimerState>;
  51135. private _observer;
  51136. private _contextObservable;
  51137. private _observableParameters;
  51138. private _startTime;
  51139. private _timer;
  51140. private _state;
  51141. private _breakCondition;
  51142. private _timeToEnd;
  51143. private _breakOnNextTick;
  51144. /**
  51145. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51146. * @param options construction options for this advanced timer
  51147. */
  51148. constructor(options: ITimerOptions<T>);
  51149. /**
  51150. * set a breaking condition for this timer. Default is to never break during count
  51151. * @param predicate the new break condition. Returns true to break, false otherwise
  51152. */
  51153. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51154. /**
  51155. * Reset ALL associated observables in this advanced timer
  51156. */
  51157. clearObservables(): void;
  51158. /**
  51159. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51160. *
  51161. * @param timeToEnd how much time to measure until timer ended
  51162. */
  51163. start(timeToEnd?: number): void;
  51164. /**
  51165. * Will force a stop on the next tick.
  51166. */
  51167. stop(): void;
  51168. /**
  51169. * Dispose this timer, clearing all resources
  51170. */
  51171. dispose(): void;
  51172. private _setState;
  51173. private _tick;
  51174. private _stop;
  51175. }
  51176. }
  51177. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51178. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51179. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51180. import { Nullable } from "babylonjs/types";
  51181. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51183. import { Vector3 } from "babylonjs/Maths/math.vector";
  51184. import { Material } from "babylonjs/Materials/material";
  51185. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51186. import { Scene } from "babylonjs/scene";
  51187. /**
  51188. * The options container for the teleportation module
  51189. */
  51190. export interface IWebXRTeleportationOptions {
  51191. /**
  51192. * if provided, this scene will be used to render meshes.
  51193. */
  51194. customUtilityLayerScene?: Scene;
  51195. /**
  51196. * Values to configure the default target mesh
  51197. */
  51198. defaultTargetMeshOptions?: {
  51199. /**
  51200. * Fill color of the teleportation area
  51201. */
  51202. teleportationFillColor?: string;
  51203. /**
  51204. * Border color for the teleportation area
  51205. */
  51206. teleportationBorderColor?: string;
  51207. /**
  51208. * Disable the mesh's animation sequence
  51209. */
  51210. disableAnimation?: boolean;
  51211. /**
  51212. * Disable lighting on the material or the ring and arrow
  51213. */
  51214. disableLighting?: boolean;
  51215. /**
  51216. * Override the default material of the torus and arrow
  51217. */
  51218. torusArrowMaterial?: Material;
  51219. };
  51220. /**
  51221. * A list of meshes to use as floor meshes.
  51222. * Meshes can be added and removed after initializing the feature using the
  51223. * addFloorMesh and removeFloorMesh functions
  51224. * If empty, rotation will still work
  51225. */
  51226. floorMeshes?: AbstractMesh[];
  51227. /**
  51228. * use this rendering group id for the meshes (optional)
  51229. */
  51230. renderingGroupId?: number;
  51231. /**
  51232. * Should teleportation move only to snap points
  51233. */
  51234. snapPointsOnly?: boolean;
  51235. /**
  51236. * An array of points to which the teleportation will snap to.
  51237. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51238. */
  51239. snapPositions?: Vector3[];
  51240. /**
  51241. * How close should the teleportation ray be in order to snap to position.
  51242. * Default to 0.8 units (meters)
  51243. */
  51244. snapToPositionRadius?: number;
  51245. /**
  51246. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51247. * If you want to support rotation, make sure your mesh has a direction indicator.
  51248. *
  51249. * When left untouched, the default mesh will be initialized.
  51250. */
  51251. teleportationTargetMesh?: AbstractMesh;
  51252. /**
  51253. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51254. */
  51255. timeToTeleport?: number;
  51256. /**
  51257. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51258. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51259. */
  51260. useMainComponentOnly?: boolean;
  51261. /**
  51262. * Should meshes created here be added to a utility layer or the main scene
  51263. */
  51264. useUtilityLayer?: boolean;
  51265. /**
  51266. * Babylon XR Input class for controller
  51267. */
  51268. xrInput: WebXRInput;
  51269. /**
  51270. * Meshes that the teleportation ray cannot go through
  51271. */
  51272. pickBlockerMeshes?: AbstractMesh[];
  51273. }
  51274. /**
  51275. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51276. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51277. * the input of the attached controllers.
  51278. */
  51279. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51280. private _options;
  51281. private _controllers;
  51282. private _currentTeleportationControllerId;
  51283. private _floorMeshes;
  51284. private _quadraticBezierCurve;
  51285. private _selectionFeature;
  51286. private _snapToPositions;
  51287. private _snappedToPoint;
  51288. private _teleportationRingMaterial?;
  51289. private _tmpRay;
  51290. private _tmpVector;
  51291. private _tmpQuaternion;
  51292. /**
  51293. * The module's name
  51294. */
  51295. static readonly Name: string;
  51296. /**
  51297. * The (Babylon) version of this module.
  51298. * This is an integer representing the implementation version.
  51299. * This number does not correspond to the webxr specs version
  51300. */
  51301. static readonly Version: number;
  51302. /**
  51303. * Is movement backwards enabled
  51304. */
  51305. backwardsMovementEnabled: boolean;
  51306. /**
  51307. * Distance to travel when moving backwards
  51308. */
  51309. backwardsTeleportationDistance: number;
  51310. /**
  51311. * The distance from the user to the inspection point in the direction of the controller
  51312. * A higher number will allow the user to move further
  51313. * defaults to 5 (meters, in xr units)
  51314. */
  51315. parabolicCheckRadius: number;
  51316. /**
  51317. * Should the module support parabolic ray on top of direct ray
  51318. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51319. * Very helpful when moving between floors / different heights
  51320. */
  51321. parabolicRayEnabled: boolean;
  51322. /**
  51323. * How much rotation should be applied when rotating right and left
  51324. */
  51325. rotationAngle: number;
  51326. /**
  51327. * Is rotation enabled when moving forward?
  51328. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51329. */
  51330. rotationEnabled: boolean;
  51331. /**
  51332. * constructs a new anchor system
  51333. * @param _xrSessionManager an instance of WebXRSessionManager
  51334. * @param _options configuration object for this feature
  51335. */
  51336. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51337. /**
  51338. * Get the snapPointsOnly flag
  51339. */
  51340. get snapPointsOnly(): boolean;
  51341. /**
  51342. * Sets the snapPointsOnly flag
  51343. * @param snapToPoints should teleportation be exclusively to snap points
  51344. */
  51345. set snapPointsOnly(snapToPoints: boolean);
  51346. /**
  51347. * Add a new mesh to the floor meshes array
  51348. * @param mesh the mesh to use as floor mesh
  51349. */
  51350. addFloorMesh(mesh: AbstractMesh): void;
  51351. /**
  51352. * Add a new snap-to point to fix teleportation to this position
  51353. * @param newSnapPoint The new Snap-To point
  51354. */
  51355. addSnapPoint(newSnapPoint: Vector3): void;
  51356. attach(): boolean;
  51357. detach(): boolean;
  51358. dispose(): void;
  51359. /**
  51360. * Remove a mesh from the floor meshes array
  51361. * @param mesh the mesh to remove
  51362. */
  51363. removeFloorMesh(mesh: AbstractMesh): void;
  51364. /**
  51365. * Remove a mesh from the floor meshes array using its name
  51366. * @param name the mesh name to remove
  51367. */
  51368. removeFloorMeshByName(name: string): void;
  51369. /**
  51370. * 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
  51371. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51372. * @returns was the point found and removed or not
  51373. */
  51374. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51375. /**
  51376. * This function sets a selection feature that will be disabled when
  51377. * the forward ray is shown and will be reattached when hidden.
  51378. * This is used to remove the selection rays when moving.
  51379. * @param selectionFeature the feature to disable when forward movement is enabled
  51380. */
  51381. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51382. protected _onXRFrame(_xrFrame: XRFrame): void;
  51383. private _attachController;
  51384. private _createDefaultTargetMesh;
  51385. private _detachController;
  51386. private _findClosestSnapPointWithRadius;
  51387. private _setTargetMeshPosition;
  51388. private _setTargetMeshVisibility;
  51389. private _showParabolicPath;
  51390. private _teleportForward;
  51391. }
  51392. }
  51393. declare module "babylonjs/XR/webXRDefaultExperience" {
  51394. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51395. import { Scene } from "babylonjs/scene";
  51396. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51397. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51398. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51399. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51401. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51402. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51403. /**
  51404. * Options for the default xr helper
  51405. */
  51406. export class WebXRDefaultExperienceOptions {
  51407. /**
  51408. * Enable or disable default UI to enter XR
  51409. */
  51410. disableDefaultUI?: boolean;
  51411. /**
  51412. * Should teleportation not initialize. defaults to false.
  51413. */
  51414. disableTeleportation?: boolean;
  51415. /**
  51416. * Floor meshes that will be used for teleport
  51417. */
  51418. floorMeshes?: Array<AbstractMesh>;
  51419. /**
  51420. * If set to true, the first frame will not be used to reset position
  51421. * The first frame is mainly used when copying transformation from the old camera
  51422. * Mainly used in AR
  51423. */
  51424. ignoreNativeCameraTransformation?: boolean;
  51425. /**
  51426. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51427. */
  51428. inputOptions?: IWebXRInputOptions;
  51429. /**
  51430. * optional configuration for the output canvas
  51431. */
  51432. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51433. /**
  51434. * optional UI options. This can be used among other to change session mode and reference space type
  51435. */
  51436. uiOptions?: WebXREnterExitUIOptions;
  51437. /**
  51438. * When loading teleportation and pointer select, use stable versions instead of latest.
  51439. */
  51440. useStablePlugins?: boolean;
  51441. /**
  51442. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51443. */
  51444. renderingGroupId?: number;
  51445. /**
  51446. * A list of optional features to init the session with
  51447. * If set to true, all features we support will be added
  51448. */
  51449. optionalFeatures?: boolean | string[];
  51450. }
  51451. /**
  51452. * Default experience which provides a similar setup to the previous webVRExperience
  51453. */
  51454. export class WebXRDefaultExperience {
  51455. /**
  51456. * Base experience
  51457. */
  51458. baseExperience: WebXRExperienceHelper;
  51459. /**
  51460. * Enables ui for entering/exiting xr
  51461. */
  51462. enterExitUI: WebXREnterExitUI;
  51463. /**
  51464. * Input experience extension
  51465. */
  51466. input: WebXRInput;
  51467. /**
  51468. * Enables laser pointer and selection
  51469. */
  51470. pointerSelection: WebXRControllerPointerSelection;
  51471. /**
  51472. * Default target xr should render to
  51473. */
  51474. renderTarget: WebXRRenderTarget;
  51475. /**
  51476. * Enables teleportation
  51477. */
  51478. teleportation: WebXRMotionControllerTeleportation;
  51479. private constructor();
  51480. /**
  51481. * Creates the default xr experience
  51482. * @param scene scene
  51483. * @param options options for basic configuration
  51484. * @returns resulting WebXRDefaultExperience
  51485. */
  51486. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51487. /**
  51488. * DIsposes of the experience helper
  51489. */
  51490. dispose(): void;
  51491. }
  51492. }
  51493. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51494. import { Observable } from "babylonjs/Misc/observable";
  51495. import { Nullable } from "babylonjs/types";
  51496. import { Camera } from "babylonjs/Cameras/camera";
  51497. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51498. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51499. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51500. import { Scene } from "babylonjs/scene";
  51501. import { Vector3 } from "babylonjs/Maths/math.vector";
  51502. import { Color3 } from "babylonjs/Maths/math.color";
  51503. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51505. import { Mesh } from "babylonjs/Meshes/mesh";
  51506. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51507. import { EasingFunction } from "babylonjs/Animations/easing";
  51508. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51509. import "babylonjs/Meshes/Builders/groundBuilder";
  51510. import "babylonjs/Meshes/Builders/torusBuilder";
  51511. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51512. import "babylonjs/Gamepads/gamepadSceneComponent";
  51513. import "babylonjs/Animations/animatable";
  51514. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51515. /**
  51516. * Options to modify the vr teleportation behavior.
  51517. */
  51518. export interface VRTeleportationOptions {
  51519. /**
  51520. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51521. */
  51522. floorMeshName?: string;
  51523. /**
  51524. * A list of meshes to be used as the teleportation floor. (default: empty)
  51525. */
  51526. floorMeshes?: Mesh[];
  51527. /**
  51528. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51529. */
  51530. teleportationMode?: number;
  51531. /**
  51532. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51533. */
  51534. teleportationTime?: number;
  51535. /**
  51536. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51537. */
  51538. teleportationSpeed?: number;
  51539. /**
  51540. * The easing function used in the animation or null for Linear. (default CircleEase)
  51541. */
  51542. easingFunction?: EasingFunction;
  51543. }
  51544. /**
  51545. * Options to modify the vr experience helper's behavior.
  51546. */
  51547. export interface VRExperienceHelperOptions extends WebVROptions {
  51548. /**
  51549. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51550. */
  51551. createDeviceOrientationCamera?: boolean;
  51552. /**
  51553. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51554. */
  51555. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51556. /**
  51557. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51558. */
  51559. laserToggle?: boolean;
  51560. /**
  51561. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51562. */
  51563. floorMeshes?: Mesh[];
  51564. /**
  51565. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51566. */
  51567. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51568. /**
  51569. * Defines if WebXR should be used instead of WebVR (if available)
  51570. */
  51571. useXR?: boolean;
  51572. }
  51573. /**
  51574. * Event containing information after VR has been entered
  51575. */
  51576. export class OnAfterEnteringVRObservableEvent {
  51577. /**
  51578. * If entering vr was successful
  51579. */
  51580. success: boolean;
  51581. }
  51582. /**
  51583. * Helps to quickly add VR support to an existing scene.
  51584. * See https://doc.babylonjs.com/how_to/webvr_helper
  51585. */
  51586. export class VRExperienceHelper {
  51587. /** Options to modify the vr experience helper's behavior. */
  51588. webVROptions: VRExperienceHelperOptions;
  51589. private _scene;
  51590. private _position;
  51591. private _btnVR;
  51592. private _btnVRDisplayed;
  51593. private _webVRsupported;
  51594. private _webVRready;
  51595. private _webVRrequesting;
  51596. private _webVRpresenting;
  51597. private _hasEnteredVR;
  51598. private _fullscreenVRpresenting;
  51599. private _inputElement;
  51600. private _webVRCamera;
  51601. private _vrDeviceOrientationCamera;
  51602. private _deviceOrientationCamera;
  51603. private _existingCamera;
  51604. private _onKeyDown;
  51605. private _onVrDisplayPresentChange;
  51606. private _onVRDisplayChanged;
  51607. private _onVRRequestPresentStart;
  51608. private _onVRRequestPresentComplete;
  51609. /**
  51610. * 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)
  51611. */
  51612. enableGazeEvenWhenNoPointerLock: boolean;
  51613. /**
  51614. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51615. */
  51616. exitVROnDoubleTap: boolean;
  51617. /**
  51618. * Observable raised right before entering VR.
  51619. */
  51620. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51621. /**
  51622. * Observable raised when entering VR has completed.
  51623. */
  51624. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51625. /**
  51626. * Observable raised when exiting VR.
  51627. */
  51628. onExitingVRObservable: Observable<VRExperienceHelper>;
  51629. /**
  51630. * Observable raised when controller mesh is loaded.
  51631. */
  51632. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51633. /** Return this.onEnteringVRObservable
  51634. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51635. */
  51636. get onEnteringVR(): Observable<VRExperienceHelper>;
  51637. /** Return this.onExitingVRObservable
  51638. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51639. */
  51640. get onExitingVR(): Observable<VRExperienceHelper>;
  51641. /** Return this.onControllerMeshLoadedObservable
  51642. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51643. */
  51644. get onControllerMeshLoaded(): Observable<WebVRController>;
  51645. private _rayLength;
  51646. private _useCustomVRButton;
  51647. private _teleportationRequested;
  51648. private _teleportActive;
  51649. private _floorMeshName;
  51650. private _floorMeshesCollection;
  51651. private _teleportationMode;
  51652. private _teleportationTime;
  51653. private _teleportationSpeed;
  51654. private _teleportationEasing;
  51655. private _rotationAllowed;
  51656. private _teleportBackwardsVector;
  51657. private _teleportationTarget;
  51658. private _isDefaultTeleportationTarget;
  51659. private _postProcessMove;
  51660. private _teleportationFillColor;
  51661. private _teleportationBorderColor;
  51662. private _rotationAngle;
  51663. private _haloCenter;
  51664. private _cameraGazer;
  51665. private _padSensibilityUp;
  51666. private _padSensibilityDown;
  51667. private _leftController;
  51668. private _rightController;
  51669. private _gazeColor;
  51670. private _laserColor;
  51671. private _pickedLaserColor;
  51672. private _pickedGazeColor;
  51673. /**
  51674. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51675. */
  51676. onNewMeshSelected: Observable<AbstractMesh>;
  51677. /**
  51678. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51679. * This observable will provide the mesh and the controller used to select the mesh
  51680. */
  51681. onMeshSelectedWithController: Observable<{
  51682. mesh: AbstractMesh;
  51683. controller: WebVRController;
  51684. }>;
  51685. /**
  51686. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51687. */
  51688. onNewMeshPicked: Observable<PickingInfo>;
  51689. private _circleEase;
  51690. /**
  51691. * Observable raised before camera teleportation
  51692. */
  51693. onBeforeCameraTeleport: Observable<Vector3>;
  51694. /**
  51695. * Observable raised after camera teleportation
  51696. */
  51697. onAfterCameraTeleport: Observable<Vector3>;
  51698. /**
  51699. * Observable raised when current selected mesh gets unselected
  51700. */
  51701. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51702. private _raySelectionPredicate;
  51703. /**
  51704. * To be optionaly changed by user to define custom ray selection
  51705. */
  51706. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51707. /**
  51708. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51709. */
  51710. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51711. /**
  51712. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51713. */
  51714. teleportationEnabled: boolean;
  51715. private _defaultHeight;
  51716. private _teleportationInitialized;
  51717. private _interactionsEnabled;
  51718. private _interactionsRequested;
  51719. private _displayGaze;
  51720. private _displayLaserPointer;
  51721. /**
  51722. * The mesh used to display where the user is going to teleport.
  51723. */
  51724. get teleportationTarget(): Mesh;
  51725. /**
  51726. * Sets the mesh to be used to display where the user is going to teleport.
  51727. */
  51728. set teleportationTarget(value: Mesh);
  51729. /**
  51730. * 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
  51731. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51732. * See https://doc.babylonjs.com/resources/baking_transformations
  51733. */
  51734. get gazeTrackerMesh(): Mesh;
  51735. set gazeTrackerMesh(value: Mesh);
  51736. /**
  51737. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51738. */
  51739. updateGazeTrackerScale: boolean;
  51740. /**
  51741. * If the gaze trackers color should be updated when selecting meshes
  51742. */
  51743. updateGazeTrackerColor: boolean;
  51744. /**
  51745. * If the controller laser color should be updated when selecting meshes
  51746. */
  51747. updateControllerLaserColor: boolean;
  51748. /**
  51749. * The gaze tracking mesh corresponding to the left controller
  51750. */
  51751. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51752. /**
  51753. * The gaze tracking mesh corresponding to the right controller
  51754. */
  51755. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51756. /**
  51757. * If the ray of the gaze should be displayed.
  51758. */
  51759. get displayGaze(): boolean;
  51760. /**
  51761. * Sets if the ray of the gaze should be displayed.
  51762. */
  51763. set displayGaze(value: boolean);
  51764. /**
  51765. * If the ray of the LaserPointer should be displayed.
  51766. */
  51767. get displayLaserPointer(): boolean;
  51768. /**
  51769. * Sets if the ray of the LaserPointer should be displayed.
  51770. */
  51771. set displayLaserPointer(value: boolean);
  51772. /**
  51773. * The deviceOrientationCamera used as the camera when not in VR.
  51774. */
  51775. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51776. /**
  51777. * Based on the current WebVR support, returns the current VR camera used.
  51778. */
  51779. get currentVRCamera(): Nullable<Camera>;
  51780. /**
  51781. * The webVRCamera which is used when in VR.
  51782. */
  51783. get webVRCamera(): WebVRFreeCamera;
  51784. /**
  51785. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51786. */
  51787. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51788. /**
  51789. * The html button that is used to trigger entering into VR.
  51790. */
  51791. get vrButton(): Nullable<HTMLButtonElement>;
  51792. private get _teleportationRequestInitiated();
  51793. /**
  51794. * Defines whether or not Pointer lock should be requested when switching to
  51795. * full screen.
  51796. */
  51797. requestPointerLockOnFullScreen: boolean;
  51798. /**
  51799. * If asking to force XR, this will be populated with the default xr experience
  51800. */
  51801. xr: WebXRDefaultExperience;
  51802. /**
  51803. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51804. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51805. */
  51806. xrTestDone: boolean;
  51807. /**
  51808. * Instantiates a VRExperienceHelper.
  51809. * Helps to quickly add VR support to an existing scene.
  51810. * @param scene The scene the VRExperienceHelper belongs to.
  51811. * @param webVROptions Options to modify the vr experience helper's behavior.
  51812. */
  51813. constructor(scene: Scene,
  51814. /** Options to modify the vr experience helper's behavior. */
  51815. webVROptions?: VRExperienceHelperOptions);
  51816. private completeVRInit;
  51817. private _onDefaultMeshLoaded;
  51818. private _onResize;
  51819. private _onFullscreenChange;
  51820. /**
  51821. * Gets a value indicating if we are currently in VR mode.
  51822. */
  51823. get isInVRMode(): boolean;
  51824. private onVrDisplayPresentChange;
  51825. private onVRDisplayChanged;
  51826. private moveButtonToBottomRight;
  51827. private displayVRButton;
  51828. private updateButtonVisibility;
  51829. private _cachedAngularSensibility;
  51830. /**
  51831. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51832. * Otherwise, will use the fullscreen API.
  51833. */
  51834. enterVR(): void;
  51835. /**
  51836. * Attempt to exit VR, or fullscreen.
  51837. */
  51838. exitVR(): void;
  51839. /**
  51840. * The position of the vr experience helper.
  51841. */
  51842. get position(): Vector3;
  51843. /**
  51844. * Sets the position of the vr experience helper.
  51845. */
  51846. set position(value: Vector3);
  51847. /**
  51848. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51849. */
  51850. enableInteractions(): void;
  51851. private get _noControllerIsActive();
  51852. private beforeRender;
  51853. private _isTeleportationFloor;
  51854. /**
  51855. * Adds a floor mesh to be used for teleportation.
  51856. * @param floorMesh the mesh to be used for teleportation.
  51857. */
  51858. addFloorMesh(floorMesh: Mesh): void;
  51859. /**
  51860. * Removes a floor mesh from being used for teleportation.
  51861. * @param floorMesh the mesh to be removed.
  51862. */
  51863. removeFloorMesh(floorMesh: Mesh): void;
  51864. /**
  51865. * Enables interactions and teleportation using the VR controllers and gaze.
  51866. * @param vrTeleportationOptions options to modify teleportation behavior.
  51867. */
  51868. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51869. private _onNewGamepadConnected;
  51870. private _tryEnableInteractionOnController;
  51871. private _onNewGamepadDisconnected;
  51872. private _enableInteractionOnController;
  51873. private _checkTeleportWithRay;
  51874. private _checkRotate;
  51875. private _checkTeleportBackwards;
  51876. private _enableTeleportationOnController;
  51877. private _createTeleportationCircles;
  51878. private _displayTeleportationTarget;
  51879. private _hideTeleportationTarget;
  51880. private _rotateCamera;
  51881. private _moveTeleportationSelectorTo;
  51882. private _workingVector;
  51883. private _workingQuaternion;
  51884. private _workingMatrix;
  51885. /**
  51886. * Time Constant Teleportation Mode
  51887. */
  51888. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51889. /**
  51890. * Speed Constant Teleportation Mode
  51891. */
  51892. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51893. /**
  51894. * Teleports the users feet to the desired location
  51895. * @param location The location where the user's feet should be placed
  51896. */
  51897. teleportCamera(location: Vector3): void;
  51898. private _convertNormalToDirectionOfRay;
  51899. private _castRayAndSelectObject;
  51900. private _notifySelectedMeshUnselected;
  51901. /**
  51902. * Permanently set new colors for the laser pointer
  51903. * @param color the new laser color
  51904. * @param pickedColor the new laser color when picked mesh detected
  51905. */
  51906. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51907. /**
  51908. * Set lighting enabled / disabled on the laser pointer of both controllers
  51909. * @param enabled should the lighting be enabled on the laser pointer
  51910. */
  51911. setLaserLightingState(enabled?: boolean): void;
  51912. /**
  51913. * Permanently set new colors for the gaze pointer
  51914. * @param color the new gaze color
  51915. * @param pickedColor the new gaze color when picked mesh detected
  51916. */
  51917. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51918. /**
  51919. * Sets the color of the laser ray from the vr controllers.
  51920. * @param color new color for the ray.
  51921. */
  51922. changeLaserColor(color: Color3): void;
  51923. /**
  51924. * Sets the color of the ray from the vr headsets gaze.
  51925. * @param color new color for the ray.
  51926. */
  51927. changeGazeColor(color: Color3): void;
  51928. /**
  51929. * Exits VR and disposes of the vr experience helper
  51930. */
  51931. dispose(): void;
  51932. /**
  51933. * Gets the name of the VRExperienceHelper class
  51934. * @returns "VRExperienceHelper"
  51935. */
  51936. getClassName(): string;
  51937. }
  51938. }
  51939. declare module "babylonjs/Cameras/VR/index" {
  51940. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51941. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51942. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51943. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51944. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51945. export * from "babylonjs/Cameras/VR/webVRCamera";
  51946. }
  51947. declare module "babylonjs/Cameras/RigModes/index" {
  51948. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51949. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51950. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51951. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51952. }
  51953. declare module "babylonjs/Cameras/index" {
  51954. export * from "babylonjs/Cameras/Inputs/index";
  51955. export * from "babylonjs/Cameras/cameraInputsManager";
  51956. export * from "babylonjs/Cameras/camera";
  51957. export * from "babylonjs/Cameras/targetCamera";
  51958. export * from "babylonjs/Cameras/freeCamera";
  51959. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51960. export * from "babylonjs/Cameras/touchCamera";
  51961. export * from "babylonjs/Cameras/arcRotateCamera";
  51962. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51963. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51964. export * from "babylonjs/Cameras/flyCamera";
  51965. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51966. export * from "babylonjs/Cameras/followCamera";
  51967. export * from "babylonjs/Cameras/followCameraInputsManager";
  51968. export * from "babylonjs/Cameras/gamepadCamera";
  51969. export * from "babylonjs/Cameras/Stereoscopic/index";
  51970. export * from "babylonjs/Cameras/universalCamera";
  51971. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51972. export * from "babylonjs/Cameras/VR/index";
  51973. export * from "babylonjs/Cameras/RigModes/index";
  51974. }
  51975. declare module "babylonjs/Collisions/index" {
  51976. export * from "babylonjs/Collisions/collider";
  51977. export * from "babylonjs/Collisions/collisionCoordinator";
  51978. export * from "babylonjs/Collisions/pickingInfo";
  51979. export * from "babylonjs/Collisions/intersectionInfo";
  51980. export * from "babylonjs/Collisions/meshCollisionData";
  51981. }
  51982. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51983. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51984. import { Vector3 } from "babylonjs/Maths/math.vector";
  51985. import { Ray } from "babylonjs/Culling/ray";
  51986. import { Plane } from "babylonjs/Maths/math.plane";
  51987. /**
  51988. * Contains an array of blocks representing the octree
  51989. */
  51990. export interface IOctreeContainer<T> {
  51991. /**
  51992. * Blocks within the octree
  51993. */
  51994. blocks: Array<OctreeBlock<T>>;
  51995. }
  51996. /**
  51997. * Class used to store a cell in an octree
  51998. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51999. */
  52000. export class OctreeBlock<T> {
  52001. /**
  52002. * Gets the content of the current block
  52003. */
  52004. entries: T[];
  52005. /**
  52006. * Gets the list of block children
  52007. */
  52008. blocks: Array<OctreeBlock<T>>;
  52009. private _depth;
  52010. private _maxDepth;
  52011. private _capacity;
  52012. private _minPoint;
  52013. private _maxPoint;
  52014. private _boundingVectors;
  52015. private _creationFunc;
  52016. /**
  52017. * Creates a new block
  52018. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52019. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52020. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52021. * @param depth defines the current depth of this block in the octree
  52022. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52023. * @param creationFunc defines a callback to call when an element is added to the block
  52024. */
  52025. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52026. /**
  52027. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52028. */
  52029. get capacity(): number;
  52030. /**
  52031. * Gets the minimum vector (in world space) of the block's bounding box
  52032. */
  52033. get minPoint(): Vector3;
  52034. /**
  52035. * Gets the maximum vector (in world space) of the block's bounding box
  52036. */
  52037. get maxPoint(): Vector3;
  52038. /**
  52039. * Add a new element to this block
  52040. * @param entry defines the element to add
  52041. */
  52042. addEntry(entry: T): void;
  52043. /**
  52044. * Remove an element from this block
  52045. * @param entry defines the element to remove
  52046. */
  52047. removeEntry(entry: T): void;
  52048. /**
  52049. * Add an array of elements to this block
  52050. * @param entries defines the array of elements to add
  52051. */
  52052. addEntries(entries: T[]): void;
  52053. /**
  52054. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52055. * @param frustumPlanes defines the frustum planes to test
  52056. * @param selection defines the array to store current content if selection is positive
  52057. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52058. */
  52059. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52060. /**
  52061. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52062. * @param sphereCenter defines the bounding sphere center
  52063. * @param sphereRadius defines the bounding sphere radius
  52064. * @param selection defines the array to store current content if selection is positive
  52065. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52066. */
  52067. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52068. /**
  52069. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52070. * @param ray defines the ray to test with
  52071. * @param selection defines the array to store current content if selection is positive
  52072. */
  52073. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52074. /**
  52075. * Subdivide the content into child blocks (this block will then be empty)
  52076. */
  52077. createInnerBlocks(): void;
  52078. /**
  52079. * @hidden
  52080. */
  52081. 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;
  52082. }
  52083. }
  52084. declare module "babylonjs/Culling/Octrees/octree" {
  52085. import { SmartArray } from "babylonjs/Misc/smartArray";
  52086. import { Vector3 } from "babylonjs/Maths/math.vector";
  52087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52089. import { Ray } from "babylonjs/Culling/ray";
  52090. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52091. import { Plane } from "babylonjs/Maths/math.plane";
  52092. /**
  52093. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52094. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52095. */
  52096. export class Octree<T> {
  52097. /** 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.) */
  52098. maxDepth: number;
  52099. /**
  52100. * Blocks within the octree containing objects
  52101. */
  52102. blocks: Array<OctreeBlock<T>>;
  52103. /**
  52104. * Content stored in the octree
  52105. */
  52106. dynamicContent: T[];
  52107. private _maxBlockCapacity;
  52108. private _selectionContent;
  52109. private _creationFunc;
  52110. /**
  52111. * Creates a octree
  52112. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52113. * @param creationFunc function to be used to instatiate the octree
  52114. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52115. * @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.)
  52116. */
  52117. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52118. /** 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.) */
  52119. maxDepth?: number);
  52120. /**
  52121. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52122. * @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);
  52123. * @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);
  52124. * @param entries meshes to be added to the octree blocks
  52125. */
  52126. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52127. /**
  52128. * Adds a mesh to the octree
  52129. * @param entry Mesh to add to the octree
  52130. */
  52131. addMesh(entry: T): void;
  52132. /**
  52133. * Remove an element from the octree
  52134. * @param entry defines the element to remove
  52135. */
  52136. removeMesh(entry: T): void;
  52137. /**
  52138. * Selects an array of meshes within the frustum
  52139. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52140. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52141. * @returns array of meshes within the frustum
  52142. */
  52143. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52144. /**
  52145. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52146. * @param sphereCenter defines the bounding sphere center
  52147. * @param sphereRadius defines the bounding sphere radius
  52148. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52149. * @returns an array of objects that intersect the sphere
  52150. */
  52151. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52152. /**
  52153. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52154. * @param ray defines the ray to test with
  52155. * @returns array of intersected objects
  52156. */
  52157. intersectsRay(ray: Ray): SmartArray<T>;
  52158. /**
  52159. * Adds a mesh into the octree block if it intersects the block
  52160. */
  52161. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52162. /**
  52163. * Adds a submesh into the octree block if it intersects the block
  52164. */
  52165. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52166. }
  52167. }
  52168. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52169. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52170. import { Scene } from "babylonjs/scene";
  52171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52173. import { Ray } from "babylonjs/Culling/ray";
  52174. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52175. import { Collider } from "babylonjs/Collisions/collider";
  52176. module "babylonjs/scene" {
  52177. interface Scene {
  52178. /**
  52179. * @hidden
  52180. * Backing Filed
  52181. */
  52182. _selectionOctree: Octree<AbstractMesh>;
  52183. /**
  52184. * Gets the octree used to boost mesh selection (picking)
  52185. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52186. */
  52187. selectionOctree: Octree<AbstractMesh>;
  52188. /**
  52189. * Creates or updates the octree used to boost selection (picking)
  52190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52191. * @param maxCapacity defines the maximum capacity per leaf
  52192. * @param maxDepth defines the maximum depth of the octree
  52193. * @returns an octree of AbstractMesh
  52194. */
  52195. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52196. }
  52197. }
  52198. module "babylonjs/Meshes/abstractMesh" {
  52199. interface AbstractMesh {
  52200. /**
  52201. * @hidden
  52202. * Backing Field
  52203. */
  52204. _submeshesOctree: Octree<SubMesh>;
  52205. /**
  52206. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52207. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52208. * @param maxCapacity defines the maximum size of each block (64 by default)
  52209. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52210. * @returns the new octree
  52211. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52213. */
  52214. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52215. }
  52216. }
  52217. /**
  52218. * Defines the octree scene component responsible to manage any octrees
  52219. * in a given scene.
  52220. */
  52221. export class OctreeSceneComponent {
  52222. /**
  52223. * The component name help to identify the component in the list of scene components.
  52224. */
  52225. readonly name: string;
  52226. /**
  52227. * The scene the component belongs to.
  52228. */
  52229. scene: Scene;
  52230. /**
  52231. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52232. */
  52233. readonly checksIsEnabled: boolean;
  52234. /**
  52235. * Creates a new instance of the component for the given scene
  52236. * @param scene Defines the scene to register the component in
  52237. */
  52238. constructor(scene: Scene);
  52239. /**
  52240. * Registers the component in a given scene
  52241. */
  52242. register(): void;
  52243. /**
  52244. * Return the list of active meshes
  52245. * @returns the list of active meshes
  52246. */
  52247. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52248. /**
  52249. * Return the list of active sub meshes
  52250. * @param mesh The mesh to get the candidates sub meshes from
  52251. * @returns the list of active sub meshes
  52252. */
  52253. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52254. private _tempRay;
  52255. /**
  52256. * Return the list of sub meshes intersecting with a given local ray
  52257. * @param mesh defines the mesh to find the submesh for
  52258. * @param localRay defines the ray in local space
  52259. * @returns the list of intersecting sub meshes
  52260. */
  52261. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52262. /**
  52263. * Return the list of sub meshes colliding with a collider
  52264. * @param mesh defines the mesh to find the submesh for
  52265. * @param collider defines the collider to evaluate the collision against
  52266. * @returns the list of colliding sub meshes
  52267. */
  52268. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52269. /**
  52270. * Rebuilds the elements related to this component in case of
  52271. * context lost for instance.
  52272. */
  52273. rebuild(): void;
  52274. /**
  52275. * Disposes the component and the associated ressources.
  52276. */
  52277. dispose(): void;
  52278. }
  52279. }
  52280. declare module "babylonjs/Culling/Octrees/index" {
  52281. export * from "babylonjs/Culling/Octrees/octree";
  52282. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52283. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52284. }
  52285. declare module "babylonjs/Culling/index" {
  52286. export * from "babylonjs/Culling/boundingBox";
  52287. export * from "babylonjs/Culling/boundingInfo";
  52288. export * from "babylonjs/Culling/boundingSphere";
  52289. export * from "babylonjs/Culling/Octrees/index";
  52290. export * from "babylonjs/Culling/ray";
  52291. }
  52292. declare module "babylonjs/Gizmos/gizmo" {
  52293. import { Nullable } from "babylonjs/types";
  52294. import { IDisposable } from "babylonjs/scene";
  52295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52296. import { Mesh } from "babylonjs/Meshes/mesh";
  52297. import { Node } from "babylonjs/node";
  52298. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52299. /**
  52300. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52301. */
  52302. export class Gizmo implements IDisposable {
  52303. /** The utility layer the gizmo will be added to */
  52304. gizmoLayer: UtilityLayerRenderer;
  52305. /**
  52306. * The root mesh of the gizmo
  52307. */
  52308. _rootMesh: Mesh;
  52309. private _attachedMesh;
  52310. private _attachedNode;
  52311. /**
  52312. * Ratio for the scale of the gizmo (Default: 1)
  52313. */
  52314. protected _scaleRatio: number;
  52315. /**
  52316. * Ratio for the scale of the gizmo (Default: 1)
  52317. */
  52318. set scaleRatio(value: number);
  52319. get scaleRatio(): number;
  52320. /**
  52321. * If a custom mesh has been set (Default: false)
  52322. */
  52323. protected _customMeshSet: boolean;
  52324. /**
  52325. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52326. * * When set, interactions will be enabled
  52327. */
  52328. get attachedMesh(): Nullable<AbstractMesh>;
  52329. set attachedMesh(value: Nullable<AbstractMesh>);
  52330. /**
  52331. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52332. * * When set, interactions will be enabled
  52333. */
  52334. get attachedNode(): Nullable<Node>;
  52335. set attachedNode(value: Nullable<Node>);
  52336. /**
  52337. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52338. * @param mesh The mesh to replace the default mesh of the gizmo
  52339. */
  52340. setCustomMesh(mesh: Mesh): void;
  52341. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52342. /**
  52343. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52344. */
  52345. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52346. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52347. /**
  52348. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52349. */
  52350. updateGizmoPositionToMatchAttachedMesh: boolean;
  52351. /**
  52352. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52353. */
  52354. updateScale: boolean;
  52355. protected _interactionsEnabled: boolean;
  52356. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52357. private _beforeRenderObserver;
  52358. private _tempQuaternion;
  52359. private _tempVector;
  52360. private _tempVector2;
  52361. private _tempMatrix1;
  52362. private _tempMatrix2;
  52363. private _rightHandtoLeftHandMatrix;
  52364. /**
  52365. * Creates a gizmo
  52366. * @param gizmoLayer The utility layer the gizmo will be added to
  52367. */
  52368. constructor(
  52369. /** The utility layer the gizmo will be added to */
  52370. gizmoLayer?: UtilityLayerRenderer);
  52371. /**
  52372. * Updates the gizmo to match the attached mesh's position/rotation
  52373. */
  52374. protected _update(): void;
  52375. /**
  52376. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52377. * @param value Node, TransformNode or mesh
  52378. */
  52379. protected _matrixChanged(): void;
  52380. /**
  52381. * Disposes of the gizmo
  52382. */
  52383. dispose(): void;
  52384. }
  52385. }
  52386. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52387. import { Observable } from "babylonjs/Misc/observable";
  52388. import { Nullable } from "babylonjs/types";
  52389. import { Vector3 } from "babylonjs/Maths/math.vector";
  52390. import { Color3 } from "babylonjs/Maths/math.color";
  52391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52392. import { Node } from "babylonjs/node";
  52393. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52394. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52395. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52396. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52397. import { Scene } from "babylonjs/scene";
  52398. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52399. /**
  52400. * Single plane drag gizmo
  52401. */
  52402. export class PlaneDragGizmo extends Gizmo {
  52403. /**
  52404. * Drag behavior responsible for the gizmos dragging interactions
  52405. */
  52406. dragBehavior: PointerDragBehavior;
  52407. private _pointerObserver;
  52408. /**
  52409. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52410. */
  52411. snapDistance: number;
  52412. /**
  52413. * Event that fires each time the gizmo snaps to a new location.
  52414. * * snapDistance is the the change in distance
  52415. */
  52416. onSnapObservable: Observable<{
  52417. snapDistance: number;
  52418. }>;
  52419. private _plane;
  52420. private _coloredMaterial;
  52421. private _hoverMaterial;
  52422. private _isEnabled;
  52423. private _parent;
  52424. /** @hidden */
  52425. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52426. /** @hidden */
  52427. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52428. /**
  52429. * Creates a PlaneDragGizmo
  52430. * @param gizmoLayer The utility layer the gizmo will be added to
  52431. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52432. * @param color The color of the gizmo
  52433. */
  52434. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52435. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52436. /**
  52437. * If the gizmo is enabled
  52438. */
  52439. set isEnabled(value: boolean);
  52440. get isEnabled(): boolean;
  52441. /**
  52442. * Disposes of the gizmo
  52443. */
  52444. dispose(): void;
  52445. }
  52446. }
  52447. declare module "babylonjs/Gizmos/positionGizmo" {
  52448. import { Observable } from "babylonjs/Misc/observable";
  52449. import { Nullable } from "babylonjs/types";
  52450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52451. import { Node } from "babylonjs/node";
  52452. import { Mesh } from "babylonjs/Meshes/mesh";
  52453. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52454. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52455. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52456. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52457. /**
  52458. * Gizmo that enables dragging a mesh along 3 axis
  52459. */
  52460. export class PositionGizmo extends Gizmo {
  52461. /**
  52462. * Internal gizmo used for interactions on the x axis
  52463. */
  52464. xGizmo: AxisDragGizmo;
  52465. /**
  52466. * Internal gizmo used for interactions on the y axis
  52467. */
  52468. yGizmo: AxisDragGizmo;
  52469. /**
  52470. * Internal gizmo used for interactions on the z axis
  52471. */
  52472. zGizmo: AxisDragGizmo;
  52473. /**
  52474. * Internal gizmo used for interactions on the yz plane
  52475. */
  52476. xPlaneGizmo: PlaneDragGizmo;
  52477. /**
  52478. * Internal gizmo used for interactions on the xz plane
  52479. */
  52480. yPlaneGizmo: PlaneDragGizmo;
  52481. /**
  52482. * Internal gizmo used for interactions on the xy plane
  52483. */
  52484. zPlaneGizmo: PlaneDragGizmo;
  52485. /**
  52486. * private variables
  52487. */
  52488. private _meshAttached;
  52489. private _nodeAttached;
  52490. private _snapDistance;
  52491. /** Fires an event when any of it's sub gizmos are dragged */
  52492. onDragStartObservable: Observable<unknown>;
  52493. /** Fires an event when any of it's sub gizmos are released from dragging */
  52494. onDragEndObservable: Observable<unknown>;
  52495. /**
  52496. * If set to true, planar drag is enabled
  52497. */
  52498. private _planarGizmoEnabled;
  52499. get attachedMesh(): Nullable<AbstractMesh>;
  52500. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52501. get attachedNode(): Nullable<Node>;
  52502. set attachedNode(node: Nullable<Node>);
  52503. /**
  52504. * Creates a PositionGizmo
  52505. * @param gizmoLayer The utility layer the gizmo will be added to
  52506. @param thickness display gizmo axis thickness
  52507. */
  52508. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52509. /**
  52510. * If the planar drag gizmo is enabled
  52511. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52512. */
  52513. set planarGizmoEnabled(value: boolean);
  52514. get planarGizmoEnabled(): boolean;
  52515. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52516. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52517. /**
  52518. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52519. */
  52520. set snapDistance(value: number);
  52521. get snapDistance(): number;
  52522. /**
  52523. * Ratio for the scale of the gizmo (Default: 1)
  52524. */
  52525. set scaleRatio(value: number);
  52526. get scaleRatio(): number;
  52527. /**
  52528. * Disposes of the gizmo
  52529. */
  52530. dispose(): void;
  52531. /**
  52532. * CustomMeshes are not supported by this gizmo
  52533. * @param mesh The mesh to replace the default mesh of the gizmo
  52534. */
  52535. setCustomMesh(mesh: Mesh): void;
  52536. }
  52537. }
  52538. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52539. import { Observable } from "babylonjs/Misc/observable";
  52540. import { Nullable } from "babylonjs/types";
  52541. import { Vector3 } from "babylonjs/Maths/math.vector";
  52542. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52543. import { Node } from "babylonjs/node";
  52544. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52545. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52546. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52547. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52548. import { Scene } from "babylonjs/scene";
  52549. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52550. import { Color3 } from "babylonjs/Maths/math.color";
  52551. /**
  52552. * Single axis drag gizmo
  52553. */
  52554. export class AxisDragGizmo extends Gizmo {
  52555. /**
  52556. * Drag behavior responsible for the gizmos dragging interactions
  52557. */
  52558. dragBehavior: PointerDragBehavior;
  52559. private _pointerObserver;
  52560. /**
  52561. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52562. */
  52563. snapDistance: number;
  52564. /**
  52565. * Event that fires each time the gizmo snaps to a new location.
  52566. * * snapDistance is the the change in distance
  52567. */
  52568. onSnapObservable: Observable<{
  52569. snapDistance: number;
  52570. }>;
  52571. private _isEnabled;
  52572. private _parent;
  52573. private _arrow;
  52574. private _coloredMaterial;
  52575. private _hoverMaterial;
  52576. /** @hidden */
  52577. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52578. /** @hidden */
  52579. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52580. /**
  52581. * Creates an AxisDragGizmo
  52582. * @param gizmoLayer The utility layer the gizmo will be added to
  52583. * @param dragAxis The axis which the gizmo will be able to drag on
  52584. * @param color The color of the gizmo
  52585. * @param thickness display gizmo axis thickness
  52586. */
  52587. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52588. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52589. /**
  52590. * If the gizmo is enabled
  52591. */
  52592. set isEnabled(value: boolean);
  52593. get isEnabled(): boolean;
  52594. /**
  52595. * Disposes of the gizmo
  52596. */
  52597. dispose(): void;
  52598. }
  52599. }
  52600. declare module "babylonjs/Debug/axesViewer" {
  52601. import { Vector3 } from "babylonjs/Maths/math.vector";
  52602. import { Nullable } from "babylonjs/types";
  52603. import { Scene } from "babylonjs/scene";
  52604. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52605. /**
  52606. * The Axes viewer will show 3 axes in a specific point in space
  52607. */
  52608. export class AxesViewer {
  52609. private _xAxis;
  52610. private _yAxis;
  52611. private _zAxis;
  52612. private _scaleLinesFactor;
  52613. private _instanced;
  52614. /**
  52615. * Gets the hosting scene
  52616. */
  52617. scene: Nullable<Scene>;
  52618. /**
  52619. * Gets or sets a number used to scale line length
  52620. */
  52621. scaleLines: number;
  52622. /** Gets the node hierarchy used to render x-axis */
  52623. get xAxis(): TransformNode;
  52624. /** Gets the node hierarchy used to render y-axis */
  52625. get yAxis(): TransformNode;
  52626. /** Gets the node hierarchy used to render z-axis */
  52627. get zAxis(): TransformNode;
  52628. /**
  52629. * Creates a new AxesViewer
  52630. * @param scene defines the hosting scene
  52631. * @param scaleLines defines a number used to scale line length (1 by default)
  52632. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52633. * @param xAxis defines the node hierarchy used to render the x-axis
  52634. * @param yAxis defines the node hierarchy used to render the y-axis
  52635. * @param zAxis defines the node hierarchy used to render the z-axis
  52636. */
  52637. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52638. /**
  52639. * Force the viewer to update
  52640. * @param position defines the position of the viewer
  52641. * @param xaxis defines the x axis of the viewer
  52642. * @param yaxis defines the y axis of the viewer
  52643. * @param zaxis defines the z axis of the viewer
  52644. */
  52645. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52646. /**
  52647. * Creates an instance of this axes viewer.
  52648. * @returns a new axes viewer with instanced meshes
  52649. */
  52650. createInstance(): AxesViewer;
  52651. /** Releases resources */
  52652. dispose(): void;
  52653. private static _SetRenderingGroupId;
  52654. }
  52655. }
  52656. declare module "babylonjs/Debug/boneAxesViewer" {
  52657. import { Nullable } from "babylonjs/types";
  52658. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52659. import { Vector3 } from "babylonjs/Maths/math.vector";
  52660. import { Mesh } from "babylonjs/Meshes/mesh";
  52661. import { Bone } from "babylonjs/Bones/bone";
  52662. import { Scene } from "babylonjs/scene";
  52663. /**
  52664. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52665. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52666. */
  52667. export class BoneAxesViewer extends AxesViewer {
  52668. /**
  52669. * Gets or sets the target mesh where to display the axes viewer
  52670. */
  52671. mesh: Nullable<Mesh>;
  52672. /**
  52673. * Gets or sets the target bone where to display the axes viewer
  52674. */
  52675. bone: Nullable<Bone>;
  52676. /** Gets current position */
  52677. pos: Vector3;
  52678. /** Gets direction of X axis */
  52679. xaxis: Vector3;
  52680. /** Gets direction of Y axis */
  52681. yaxis: Vector3;
  52682. /** Gets direction of Z axis */
  52683. zaxis: Vector3;
  52684. /**
  52685. * Creates a new BoneAxesViewer
  52686. * @param scene defines the hosting scene
  52687. * @param bone defines the target bone
  52688. * @param mesh defines the target mesh
  52689. * @param scaleLines defines a scaling factor for line length (1 by default)
  52690. */
  52691. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52692. /**
  52693. * Force the viewer to update
  52694. */
  52695. update(): void;
  52696. /** Releases resources */
  52697. dispose(): void;
  52698. }
  52699. }
  52700. declare module "babylonjs/Debug/debugLayer" {
  52701. import { Scene } from "babylonjs/scene";
  52702. /**
  52703. * Interface used to define scene explorer extensibility option
  52704. */
  52705. export interface IExplorerExtensibilityOption {
  52706. /**
  52707. * Define the option label
  52708. */
  52709. label: string;
  52710. /**
  52711. * Defines the action to execute on click
  52712. */
  52713. action: (entity: any) => void;
  52714. }
  52715. /**
  52716. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52717. */
  52718. export interface IExplorerExtensibilityGroup {
  52719. /**
  52720. * Defines a predicate to test if a given type mut be extended
  52721. */
  52722. predicate: (entity: any) => boolean;
  52723. /**
  52724. * Gets the list of options added to a type
  52725. */
  52726. entries: IExplorerExtensibilityOption[];
  52727. }
  52728. /**
  52729. * Interface used to define the options to use to create the Inspector
  52730. */
  52731. export interface IInspectorOptions {
  52732. /**
  52733. * Display in overlay mode (default: false)
  52734. */
  52735. overlay?: boolean;
  52736. /**
  52737. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52738. */
  52739. globalRoot?: HTMLElement;
  52740. /**
  52741. * Display the Scene explorer
  52742. */
  52743. showExplorer?: boolean;
  52744. /**
  52745. * Display the property inspector
  52746. */
  52747. showInspector?: boolean;
  52748. /**
  52749. * Display in embed mode (both panes on the right)
  52750. */
  52751. embedMode?: boolean;
  52752. /**
  52753. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52754. */
  52755. handleResize?: boolean;
  52756. /**
  52757. * Allow the panes to popup (default: true)
  52758. */
  52759. enablePopup?: boolean;
  52760. /**
  52761. * Allow the panes to be closed by users (default: true)
  52762. */
  52763. enableClose?: boolean;
  52764. /**
  52765. * Optional list of extensibility entries
  52766. */
  52767. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52768. /**
  52769. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52770. */
  52771. inspectorURL?: string;
  52772. /**
  52773. * Optional initial tab (default to DebugLayerTab.Properties)
  52774. */
  52775. initialTab?: DebugLayerTab;
  52776. }
  52777. module "babylonjs/scene" {
  52778. interface Scene {
  52779. /**
  52780. * @hidden
  52781. * Backing field
  52782. */
  52783. _debugLayer: DebugLayer;
  52784. /**
  52785. * Gets the debug layer (aka Inspector) associated with the scene
  52786. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52787. */
  52788. debugLayer: DebugLayer;
  52789. }
  52790. }
  52791. /**
  52792. * Enum of inspector action tab
  52793. */
  52794. export enum DebugLayerTab {
  52795. /**
  52796. * Properties tag (default)
  52797. */
  52798. Properties = 0,
  52799. /**
  52800. * Debug tab
  52801. */
  52802. Debug = 1,
  52803. /**
  52804. * Statistics tab
  52805. */
  52806. Statistics = 2,
  52807. /**
  52808. * Tools tab
  52809. */
  52810. Tools = 3,
  52811. /**
  52812. * Settings tab
  52813. */
  52814. Settings = 4
  52815. }
  52816. /**
  52817. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52818. * what is happening in your scene
  52819. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52820. */
  52821. export class DebugLayer {
  52822. /**
  52823. * Define the url to get the inspector script from.
  52824. * By default it uses the babylonjs CDN.
  52825. * @ignoreNaming
  52826. */
  52827. static InspectorURL: string;
  52828. private _scene;
  52829. private BJSINSPECTOR;
  52830. private _onPropertyChangedObservable?;
  52831. /**
  52832. * Observable triggered when a property is changed through the inspector.
  52833. */
  52834. get onPropertyChangedObservable(): any;
  52835. /**
  52836. * Instantiates a new debug layer.
  52837. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52838. * what is happening in your scene
  52839. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52840. * @param scene Defines the scene to inspect
  52841. */
  52842. constructor(scene: Scene);
  52843. /** Creates the inspector window. */
  52844. private _createInspector;
  52845. /**
  52846. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52847. * @param entity defines the entity to select
  52848. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52849. */
  52850. select(entity: any, lineContainerTitles?: string | string[]): void;
  52851. /** Get the inspector from bundle or global */
  52852. private _getGlobalInspector;
  52853. /**
  52854. * Get if the inspector is visible or not.
  52855. * @returns true if visible otherwise, false
  52856. */
  52857. isVisible(): boolean;
  52858. /**
  52859. * Hide the inspector and close its window.
  52860. */
  52861. hide(): void;
  52862. /**
  52863. * Update the scene in the inspector
  52864. */
  52865. setAsActiveScene(): void;
  52866. /**
  52867. * Launch the debugLayer.
  52868. * @param config Define the configuration of the inspector
  52869. * @return a promise fulfilled when the debug layer is visible
  52870. */
  52871. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52872. }
  52873. }
  52874. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52875. import { Nullable } from "babylonjs/types";
  52876. import { Scene } from "babylonjs/scene";
  52877. import { Vector4 } from "babylonjs/Maths/math.vector";
  52878. import { Color4 } from "babylonjs/Maths/math.color";
  52879. import { Mesh } from "babylonjs/Meshes/mesh";
  52880. /**
  52881. * Class containing static functions to help procedurally build meshes
  52882. */
  52883. export class BoxBuilder {
  52884. /**
  52885. * Creates a box mesh
  52886. * * The parameter `size` sets the size (float) of each box side (default 1)
  52887. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52888. * * 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)
  52889. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52893. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52894. * @param name defines the name of the mesh
  52895. * @param options defines the options used to create the mesh
  52896. * @param scene defines the hosting scene
  52897. * @returns the box mesh
  52898. */
  52899. static CreateBox(name: string, options: {
  52900. size?: number;
  52901. width?: number;
  52902. height?: number;
  52903. depth?: number;
  52904. faceUV?: Vector4[];
  52905. faceColors?: Color4[];
  52906. sideOrientation?: number;
  52907. frontUVs?: Vector4;
  52908. backUVs?: Vector4;
  52909. wrap?: boolean;
  52910. topBaseAt?: number;
  52911. bottomBaseAt?: number;
  52912. updatable?: boolean;
  52913. }, scene?: Nullable<Scene>): Mesh;
  52914. }
  52915. }
  52916. declare module "babylonjs/Debug/physicsViewer" {
  52917. import { Nullable } from "babylonjs/types";
  52918. import { Scene } from "babylonjs/scene";
  52919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52920. import { Mesh } from "babylonjs/Meshes/mesh";
  52921. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52922. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52923. /**
  52924. * Used to show the physics impostor around the specific mesh
  52925. */
  52926. export class PhysicsViewer {
  52927. /** @hidden */
  52928. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52929. /** @hidden */
  52930. protected _meshes: Array<Nullable<AbstractMesh>>;
  52931. /** @hidden */
  52932. protected _scene: Nullable<Scene>;
  52933. /** @hidden */
  52934. protected _numMeshes: number;
  52935. /** @hidden */
  52936. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52937. private _renderFunction;
  52938. private _utilityLayer;
  52939. private _debugBoxMesh;
  52940. private _debugSphereMesh;
  52941. private _debugCylinderMesh;
  52942. private _debugMaterial;
  52943. private _debugMeshMeshes;
  52944. /**
  52945. * Creates a new PhysicsViewer
  52946. * @param scene defines the hosting scene
  52947. */
  52948. constructor(scene: Scene);
  52949. /** @hidden */
  52950. protected _updateDebugMeshes(): void;
  52951. /**
  52952. * Renders a specified physic impostor
  52953. * @param impostor defines the impostor to render
  52954. * @param targetMesh defines the mesh represented by the impostor
  52955. * @returns the new debug mesh used to render the impostor
  52956. */
  52957. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52958. /**
  52959. * Hides a specified physic impostor
  52960. * @param impostor defines the impostor to hide
  52961. */
  52962. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52963. private _getDebugMaterial;
  52964. private _getDebugBoxMesh;
  52965. private _getDebugSphereMesh;
  52966. private _getDebugCylinderMesh;
  52967. private _getDebugMeshMesh;
  52968. private _getDebugMesh;
  52969. /** Releases all resources */
  52970. dispose(): void;
  52971. }
  52972. }
  52973. declare module "babylonjs/Debug/rayHelper" {
  52974. import { Nullable } from "babylonjs/types";
  52975. import { Ray } from "babylonjs/Culling/ray";
  52976. import { Vector3 } from "babylonjs/Maths/math.vector";
  52977. import { Color3 } from "babylonjs/Maths/math.color";
  52978. import { Scene } from "babylonjs/scene";
  52979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52980. import "babylonjs/Meshes/Builders/linesBuilder";
  52981. /**
  52982. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52983. * in order to better appreciate the issue one might have.
  52984. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52985. */
  52986. export class RayHelper {
  52987. /**
  52988. * Defines the ray we are currently tryin to visualize.
  52989. */
  52990. ray: Nullable<Ray>;
  52991. private _renderPoints;
  52992. private _renderLine;
  52993. private _renderFunction;
  52994. private _scene;
  52995. private _onAfterRenderObserver;
  52996. private _onAfterStepObserver;
  52997. private _attachedToMesh;
  52998. private _meshSpaceDirection;
  52999. private _meshSpaceOrigin;
  53000. /**
  53001. * Helper function to create a colored helper in a scene in one line.
  53002. * @param ray Defines the ray we are currently tryin to visualize
  53003. * @param scene Defines the scene the ray is used in
  53004. * @param color Defines the color we want to see the ray in
  53005. * @returns The newly created ray helper.
  53006. */
  53007. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53008. /**
  53009. * Instantiate a new ray helper.
  53010. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53011. * in order to better appreciate the issue one might have.
  53012. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53013. * @param ray Defines the ray we are currently tryin to visualize
  53014. */
  53015. constructor(ray: Ray);
  53016. /**
  53017. * Shows the ray we are willing to debug.
  53018. * @param scene Defines the scene the ray needs to be rendered in
  53019. * @param color Defines the color the ray needs to be rendered in
  53020. */
  53021. show(scene: Scene, color?: Color3): void;
  53022. /**
  53023. * Hides the ray we are debugging.
  53024. */
  53025. hide(): void;
  53026. private _render;
  53027. /**
  53028. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53029. * @param mesh Defines the mesh we want the helper attached to
  53030. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53031. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53032. * @param length Defines the length of the ray
  53033. */
  53034. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53035. /**
  53036. * Detach the ray helper from the mesh it has previously been attached to.
  53037. */
  53038. detachFromMesh(): void;
  53039. private _updateToMesh;
  53040. /**
  53041. * Dispose the helper and release its associated resources.
  53042. */
  53043. dispose(): void;
  53044. }
  53045. }
  53046. declare module "babylonjs/Debug/ISkeletonViewer" {
  53047. import { Skeleton } from "babylonjs/Bones/skeleton";
  53048. import { Color3 } from "babylonjs/Maths/math.color";
  53049. /**
  53050. * Defines the options associated with the creation of a SkeletonViewer.
  53051. */
  53052. export interface ISkeletonViewerOptions {
  53053. /** Should the system pause animations before building the Viewer? */
  53054. pauseAnimations: boolean;
  53055. /** Should the system return the skeleton to rest before building? */
  53056. returnToRest: boolean;
  53057. /** public Display Mode of the Viewer */
  53058. displayMode: number;
  53059. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53060. displayOptions: ISkeletonViewerDisplayOptions;
  53061. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53062. computeBonesUsingShaders: boolean;
  53063. /** Flag ignore non weighted bones */
  53064. useAllBones: boolean;
  53065. }
  53066. /**
  53067. * Defines how to display the various bone meshes for the viewer.
  53068. */
  53069. export interface ISkeletonViewerDisplayOptions {
  53070. /** How far down to start tapering the bone spurs */
  53071. midStep?: number;
  53072. /** How big is the midStep? */
  53073. midStepFactor?: number;
  53074. /** Base for the Sphere Size */
  53075. sphereBaseSize?: number;
  53076. /** The ratio of the sphere to the longest bone in units */
  53077. sphereScaleUnit?: number;
  53078. /** Ratio for the Sphere Size */
  53079. sphereFactor?: number;
  53080. }
  53081. /**
  53082. * Defines the constructor options for the BoneWeight Shader.
  53083. */
  53084. export interface IBoneWeightShaderOptions {
  53085. /** Skeleton to Map */
  53086. skeleton: Skeleton;
  53087. /** Colors for Uninfluenced bones */
  53088. colorBase?: Color3;
  53089. /** Colors for 0.0-0.25 Weight bones */
  53090. colorZero?: Color3;
  53091. /** Color for 0.25-0.5 Weight Influence */
  53092. colorQuarter?: Color3;
  53093. /** Color for 0.5-0.75 Weight Influence */
  53094. colorHalf?: Color3;
  53095. /** Color for 0.75-1 Weight Influence */
  53096. colorFull?: Color3;
  53097. /** Color for Zero Weight Influence */
  53098. targetBoneIndex?: number;
  53099. }
  53100. /**
  53101. * Simple structure of the gradient steps for the Color Map.
  53102. */
  53103. export interface ISkeletonMapShaderColorMapKnot {
  53104. /** Color of the Knot */
  53105. color: Color3;
  53106. /** Location of the Knot */
  53107. location: number;
  53108. }
  53109. /**
  53110. * Defines the constructor options for the SkeletonMap Shader.
  53111. */
  53112. export interface ISkeletonMapShaderOptions {
  53113. /** Skeleton to Map */
  53114. skeleton: Skeleton;
  53115. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53116. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53117. }
  53118. }
  53119. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53120. import { Nullable } from "babylonjs/types";
  53121. import { Scene } from "babylonjs/scene";
  53122. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53123. import { Color4 } from "babylonjs/Maths/math.color";
  53124. import { Mesh } from "babylonjs/Meshes/mesh";
  53125. /**
  53126. * Class containing static functions to help procedurally build meshes
  53127. */
  53128. export class RibbonBuilder {
  53129. /**
  53130. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53131. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53132. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53133. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53134. * * 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
  53135. * * 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
  53136. * * 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
  53137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53139. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53140. * * 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
  53141. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53142. * * 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
  53143. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53145. * @param name defines the name of the mesh
  53146. * @param options defines the options used to create the mesh
  53147. * @param scene defines the hosting scene
  53148. * @returns the ribbon mesh
  53149. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53151. */
  53152. static CreateRibbon(name: string, options: {
  53153. pathArray: Vector3[][];
  53154. closeArray?: boolean;
  53155. closePath?: boolean;
  53156. offset?: number;
  53157. updatable?: boolean;
  53158. sideOrientation?: number;
  53159. frontUVs?: Vector4;
  53160. backUVs?: Vector4;
  53161. instance?: Mesh;
  53162. invertUV?: boolean;
  53163. uvs?: Vector2[];
  53164. colors?: Color4[];
  53165. }, scene?: Nullable<Scene>): Mesh;
  53166. }
  53167. }
  53168. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53169. import { Nullable } from "babylonjs/types";
  53170. import { Scene } from "babylonjs/scene";
  53171. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53172. import { Mesh } from "babylonjs/Meshes/mesh";
  53173. /**
  53174. * Class containing static functions to help procedurally build meshes
  53175. */
  53176. export class ShapeBuilder {
  53177. /**
  53178. * 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.
  53179. * * 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.
  53180. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53181. * * 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.
  53182. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53183. * * 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
  53184. * * 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
  53185. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53190. * @param name defines the name of the mesh
  53191. * @param options defines the options used to create the mesh
  53192. * @param scene defines the hosting scene
  53193. * @returns the extruded shape mesh
  53194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53196. */
  53197. static ExtrudeShape(name: string, options: {
  53198. shape: Vector3[];
  53199. path: Vector3[];
  53200. scale?: number;
  53201. rotation?: number;
  53202. cap?: number;
  53203. updatable?: boolean;
  53204. sideOrientation?: number;
  53205. frontUVs?: Vector4;
  53206. backUVs?: Vector4;
  53207. instance?: Mesh;
  53208. invertUV?: boolean;
  53209. }, scene?: Nullable<Scene>): Mesh;
  53210. /**
  53211. * Creates an custom extruded shape mesh.
  53212. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53213. * * 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.
  53214. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53215. * * 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
  53216. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53217. * * 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
  53218. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53219. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53220. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53221. * * 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
  53222. * * 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
  53223. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53228. * @param name defines the name of the mesh
  53229. * @param options defines the options used to create the mesh
  53230. * @param scene defines the hosting scene
  53231. * @returns the custom extruded shape mesh
  53232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53235. */
  53236. static ExtrudeShapeCustom(name: string, options: {
  53237. shape: Vector3[];
  53238. path: Vector3[];
  53239. scaleFunction?: any;
  53240. rotationFunction?: any;
  53241. ribbonCloseArray?: boolean;
  53242. ribbonClosePath?: boolean;
  53243. cap?: number;
  53244. updatable?: boolean;
  53245. sideOrientation?: number;
  53246. frontUVs?: Vector4;
  53247. backUVs?: Vector4;
  53248. instance?: Mesh;
  53249. invertUV?: boolean;
  53250. }, scene?: Nullable<Scene>): Mesh;
  53251. private static _ExtrudeShapeGeneric;
  53252. }
  53253. }
  53254. declare module "babylonjs/Debug/skeletonViewer" {
  53255. import { Color3 } from "babylonjs/Maths/math.color";
  53256. import { Scene } from "babylonjs/scene";
  53257. import { Nullable } from "babylonjs/types";
  53258. import { Skeleton } from "babylonjs/Bones/skeleton";
  53259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53260. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53261. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53262. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  53263. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53264. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53265. /**
  53266. * Class used to render a debug view of a given skeleton
  53267. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53268. */
  53269. export class SkeletonViewer {
  53270. /** defines the skeleton to render */
  53271. skeleton: Skeleton;
  53272. /** defines the mesh attached to the skeleton */
  53273. mesh: AbstractMesh;
  53274. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53275. autoUpdateBonesMatrices: boolean;
  53276. /** defines the rendering group id to use with the viewer */
  53277. renderingGroupId: number;
  53278. /** is the options for the viewer */
  53279. options: Partial<ISkeletonViewerOptions>;
  53280. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53281. static readonly DISPLAY_LINES: number;
  53282. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53283. static readonly DISPLAY_SPHERES: number;
  53284. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53285. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53286. /** public static method to create a BoneWeight Shader
  53287. * @param options The constructor options
  53288. * @param scene The scene that the shader is scoped to
  53289. * @returns The created ShaderMaterial
  53290. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53291. */
  53292. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53293. /** public static method to create a BoneWeight Shader
  53294. * @param options The constructor options
  53295. * @param scene The scene that the shader is scoped to
  53296. * @returns The created ShaderMaterial
  53297. */
  53298. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53299. /** private static method to create a BoneWeight Shader
  53300. * @param size The size of the buffer to create (usually the bone count)
  53301. * @param colorMap The gradient data to generate
  53302. * @param scene The scene that the shader is scoped to
  53303. * @returns an Array of floats from the color gradient values
  53304. */
  53305. private static _CreateBoneMapColorBuffer;
  53306. /** If SkeletonViewer scene scope. */
  53307. private _scene;
  53308. /** Gets or sets the color used to render the skeleton */
  53309. color: Color3;
  53310. /** Array of the points of the skeleton fo the line view. */
  53311. private _debugLines;
  53312. /** The SkeletonViewers Mesh. */
  53313. private _debugMesh;
  53314. /** If SkeletonViewer is enabled. */
  53315. private _isEnabled;
  53316. /** If SkeletonViewer is ready. */
  53317. private _ready;
  53318. /** SkeletonViewer render observable. */
  53319. private _obs;
  53320. /** The Utility Layer to render the gizmos in. */
  53321. private _utilityLayer;
  53322. private _boneIndices;
  53323. /** Gets the Scene. */
  53324. get scene(): Scene;
  53325. /** Gets the utilityLayer. */
  53326. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53327. /** Checks Ready Status. */
  53328. get isReady(): Boolean;
  53329. /** Sets Ready Status. */
  53330. set ready(value: boolean);
  53331. /** Gets the debugMesh */
  53332. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53333. /** Sets the debugMesh */
  53334. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53335. /** Gets the material */
  53336. get material(): StandardMaterial;
  53337. /** Sets the material */
  53338. set material(value: StandardMaterial);
  53339. /** Gets the material */
  53340. get displayMode(): number;
  53341. /** Sets the material */
  53342. set displayMode(value: number);
  53343. /**
  53344. * Creates a new SkeletonViewer
  53345. * @param skeleton defines the skeleton to render
  53346. * @param mesh defines the mesh attached to the skeleton
  53347. * @param scene defines the hosting scene
  53348. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53349. * @param renderingGroupId defines the rendering group id to use with the viewer
  53350. * @param options All of the extra constructor options for the SkeletonViewer
  53351. */
  53352. constructor(
  53353. /** defines the skeleton to render */
  53354. skeleton: Skeleton,
  53355. /** defines the mesh attached to the skeleton */
  53356. mesh: AbstractMesh,
  53357. /** The Scene scope*/
  53358. scene: Scene,
  53359. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53360. autoUpdateBonesMatrices?: boolean,
  53361. /** defines the rendering group id to use with the viewer */
  53362. renderingGroupId?: number,
  53363. /** is the options for the viewer */
  53364. options?: Partial<ISkeletonViewerOptions>);
  53365. /** The Dynamic bindings for the update functions */
  53366. private _bindObs;
  53367. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53368. update(): void;
  53369. /** Gets or sets a boolean indicating if the viewer is enabled */
  53370. set isEnabled(value: boolean);
  53371. get isEnabled(): boolean;
  53372. private _getBonePosition;
  53373. private _getLinesForBonesWithLength;
  53374. private _getLinesForBonesNoLength;
  53375. /** function to revert the mesh and scene back to the initial state. */
  53376. private _revert;
  53377. /** function to build and bind sphere joint points and spur bone representations. */
  53378. private _buildSpheresAndSpurs;
  53379. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53380. private _displayLinesUpdate;
  53381. /** Changes the displayMode of the skeleton viewer
  53382. * @param mode The displayMode numerical value
  53383. */
  53384. changeDisplayMode(mode: number): void;
  53385. /** Changes the displayMode of the skeleton viewer
  53386. * @param option String of the option name
  53387. * @param value The numerical option value
  53388. */
  53389. changeDisplayOptions(option: string, value: number): void;
  53390. /** Release associated resources */
  53391. dispose(): void;
  53392. }
  53393. }
  53394. declare module "babylonjs/Debug/index" {
  53395. export * from "babylonjs/Debug/axesViewer";
  53396. export * from "babylonjs/Debug/boneAxesViewer";
  53397. export * from "babylonjs/Debug/debugLayer";
  53398. export * from "babylonjs/Debug/physicsViewer";
  53399. export * from "babylonjs/Debug/rayHelper";
  53400. export * from "babylonjs/Debug/skeletonViewer";
  53401. export * from "babylonjs/Debug/ISkeletonViewer";
  53402. }
  53403. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53404. /**
  53405. * Enum for Device Types
  53406. */
  53407. export enum DeviceType {
  53408. /** Generic */
  53409. Generic = 0,
  53410. /** Keyboard */
  53411. Keyboard = 1,
  53412. /** Mouse */
  53413. Mouse = 2,
  53414. /** Touch Pointers */
  53415. Touch = 3,
  53416. /** PS4 Dual Shock */
  53417. DualShock = 4,
  53418. /** Xbox */
  53419. Xbox = 5,
  53420. /** Switch Controller */
  53421. Switch = 6
  53422. }
  53423. /**
  53424. * Enum for All Pointers (Touch/Mouse)
  53425. */
  53426. export enum PointerInput {
  53427. /** Horizontal Axis */
  53428. Horizontal = 0,
  53429. /** Vertical Axis */
  53430. Vertical = 1,
  53431. /** Left Click or Touch */
  53432. LeftClick = 2,
  53433. /** Middle Click */
  53434. MiddleClick = 3,
  53435. /** Right Click */
  53436. RightClick = 4,
  53437. /** Browser Back */
  53438. BrowserBack = 5,
  53439. /** Browser Forward */
  53440. BrowserForward = 6
  53441. }
  53442. /**
  53443. * Enum for Dual Shock Gamepad
  53444. */
  53445. export enum DualShockInput {
  53446. /** Cross */
  53447. Cross = 0,
  53448. /** Circle */
  53449. Circle = 1,
  53450. /** Square */
  53451. Square = 2,
  53452. /** Triangle */
  53453. Triangle = 3,
  53454. /** L1 */
  53455. L1 = 4,
  53456. /** R1 */
  53457. R1 = 5,
  53458. /** L2 */
  53459. L2 = 6,
  53460. /** R2 */
  53461. R2 = 7,
  53462. /** Share */
  53463. Share = 8,
  53464. /** Options */
  53465. Options = 9,
  53466. /** L3 */
  53467. L3 = 10,
  53468. /** R3 */
  53469. R3 = 11,
  53470. /** DPadUp */
  53471. DPadUp = 12,
  53472. /** DPadDown */
  53473. DPadDown = 13,
  53474. /** DPadLeft */
  53475. DPadLeft = 14,
  53476. /** DRight */
  53477. DPadRight = 15,
  53478. /** Home */
  53479. Home = 16,
  53480. /** TouchPad */
  53481. TouchPad = 17,
  53482. /** LStickXAxis */
  53483. LStickXAxis = 18,
  53484. /** LStickYAxis */
  53485. LStickYAxis = 19,
  53486. /** RStickXAxis */
  53487. RStickXAxis = 20,
  53488. /** RStickYAxis */
  53489. RStickYAxis = 21
  53490. }
  53491. /**
  53492. * Enum for Xbox Gamepad
  53493. */
  53494. export enum XboxInput {
  53495. /** A */
  53496. A = 0,
  53497. /** B */
  53498. B = 1,
  53499. /** X */
  53500. X = 2,
  53501. /** Y */
  53502. Y = 3,
  53503. /** LB */
  53504. LB = 4,
  53505. /** RB */
  53506. RB = 5,
  53507. /** LT */
  53508. LT = 6,
  53509. /** RT */
  53510. RT = 7,
  53511. /** Back */
  53512. Back = 8,
  53513. /** Start */
  53514. Start = 9,
  53515. /** LS */
  53516. LS = 10,
  53517. /** RS */
  53518. RS = 11,
  53519. /** DPadUp */
  53520. DPadUp = 12,
  53521. /** DPadDown */
  53522. DPadDown = 13,
  53523. /** DPadLeft */
  53524. DPadLeft = 14,
  53525. /** DRight */
  53526. DPadRight = 15,
  53527. /** Home */
  53528. Home = 16,
  53529. /** LStickXAxis */
  53530. LStickXAxis = 17,
  53531. /** LStickYAxis */
  53532. LStickYAxis = 18,
  53533. /** RStickXAxis */
  53534. RStickXAxis = 19,
  53535. /** RStickYAxis */
  53536. RStickYAxis = 20
  53537. }
  53538. /**
  53539. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53540. */
  53541. export enum SwitchInput {
  53542. /** B */
  53543. B = 0,
  53544. /** A */
  53545. A = 1,
  53546. /** Y */
  53547. Y = 2,
  53548. /** X */
  53549. X = 3,
  53550. /** L */
  53551. L = 4,
  53552. /** R */
  53553. R = 5,
  53554. /** ZL */
  53555. ZL = 6,
  53556. /** ZR */
  53557. ZR = 7,
  53558. /** Minus */
  53559. Minus = 8,
  53560. /** Plus */
  53561. Plus = 9,
  53562. /** LS */
  53563. LS = 10,
  53564. /** RS */
  53565. RS = 11,
  53566. /** DPadUp */
  53567. DPadUp = 12,
  53568. /** DPadDown */
  53569. DPadDown = 13,
  53570. /** DPadLeft */
  53571. DPadLeft = 14,
  53572. /** DRight */
  53573. DPadRight = 15,
  53574. /** Home */
  53575. Home = 16,
  53576. /** Capture */
  53577. Capture = 17,
  53578. /** LStickXAxis */
  53579. LStickXAxis = 18,
  53580. /** LStickYAxis */
  53581. LStickYAxis = 19,
  53582. /** RStickXAxis */
  53583. RStickXAxis = 20,
  53584. /** RStickYAxis */
  53585. RStickYAxis = 21
  53586. }
  53587. }
  53588. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53589. import { Engine } from "babylonjs/Engines/engine";
  53590. import { IDisposable } from "babylonjs/scene";
  53591. import { Nullable } from "babylonjs/types";
  53592. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53593. /**
  53594. * This class will take all inputs from Keyboard, Pointer, and
  53595. * any Gamepads and provide a polling system that all devices
  53596. * will use. This class assumes that there will only be one
  53597. * pointer device and one keyboard.
  53598. */
  53599. export class DeviceInputSystem implements IDisposable {
  53600. /**
  53601. * Callback to be triggered when a device is connected
  53602. */
  53603. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53604. /**
  53605. * Callback to be triggered when a device is disconnected
  53606. */
  53607. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53608. /**
  53609. * Callback to be triggered when event driven input is updated
  53610. */
  53611. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53612. private _inputs;
  53613. private _gamepads;
  53614. private _keyboardActive;
  53615. private _pointerActive;
  53616. private _elementToAttachTo;
  53617. private _keyboardDownEvent;
  53618. private _keyboardUpEvent;
  53619. private _pointerMoveEvent;
  53620. private _pointerDownEvent;
  53621. private _pointerUpEvent;
  53622. private _gamepadConnectedEvent;
  53623. private _gamepadDisconnectedEvent;
  53624. private static _MAX_KEYCODES;
  53625. private static _MAX_POINTER_INPUTS;
  53626. private constructor();
  53627. /**
  53628. * Creates a new DeviceInputSystem instance
  53629. * @param engine Engine to pull input element from
  53630. * @returns The new instance
  53631. */
  53632. static Create(engine: Engine): DeviceInputSystem;
  53633. /**
  53634. * Checks for current device input value, given an id and input index
  53635. * @param deviceName Id of connected device
  53636. * @param inputIndex Index of device input
  53637. * @returns Current value of input
  53638. */
  53639. /**
  53640. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53641. * @param deviceType Enum specifiying device type
  53642. * @param deviceSlot "Slot" or index that device is referenced in
  53643. * @param inputIndex Id of input to be checked
  53644. * @returns Current value of input
  53645. */
  53646. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53647. /**
  53648. * Dispose of all the eventlisteners
  53649. */
  53650. dispose(): void;
  53651. /**
  53652. * Add device and inputs to device array
  53653. * @param deviceType Enum specifiying device type
  53654. * @param deviceSlot "Slot" or index that device is referenced in
  53655. * @param numberOfInputs Number of input entries to create for given device
  53656. */
  53657. private _registerDevice;
  53658. /**
  53659. * Given a specific device name, remove that device from the device map
  53660. * @param deviceType Enum specifiying device type
  53661. * @param deviceSlot "Slot" or index that device is referenced in
  53662. */
  53663. private _unregisterDevice;
  53664. /**
  53665. * Handle all actions that come from keyboard interaction
  53666. */
  53667. private _handleKeyActions;
  53668. /**
  53669. * Handle all actions that come from pointer interaction
  53670. */
  53671. private _handlePointerActions;
  53672. /**
  53673. * Handle all actions that come from gamepad interaction
  53674. */
  53675. private _handleGamepadActions;
  53676. /**
  53677. * Update all non-event based devices with each frame
  53678. * @param deviceType Enum specifiying device type
  53679. * @param deviceSlot "Slot" or index that device is referenced in
  53680. * @param inputIndex Id of input to be checked
  53681. */
  53682. private _updateDevice;
  53683. /**
  53684. * Gets DeviceType from the device name
  53685. * @param deviceName Name of Device from DeviceInputSystem
  53686. * @returns DeviceType enum value
  53687. */
  53688. private _getGamepadDeviceType;
  53689. }
  53690. }
  53691. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53692. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53693. /**
  53694. * Type to handle enforcement of inputs
  53695. */
  53696. 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;
  53697. }
  53698. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53699. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53700. import { Engine } from "babylonjs/Engines/engine";
  53701. import { IDisposable } from "babylonjs/scene";
  53702. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53703. import { Nullable } from "babylonjs/types";
  53704. import { Observable } from "babylonjs/Misc/observable";
  53705. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53706. /**
  53707. * Class that handles all input for a specific device
  53708. */
  53709. export class DeviceSource<T extends DeviceType> {
  53710. /** Type of device */
  53711. readonly deviceType: DeviceType;
  53712. /** "Slot" or index that device is referenced in */
  53713. readonly deviceSlot: number;
  53714. /**
  53715. * Observable to handle device input changes per device
  53716. */
  53717. readonly onInputChangedObservable: Observable<{
  53718. inputIndex: DeviceInput<T>;
  53719. previousState: Nullable<number>;
  53720. currentState: Nullable<number>;
  53721. }>;
  53722. private readonly _deviceInputSystem;
  53723. /**
  53724. * Default Constructor
  53725. * @param deviceInputSystem Reference to DeviceInputSystem
  53726. * @param deviceType Type of device
  53727. * @param deviceSlot "Slot" or index that device is referenced in
  53728. */
  53729. constructor(deviceInputSystem: DeviceInputSystem,
  53730. /** Type of device */
  53731. deviceType: DeviceType,
  53732. /** "Slot" or index that device is referenced in */
  53733. deviceSlot?: number);
  53734. /**
  53735. * Get input for specific input
  53736. * @param inputIndex index of specific input on device
  53737. * @returns Input value from DeviceInputSystem
  53738. */
  53739. getInput(inputIndex: DeviceInput<T>): number;
  53740. }
  53741. /**
  53742. * Class to keep track of devices
  53743. */
  53744. export class DeviceSourceManager implements IDisposable {
  53745. /**
  53746. * Observable to be triggered when before a device is connected
  53747. */
  53748. readonly onBeforeDeviceConnectedObservable: Observable<{
  53749. deviceType: DeviceType;
  53750. deviceSlot: number;
  53751. }>;
  53752. /**
  53753. * Observable to be triggered when before a device is disconnected
  53754. */
  53755. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53756. deviceType: DeviceType;
  53757. deviceSlot: number;
  53758. }>;
  53759. /**
  53760. * Observable to be triggered when after a device is connected
  53761. */
  53762. readonly onAfterDeviceConnectedObservable: Observable<{
  53763. deviceType: DeviceType;
  53764. deviceSlot: number;
  53765. }>;
  53766. /**
  53767. * Observable to be triggered when after a device is disconnected
  53768. */
  53769. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53770. deviceType: DeviceType;
  53771. deviceSlot: number;
  53772. }>;
  53773. private readonly _devices;
  53774. private readonly _firstDevice;
  53775. private readonly _deviceInputSystem;
  53776. /**
  53777. * Default Constructor
  53778. * @param engine engine to pull input element from
  53779. */
  53780. constructor(engine: Engine);
  53781. /**
  53782. * Gets a DeviceSource, given a type and slot
  53783. * @param deviceType Enum specifying device type
  53784. * @param deviceSlot "Slot" or index that device is referenced in
  53785. * @returns DeviceSource object
  53786. */
  53787. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53788. /**
  53789. * Gets an array of DeviceSource objects for a given device type
  53790. * @param deviceType Enum specifying device type
  53791. * @returns Array of DeviceSource objects
  53792. */
  53793. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53794. /**
  53795. * Dispose of DeviceInputSystem and other parts
  53796. */
  53797. dispose(): void;
  53798. /**
  53799. * Function to add device name to device list
  53800. * @param deviceType Enum specifying device type
  53801. * @param deviceSlot "Slot" or index that device is referenced in
  53802. */
  53803. private _addDevice;
  53804. /**
  53805. * Function to remove device name to device list
  53806. * @param deviceType Enum specifying device type
  53807. * @param deviceSlot "Slot" or index that device is referenced in
  53808. */
  53809. private _removeDevice;
  53810. /**
  53811. * Updates array storing first connected device of each type
  53812. * @param type Type of Device
  53813. */
  53814. private _updateFirstDevices;
  53815. }
  53816. }
  53817. declare module "babylonjs/DeviceInput/index" {
  53818. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53819. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53820. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53821. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53822. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53823. }
  53824. declare module "babylonjs/Engines/nullEngine" {
  53825. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53826. import { Engine } from "babylonjs/Engines/engine";
  53827. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53828. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53829. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53830. import { Effect } from "babylonjs/Materials/effect";
  53831. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53832. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53833. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53834. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53835. /**
  53836. * Options to create the null engine
  53837. */
  53838. export class NullEngineOptions {
  53839. /**
  53840. * Render width (Default: 512)
  53841. */
  53842. renderWidth: number;
  53843. /**
  53844. * Render height (Default: 256)
  53845. */
  53846. renderHeight: number;
  53847. /**
  53848. * Texture size (Default: 512)
  53849. */
  53850. textureSize: number;
  53851. /**
  53852. * If delta time between frames should be constant
  53853. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53854. */
  53855. deterministicLockstep: boolean;
  53856. /**
  53857. * Maximum about of steps between frames (Default: 4)
  53858. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53859. */
  53860. lockstepMaxSteps: number;
  53861. /**
  53862. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53863. */
  53864. useHighPrecisionMatrix?: boolean;
  53865. }
  53866. /**
  53867. * The null engine class provides support for headless version of babylon.js.
  53868. * This can be used in server side scenario or for testing purposes
  53869. */
  53870. export class NullEngine extends Engine {
  53871. private _options;
  53872. /**
  53873. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53874. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53875. * @returns true if engine is in deterministic lock step mode
  53876. */
  53877. isDeterministicLockStep(): boolean;
  53878. /**
  53879. * Gets the max steps when engine is running in deterministic lock step
  53880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53881. * @returns the max steps
  53882. */
  53883. getLockstepMaxSteps(): number;
  53884. /**
  53885. * Gets the current hardware scaling level.
  53886. * By default the hardware scaling level is computed from the window device ratio.
  53887. * 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.
  53888. * @returns a number indicating the current hardware scaling level
  53889. */
  53890. getHardwareScalingLevel(): number;
  53891. constructor(options?: NullEngineOptions);
  53892. /**
  53893. * Creates a vertex buffer
  53894. * @param vertices the data for the vertex buffer
  53895. * @returns the new WebGL static buffer
  53896. */
  53897. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53898. /**
  53899. * Creates a new index buffer
  53900. * @param indices defines the content of the index buffer
  53901. * @param updatable defines if the index buffer must be updatable
  53902. * @returns a new webGL buffer
  53903. */
  53904. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53905. /**
  53906. * Clear the current render buffer or the current render target (if any is set up)
  53907. * @param color defines the color to use
  53908. * @param backBuffer defines if the back buffer must be cleared
  53909. * @param depth defines if the depth buffer must be cleared
  53910. * @param stencil defines if the stencil buffer must be cleared
  53911. */
  53912. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53913. /**
  53914. * Gets the current render width
  53915. * @param useScreen defines if screen size must be used (or the current render target if any)
  53916. * @returns a number defining the current render width
  53917. */
  53918. getRenderWidth(useScreen?: boolean): number;
  53919. /**
  53920. * Gets the current render height
  53921. * @param useScreen defines if screen size must be used (or the current render target if any)
  53922. * @returns a number defining the current render height
  53923. */
  53924. getRenderHeight(useScreen?: boolean): number;
  53925. /**
  53926. * Set the WebGL's viewport
  53927. * @param viewport defines the viewport element to be used
  53928. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53929. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53930. */
  53931. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53932. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53933. /**
  53934. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53935. * @param pipelineContext defines the pipeline context to use
  53936. * @param uniformsNames defines the list of uniform names
  53937. * @returns an array of webGL uniform locations
  53938. */
  53939. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53940. /**
  53941. * Gets the lsit of active attributes for a given webGL program
  53942. * @param pipelineContext defines the pipeline context to use
  53943. * @param attributesNames defines the list of attribute names to get
  53944. * @returns an array of indices indicating the offset of each attribute
  53945. */
  53946. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53947. /**
  53948. * Binds an effect to the webGL context
  53949. * @param effect defines the effect to bind
  53950. */
  53951. bindSamplers(effect: Effect): void;
  53952. /**
  53953. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53954. * @param effect defines the effect to activate
  53955. */
  53956. enableEffect(effect: Effect): void;
  53957. /**
  53958. * Set various states to the webGL context
  53959. * @param culling defines backface culling state
  53960. * @param zOffset defines the value to apply to zOffset (0 by default)
  53961. * @param force defines if states must be applied even if cache is up to date
  53962. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53963. */
  53964. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53965. /**
  53966. * Set the value of an uniform to an array of int32
  53967. * @param uniform defines the webGL uniform location where to store the value
  53968. * @param array defines the array of int32 to store
  53969. */
  53970. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53971. /**
  53972. * Set the value of an uniform to an array of int32 (stored as vec2)
  53973. * @param uniform defines the webGL uniform location where to store the value
  53974. * @param array defines the array of int32 to store
  53975. */
  53976. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53977. /**
  53978. * Set the value of an uniform to an array of int32 (stored as vec3)
  53979. * @param uniform defines the webGL uniform location where to store the value
  53980. * @param array defines the array of int32 to store
  53981. */
  53982. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53983. /**
  53984. * Set the value of an uniform to an array of int32 (stored as vec4)
  53985. * @param uniform defines the webGL uniform location where to store the value
  53986. * @param array defines the array of int32 to store
  53987. */
  53988. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53989. /**
  53990. * Set the value of an uniform to an array of float32
  53991. * @param uniform defines the webGL uniform location where to store the value
  53992. * @param array defines the array of float32 to store
  53993. */
  53994. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53995. /**
  53996. * Set the value of an uniform to an array of float32 (stored as vec2)
  53997. * @param uniform defines the webGL uniform location where to store the value
  53998. * @param array defines the array of float32 to store
  53999. */
  54000. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54001. /**
  54002. * Set the value of an uniform to an array of float32 (stored as vec3)
  54003. * @param uniform defines the webGL uniform location where to store the value
  54004. * @param array defines the array of float32 to store
  54005. */
  54006. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54007. /**
  54008. * Set the value of an uniform to an array of float32 (stored as vec4)
  54009. * @param uniform defines the webGL uniform location where to store the value
  54010. * @param array defines the array of float32 to store
  54011. */
  54012. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54013. /**
  54014. * Set the value of an uniform to an array of number
  54015. * @param uniform defines the webGL uniform location where to store the value
  54016. * @param array defines the array of number to store
  54017. */
  54018. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54019. /**
  54020. * Set the value of an uniform to an array of number (stored as vec2)
  54021. * @param uniform defines the webGL uniform location where to store the value
  54022. * @param array defines the array of number to store
  54023. */
  54024. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54025. /**
  54026. * Set the value of an uniform to an array of number (stored as vec3)
  54027. * @param uniform defines the webGL uniform location where to store the value
  54028. * @param array defines the array of number to store
  54029. */
  54030. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54031. /**
  54032. * Set the value of an uniform to an array of number (stored as vec4)
  54033. * @param uniform defines the webGL uniform location where to store the value
  54034. * @param array defines the array of number to store
  54035. */
  54036. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54037. /**
  54038. * Set the value of an uniform to an array of float32 (stored as matrices)
  54039. * @param uniform defines the webGL uniform location where to store the value
  54040. * @param matrices defines the array of float32 to store
  54041. */
  54042. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54043. /**
  54044. * Set the value of an uniform to a matrix (3x3)
  54045. * @param uniform defines the webGL uniform location where to store the value
  54046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54047. */
  54048. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54049. /**
  54050. * Set the value of an uniform to a matrix (2x2)
  54051. * @param uniform defines the webGL uniform location where to store the value
  54052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54053. */
  54054. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54055. /**
  54056. * Set the value of an uniform to a number (float)
  54057. * @param uniform defines the webGL uniform location where to store the value
  54058. * @param value defines the float number to store
  54059. */
  54060. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54061. /**
  54062. * Set the value of an uniform to a vec2
  54063. * @param uniform defines the webGL uniform location where to store the value
  54064. * @param x defines the 1st component of the value
  54065. * @param y defines the 2nd component of the value
  54066. */
  54067. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54068. /**
  54069. * Set the value of an uniform to a vec3
  54070. * @param uniform defines the webGL uniform location where to store the value
  54071. * @param x defines the 1st component of the value
  54072. * @param y defines the 2nd component of the value
  54073. * @param z defines the 3rd component of the value
  54074. */
  54075. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54076. /**
  54077. * Set the value of an uniform to a boolean
  54078. * @param uniform defines the webGL uniform location where to store the value
  54079. * @param bool defines the boolean to store
  54080. */
  54081. setBool(uniform: WebGLUniformLocation, bool: number): void;
  54082. /**
  54083. * Set the value of an uniform to a vec4
  54084. * @param uniform defines the webGL uniform location where to store the value
  54085. * @param x defines the 1st component of the value
  54086. * @param y defines the 2nd component of the value
  54087. * @param z defines the 3rd component of the value
  54088. * @param w defines the 4th component of the value
  54089. */
  54090. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54091. /**
  54092. * Sets the current alpha mode
  54093. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54094. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54095. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54096. */
  54097. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54098. /**
  54099. * Bind webGl buffers directly to the webGL context
  54100. * @param vertexBuffers defines the vertex buffer to bind
  54101. * @param indexBuffer defines the index buffer to bind
  54102. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54103. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54104. * @param effect defines the effect associated with the vertex buffer
  54105. */
  54106. bindBuffers(vertexBuffers: {
  54107. [key: string]: VertexBuffer;
  54108. }, indexBuffer: DataBuffer, effect: Effect): void;
  54109. /**
  54110. * Force the entire cache to be cleared
  54111. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54112. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54113. */
  54114. wipeCaches(bruteForce?: boolean): void;
  54115. /**
  54116. * Send a draw order
  54117. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54118. * @param indexStart defines the starting index
  54119. * @param indexCount defines the number of index to draw
  54120. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54121. */
  54122. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54123. /**
  54124. * Draw a list of indexed primitives
  54125. * @param fillMode defines the primitive to use
  54126. * @param indexStart defines the starting index
  54127. * @param indexCount defines the number of index to draw
  54128. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54129. */
  54130. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54131. /**
  54132. * Draw a list of unindexed primitives
  54133. * @param fillMode defines the primitive to use
  54134. * @param verticesStart defines the index of first vertex to draw
  54135. * @param verticesCount defines the count of vertices to draw
  54136. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54137. */
  54138. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54139. /** @hidden */
  54140. _createTexture(): WebGLTexture;
  54141. /** @hidden */
  54142. _releaseTexture(texture: InternalTexture): void;
  54143. /**
  54144. * Usually called from Texture.ts.
  54145. * Passed information to create a WebGLTexture
  54146. * @param urlArg defines a value which contains one of the following:
  54147. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54148. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54149. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54150. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54151. * @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)
  54152. * @param scene needed for loading to the correct scene
  54153. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54154. * @param onLoad optional callback to be called upon successful completion
  54155. * @param onError optional callback to be called upon failure
  54156. * @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
  54157. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54158. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54159. * @param forcedExtension defines the extension to use to pick the right loader
  54160. * @param mimeType defines an optional mime type
  54161. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54162. */
  54163. 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;
  54164. /**
  54165. * Creates a new render target texture
  54166. * @param size defines the size of the texture
  54167. * @param options defines the options used to create the texture
  54168. * @returns a new render target texture stored in an InternalTexture
  54169. */
  54170. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54171. /**
  54172. * Update the sampling mode of a given texture
  54173. * @param samplingMode defines the required sampling mode
  54174. * @param texture defines the texture to update
  54175. */
  54176. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54177. /**
  54178. * Binds the frame buffer to the specified texture.
  54179. * @param texture The texture to render to or null for the default canvas
  54180. * @param faceIndex The face of the texture to render to in case of cube texture
  54181. * @param requiredWidth The width of the target to render to
  54182. * @param requiredHeight The height of the target to render to
  54183. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54184. * @param lodLevel defines le lod level to bind to the frame buffer
  54185. */
  54186. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54187. /**
  54188. * Unbind the current render target texture from the webGL context
  54189. * @param texture defines the render target texture to unbind
  54190. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54191. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54192. */
  54193. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54194. /**
  54195. * Creates a dynamic vertex buffer
  54196. * @param vertices the data for the dynamic vertex buffer
  54197. * @returns the new WebGL dynamic buffer
  54198. */
  54199. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54200. /**
  54201. * Update the content of a dynamic texture
  54202. * @param texture defines the texture to update
  54203. * @param canvas defines the canvas containing the source
  54204. * @param invertY defines if data must be stored with Y axis inverted
  54205. * @param premulAlpha defines if alpha is stored as premultiplied
  54206. * @param format defines the format of the data
  54207. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54208. */
  54209. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54210. /**
  54211. * Gets a boolean indicating if all created effects are ready
  54212. * @returns true if all effects are ready
  54213. */
  54214. areAllEffectsReady(): boolean;
  54215. /**
  54216. * @hidden
  54217. * Get the current error code of the webGL context
  54218. * @returns the error code
  54219. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54220. */
  54221. getError(): number;
  54222. /** @hidden */
  54223. _getUnpackAlignement(): number;
  54224. /** @hidden */
  54225. _unpackFlipY(value: boolean): void;
  54226. /**
  54227. * Update a dynamic index buffer
  54228. * @param indexBuffer defines the target index buffer
  54229. * @param indices defines the data to update
  54230. * @param offset defines the offset in the target index buffer where update should start
  54231. */
  54232. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54233. /**
  54234. * Updates a dynamic vertex buffer.
  54235. * @param vertexBuffer the vertex buffer to update
  54236. * @param vertices the data used to update the vertex buffer
  54237. * @param byteOffset the byte offset of the data (optional)
  54238. * @param byteLength the byte length of the data (optional)
  54239. */
  54240. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54241. /** @hidden */
  54242. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54243. /** @hidden */
  54244. _bindTexture(channel: number, texture: InternalTexture): void;
  54245. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54246. /**
  54247. * 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
  54248. */
  54249. releaseEffects(): void;
  54250. displayLoadingUI(): void;
  54251. hideLoadingUI(): void;
  54252. /** @hidden */
  54253. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54254. /** @hidden */
  54255. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54256. /** @hidden */
  54257. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54258. /** @hidden */
  54259. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54260. }
  54261. }
  54262. declare module "babylonjs/Instrumentation/timeToken" {
  54263. import { Nullable } from "babylonjs/types";
  54264. /**
  54265. * @hidden
  54266. **/
  54267. export class _TimeToken {
  54268. _startTimeQuery: Nullable<WebGLQuery>;
  54269. _endTimeQuery: Nullable<WebGLQuery>;
  54270. _timeElapsedQuery: Nullable<WebGLQuery>;
  54271. _timeElapsedQueryEnded: boolean;
  54272. }
  54273. }
  54274. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54275. import { Nullable, int } from "babylonjs/types";
  54276. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54277. /** @hidden */
  54278. export class _OcclusionDataStorage {
  54279. /** @hidden */
  54280. occlusionInternalRetryCounter: number;
  54281. /** @hidden */
  54282. isOcclusionQueryInProgress: boolean;
  54283. /** @hidden */
  54284. isOccluded: boolean;
  54285. /** @hidden */
  54286. occlusionRetryCount: number;
  54287. /** @hidden */
  54288. occlusionType: number;
  54289. /** @hidden */
  54290. occlusionQueryAlgorithmType: number;
  54291. }
  54292. module "babylonjs/Engines/engine" {
  54293. interface Engine {
  54294. /**
  54295. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54296. * @return the new query
  54297. */
  54298. createQuery(): WebGLQuery;
  54299. /**
  54300. * Delete and release a webGL query
  54301. * @param query defines the query to delete
  54302. * @return the current engine
  54303. */
  54304. deleteQuery(query: WebGLQuery): Engine;
  54305. /**
  54306. * Check if a given query has resolved and got its value
  54307. * @param query defines the query to check
  54308. * @returns true if the query got its value
  54309. */
  54310. isQueryResultAvailable(query: WebGLQuery): boolean;
  54311. /**
  54312. * Gets the value of a given query
  54313. * @param query defines the query to check
  54314. * @returns the value of the query
  54315. */
  54316. getQueryResult(query: WebGLQuery): number;
  54317. /**
  54318. * Initiates an occlusion query
  54319. * @param algorithmType defines the algorithm to use
  54320. * @param query defines the query to use
  54321. * @returns the current engine
  54322. * @see https://doc.babylonjs.com/features/occlusionquery
  54323. */
  54324. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54325. /**
  54326. * Ends an occlusion query
  54327. * @see https://doc.babylonjs.com/features/occlusionquery
  54328. * @param algorithmType defines the algorithm to use
  54329. * @returns the current engine
  54330. */
  54331. endOcclusionQuery(algorithmType: number): Engine;
  54332. /**
  54333. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54334. * Please note that only one query can be issued at a time
  54335. * @returns a time token used to track the time span
  54336. */
  54337. startTimeQuery(): Nullable<_TimeToken>;
  54338. /**
  54339. * Ends a time query
  54340. * @param token defines the token used to measure the time span
  54341. * @returns the time spent (in ns)
  54342. */
  54343. endTimeQuery(token: _TimeToken): int;
  54344. /** @hidden */
  54345. _currentNonTimestampToken: Nullable<_TimeToken>;
  54346. /** @hidden */
  54347. _createTimeQuery(): WebGLQuery;
  54348. /** @hidden */
  54349. _deleteTimeQuery(query: WebGLQuery): void;
  54350. /** @hidden */
  54351. _getGlAlgorithmType(algorithmType: number): number;
  54352. /** @hidden */
  54353. _getTimeQueryResult(query: WebGLQuery): any;
  54354. /** @hidden */
  54355. _getTimeQueryAvailability(query: WebGLQuery): any;
  54356. }
  54357. }
  54358. module "babylonjs/Meshes/abstractMesh" {
  54359. interface AbstractMesh {
  54360. /**
  54361. * Backing filed
  54362. * @hidden
  54363. */
  54364. __occlusionDataStorage: _OcclusionDataStorage;
  54365. /**
  54366. * Access property
  54367. * @hidden
  54368. */
  54369. _occlusionDataStorage: _OcclusionDataStorage;
  54370. /**
  54371. * 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.
  54372. * The default value is -1 which means don't break the query and wait till the result
  54373. * @see https://doc.babylonjs.com/features/occlusionquery
  54374. */
  54375. occlusionRetryCount: number;
  54376. /**
  54377. * 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:
  54378. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54379. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54380. * * 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.
  54381. * @see https://doc.babylonjs.com/features/occlusionquery
  54382. */
  54383. occlusionType: number;
  54384. /**
  54385. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54386. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54387. * * 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.
  54388. * @see https://doc.babylonjs.com/features/occlusionquery
  54389. */
  54390. occlusionQueryAlgorithmType: number;
  54391. /**
  54392. * 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
  54393. * @see https://doc.babylonjs.com/features/occlusionquery
  54394. */
  54395. isOccluded: boolean;
  54396. /**
  54397. * Flag to check the progress status of the query
  54398. * @see https://doc.babylonjs.com/features/occlusionquery
  54399. */
  54400. isOcclusionQueryInProgress: boolean;
  54401. }
  54402. }
  54403. }
  54404. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54405. import { Nullable } from "babylonjs/types";
  54406. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54407. /** @hidden */
  54408. export var _forceTransformFeedbackToBundle: boolean;
  54409. module "babylonjs/Engines/engine" {
  54410. interface Engine {
  54411. /**
  54412. * Creates a webGL transform feedback object
  54413. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54414. * @returns the webGL transform feedback object
  54415. */
  54416. createTransformFeedback(): WebGLTransformFeedback;
  54417. /**
  54418. * Delete a webGL transform feedback object
  54419. * @param value defines the webGL transform feedback object to delete
  54420. */
  54421. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54422. /**
  54423. * Bind a webGL transform feedback object to the webgl context
  54424. * @param value defines the webGL transform feedback object to bind
  54425. */
  54426. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54427. /**
  54428. * Begins a transform feedback operation
  54429. * @param usePoints defines if points or triangles must be used
  54430. */
  54431. beginTransformFeedback(usePoints: boolean): void;
  54432. /**
  54433. * Ends a transform feedback operation
  54434. */
  54435. endTransformFeedback(): void;
  54436. /**
  54437. * Specify the varyings to use with transform feedback
  54438. * @param program defines the associated webGL program
  54439. * @param value defines the list of strings representing the varying names
  54440. */
  54441. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54442. /**
  54443. * Bind a webGL buffer for a transform feedback operation
  54444. * @param value defines the webGL buffer to bind
  54445. */
  54446. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54447. }
  54448. }
  54449. }
  54450. declare module "babylonjs/Engines/Extensions/engine.views" {
  54451. import { Camera } from "babylonjs/Cameras/camera";
  54452. import { Nullable } from "babylonjs/types";
  54453. /**
  54454. * Class used to define an additional view for the engine
  54455. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54456. */
  54457. export class EngineView {
  54458. /** Defines the canvas where to render the view */
  54459. target: HTMLCanvasElement;
  54460. /** Defines an optional camera used to render the view (will use active camera else) */
  54461. camera?: Camera;
  54462. }
  54463. module "babylonjs/Engines/engine" {
  54464. interface Engine {
  54465. /**
  54466. * Gets or sets the HTML element to use for attaching events
  54467. */
  54468. inputElement: Nullable<HTMLElement>;
  54469. /**
  54470. * Gets the current engine view
  54471. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54472. */
  54473. activeView: Nullable<EngineView>;
  54474. /** Gets or sets the list of views */
  54475. views: EngineView[];
  54476. /**
  54477. * Register a new child canvas
  54478. * @param canvas defines the canvas to register
  54479. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54480. * @returns the associated view
  54481. */
  54482. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54483. /**
  54484. * Remove a registered child canvas
  54485. * @param canvas defines the canvas to remove
  54486. * @returns the current engine
  54487. */
  54488. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54489. }
  54490. }
  54491. }
  54492. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54493. import { Nullable } from "babylonjs/types";
  54494. module "babylonjs/Engines/engine" {
  54495. interface Engine {
  54496. /** @hidden */
  54497. _excludedCompressedTextures: string[];
  54498. /** @hidden */
  54499. _textureFormatInUse: string;
  54500. /**
  54501. * Gets the list of texture formats supported
  54502. */
  54503. readonly texturesSupported: Array<string>;
  54504. /**
  54505. * Gets the texture format in use
  54506. */
  54507. readonly textureFormatInUse: Nullable<string>;
  54508. /**
  54509. * Set the compressed texture extensions or file names to skip.
  54510. *
  54511. * @param skippedFiles defines the list of those texture files you want to skip
  54512. * Example: [".dds", ".env", "myfile.png"]
  54513. */
  54514. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54515. /**
  54516. * Set the compressed texture format to use, based on the formats you have, and the formats
  54517. * supported by the hardware / browser.
  54518. *
  54519. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54520. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54521. * to API arguments needed to compressed textures. This puts the burden on the container
  54522. * generator to house the arcane code for determining these for current & future formats.
  54523. *
  54524. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54525. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54526. *
  54527. * Note: The result of this call is not taken into account when a texture is base64.
  54528. *
  54529. * @param formatsAvailable defines the list of those format families you have created
  54530. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54531. *
  54532. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54533. * @returns The extension selected.
  54534. */
  54535. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54536. }
  54537. }
  54538. }
  54539. declare module "babylonjs/Engines/Extensions/index" {
  54540. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54541. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54542. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54543. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54544. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54545. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54546. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54547. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54548. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54549. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54550. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54551. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54552. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54553. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54554. export * from "babylonjs/Engines/Extensions/engine.views";
  54555. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54556. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54557. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54558. }
  54559. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54560. import { Nullable } from "babylonjs/types";
  54561. /**
  54562. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54563. */
  54564. export interface CubeMapInfo {
  54565. /**
  54566. * The pixel array for the front face.
  54567. * This is stored in format, left to right, up to down format.
  54568. */
  54569. front: Nullable<ArrayBufferView>;
  54570. /**
  54571. * The pixel array for the back face.
  54572. * This is stored in format, left to right, up to down format.
  54573. */
  54574. back: Nullable<ArrayBufferView>;
  54575. /**
  54576. * The pixel array for the left face.
  54577. * This is stored in format, left to right, up to down format.
  54578. */
  54579. left: Nullable<ArrayBufferView>;
  54580. /**
  54581. * The pixel array for the right face.
  54582. * This is stored in format, left to right, up to down format.
  54583. */
  54584. right: Nullable<ArrayBufferView>;
  54585. /**
  54586. * The pixel array for the up face.
  54587. * This is stored in format, left to right, up to down format.
  54588. */
  54589. up: Nullable<ArrayBufferView>;
  54590. /**
  54591. * The pixel array for the down face.
  54592. * This is stored in format, left to right, up to down format.
  54593. */
  54594. down: Nullable<ArrayBufferView>;
  54595. /**
  54596. * The size of the cubemap stored.
  54597. *
  54598. * Each faces will be size * size pixels.
  54599. */
  54600. size: number;
  54601. /**
  54602. * The format of the texture.
  54603. *
  54604. * RGBA, RGB.
  54605. */
  54606. format: number;
  54607. /**
  54608. * The type of the texture data.
  54609. *
  54610. * UNSIGNED_INT, FLOAT.
  54611. */
  54612. type: number;
  54613. /**
  54614. * Specifies whether the texture is in gamma space.
  54615. */
  54616. gammaSpace: boolean;
  54617. }
  54618. /**
  54619. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54620. */
  54621. export class PanoramaToCubeMapTools {
  54622. private static FACE_LEFT;
  54623. private static FACE_RIGHT;
  54624. private static FACE_FRONT;
  54625. private static FACE_BACK;
  54626. private static FACE_DOWN;
  54627. private static FACE_UP;
  54628. /**
  54629. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54630. *
  54631. * @param float32Array The source data.
  54632. * @param inputWidth The width of the input panorama.
  54633. * @param inputHeight The height of the input panorama.
  54634. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54635. * @return The cubemap data
  54636. */
  54637. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54638. private static CreateCubemapTexture;
  54639. private static CalcProjectionSpherical;
  54640. }
  54641. }
  54642. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54643. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54645. import { Nullable } from "babylonjs/types";
  54646. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54647. /**
  54648. * Helper class dealing with the extraction of spherical polynomial dataArray
  54649. * from a cube map.
  54650. */
  54651. export class CubeMapToSphericalPolynomialTools {
  54652. private static FileFaces;
  54653. /**
  54654. * Converts a texture to the according Spherical Polynomial data.
  54655. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54656. *
  54657. * @param texture The texture to extract the information from.
  54658. * @return The Spherical Polynomial data.
  54659. */
  54660. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54661. /**
  54662. * Converts a cubemap to the according Spherical Polynomial data.
  54663. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54664. *
  54665. * @param cubeInfo The Cube map to extract the information from.
  54666. * @return The Spherical Polynomial data.
  54667. */
  54668. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54669. }
  54670. }
  54671. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54672. import { Nullable } from "babylonjs/types";
  54673. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54674. module "babylonjs/Materials/Textures/baseTexture" {
  54675. interface BaseTexture {
  54676. /**
  54677. * Get the polynomial representation of the texture data.
  54678. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54679. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54680. */
  54681. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54682. }
  54683. }
  54684. }
  54685. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54686. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54687. /** @hidden */
  54688. export var rgbdEncodePixelShader: {
  54689. name: string;
  54690. shader: string;
  54691. };
  54692. }
  54693. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54694. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54695. /** @hidden */
  54696. export var rgbdDecodePixelShader: {
  54697. name: string;
  54698. shader: string;
  54699. };
  54700. }
  54701. declare module "babylonjs/Misc/environmentTextureTools" {
  54702. import { Nullable } from "babylonjs/types";
  54703. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54704. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54706. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54707. import "babylonjs/Engines/Extensions/engine.readTexture";
  54708. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54709. import "babylonjs/Shaders/rgbdEncode.fragment";
  54710. import "babylonjs/Shaders/rgbdDecode.fragment";
  54711. /**
  54712. * Raw texture data and descriptor sufficient for WebGL texture upload
  54713. */
  54714. export interface EnvironmentTextureInfo {
  54715. /**
  54716. * Version of the environment map
  54717. */
  54718. version: number;
  54719. /**
  54720. * Width of image
  54721. */
  54722. width: number;
  54723. /**
  54724. * Irradiance information stored in the file.
  54725. */
  54726. irradiance: any;
  54727. /**
  54728. * Specular information stored in the file.
  54729. */
  54730. specular: any;
  54731. }
  54732. /**
  54733. * Defines One Image in the file. It requires only the position in the file
  54734. * as well as the length.
  54735. */
  54736. interface BufferImageData {
  54737. /**
  54738. * Length of the image data.
  54739. */
  54740. length: number;
  54741. /**
  54742. * Position of the data from the null terminator delimiting the end of the JSON.
  54743. */
  54744. position: number;
  54745. }
  54746. /**
  54747. * Defines the specular data enclosed in the file.
  54748. * This corresponds to the version 1 of the data.
  54749. */
  54750. export interface EnvironmentTextureSpecularInfoV1 {
  54751. /**
  54752. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54753. */
  54754. specularDataPosition?: number;
  54755. /**
  54756. * This contains all the images data needed to reconstruct the cubemap.
  54757. */
  54758. mipmaps: Array<BufferImageData>;
  54759. /**
  54760. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54761. */
  54762. lodGenerationScale: number;
  54763. }
  54764. /**
  54765. * Sets of helpers addressing the serialization and deserialization of environment texture
  54766. * stored in a BabylonJS env file.
  54767. * Those files are usually stored as .env files.
  54768. */
  54769. export class EnvironmentTextureTools {
  54770. /**
  54771. * Magic number identifying the env file.
  54772. */
  54773. private static _MagicBytes;
  54774. /**
  54775. * Gets the environment info from an env file.
  54776. * @param data The array buffer containing the .env bytes.
  54777. * @returns the environment file info (the json header) if successfully parsed.
  54778. */
  54779. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54780. /**
  54781. * Creates an environment texture from a loaded cube texture.
  54782. * @param texture defines the cube texture to convert in env file
  54783. * @return a promise containing the environment data if succesfull.
  54784. */
  54785. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54786. /**
  54787. * Creates a JSON representation of the spherical data.
  54788. * @param texture defines the texture containing the polynomials
  54789. * @return the JSON representation of the spherical info
  54790. */
  54791. private static _CreateEnvTextureIrradiance;
  54792. /**
  54793. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54794. * @param data the image data
  54795. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54796. * @return the views described by info providing access to the underlying buffer
  54797. */
  54798. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54799. /**
  54800. * Uploads the texture info contained in the env file to the GPU.
  54801. * @param texture defines the internal texture to upload to
  54802. * @param data defines the data to load
  54803. * @param info defines the texture info retrieved through the GetEnvInfo method
  54804. * @returns a promise
  54805. */
  54806. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54807. private static _OnImageReadyAsync;
  54808. /**
  54809. * Uploads the levels of image data to the GPU.
  54810. * @param texture defines the internal texture to upload to
  54811. * @param imageData defines the array buffer views of image data [mipmap][face]
  54812. * @returns a promise
  54813. */
  54814. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54815. /**
  54816. * Uploads spherical polynomials information to the texture.
  54817. * @param texture defines the texture we are trying to upload the information to
  54818. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54819. */
  54820. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54821. /** @hidden */
  54822. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54823. }
  54824. }
  54825. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54826. /**
  54827. * Class used to inline functions in shader code
  54828. */
  54829. export class ShaderCodeInliner {
  54830. private static readonly _RegexpFindFunctionNameAndType;
  54831. private _sourceCode;
  54832. private _functionDescr;
  54833. private _numMaxIterations;
  54834. /** Gets or sets the token used to mark the functions to inline */
  54835. inlineToken: string;
  54836. /** Gets or sets the debug mode */
  54837. debug: boolean;
  54838. /** Gets the code after the inlining process */
  54839. get code(): string;
  54840. /**
  54841. * Initializes the inliner
  54842. * @param sourceCode shader code source to inline
  54843. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54844. */
  54845. constructor(sourceCode: string, numMaxIterations?: number);
  54846. /**
  54847. * Start the processing of the shader code
  54848. */
  54849. processCode(): void;
  54850. private _collectFunctions;
  54851. private _processInlining;
  54852. private _extractBetweenMarkers;
  54853. private _skipWhitespaces;
  54854. private _removeComments;
  54855. private _replaceFunctionCallsByCode;
  54856. private _findBackward;
  54857. private _escapeRegExp;
  54858. private _replaceNames;
  54859. }
  54860. }
  54861. declare module "babylonjs/Engines/nativeEngine" {
  54862. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54863. import { Engine } from "babylonjs/Engines/engine";
  54864. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54865. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54867. import { Effect } from "babylonjs/Materials/effect";
  54868. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54869. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54870. import { IColor4Like } from "babylonjs/Maths/math.like";
  54871. import { Scene } from "babylonjs/scene";
  54872. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54873. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54874. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54875. /**
  54876. * Container for accessors for natively-stored mesh data buffers.
  54877. */
  54878. class NativeDataBuffer extends DataBuffer {
  54879. /**
  54880. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54881. */
  54882. nativeIndexBuffer?: any;
  54883. /**
  54884. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54885. */
  54886. nativeVertexBuffer?: any;
  54887. }
  54888. /** @hidden */
  54889. class NativeTexture extends InternalTexture {
  54890. getInternalTexture(): InternalTexture;
  54891. getViewCount(): number;
  54892. }
  54893. /** @hidden */
  54894. export class NativeEngine extends Engine {
  54895. private readonly _native;
  54896. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54897. private readonly INVALID_HANDLE;
  54898. private _boundBuffersVertexArray;
  54899. getHardwareScalingLevel(): number;
  54900. constructor();
  54901. dispose(): void;
  54902. /**
  54903. * Can be used to override the current requestAnimationFrame requester.
  54904. * @hidden
  54905. */
  54906. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54907. /**
  54908. * Override default engine behavior.
  54909. * @param color
  54910. * @param backBuffer
  54911. * @param depth
  54912. * @param stencil
  54913. */
  54914. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54915. /**
  54916. * Gets host document
  54917. * @returns the host document object
  54918. */
  54919. getHostDocument(): Nullable<Document>;
  54920. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54921. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54922. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54923. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54924. [key: string]: VertexBuffer;
  54925. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54926. bindBuffers(vertexBuffers: {
  54927. [key: string]: VertexBuffer;
  54928. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54929. recordVertexArrayObject(vertexBuffers: {
  54930. [key: string]: VertexBuffer;
  54931. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54932. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54933. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54934. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54935. /**
  54936. * Draw a list of indexed primitives
  54937. * @param fillMode defines the primitive to use
  54938. * @param indexStart defines the starting index
  54939. * @param indexCount defines the number of index to draw
  54940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54941. */
  54942. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54943. /**
  54944. * Draw a list of unindexed primitives
  54945. * @param fillMode defines the primitive to use
  54946. * @param verticesStart defines the index of first vertex to draw
  54947. * @param verticesCount defines the count of vertices to draw
  54948. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54949. */
  54950. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54951. createPipelineContext(): IPipelineContext;
  54952. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54953. /** @hidden */
  54954. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54955. /** @hidden */
  54956. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54957. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54958. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54959. protected _setProgram(program: WebGLProgram): void;
  54960. _releaseEffect(effect: Effect): void;
  54961. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54962. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54963. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54964. bindSamplers(effect: Effect): void;
  54965. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54966. getRenderWidth(useScreen?: boolean): number;
  54967. getRenderHeight(useScreen?: boolean): number;
  54968. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54969. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54970. /**
  54971. * Set the z offset to apply to current rendering
  54972. * @param value defines the offset to apply
  54973. */
  54974. setZOffset(value: number): void;
  54975. /**
  54976. * Gets the current value of the zOffset
  54977. * @returns the current zOffset state
  54978. */
  54979. getZOffset(): number;
  54980. /**
  54981. * Enable or disable depth buffering
  54982. * @param enable defines the state to set
  54983. */
  54984. setDepthBuffer(enable: boolean): void;
  54985. /**
  54986. * Gets a boolean indicating if depth writing is enabled
  54987. * @returns the current depth writing state
  54988. */
  54989. getDepthWrite(): boolean;
  54990. /**
  54991. * Enable or disable depth writing
  54992. * @param enable defines the state to set
  54993. */
  54994. setDepthWrite(enable: boolean): void;
  54995. /**
  54996. * Enable or disable color writing
  54997. * @param enable defines the state to set
  54998. */
  54999. setColorWrite(enable: boolean): void;
  55000. /**
  55001. * Gets a boolean indicating if color writing is enabled
  55002. * @returns the current color writing state
  55003. */
  55004. getColorWrite(): boolean;
  55005. /**
  55006. * Sets alpha constants used by some alpha blending modes
  55007. * @param r defines the red component
  55008. * @param g defines the green component
  55009. * @param b defines the blue component
  55010. * @param a defines the alpha component
  55011. */
  55012. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55013. /**
  55014. * Sets the current alpha mode
  55015. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55016. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55017. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55018. */
  55019. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55020. /**
  55021. * Gets the current alpha mode
  55022. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55023. * @returns the current alpha mode
  55024. */
  55025. getAlphaMode(): number;
  55026. setInt(uniform: WebGLUniformLocation, int: number): void;
  55027. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  55028. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  55029. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  55030. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  55031. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  55032. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  55033. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  55034. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  55035. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  55036. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  55037. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  55038. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  55039. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  55040. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55041. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55042. setFloat(uniform: WebGLUniformLocation, value: number): void;
  55043. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  55044. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  55045. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  55046. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  55047. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  55048. wipeCaches(bruteForce?: boolean): void;
  55049. _createTexture(): WebGLTexture;
  55050. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55051. /**
  55052. * Usually called from Texture.ts.
  55053. * Passed information to create a WebGLTexture
  55054. * @param url defines a value which contains one of the following:
  55055. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55056. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55057. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55058. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55059. * @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)
  55060. * @param scene needed for loading to the correct scene
  55061. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55062. * @param onLoad optional callback to be called upon successful completion
  55063. * @param onError optional callback to be called upon failure
  55064. * @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
  55065. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55066. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55067. * @param forcedExtension defines the extension to use to pick the right loader
  55068. * @param mimeType defines an optional mime type
  55069. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55070. */
  55071. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  55072. /**
  55073. * Creates a cube texture
  55074. * @param rootUrl defines the url where the files to load is located
  55075. * @param scene defines the current scene
  55076. * @param files defines the list of files to load (1 per face)
  55077. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55078. * @param onLoad defines an optional callback raised when the texture is loaded
  55079. * @param onError defines an optional callback raised if there is an issue to load the texture
  55080. * @param format defines the format of the data
  55081. * @param forcedExtension defines the extension to use to pick the right loader
  55082. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55083. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55084. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55085. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55086. * @returns the cube texture as an InternalTexture
  55087. */
  55088. 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;
  55089. private _getSamplingFilter;
  55090. private static _GetNativeTextureFormat;
  55091. createRenderTargetTexture(size: number | {
  55092. width: number;
  55093. height: number;
  55094. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55095. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55096. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55097. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55098. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55099. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55100. /**
  55101. * Updates a dynamic vertex buffer.
  55102. * @param vertexBuffer the vertex buffer to update
  55103. * @param data the data used to update the vertex buffer
  55104. * @param byteOffset the byte offset of the data (optional)
  55105. * @param byteLength the byte length of the data (optional)
  55106. */
  55107. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55108. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55109. private _updateAnisotropicLevel;
  55110. private _getAddressMode;
  55111. /** @hidden */
  55112. _bindTexture(channel: number, texture: InternalTexture): void;
  55113. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55114. releaseEffects(): void;
  55115. /** @hidden */
  55116. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55117. /** @hidden */
  55118. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55119. /** @hidden */
  55120. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55121. /** @hidden */
  55122. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55123. }
  55124. }
  55125. declare module "babylonjs/Engines/index" {
  55126. export * from "babylonjs/Engines/constants";
  55127. export * from "babylonjs/Engines/engineCapabilities";
  55128. export * from "babylonjs/Engines/instancingAttributeInfo";
  55129. export * from "babylonjs/Engines/thinEngine";
  55130. export * from "babylonjs/Engines/engine";
  55131. export * from "babylonjs/Engines/engineStore";
  55132. export * from "babylonjs/Engines/nullEngine";
  55133. export * from "babylonjs/Engines/Extensions/index";
  55134. export * from "babylonjs/Engines/IPipelineContext";
  55135. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55136. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55137. export * from "babylonjs/Engines/nativeEngine";
  55138. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55139. export * from "babylonjs/Engines/performanceConfigurator";
  55140. }
  55141. declare module "babylonjs/Events/clipboardEvents" {
  55142. /**
  55143. * Gather the list of clipboard event types as constants.
  55144. */
  55145. export class ClipboardEventTypes {
  55146. /**
  55147. * The clipboard event is fired when a copy command is active (pressed).
  55148. */
  55149. static readonly COPY: number;
  55150. /**
  55151. * The clipboard event is fired when a cut command is active (pressed).
  55152. */
  55153. static readonly CUT: number;
  55154. /**
  55155. * The clipboard event is fired when a paste command is active (pressed).
  55156. */
  55157. static readonly PASTE: number;
  55158. }
  55159. /**
  55160. * This class is used to store clipboard related info for the onClipboardObservable event.
  55161. */
  55162. export class ClipboardInfo {
  55163. /**
  55164. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55165. */
  55166. type: number;
  55167. /**
  55168. * Defines the related dom event
  55169. */
  55170. event: ClipboardEvent;
  55171. /**
  55172. *Creates an instance of ClipboardInfo.
  55173. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55174. * @param event Defines the related dom event
  55175. */
  55176. constructor(
  55177. /**
  55178. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55179. */
  55180. type: number,
  55181. /**
  55182. * Defines the related dom event
  55183. */
  55184. event: ClipboardEvent);
  55185. /**
  55186. * Get the clipboard event's type from the keycode.
  55187. * @param keyCode Defines the keyCode for the current keyboard event.
  55188. * @return {number}
  55189. */
  55190. static GetTypeFromCharacter(keyCode: number): number;
  55191. }
  55192. }
  55193. declare module "babylonjs/Events/index" {
  55194. export * from "babylonjs/Events/keyboardEvents";
  55195. export * from "babylonjs/Events/pointerEvents";
  55196. export * from "babylonjs/Events/clipboardEvents";
  55197. }
  55198. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55199. import { Scene } from "babylonjs/scene";
  55200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55201. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55202. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55203. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55204. /**
  55205. * Google Daydream controller
  55206. */
  55207. export class DaydreamController extends WebVRController {
  55208. /**
  55209. * Base Url for the controller model.
  55210. */
  55211. static MODEL_BASE_URL: string;
  55212. /**
  55213. * File name for the controller model.
  55214. */
  55215. static MODEL_FILENAME: string;
  55216. /**
  55217. * Gamepad Id prefix used to identify Daydream Controller.
  55218. */
  55219. static readonly GAMEPAD_ID_PREFIX: string;
  55220. /**
  55221. * Creates a new DaydreamController from a gamepad
  55222. * @param vrGamepad the gamepad that the controller should be created from
  55223. */
  55224. constructor(vrGamepad: any);
  55225. /**
  55226. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55227. * @param scene scene in which to add meshes
  55228. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55229. */
  55230. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55231. /**
  55232. * Called once for each button that changed state since the last frame
  55233. * @param buttonIdx Which button index changed
  55234. * @param state New state of the button
  55235. * @param changes Which properties on the state changed since last frame
  55236. */
  55237. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55238. }
  55239. }
  55240. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55241. import { Scene } from "babylonjs/scene";
  55242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55243. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55244. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55245. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55246. /**
  55247. * Gear VR Controller
  55248. */
  55249. export class GearVRController extends WebVRController {
  55250. /**
  55251. * Base Url for the controller model.
  55252. */
  55253. static MODEL_BASE_URL: string;
  55254. /**
  55255. * File name for the controller model.
  55256. */
  55257. static MODEL_FILENAME: string;
  55258. /**
  55259. * Gamepad Id prefix used to identify this controller.
  55260. */
  55261. static readonly GAMEPAD_ID_PREFIX: string;
  55262. private readonly _buttonIndexToObservableNameMap;
  55263. /**
  55264. * Creates a new GearVRController from a gamepad
  55265. * @param vrGamepad the gamepad that the controller should be created from
  55266. */
  55267. constructor(vrGamepad: any);
  55268. /**
  55269. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55270. * @param scene scene in which to add meshes
  55271. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55272. */
  55273. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55274. /**
  55275. * Called once for each button that changed state since the last frame
  55276. * @param buttonIdx Which button index changed
  55277. * @param state New state of the button
  55278. * @param changes Which properties on the state changed since last frame
  55279. */
  55280. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55281. }
  55282. }
  55283. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55284. import { Scene } from "babylonjs/scene";
  55285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55286. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55287. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55288. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55289. /**
  55290. * Generic Controller
  55291. */
  55292. export class GenericController extends WebVRController {
  55293. /**
  55294. * Base Url for the controller model.
  55295. */
  55296. static readonly MODEL_BASE_URL: string;
  55297. /**
  55298. * File name for the controller model.
  55299. */
  55300. static readonly MODEL_FILENAME: string;
  55301. /**
  55302. * Creates a new GenericController from a gamepad
  55303. * @param vrGamepad the gamepad that the controller should be created from
  55304. */
  55305. constructor(vrGamepad: any);
  55306. /**
  55307. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55308. * @param scene scene in which to add meshes
  55309. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55310. */
  55311. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55312. /**
  55313. * Called once for each button that changed state since the last frame
  55314. * @param buttonIdx Which button index changed
  55315. * @param state New state of the button
  55316. * @param changes Which properties on the state changed since last frame
  55317. */
  55318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55319. }
  55320. }
  55321. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55322. import { Observable } from "babylonjs/Misc/observable";
  55323. import { Scene } from "babylonjs/scene";
  55324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55325. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55326. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55327. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55328. /**
  55329. * Oculus Touch Controller
  55330. */
  55331. export class OculusTouchController extends WebVRController {
  55332. /**
  55333. * Base Url for the controller model.
  55334. */
  55335. static MODEL_BASE_URL: string;
  55336. /**
  55337. * File name for the left controller model.
  55338. */
  55339. static MODEL_LEFT_FILENAME: string;
  55340. /**
  55341. * File name for the right controller model.
  55342. */
  55343. static MODEL_RIGHT_FILENAME: string;
  55344. /**
  55345. * Base Url for the Quest controller model.
  55346. */
  55347. static QUEST_MODEL_BASE_URL: string;
  55348. /**
  55349. * @hidden
  55350. * If the controllers are running on a device that needs the updated Quest controller models
  55351. */
  55352. static _IsQuest: boolean;
  55353. /**
  55354. * Fired when the secondary trigger on this controller is modified
  55355. */
  55356. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55357. /**
  55358. * Fired when the thumb rest on this controller is modified
  55359. */
  55360. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55361. /**
  55362. * Creates a new OculusTouchController from a gamepad
  55363. * @param vrGamepad the gamepad that the controller should be created from
  55364. */
  55365. constructor(vrGamepad: any);
  55366. /**
  55367. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55368. * @param scene scene in which to add meshes
  55369. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55370. */
  55371. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55372. /**
  55373. * Fired when the A button on this controller is modified
  55374. */
  55375. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55376. /**
  55377. * Fired when the B button on this controller is modified
  55378. */
  55379. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55380. /**
  55381. * Fired when the X button on this controller is modified
  55382. */
  55383. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55384. /**
  55385. * Fired when the Y button on this controller is modified
  55386. */
  55387. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55388. /**
  55389. * Called once for each button that changed state since the last frame
  55390. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55391. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55392. * 2) secondary trigger (same)
  55393. * 3) A (right) X (left), touch, pressed = value
  55394. * 4) B / Y
  55395. * 5) thumb rest
  55396. * @param buttonIdx Which button index changed
  55397. * @param state New state of the button
  55398. * @param changes Which properties on the state changed since last frame
  55399. */
  55400. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55401. }
  55402. }
  55403. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55404. import { Scene } from "babylonjs/scene";
  55405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55406. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55407. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55408. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55409. import { Observable } from "babylonjs/Misc/observable";
  55410. /**
  55411. * Vive Controller
  55412. */
  55413. export class ViveController extends WebVRController {
  55414. /**
  55415. * Base Url for the controller model.
  55416. */
  55417. static MODEL_BASE_URL: string;
  55418. /**
  55419. * File name for the controller model.
  55420. */
  55421. static MODEL_FILENAME: string;
  55422. /**
  55423. * Creates a new ViveController from a gamepad
  55424. * @param vrGamepad the gamepad that the controller should be created from
  55425. */
  55426. constructor(vrGamepad: any);
  55427. /**
  55428. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55429. * @param scene scene in which to add meshes
  55430. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55431. */
  55432. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55433. /**
  55434. * Fired when the left button on this controller is modified
  55435. */
  55436. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55437. /**
  55438. * Fired when the right button on this controller is modified
  55439. */
  55440. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55441. /**
  55442. * Fired when the menu button on this controller is modified
  55443. */
  55444. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55445. /**
  55446. * Called once for each button that changed state since the last frame
  55447. * Vive mapping:
  55448. * 0: touchpad
  55449. * 1: trigger
  55450. * 2: left AND right buttons
  55451. * 3: menu button
  55452. * @param buttonIdx Which button index changed
  55453. * @param state New state of the button
  55454. * @param changes Which properties on the state changed since last frame
  55455. */
  55456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55457. }
  55458. }
  55459. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55460. import { Observable } from "babylonjs/Misc/observable";
  55461. import { Scene } from "babylonjs/scene";
  55462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55463. import { Ray } from "babylonjs/Culling/ray";
  55464. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55465. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55466. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55467. /**
  55468. * Defines the WindowsMotionController object that the state of the windows motion controller
  55469. */
  55470. export class WindowsMotionController extends WebVRController {
  55471. /**
  55472. * The base url used to load the left and right controller models
  55473. */
  55474. static MODEL_BASE_URL: string;
  55475. /**
  55476. * The name of the left controller model file
  55477. */
  55478. static MODEL_LEFT_FILENAME: string;
  55479. /**
  55480. * The name of the right controller model file
  55481. */
  55482. static MODEL_RIGHT_FILENAME: string;
  55483. /**
  55484. * The controller name prefix for this controller type
  55485. */
  55486. static readonly GAMEPAD_ID_PREFIX: string;
  55487. /**
  55488. * The controller id pattern for this controller type
  55489. */
  55490. private static readonly GAMEPAD_ID_PATTERN;
  55491. private _loadedMeshInfo;
  55492. protected readonly _mapping: {
  55493. buttons: string[];
  55494. buttonMeshNames: {
  55495. trigger: string;
  55496. menu: string;
  55497. grip: string;
  55498. thumbstick: string;
  55499. trackpad: string;
  55500. };
  55501. buttonObservableNames: {
  55502. trigger: string;
  55503. menu: string;
  55504. grip: string;
  55505. thumbstick: string;
  55506. trackpad: string;
  55507. };
  55508. axisMeshNames: string[];
  55509. pointingPoseMeshName: string;
  55510. };
  55511. /**
  55512. * Fired when the trackpad on this controller is clicked
  55513. */
  55514. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55515. /**
  55516. * Fired when the trackpad on this controller is modified
  55517. */
  55518. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55519. /**
  55520. * The current x and y values of this controller's trackpad
  55521. */
  55522. trackpad: StickValues;
  55523. /**
  55524. * Creates a new WindowsMotionController from a gamepad
  55525. * @param vrGamepad the gamepad that the controller should be created from
  55526. */
  55527. constructor(vrGamepad: any);
  55528. /**
  55529. * Fired when the trigger on this controller is modified
  55530. */
  55531. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55532. /**
  55533. * Fired when the menu button on this controller is modified
  55534. */
  55535. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55536. /**
  55537. * Fired when the grip button on this controller is modified
  55538. */
  55539. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55540. /**
  55541. * Fired when the thumbstick button on this controller is modified
  55542. */
  55543. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55544. /**
  55545. * Fired when the touchpad button on this controller is modified
  55546. */
  55547. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55548. /**
  55549. * Fired when the touchpad values on this controller are modified
  55550. */
  55551. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55552. protected _updateTrackpad(): void;
  55553. /**
  55554. * Called once per frame by the engine.
  55555. */
  55556. update(): void;
  55557. /**
  55558. * Called once for each button that changed state since the last frame
  55559. * @param buttonIdx Which button index changed
  55560. * @param state New state of the button
  55561. * @param changes Which properties on the state changed since last frame
  55562. */
  55563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55564. /**
  55565. * Moves the buttons on the controller mesh based on their current state
  55566. * @param buttonName the name of the button to move
  55567. * @param buttonValue the value of the button which determines the buttons new position
  55568. */
  55569. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55570. /**
  55571. * Moves the axis on the controller mesh based on its current state
  55572. * @param axis the index of the axis
  55573. * @param axisValue the value of the axis which determines the meshes new position
  55574. * @hidden
  55575. */
  55576. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55577. /**
  55578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55579. * @param scene scene in which to add meshes
  55580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55581. */
  55582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55583. /**
  55584. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55585. * can be transformed by button presses and axes values, based on this._mapping.
  55586. *
  55587. * @param scene scene in which the meshes exist
  55588. * @param meshes list of meshes that make up the controller model to process
  55589. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55590. */
  55591. private processModel;
  55592. private createMeshInfo;
  55593. /**
  55594. * Gets the ray of the controller in the direction the controller is pointing
  55595. * @param length the length the resulting ray should be
  55596. * @returns a ray in the direction the controller is pointing
  55597. */
  55598. getForwardRay(length?: number): Ray;
  55599. /**
  55600. * Disposes of the controller
  55601. */
  55602. dispose(): void;
  55603. }
  55604. /**
  55605. * This class represents a new windows motion controller in XR.
  55606. */
  55607. export class XRWindowsMotionController extends WindowsMotionController {
  55608. /**
  55609. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55610. */
  55611. protected readonly _mapping: {
  55612. buttons: string[];
  55613. buttonMeshNames: {
  55614. trigger: string;
  55615. menu: string;
  55616. grip: string;
  55617. thumbstick: string;
  55618. trackpad: string;
  55619. };
  55620. buttonObservableNames: {
  55621. trigger: string;
  55622. menu: string;
  55623. grip: string;
  55624. thumbstick: string;
  55625. trackpad: string;
  55626. };
  55627. axisMeshNames: string[];
  55628. pointingPoseMeshName: string;
  55629. };
  55630. /**
  55631. * Construct a new XR-Based windows motion controller
  55632. *
  55633. * @param gamepadInfo the gamepad object from the browser
  55634. */
  55635. constructor(gamepadInfo: any);
  55636. /**
  55637. * holds the thumbstick values (X,Y)
  55638. */
  55639. thumbstickValues: StickValues;
  55640. /**
  55641. * Fired when the thumbstick on this controller is clicked
  55642. */
  55643. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55644. /**
  55645. * Fired when the thumbstick on this controller is modified
  55646. */
  55647. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55648. /**
  55649. * Fired when the touchpad button on this controller is modified
  55650. */
  55651. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55652. /**
  55653. * Fired when the touchpad values on this controller are modified
  55654. */
  55655. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55656. /**
  55657. * Fired when the thumbstick button on this controller is modified
  55658. * here to prevent breaking changes
  55659. */
  55660. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55661. /**
  55662. * updating the thumbstick(!) and not the trackpad.
  55663. * This is named this way due to the difference between WebVR and XR and to avoid
  55664. * changing the parent class.
  55665. */
  55666. protected _updateTrackpad(): void;
  55667. /**
  55668. * Disposes the class with joy
  55669. */
  55670. dispose(): void;
  55671. }
  55672. }
  55673. declare module "babylonjs/Gamepads/Controllers/index" {
  55674. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55675. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55676. export * from "babylonjs/Gamepads/Controllers/genericController";
  55677. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55678. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55679. export * from "babylonjs/Gamepads/Controllers/viveController";
  55680. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55681. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55682. }
  55683. declare module "babylonjs/Gamepads/index" {
  55684. export * from "babylonjs/Gamepads/Controllers/index";
  55685. export * from "babylonjs/Gamepads/gamepad";
  55686. export * from "babylonjs/Gamepads/gamepadManager";
  55687. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55688. export * from "babylonjs/Gamepads/xboxGamepad";
  55689. export * from "babylonjs/Gamepads/dualShockGamepad";
  55690. }
  55691. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55692. import { Scene } from "babylonjs/scene";
  55693. import { Vector4 } from "babylonjs/Maths/math.vector";
  55694. import { Color4 } from "babylonjs/Maths/math.color";
  55695. import { Mesh } from "babylonjs/Meshes/mesh";
  55696. import { Nullable } from "babylonjs/types";
  55697. /**
  55698. * Class containing static functions to help procedurally build meshes
  55699. */
  55700. export class PolyhedronBuilder {
  55701. /**
  55702. * Creates a polyhedron mesh
  55703. * * 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
  55704. * * The parameter `size` (positive float, default 1) sets the polygon size
  55705. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55706. * * 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`
  55707. * * 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
  55708. * * 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)`)
  55709. * * 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
  55710. * * 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
  55711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55714. * @param name defines the name of the mesh
  55715. * @param options defines the options used to create the mesh
  55716. * @param scene defines the hosting scene
  55717. * @returns the polyhedron mesh
  55718. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55719. */
  55720. static CreatePolyhedron(name: string, options: {
  55721. type?: number;
  55722. size?: number;
  55723. sizeX?: number;
  55724. sizeY?: number;
  55725. sizeZ?: number;
  55726. custom?: any;
  55727. faceUV?: Vector4[];
  55728. faceColors?: Color4[];
  55729. flat?: boolean;
  55730. updatable?: boolean;
  55731. sideOrientation?: number;
  55732. frontUVs?: Vector4;
  55733. backUVs?: Vector4;
  55734. }, scene?: Nullable<Scene>): Mesh;
  55735. }
  55736. }
  55737. declare module "babylonjs/Gizmos/scaleGizmo" {
  55738. import { Observable } from "babylonjs/Misc/observable";
  55739. import { Nullable } from "babylonjs/types";
  55740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55741. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55742. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55743. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55744. import { Node } from "babylonjs/node";
  55745. /**
  55746. * Gizmo that enables scaling a mesh along 3 axis
  55747. */
  55748. export class ScaleGizmo extends Gizmo {
  55749. /**
  55750. * Internal gizmo used for interactions on the x axis
  55751. */
  55752. xGizmo: AxisScaleGizmo;
  55753. /**
  55754. * Internal gizmo used for interactions on the y axis
  55755. */
  55756. yGizmo: AxisScaleGizmo;
  55757. /**
  55758. * Internal gizmo used for interactions on the z axis
  55759. */
  55760. zGizmo: AxisScaleGizmo;
  55761. /**
  55762. * Internal gizmo used to scale all axis equally
  55763. */
  55764. uniformScaleGizmo: AxisScaleGizmo;
  55765. private _meshAttached;
  55766. private _nodeAttached;
  55767. private _snapDistance;
  55768. private _uniformScalingMesh;
  55769. private _octahedron;
  55770. private _sensitivity;
  55771. /** Fires an event when any of it's sub gizmos are dragged */
  55772. onDragStartObservable: Observable<unknown>;
  55773. /** Fires an event when any of it's sub gizmos are released from dragging */
  55774. onDragEndObservable: Observable<unknown>;
  55775. get attachedMesh(): Nullable<AbstractMesh>;
  55776. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55777. get attachedNode(): Nullable<Node>;
  55778. set attachedNode(node: Nullable<Node>);
  55779. /**
  55780. * Creates a ScaleGizmo
  55781. * @param gizmoLayer The utility layer the gizmo will be added to
  55782. * @param thickness display gizmo axis thickness
  55783. */
  55784. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55785. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55786. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55787. /**
  55788. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55789. */
  55790. set snapDistance(value: number);
  55791. get snapDistance(): number;
  55792. /**
  55793. * Ratio for the scale of the gizmo (Default: 1)
  55794. */
  55795. set scaleRatio(value: number);
  55796. get scaleRatio(): number;
  55797. /**
  55798. * Sensitivity factor for dragging (Default: 1)
  55799. */
  55800. set sensitivity(value: number);
  55801. get sensitivity(): number;
  55802. /**
  55803. * Disposes of the gizmo
  55804. */
  55805. dispose(): void;
  55806. }
  55807. }
  55808. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55809. import { Observable } from "babylonjs/Misc/observable";
  55810. import { Nullable } from "babylonjs/types";
  55811. import { Vector3 } from "babylonjs/Maths/math.vector";
  55812. import { Node } from "babylonjs/node";
  55813. import { Mesh } from "babylonjs/Meshes/mesh";
  55814. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55815. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55816. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55817. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55818. import { Color3 } from "babylonjs/Maths/math.color";
  55819. /**
  55820. * Single axis scale gizmo
  55821. */
  55822. export class AxisScaleGizmo extends Gizmo {
  55823. /**
  55824. * Drag behavior responsible for the gizmos dragging interactions
  55825. */
  55826. dragBehavior: PointerDragBehavior;
  55827. private _pointerObserver;
  55828. /**
  55829. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55830. */
  55831. snapDistance: number;
  55832. /**
  55833. * Event that fires each time the gizmo snaps to a new location.
  55834. * * snapDistance is the the change in distance
  55835. */
  55836. onSnapObservable: Observable<{
  55837. snapDistance: number;
  55838. }>;
  55839. /**
  55840. * If the scaling operation should be done on all axis (default: false)
  55841. */
  55842. uniformScaling: boolean;
  55843. /**
  55844. * Custom sensitivity value for the drag strength
  55845. */
  55846. sensitivity: number;
  55847. private _isEnabled;
  55848. private _parent;
  55849. private _arrow;
  55850. private _coloredMaterial;
  55851. private _hoverMaterial;
  55852. /**
  55853. * Creates an AxisScaleGizmo
  55854. * @param gizmoLayer The utility layer the gizmo will be added to
  55855. * @param dragAxis The axis which the gizmo will be able to scale on
  55856. * @param color The color of the gizmo
  55857. * @param thickness display gizmo axis thickness
  55858. */
  55859. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55860. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55861. /**
  55862. * If the gizmo is enabled
  55863. */
  55864. set isEnabled(value: boolean);
  55865. get isEnabled(): boolean;
  55866. /**
  55867. * Disposes of the gizmo
  55868. */
  55869. dispose(): void;
  55870. /**
  55871. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55872. * @param mesh The mesh to replace the default mesh of the gizmo
  55873. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55874. */
  55875. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55876. }
  55877. }
  55878. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55879. import { Observable } from "babylonjs/Misc/observable";
  55880. import { Nullable } from "babylonjs/types";
  55881. import { Vector3 } from "babylonjs/Maths/math.vector";
  55882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55883. import { Mesh } from "babylonjs/Meshes/mesh";
  55884. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55885. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55886. import { Color3 } from "babylonjs/Maths/math.color";
  55887. import "babylonjs/Meshes/Builders/boxBuilder";
  55888. /**
  55889. * Bounding box gizmo
  55890. */
  55891. export class BoundingBoxGizmo extends Gizmo {
  55892. private _lineBoundingBox;
  55893. private _rotateSpheresParent;
  55894. private _scaleBoxesParent;
  55895. private _boundingDimensions;
  55896. private _renderObserver;
  55897. private _pointerObserver;
  55898. private _scaleDragSpeed;
  55899. private _tmpQuaternion;
  55900. private _tmpVector;
  55901. private _tmpRotationMatrix;
  55902. /**
  55903. * 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)
  55904. */
  55905. ignoreChildren: boolean;
  55906. /**
  55907. * 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)
  55908. */
  55909. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55910. /**
  55911. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55912. */
  55913. rotationSphereSize: number;
  55914. /**
  55915. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55916. */
  55917. scaleBoxSize: number;
  55918. /**
  55919. * 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)
  55920. */
  55921. fixedDragMeshScreenSize: boolean;
  55922. /**
  55923. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55924. */
  55925. fixedDragMeshScreenSizeDistanceFactor: number;
  55926. /**
  55927. * Fired when a rotation sphere or scale box is dragged
  55928. */
  55929. onDragStartObservable: Observable<{}>;
  55930. /**
  55931. * Fired when a scale box is dragged
  55932. */
  55933. onScaleBoxDragObservable: Observable<{}>;
  55934. /**
  55935. * Fired when a scale box drag is ended
  55936. */
  55937. onScaleBoxDragEndObservable: Observable<{}>;
  55938. /**
  55939. * Fired when a rotation sphere is dragged
  55940. */
  55941. onRotationSphereDragObservable: Observable<{}>;
  55942. /**
  55943. * Fired when a rotation sphere drag is ended
  55944. */
  55945. onRotationSphereDragEndObservable: Observable<{}>;
  55946. /**
  55947. * 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)
  55948. */
  55949. scalePivot: Nullable<Vector3>;
  55950. /**
  55951. * Mesh used as a pivot to rotate the attached node
  55952. */
  55953. private _anchorMesh;
  55954. private _existingMeshScale;
  55955. private _dragMesh;
  55956. private pointerDragBehavior;
  55957. private coloredMaterial;
  55958. private hoverColoredMaterial;
  55959. /**
  55960. * Sets the color of the bounding box gizmo
  55961. * @param color the color to set
  55962. */
  55963. setColor(color: Color3): void;
  55964. /**
  55965. * Creates an BoundingBoxGizmo
  55966. * @param gizmoLayer The utility layer the gizmo will be added to
  55967. * @param color The color of the gizmo
  55968. */
  55969. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55970. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55971. private _selectNode;
  55972. /**
  55973. * Updates the bounding box information for the Gizmo
  55974. */
  55975. updateBoundingBox(): void;
  55976. private _updateRotationSpheres;
  55977. private _updateScaleBoxes;
  55978. /**
  55979. * Enables rotation on the specified axis and disables rotation on the others
  55980. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55981. */
  55982. setEnabledRotationAxis(axis: string): void;
  55983. /**
  55984. * Enables/disables scaling
  55985. * @param enable if scaling should be enabled
  55986. * @param homogeneousScaling defines if scaling should only be homogeneous
  55987. */
  55988. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55989. private _updateDummy;
  55990. /**
  55991. * Enables a pointer drag behavior on the bounding box of the gizmo
  55992. */
  55993. enableDragBehavior(): void;
  55994. /**
  55995. * Disposes of the gizmo
  55996. */
  55997. dispose(): void;
  55998. /**
  55999. * 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)
  56000. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56001. * @returns the bounding box mesh with the passed in mesh as a child
  56002. */
  56003. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56004. /**
  56005. * CustomMeshes are not supported by this gizmo
  56006. * @param mesh The mesh to replace the default mesh of the gizmo
  56007. */
  56008. setCustomMesh(mesh: Mesh): void;
  56009. }
  56010. }
  56011. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56012. import { Observable } from "babylonjs/Misc/observable";
  56013. import { Nullable } from "babylonjs/types";
  56014. import { Vector3 } from "babylonjs/Maths/math.vector";
  56015. import { Color3 } from "babylonjs/Maths/math.color";
  56016. import { Node } from "babylonjs/node";
  56017. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56018. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56019. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56020. import "babylonjs/Meshes/Builders/linesBuilder";
  56021. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56022. /**
  56023. * Single plane rotation gizmo
  56024. */
  56025. export class PlaneRotationGizmo extends Gizmo {
  56026. /**
  56027. * Drag behavior responsible for the gizmos dragging interactions
  56028. */
  56029. dragBehavior: PointerDragBehavior;
  56030. private _pointerObserver;
  56031. /**
  56032. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56033. */
  56034. snapDistance: number;
  56035. /**
  56036. * Event that fires each time the gizmo snaps to a new location.
  56037. * * snapDistance is the the change in distance
  56038. */
  56039. onSnapObservable: Observable<{
  56040. snapDistance: number;
  56041. }>;
  56042. private _isEnabled;
  56043. private _parent;
  56044. /**
  56045. * Creates a PlaneRotationGizmo
  56046. * @param gizmoLayer The utility layer the gizmo will be added to
  56047. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56048. * @param color The color of the gizmo
  56049. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56050. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56051. * @param thickness display gizmo axis thickness
  56052. */
  56053. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56054. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56055. /**
  56056. * If the gizmo is enabled
  56057. */
  56058. set isEnabled(value: boolean);
  56059. get isEnabled(): boolean;
  56060. /**
  56061. * Disposes of the gizmo
  56062. */
  56063. dispose(): void;
  56064. }
  56065. }
  56066. declare module "babylonjs/Gizmos/rotationGizmo" {
  56067. import { Observable } from "babylonjs/Misc/observable";
  56068. import { Nullable } from "babylonjs/types";
  56069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56070. import { Mesh } from "babylonjs/Meshes/mesh";
  56071. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56072. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56073. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56074. import { Node } from "babylonjs/node";
  56075. /**
  56076. * Gizmo that enables rotating a mesh along 3 axis
  56077. */
  56078. export class RotationGizmo extends Gizmo {
  56079. /**
  56080. * Internal gizmo used for interactions on the x axis
  56081. */
  56082. xGizmo: PlaneRotationGizmo;
  56083. /**
  56084. * Internal gizmo used for interactions on the y axis
  56085. */
  56086. yGizmo: PlaneRotationGizmo;
  56087. /**
  56088. * Internal gizmo used for interactions on the z axis
  56089. */
  56090. zGizmo: PlaneRotationGizmo;
  56091. /** Fires an event when any of it's sub gizmos are dragged */
  56092. onDragStartObservable: Observable<unknown>;
  56093. /** Fires an event when any of it's sub gizmos are released from dragging */
  56094. onDragEndObservable: Observable<unknown>;
  56095. private _meshAttached;
  56096. private _nodeAttached;
  56097. get attachedMesh(): Nullable<AbstractMesh>;
  56098. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56099. get attachedNode(): Nullable<Node>;
  56100. set attachedNode(node: Nullable<Node>);
  56101. /**
  56102. * Creates a RotationGizmo
  56103. * @param gizmoLayer The utility layer the gizmo will be added to
  56104. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56105. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56106. * @param thickness display gizmo axis thickness
  56107. */
  56108. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56109. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56110. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56111. /**
  56112. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56113. */
  56114. set snapDistance(value: number);
  56115. get snapDistance(): number;
  56116. /**
  56117. * Ratio for the scale of the gizmo (Default: 1)
  56118. */
  56119. set scaleRatio(value: number);
  56120. get scaleRatio(): number;
  56121. /**
  56122. * Disposes of the gizmo
  56123. */
  56124. dispose(): void;
  56125. /**
  56126. * CustomMeshes are not supported by this gizmo
  56127. * @param mesh The mesh to replace the default mesh of the gizmo
  56128. */
  56129. setCustomMesh(mesh: Mesh): void;
  56130. }
  56131. }
  56132. declare module "babylonjs/Gizmos/gizmoManager" {
  56133. import { Observable } from "babylonjs/Misc/observable";
  56134. import { Nullable } from "babylonjs/types";
  56135. import { Scene, IDisposable } from "babylonjs/scene";
  56136. import { Node } from "babylonjs/node";
  56137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56138. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56139. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56140. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56141. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56142. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56143. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56144. /**
  56145. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56146. */
  56147. export class GizmoManager implements IDisposable {
  56148. private scene;
  56149. /**
  56150. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56151. */
  56152. gizmos: {
  56153. positionGizmo: Nullable<PositionGizmo>;
  56154. rotationGizmo: Nullable<RotationGizmo>;
  56155. scaleGizmo: Nullable<ScaleGizmo>;
  56156. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56157. };
  56158. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56159. clearGizmoOnEmptyPointerEvent: boolean;
  56160. /** Fires an event when the manager is attached to a mesh */
  56161. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56162. /** Fires an event when the manager is attached to a node */
  56163. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56164. private _gizmosEnabled;
  56165. private _pointerObserver;
  56166. private _attachedMesh;
  56167. private _attachedNode;
  56168. private _boundingBoxColor;
  56169. private _defaultUtilityLayer;
  56170. private _defaultKeepDepthUtilityLayer;
  56171. private _thickness;
  56172. /**
  56173. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56174. */
  56175. boundingBoxDragBehavior: SixDofDragBehavior;
  56176. /**
  56177. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56178. */
  56179. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56180. /**
  56181. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56182. */
  56183. attachableNodes: Nullable<Array<Node>>;
  56184. /**
  56185. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56186. */
  56187. usePointerToAttachGizmos: boolean;
  56188. /**
  56189. * Utility layer that the bounding box gizmo belongs to
  56190. */
  56191. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56192. /**
  56193. * Utility layer that all gizmos besides bounding box belong to
  56194. */
  56195. get utilityLayer(): UtilityLayerRenderer;
  56196. /**
  56197. * Instatiates a gizmo manager
  56198. * @param scene the scene to overlay the gizmos on top of
  56199. * @param thickness display gizmo axis thickness
  56200. */
  56201. constructor(scene: Scene, thickness?: number);
  56202. /**
  56203. * Attaches a set of gizmos to the specified mesh
  56204. * @param mesh The mesh the gizmo's should be attached to
  56205. */
  56206. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56207. /**
  56208. * Attaches a set of gizmos to the specified node
  56209. * @param node The node the gizmo's should be attached to
  56210. */
  56211. attachToNode(node: Nullable<Node>): void;
  56212. /**
  56213. * If the position gizmo is enabled
  56214. */
  56215. set positionGizmoEnabled(value: boolean);
  56216. get positionGizmoEnabled(): boolean;
  56217. /**
  56218. * If the rotation gizmo is enabled
  56219. */
  56220. set rotationGizmoEnabled(value: boolean);
  56221. get rotationGizmoEnabled(): boolean;
  56222. /**
  56223. * If the scale gizmo is enabled
  56224. */
  56225. set scaleGizmoEnabled(value: boolean);
  56226. get scaleGizmoEnabled(): boolean;
  56227. /**
  56228. * If the boundingBox gizmo is enabled
  56229. */
  56230. set boundingBoxGizmoEnabled(value: boolean);
  56231. get boundingBoxGizmoEnabled(): boolean;
  56232. /**
  56233. * Disposes of the gizmo manager
  56234. */
  56235. dispose(): void;
  56236. }
  56237. }
  56238. declare module "babylonjs/Lights/directionalLight" {
  56239. import { Camera } from "babylonjs/Cameras/camera";
  56240. import { Scene } from "babylonjs/scene";
  56241. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56243. import { Light } from "babylonjs/Lights/light";
  56244. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56245. import { Effect } from "babylonjs/Materials/effect";
  56246. /**
  56247. * A directional light is defined by a direction (what a surprise!).
  56248. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56249. * 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.
  56250. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56251. */
  56252. export class DirectionalLight extends ShadowLight {
  56253. private _shadowFrustumSize;
  56254. /**
  56255. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56256. */
  56257. get shadowFrustumSize(): number;
  56258. /**
  56259. * Specifies a fix frustum size for the shadow generation.
  56260. */
  56261. set shadowFrustumSize(value: number);
  56262. private _shadowOrthoScale;
  56263. /**
  56264. * Gets the shadow projection scale against the optimal computed one.
  56265. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56266. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56267. */
  56268. get shadowOrthoScale(): number;
  56269. /**
  56270. * Sets the shadow projection scale against the optimal computed one.
  56271. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56272. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56273. */
  56274. set shadowOrthoScale(value: number);
  56275. /**
  56276. * Automatically compute the projection matrix to best fit (including all the casters)
  56277. * on each frame.
  56278. */
  56279. autoUpdateExtends: boolean;
  56280. /**
  56281. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56282. * on each frame. autoUpdateExtends must be set to true for this to work
  56283. */
  56284. autoCalcShadowZBounds: boolean;
  56285. private _orthoLeft;
  56286. private _orthoRight;
  56287. private _orthoTop;
  56288. private _orthoBottom;
  56289. /**
  56290. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56291. * The directional light is emitted from everywhere in the given direction.
  56292. * It can cast shadows.
  56293. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56294. * @param name The friendly name of the light
  56295. * @param direction The direction of the light
  56296. * @param scene The scene the light belongs to
  56297. */
  56298. constructor(name: string, direction: Vector3, scene: Scene);
  56299. /**
  56300. * Returns the string "DirectionalLight".
  56301. * @return The class name
  56302. */
  56303. getClassName(): string;
  56304. /**
  56305. * Returns the integer 1.
  56306. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56307. */
  56308. getTypeID(): number;
  56309. /**
  56310. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56311. * Returns the DirectionalLight Shadow projection matrix.
  56312. */
  56313. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56314. /**
  56315. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56316. * Returns the DirectionalLight Shadow projection matrix.
  56317. */
  56318. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56319. /**
  56320. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56321. * Returns the DirectionalLight Shadow projection matrix.
  56322. */
  56323. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56324. protected _buildUniformLayout(): void;
  56325. /**
  56326. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56327. * @param effect The effect to update
  56328. * @param lightIndex The index of the light in the effect to update
  56329. * @returns The directional light
  56330. */
  56331. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56332. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56333. /**
  56334. * Gets the minZ used for shadow according to both the scene and the light.
  56335. *
  56336. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56337. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56338. * @param activeCamera The camera we are returning the min for
  56339. * @returns the depth min z
  56340. */
  56341. getDepthMinZ(activeCamera: Camera): number;
  56342. /**
  56343. * Gets the maxZ used for shadow according to both the scene and the light.
  56344. *
  56345. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56346. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56347. * @param activeCamera The camera we are returning the max for
  56348. * @returns the depth max z
  56349. */
  56350. getDepthMaxZ(activeCamera: Camera): number;
  56351. /**
  56352. * Prepares the list of defines specific to the light type.
  56353. * @param defines the list of defines
  56354. * @param lightIndex defines the index of the light for the effect
  56355. */
  56356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56357. }
  56358. }
  56359. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56360. import { Mesh } from "babylonjs/Meshes/mesh";
  56361. /**
  56362. * Class containing static functions to help procedurally build meshes
  56363. */
  56364. export class HemisphereBuilder {
  56365. /**
  56366. * Creates a hemisphere mesh
  56367. * @param name defines the name of the mesh
  56368. * @param options defines the options used to create the mesh
  56369. * @param scene defines the hosting scene
  56370. * @returns the hemisphere mesh
  56371. */
  56372. static CreateHemisphere(name: string, options: {
  56373. segments?: number;
  56374. diameter?: number;
  56375. sideOrientation?: number;
  56376. }, scene: any): Mesh;
  56377. }
  56378. }
  56379. declare module "babylonjs/Lights/spotLight" {
  56380. import { Nullable } from "babylonjs/types";
  56381. import { Scene } from "babylonjs/scene";
  56382. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56384. import { Effect } from "babylonjs/Materials/effect";
  56385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56386. import { Light } from "babylonjs/Lights/light";
  56387. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56388. /**
  56389. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56390. * These values define a cone of light starting from the position, emitting toward the direction.
  56391. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56392. * and the exponent defines the speed of the decay of the light with distance (reach).
  56393. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56394. */
  56395. export class SpotLight extends ShadowLight {
  56396. private _angle;
  56397. private _innerAngle;
  56398. private _cosHalfAngle;
  56399. private _lightAngleScale;
  56400. private _lightAngleOffset;
  56401. /**
  56402. * Gets the cone angle of the spot light in Radians.
  56403. */
  56404. get angle(): number;
  56405. /**
  56406. * Sets the cone angle of the spot light in Radians.
  56407. */
  56408. set angle(value: number);
  56409. /**
  56410. * Only used in gltf falloff mode, this defines the angle where
  56411. * the directional falloff will start before cutting at angle which could be seen
  56412. * as outer angle.
  56413. */
  56414. get innerAngle(): number;
  56415. /**
  56416. * Only used in gltf falloff mode, this defines the angle where
  56417. * the directional falloff will start before cutting at angle which could be seen
  56418. * as outer angle.
  56419. */
  56420. set innerAngle(value: number);
  56421. private _shadowAngleScale;
  56422. /**
  56423. * Allows scaling the angle of the light for shadow generation only.
  56424. */
  56425. get shadowAngleScale(): number;
  56426. /**
  56427. * Allows scaling the angle of the light for shadow generation only.
  56428. */
  56429. set shadowAngleScale(value: number);
  56430. /**
  56431. * The light decay speed with the distance from the emission spot.
  56432. */
  56433. exponent: number;
  56434. private _projectionTextureMatrix;
  56435. /**
  56436. * Allows reading the projecton texture
  56437. */
  56438. get projectionTextureMatrix(): Matrix;
  56439. protected _projectionTextureLightNear: number;
  56440. /**
  56441. * Gets the near clip of the Spotlight for texture projection.
  56442. */
  56443. get projectionTextureLightNear(): number;
  56444. /**
  56445. * Sets the near clip of the Spotlight for texture projection.
  56446. */
  56447. set projectionTextureLightNear(value: number);
  56448. protected _projectionTextureLightFar: number;
  56449. /**
  56450. * Gets the far clip of the Spotlight for texture projection.
  56451. */
  56452. get projectionTextureLightFar(): number;
  56453. /**
  56454. * Sets the far clip of the Spotlight for texture projection.
  56455. */
  56456. set projectionTextureLightFar(value: number);
  56457. protected _projectionTextureUpDirection: Vector3;
  56458. /**
  56459. * Gets the Up vector of the Spotlight for texture projection.
  56460. */
  56461. get projectionTextureUpDirection(): Vector3;
  56462. /**
  56463. * Sets the Up vector of the Spotlight for texture projection.
  56464. */
  56465. set projectionTextureUpDirection(value: Vector3);
  56466. private _projectionTexture;
  56467. /**
  56468. * Gets the projection texture of the light.
  56469. */
  56470. get projectionTexture(): Nullable<BaseTexture>;
  56471. /**
  56472. * Sets the projection texture of the light.
  56473. */
  56474. set projectionTexture(value: Nullable<BaseTexture>);
  56475. private _projectionTextureViewLightDirty;
  56476. private _projectionTextureProjectionLightDirty;
  56477. private _projectionTextureDirty;
  56478. private _projectionTextureViewTargetVector;
  56479. private _projectionTextureViewLightMatrix;
  56480. private _projectionTextureProjectionLightMatrix;
  56481. private _projectionTextureScalingMatrix;
  56482. /**
  56483. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56484. * It can cast shadows.
  56485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56486. * @param name The light friendly name
  56487. * @param position The position of the spot light in the scene
  56488. * @param direction The direction of the light in the scene
  56489. * @param angle The cone angle of the light in Radians
  56490. * @param exponent The light decay speed with the distance from the emission spot
  56491. * @param scene The scene the lights belongs to
  56492. */
  56493. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56494. /**
  56495. * Returns the string "SpotLight".
  56496. * @returns the class name
  56497. */
  56498. getClassName(): string;
  56499. /**
  56500. * Returns the integer 2.
  56501. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56502. */
  56503. getTypeID(): number;
  56504. /**
  56505. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56506. */
  56507. protected _setDirection(value: Vector3): void;
  56508. /**
  56509. * Overrides the position setter to recompute the projection texture view light Matrix.
  56510. */
  56511. protected _setPosition(value: Vector3): void;
  56512. /**
  56513. * 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.
  56514. * Returns the SpotLight.
  56515. */
  56516. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56517. protected _computeProjectionTextureViewLightMatrix(): void;
  56518. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56519. /**
  56520. * Main function for light texture projection matrix computing.
  56521. */
  56522. protected _computeProjectionTextureMatrix(): void;
  56523. protected _buildUniformLayout(): void;
  56524. private _computeAngleValues;
  56525. /**
  56526. * Sets the passed Effect "effect" with the Light textures.
  56527. * @param effect The effect to update
  56528. * @param lightIndex The index of the light in the effect to update
  56529. * @returns The light
  56530. */
  56531. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56532. /**
  56533. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56534. * @param effect The effect to update
  56535. * @param lightIndex The index of the light in the effect to update
  56536. * @returns The spot light
  56537. */
  56538. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56539. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56540. /**
  56541. * Disposes the light and the associated resources.
  56542. */
  56543. dispose(): void;
  56544. /**
  56545. * Prepares the list of defines specific to the light type.
  56546. * @param defines the list of defines
  56547. * @param lightIndex defines the index of the light for the effect
  56548. */
  56549. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56550. }
  56551. }
  56552. declare module "babylonjs/Gizmos/lightGizmo" {
  56553. import { Nullable } from "babylonjs/types";
  56554. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56555. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56556. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56557. import { Light } from "babylonjs/Lights/light";
  56558. import { Observable } from "babylonjs/Misc/observable";
  56559. /**
  56560. * Gizmo that enables viewing a light
  56561. */
  56562. export class LightGizmo extends Gizmo {
  56563. private _lightMesh;
  56564. private _material;
  56565. private _cachedPosition;
  56566. private _cachedForward;
  56567. private _attachedMeshParent;
  56568. private _pointerObserver;
  56569. /**
  56570. * Event that fires each time the gizmo is clicked
  56571. */
  56572. onClickedObservable: Observable<Light>;
  56573. /**
  56574. * Creates a LightGizmo
  56575. * @param gizmoLayer The utility layer the gizmo will be added to
  56576. */
  56577. constructor(gizmoLayer?: UtilityLayerRenderer);
  56578. private _light;
  56579. /**
  56580. * The light that the gizmo is attached to
  56581. */
  56582. set light(light: Nullable<Light>);
  56583. get light(): Nullable<Light>;
  56584. /**
  56585. * Gets the material used to render the light gizmo
  56586. */
  56587. get material(): StandardMaterial;
  56588. /**
  56589. * @hidden
  56590. * Updates the gizmo to match the attached mesh's position/rotation
  56591. */
  56592. protected _update(): void;
  56593. private static _Scale;
  56594. /**
  56595. * Creates the lines for a light mesh
  56596. */
  56597. private static _CreateLightLines;
  56598. /**
  56599. * Disposes of the light gizmo
  56600. */
  56601. dispose(): void;
  56602. private static _CreateHemisphericLightMesh;
  56603. private static _CreatePointLightMesh;
  56604. private static _CreateSpotLightMesh;
  56605. private static _CreateDirectionalLightMesh;
  56606. }
  56607. }
  56608. declare module "babylonjs/Gizmos/cameraGizmo" {
  56609. import { Nullable } from "babylonjs/types";
  56610. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56611. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56612. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56613. import { Camera } from "babylonjs/Cameras/camera";
  56614. import { Observable } from "babylonjs/Misc/observable";
  56615. /**
  56616. * Gizmo that enables viewing a camera
  56617. */
  56618. export class CameraGizmo extends Gizmo {
  56619. private _cameraMesh;
  56620. private _cameraLinesMesh;
  56621. private _material;
  56622. private _pointerObserver;
  56623. /**
  56624. * Event that fires each time the gizmo is clicked
  56625. */
  56626. onClickedObservable: Observable<Camera>;
  56627. /**
  56628. * Creates a CameraGizmo
  56629. * @param gizmoLayer The utility layer the gizmo will be added to
  56630. */
  56631. constructor(gizmoLayer?: UtilityLayerRenderer);
  56632. private _camera;
  56633. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56634. get displayFrustum(): boolean;
  56635. set displayFrustum(value: boolean);
  56636. /**
  56637. * The camera that the gizmo is attached to
  56638. */
  56639. set camera(camera: Nullable<Camera>);
  56640. get camera(): Nullable<Camera>;
  56641. /**
  56642. * Gets the material used to render the camera gizmo
  56643. */
  56644. get material(): StandardMaterial;
  56645. /**
  56646. * @hidden
  56647. * Updates the gizmo to match the attached mesh's position/rotation
  56648. */
  56649. protected _update(): void;
  56650. private static _Scale;
  56651. private _invProjection;
  56652. /**
  56653. * Disposes of the camera gizmo
  56654. */
  56655. dispose(): void;
  56656. private static _CreateCameraMesh;
  56657. private static _CreateCameraFrustum;
  56658. }
  56659. }
  56660. declare module "babylonjs/Gizmos/index" {
  56661. export * from "babylonjs/Gizmos/axisDragGizmo";
  56662. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56663. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56664. export * from "babylonjs/Gizmos/gizmo";
  56665. export * from "babylonjs/Gizmos/gizmoManager";
  56666. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56667. export * from "babylonjs/Gizmos/positionGizmo";
  56668. export * from "babylonjs/Gizmos/rotationGizmo";
  56669. export * from "babylonjs/Gizmos/scaleGizmo";
  56670. export * from "babylonjs/Gizmos/lightGizmo";
  56671. export * from "babylonjs/Gizmos/cameraGizmo";
  56672. export * from "babylonjs/Gizmos/planeDragGizmo";
  56673. }
  56674. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56675. /** @hidden */
  56676. export var backgroundFragmentDeclaration: {
  56677. name: string;
  56678. shader: string;
  56679. };
  56680. }
  56681. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56682. /** @hidden */
  56683. export var backgroundUboDeclaration: {
  56684. name: string;
  56685. shader: string;
  56686. };
  56687. }
  56688. declare module "babylonjs/Shaders/background.fragment" {
  56689. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56690. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56691. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56692. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56693. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56694. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56695. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56696. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56697. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56698. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56699. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56700. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56701. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56702. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56703. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56704. /** @hidden */
  56705. export var backgroundPixelShader: {
  56706. name: string;
  56707. shader: string;
  56708. };
  56709. }
  56710. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56711. /** @hidden */
  56712. export var backgroundVertexDeclaration: {
  56713. name: string;
  56714. shader: string;
  56715. };
  56716. }
  56717. declare module "babylonjs/Shaders/background.vertex" {
  56718. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56719. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56720. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56721. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56722. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56723. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56724. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56725. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56726. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56727. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56728. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56729. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56730. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56731. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56732. /** @hidden */
  56733. export var backgroundVertexShader: {
  56734. name: string;
  56735. shader: string;
  56736. };
  56737. }
  56738. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56739. import { Nullable, int, float } from "babylonjs/types";
  56740. import { Scene } from "babylonjs/scene";
  56741. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56744. import { Mesh } from "babylonjs/Meshes/mesh";
  56745. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56746. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56747. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56749. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56750. import { Color3 } from "babylonjs/Maths/math.color";
  56751. import "babylonjs/Shaders/background.fragment";
  56752. import "babylonjs/Shaders/background.vertex";
  56753. /**
  56754. * Background material used to create an efficient environement around your scene.
  56755. */
  56756. export class BackgroundMaterial extends PushMaterial {
  56757. /**
  56758. * Standard reflectance value at parallel view angle.
  56759. */
  56760. static StandardReflectance0: number;
  56761. /**
  56762. * Standard reflectance value at grazing angle.
  56763. */
  56764. static StandardReflectance90: number;
  56765. protected _primaryColor: Color3;
  56766. /**
  56767. * Key light Color (multiply against the environement texture)
  56768. */
  56769. primaryColor: Color3;
  56770. protected __perceptualColor: Nullable<Color3>;
  56771. /**
  56772. * Experimental Internal Use Only.
  56773. *
  56774. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56775. * This acts as a helper to set the primary color to a more "human friendly" value.
  56776. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56777. * output color as close as possible from the chosen value.
  56778. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56779. * part of lighting setup.)
  56780. */
  56781. get _perceptualColor(): Nullable<Color3>;
  56782. set _perceptualColor(value: Nullable<Color3>);
  56783. protected _primaryColorShadowLevel: float;
  56784. /**
  56785. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56786. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56787. */
  56788. get primaryColorShadowLevel(): float;
  56789. set primaryColorShadowLevel(value: float);
  56790. protected _primaryColorHighlightLevel: float;
  56791. /**
  56792. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56793. * The primary color is used at the level chosen to define what the white area would look.
  56794. */
  56795. get primaryColorHighlightLevel(): float;
  56796. set primaryColorHighlightLevel(value: float);
  56797. protected _reflectionTexture: Nullable<BaseTexture>;
  56798. /**
  56799. * Reflection Texture used in the material.
  56800. * Should be author in a specific way for the best result (refer to the documentation).
  56801. */
  56802. reflectionTexture: Nullable<BaseTexture>;
  56803. protected _reflectionBlur: float;
  56804. /**
  56805. * Reflection Texture level of blur.
  56806. *
  56807. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56808. * texture twice.
  56809. */
  56810. reflectionBlur: float;
  56811. protected _diffuseTexture: Nullable<BaseTexture>;
  56812. /**
  56813. * Diffuse Texture used in the material.
  56814. * Should be author in a specific way for the best result (refer to the documentation).
  56815. */
  56816. diffuseTexture: Nullable<BaseTexture>;
  56817. protected _shadowLights: Nullable<IShadowLight[]>;
  56818. /**
  56819. * Specify the list of lights casting shadow on the material.
  56820. * All scene shadow lights will be included if null.
  56821. */
  56822. shadowLights: Nullable<IShadowLight[]>;
  56823. protected _shadowLevel: float;
  56824. /**
  56825. * Helps adjusting the shadow to a softer level if required.
  56826. * 0 means black shadows and 1 means no shadows.
  56827. */
  56828. shadowLevel: float;
  56829. protected _sceneCenter: Vector3;
  56830. /**
  56831. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56832. * It is usually zero but might be interesting to modify according to your setup.
  56833. */
  56834. sceneCenter: Vector3;
  56835. protected _opacityFresnel: boolean;
  56836. /**
  56837. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56838. * This helps ensuring a nice transition when the camera goes under the ground.
  56839. */
  56840. opacityFresnel: boolean;
  56841. protected _reflectionFresnel: boolean;
  56842. /**
  56843. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56844. * This helps adding a mirror texture on the ground.
  56845. */
  56846. reflectionFresnel: boolean;
  56847. protected _reflectionFalloffDistance: number;
  56848. /**
  56849. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56850. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56851. */
  56852. reflectionFalloffDistance: number;
  56853. protected _reflectionAmount: number;
  56854. /**
  56855. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56856. */
  56857. reflectionAmount: number;
  56858. protected _reflectionReflectance0: number;
  56859. /**
  56860. * This specifies the weight of the reflection at grazing angle.
  56861. */
  56862. reflectionReflectance0: number;
  56863. protected _reflectionReflectance90: number;
  56864. /**
  56865. * This specifies the weight of the reflection at a perpendicular point of view.
  56866. */
  56867. reflectionReflectance90: number;
  56868. /**
  56869. * Sets the reflection reflectance fresnel values according to the default standard
  56870. * empirically know to work well :-)
  56871. */
  56872. set reflectionStandardFresnelWeight(value: number);
  56873. protected _useRGBColor: boolean;
  56874. /**
  56875. * Helps to directly use the maps channels instead of their level.
  56876. */
  56877. useRGBColor: boolean;
  56878. protected _enableNoise: boolean;
  56879. /**
  56880. * This helps reducing the banding effect that could occur on the background.
  56881. */
  56882. enableNoise: boolean;
  56883. /**
  56884. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56885. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56886. * Recommended to be keep at 1.0 except for special cases.
  56887. */
  56888. get fovMultiplier(): number;
  56889. set fovMultiplier(value: number);
  56890. private _fovMultiplier;
  56891. /**
  56892. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56893. */
  56894. useEquirectangularFOV: boolean;
  56895. private _maxSimultaneousLights;
  56896. /**
  56897. * Number of Simultaneous lights allowed on the material.
  56898. */
  56899. maxSimultaneousLights: int;
  56900. private _shadowOnly;
  56901. /**
  56902. * Make the material only render shadows
  56903. */
  56904. shadowOnly: boolean;
  56905. /**
  56906. * Default configuration related to image processing available in the Background Material.
  56907. */
  56908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56909. /**
  56910. * Keep track of the image processing observer to allow dispose and replace.
  56911. */
  56912. private _imageProcessingObserver;
  56913. /**
  56914. * Attaches a new image processing configuration to the PBR Material.
  56915. * @param configuration (if null the scene configuration will be use)
  56916. */
  56917. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56918. /**
  56919. * Gets the image processing configuration used either in this material.
  56920. */
  56921. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56922. /**
  56923. * Sets the Default image processing configuration used either in the this material.
  56924. *
  56925. * If sets to null, the scene one is in use.
  56926. */
  56927. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56928. /**
  56929. * Gets wether the color curves effect is enabled.
  56930. */
  56931. get cameraColorCurvesEnabled(): boolean;
  56932. /**
  56933. * Sets wether the color curves effect is enabled.
  56934. */
  56935. set cameraColorCurvesEnabled(value: boolean);
  56936. /**
  56937. * Gets wether the color grading effect is enabled.
  56938. */
  56939. get cameraColorGradingEnabled(): boolean;
  56940. /**
  56941. * Gets wether the color grading effect is enabled.
  56942. */
  56943. set cameraColorGradingEnabled(value: boolean);
  56944. /**
  56945. * Gets wether tonemapping is enabled or not.
  56946. */
  56947. get cameraToneMappingEnabled(): boolean;
  56948. /**
  56949. * Sets wether tonemapping is enabled or not
  56950. */
  56951. set cameraToneMappingEnabled(value: boolean);
  56952. /**
  56953. * The camera exposure used on this material.
  56954. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56955. * This corresponds to a photographic exposure.
  56956. */
  56957. get cameraExposure(): float;
  56958. /**
  56959. * The camera exposure used on this material.
  56960. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56961. * This corresponds to a photographic exposure.
  56962. */
  56963. set cameraExposure(value: float);
  56964. /**
  56965. * Gets The camera contrast used on this material.
  56966. */
  56967. get cameraContrast(): float;
  56968. /**
  56969. * Sets The camera contrast used on this material.
  56970. */
  56971. set cameraContrast(value: float);
  56972. /**
  56973. * Gets the Color Grading 2D Lookup Texture.
  56974. */
  56975. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56976. /**
  56977. * Sets the Color Grading 2D Lookup Texture.
  56978. */
  56979. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56980. /**
  56981. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56982. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56983. * 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;
  56984. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56985. */
  56986. get cameraColorCurves(): Nullable<ColorCurves>;
  56987. /**
  56988. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56989. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56990. * 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;
  56991. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56992. */
  56993. set cameraColorCurves(value: Nullable<ColorCurves>);
  56994. /**
  56995. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56996. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56997. */
  56998. switchToBGR: boolean;
  56999. private _renderTargets;
  57000. private _reflectionControls;
  57001. private _white;
  57002. private _primaryShadowColor;
  57003. private _primaryHighlightColor;
  57004. /**
  57005. * Instantiates a Background Material in the given scene
  57006. * @param name The friendly name of the material
  57007. * @param scene The scene to add the material to
  57008. */
  57009. constructor(name: string, scene: Scene);
  57010. /**
  57011. * Gets a boolean indicating that current material needs to register RTT
  57012. */
  57013. get hasRenderTargetTextures(): boolean;
  57014. /**
  57015. * The entire material has been created in order to prevent overdraw.
  57016. * @returns false
  57017. */
  57018. needAlphaTesting(): boolean;
  57019. /**
  57020. * The entire material has been created in order to prevent overdraw.
  57021. * @returns true if blending is enable
  57022. */
  57023. needAlphaBlending(): boolean;
  57024. /**
  57025. * Checks wether the material is ready to be rendered for a given mesh.
  57026. * @param mesh The mesh to render
  57027. * @param subMesh The submesh to check against
  57028. * @param useInstances Specify wether or not the material is used with instances
  57029. * @returns true if all the dependencies are ready (Textures, Effects...)
  57030. */
  57031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57032. /**
  57033. * Compute the primary color according to the chosen perceptual color.
  57034. */
  57035. private _computePrimaryColorFromPerceptualColor;
  57036. /**
  57037. * Compute the highlights and shadow colors according to their chosen levels.
  57038. */
  57039. private _computePrimaryColors;
  57040. /**
  57041. * Build the uniform buffer used in the material.
  57042. */
  57043. buildUniformLayout(): void;
  57044. /**
  57045. * Unbind the material.
  57046. */
  57047. unbind(): void;
  57048. /**
  57049. * Bind only the world matrix to the material.
  57050. * @param world The world matrix to bind.
  57051. */
  57052. bindOnlyWorldMatrix(world: Matrix): void;
  57053. /**
  57054. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57055. * @param world The world matrix to bind.
  57056. * @param subMesh The submesh to bind for.
  57057. */
  57058. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57059. /**
  57060. * Checks to see if a texture is used in the material.
  57061. * @param texture - Base texture to use.
  57062. * @returns - Boolean specifying if a texture is used in the material.
  57063. */
  57064. hasTexture(texture: BaseTexture): boolean;
  57065. /**
  57066. * Dispose the material.
  57067. * @param forceDisposeEffect Force disposal of the associated effect.
  57068. * @param forceDisposeTextures Force disposal of the associated textures.
  57069. */
  57070. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57071. /**
  57072. * Clones the material.
  57073. * @param name The cloned name.
  57074. * @returns The cloned material.
  57075. */
  57076. clone(name: string): BackgroundMaterial;
  57077. /**
  57078. * Serializes the current material to its JSON representation.
  57079. * @returns The JSON representation.
  57080. */
  57081. serialize(): any;
  57082. /**
  57083. * Gets the class name of the material
  57084. * @returns "BackgroundMaterial"
  57085. */
  57086. getClassName(): string;
  57087. /**
  57088. * Parse a JSON input to create back a background material.
  57089. * @param source The JSON data to parse
  57090. * @param scene The scene to create the parsed material in
  57091. * @param rootUrl The root url of the assets the material depends upon
  57092. * @returns the instantiated BackgroundMaterial.
  57093. */
  57094. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57095. }
  57096. }
  57097. declare module "babylonjs/Helpers/environmentHelper" {
  57098. import { Observable } from "babylonjs/Misc/observable";
  57099. import { Nullable } from "babylonjs/types";
  57100. import { Scene } from "babylonjs/scene";
  57101. import { Vector3 } from "babylonjs/Maths/math.vector";
  57102. import { Color3 } from "babylonjs/Maths/math.color";
  57103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57104. import { Mesh } from "babylonjs/Meshes/mesh";
  57105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57106. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57107. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57108. import "babylonjs/Meshes/Builders/planeBuilder";
  57109. import "babylonjs/Meshes/Builders/boxBuilder";
  57110. /**
  57111. * Represents the different options available during the creation of
  57112. * a Environment helper.
  57113. *
  57114. * This can control the default ground, skybox and image processing setup of your scene.
  57115. */
  57116. export interface IEnvironmentHelperOptions {
  57117. /**
  57118. * Specifies whether or not to create a ground.
  57119. * True by default.
  57120. */
  57121. createGround: boolean;
  57122. /**
  57123. * Specifies the ground size.
  57124. * 15 by default.
  57125. */
  57126. groundSize: number;
  57127. /**
  57128. * The texture used on the ground for the main color.
  57129. * Comes from the BabylonJS CDN by default.
  57130. *
  57131. * Remarks: Can be either a texture or a url.
  57132. */
  57133. groundTexture: string | BaseTexture;
  57134. /**
  57135. * The color mixed in the ground texture by default.
  57136. * BabylonJS clearColor by default.
  57137. */
  57138. groundColor: Color3;
  57139. /**
  57140. * Specifies the ground opacity.
  57141. * 1 by default.
  57142. */
  57143. groundOpacity: number;
  57144. /**
  57145. * Enables the ground to receive shadows.
  57146. * True by default.
  57147. */
  57148. enableGroundShadow: boolean;
  57149. /**
  57150. * Helps preventing the shadow to be fully black on the ground.
  57151. * 0.5 by default.
  57152. */
  57153. groundShadowLevel: number;
  57154. /**
  57155. * Creates a mirror texture attach to the ground.
  57156. * false by default.
  57157. */
  57158. enableGroundMirror: boolean;
  57159. /**
  57160. * Specifies the ground mirror size ratio.
  57161. * 0.3 by default as the default kernel is 64.
  57162. */
  57163. groundMirrorSizeRatio: number;
  57164. /**
  57165. * Specifies the ground mirror blur kernel size.
  57166. * 64 by default.
  57167. */
  57168. groundMirrorBlurKernel: number;
  57169. /**
  57170. * Specifies the ground mirror visibility amount.
  57171. * 1 by default
  57172. */
  57173. groundMirrorAmount: number;
  57174. /**
  57175. * Specifies the ground mirror reflectance weight.
  57176. * This uses the standard weight of the background material to setup the fresnel effect
  57177. * of the mirror.
  57178. * 1 by default.
  57179. */
  57180. groundMirrorFresnelWeight: number;
  57181. /**
  57182. * Specifies the ground mirror Falloff distance.
  57183. * This can helps reducing the size of the reflection.
  57184. * 0 by Default.
  57185. */
  57186. groundMirrorFallOffDistance: number;
  57187. /**
  57188. * Specifies the ground mirror texture type.
  57189. * Unsigned Int by Default.
  57190. */
  57191. groundMirrorTextureType: number;
  57192. /**
  57193. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57194. * the shown objects.
  57195. */
  57196. groundYBias: number;
  57197. /**
  57198. * Specifies whether or not to create a skybox.
  57199. * True by default.
  57200. */
  57201. createSkybox: boolean;
  57202. /**
  57203. * Specifies the skybox size.
  57204. * 20 by default.
  57205. */
  57206. skyboxSize: number;
  57207. /**
  57208. * The texture used on the skybox for the main color.
  57209. * Comes from the BabylonJS CDN by default.
  57210. *
  57211. * Remarks: Can be either a texture or a url.
  57212. */
  57213. skyboxTexture: string | BaseTexture;
  57214. /**
  57215. * The color mixed in the skybox texture by default.
  57216. * BabylonJS clearColor by default.
  57217. */
  57218. skyboxColor: Color3;
  57219. /**
  57220. * The background rotation around the Y axis of the scene.
  57221. * This helps aligning the key lights of your scene with the background.
  57222. * 0 by default.
  57223. */
  57224. backgroundYRotation: number;
  57225. /**
  57226. * Compute automatically the size of the elements to best fit with the scene.
  57227. */
  57228. sizeAuto: boolean;
  57229. /**
  57230. * Default position of the rootMesh if autoSize is not true.
  57231. */
  57232. rootPosition: Vector3;
  57233. /**
  57234. * Sets up the image processing in the scene.
  57235. * true by default.
  57236. */
  57237. setupImageProcessing: boolean;
  57238. /**
  57239. * The texture used as your environment texture in the scene.
  57240. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57241. *
  57242. * Remarks: Can be either a texture or a url.
  57243. */
  57244. environmentTexture: string | BaseTexture;
  57245. /**
  57246. * The value of the exposure to apply to the scene.
  57247. * 0.6 by default if setupImageProcessing is true.
  57248. */
  57249. cameraExposure: number;
  57250. /**
  57251. * The value of the contrast to apply to the scene.
  57252. * 1.6 by default if setupImageProcessing is true.
  57253. */
  57254. cameraContrast: number;
  57255. /**
  57256. * Specifies whether or not tonemapping should be enabled in the scene.
  57257. * true by default if setupImageProcessing is true.
  57258. */
  57259. toneMappingEnabled: boolean;
  57260. }
  57261. /**
  57262. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57263. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57264. * It also helps with the default setup of your imageProcessing configuration.
  57265. */
  57266. export class EnvironmentHelper {
  57267. /**
  57268. * Default ground texture URL.
  57269. */
  57270. private static _groundTextureCDNUrl;
  57271. /**
  57272. * Default skybox texture URL.
  57273. */
  57274. private static _skyboxTextureCDNUrl;
  57275. /**
  57276. * Default environment texture URL.
  57277. */
  57278. private static _environmentTextureCDNUrl;
  57279. /**
  57280. * Creates the default options for the helper.
  57281. */
  57282. private static _getDefaultOptions;
  57283. private _rootMesh;
  57284. /**
  57285. * Gets the root mesh created by the helper.
  57286. */
  57287. get rootMesh(): Mesh;
  57288. private _skybox;
  57289. /**
  57290. * Gets the skybox created by the helper.
  57291. */
  57292. get skybox(): Nullable<Mesh>;
  57293. private _skyboxTexture;
  57294. /**
  57295. * Gets the skybox texture created by the helper.
  57296. */
  57297. get skyboxTexture(): Nullable<BaseTexture>;
  57298. private _skyboxMaterial;
  57299. /**
  57300. * Gets the skybox material created by the helper.
  57301. */
  57302. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57303. private _ground;
  57304. /**
  57305. * Gets the ground mesh created by the helper.
  57306. */
  57307. get ground(): Nullable<Mesh>;
  57308. private _groundTexture;
  57309. /**
  57310. * Gets the ground texture created by the helper.
  57311. */
  57312. get groundTexture(): Nullable<BaseTexture>;
  57313. private _groundMirror;
  57314. /**
  57315. * Gets the ground mirror created by the helper.
  57316. */
  57317. get groundMirror(): Nullable<MirrorTexture>;
  57318. /**
  57319. * Gets the ground mirror render list to helps pushing the meshes
  57320. * you wish in the ground reflection.
  57321. */
  57322. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57323. private _groundMaterial;
  57324. /**
  57325. * Gets the ground material created by the helper.
  57326. */
  57327. get groundMaterial(): Nullable<BackgroundMaterial>;
  57328. /**
  57329. * Stores the creation options.
  57330. */
  57331. private readonly _scene;
  57332. private _options;
  57333. /**
  57334. * This observable will be notified with any error during the creation of the environment,
  57335. * mainly texture creation errors.
  57336. */
  57337. onErrorObservable: Observable<{
  57338. message?: string;
  57339. exception?: any;
  57340. }>;
  57341. /**
  57342. * constructor
  57343. * @param options Defines the options we want to customize the helper
  57344. * @param scene The scene to add the material to
  57345. */
  57346. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57347. /**
  57348. * Updates the background according to the new options
  57349. * @param options
  57350. */
  57351. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57352. /**
  57353. * Sets the primary color of all the available elements.
  57354. * @param color the main color to affect to the ground and the background
  57355. */
  57356. setMainColor(color: Color3): void;
  57357. /**
  57358. * Setup the image processing according to the specified options.
  57359. */
  57360. private _setupImageProcessing;
  57361. /**
  57362. * Setup the environment texture according to the specified options.
  57363. */
  57364. private _setupEnvironmentTexture;
  57365. /**
  57366. * Setup the background according to the specified options.
  57367. */
  57368. private _setupBackground;
  57369. /**
  57370. * Get the scene sizes according to the setup.
  57371. */
  57372. private _getSceneSize;
  57373. /**
  57374. * Setup the ground according to the specified options.
  57375. */
  57376. private _setupGround;
  57377. /**
  57378. * Setup the ground material according to the specified options.
  57379. */
  57380. private _setupGroundMaterial;
  57381. /**
  57382. * Setup the ground diffuse texture according to the specified options.
  57383. */
  57384. private _setupGroundDiffuseTexture;
  57385. /**
  57386. * Setup the ground mirror texture according to the specified options.
  57387. */
  57388. private _setupGroundMirrorTexture;
  57389. /**
  57390. * Setup the ground to receive the mirror texture.
  57391. */
  57392. private _setupMirrorInGroundMaterial;
  57393. /**
  57394. * Setup the skybox according to the specified options.
  57395. */
  57396. private _setupSkybox;
  57397. /**
  57398. * Setup the skybox material according to the specified options.
  57399. */
  57400. private _setupSkyboxMaterial;
  57401. /**
  57402. * Setup the skybox reflection texture according to the specified options.
  57403. */
  57404. private _setupSkyboxReflectionTexture;
  57405. private _errorHandler;
  57406. /**
  57407. * Dispose all the elements created by the Helper.
  57408. */
  57409. dispose(): void;
  57410. }
  57411. }
  57412. declare module "babylonjs/Helpers/textureDome" {
  57413. import { Scene } from "babylonjs/scene";
  57414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57415. import { Mesh } from "babylonjs/Meshes/mesh";
  57416. import { Texture } from "babylonjs/Materials/Textures/texture";
  57417. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57418. import "babylonjs/Meshes/Builders/sphereBuilder";
  57419. import { Nullable } from "babylonjs/types";
  57420. import { Observable } from "babylonjs/Misc/observable";
  57421. /**
  57422. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57423. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57424. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57425. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57426. */
  57427. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57428. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57429. /**
  57430. * Define the source as a Monoscopic panoramic 360/180.
  57431. */
  57432. static readonly MODE_MONOSCOPIC: number;
  57433. /**
  57434. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57435. */
  57436. static readonly MODE_TOPBOTTOM: number;
  57437. /**
  57438. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57439. */
  57440. static readonly MODE_SIDEBYSIDE: number;
  57441. private _halfDome;
  57442. protected _useDirectMapping: boolean;
  57443. /**
  57444. * The texture being displayed on the sphere
  57445. */
  57446. protected _texture: T;
  57447. /**
  57448. * Gets the texture being displayed on the sphere
  57449. */
  57450. get texture(): T;
  57451. /**
  57452. * Sets the texture being displayed on the sphere
  57453. */
  57454. set texture(newTexture: T);
  57455. /**
  57456. * The skybox material
  57457. */
  57458. protected _material: BackgroundMaterial;
  57459. /**
  57460. * The surface used for the dome
  57461. */
  57462. protected _mesh: Mesh;
  57463. /**
  57464. * Gets the mesh used for the dome.
  57465. */
  57466. get mesh(): Mesh;
  57467. /**
  57468. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57469. */
  57470. private _halfDomeMask;
  57471. /**
  57472. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57473. * Also see the options.resolution property.
  57474. */
  57475. get fovMultiplier(): number;
  57476. set fovMultiplier(value: number);
  57477. protected _textureMode: number;
  57478. /**
  57479. * Gets or set the current texture mode for the texture. It can be:
  57480. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57481. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57482. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57483. */
  57484. get textureMode(): number;
  57485. /**
  57486. * Sets the current texture mode for the texture. It can be:
  57487. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57488. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57489. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57490. */
  57491. set textureMode(value: number);
  57492. /**
  57493. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57494. */
  57495. get halfDome(): boolean;
  57496. /**
  57497. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57498. */
  57499. set halfDome(enabled: boolean);
  57500. /**
  57501. * Oberserver used in Stereoscopic VR Mode.
  57502. */
  57503. private _onBeforeCameraRenderObserver;
  57504. /**
  57505. * Observable raised when an error occured while loading the 360 image
  57506. */
  57507. onLoadErrorObservable: Observable<string>;
  57508. /**
  57509. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57510. * @param name Element's name, child elements will append suffixes for their own names.
  57511. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57512. * @param options An object containing optional or exposed sub element properties
  57513. */
  57514. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57515. resolution?: number;
  57516. clickToPlay?: boolean;
  57517. autoPlay?: boolean;
  57518. loop?: boolean;
  57519. size?: number;
  57520. poster?: string;
  57521. faceForward?: boolean;
  57522. useDirectMapping?: boolean;
  57523. halfDomeMode?: boolean;
  57524. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57525. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57526. protected _changeTextureMode(value: number): void;
  57527. /**
  57528. * Releases resources associated with this node.
  57529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57531. */
  57532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57533. }
  57534. }
  57535. declare module "babylonjs/Helpers/photoDome" {
  57536. import { Scene } from "babylonjs/scene";
  57537. import { Texture } from "babylonjs/Materials/Textures/texture";
  57538. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57539. /**
  57540. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57541. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57542. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57543. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57544. */
  57545. export class PhotoDome extends TextureDome<Texture> {
  57546. /**
  57547. * Define the image as a Monoscopic panoramic 360 image.
  57548. */
  57549. static readonly MODE_MONOSCOPIC: number;
  57550. /**
  57551. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57552. */
  57553. static readonly MODE_TOPBOTTOM: number;
  57554. /**
  57555. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57556. */
  57557. static readonly MODE_SIDEBYSIDE: number;
  57558. /**
  57559. * Gets or sets the texture being displayed on the sphere
  57560. */
  57561. get photoTexture(): Texture;
  57562. /**
  57563. * sets the texture being displayed on the sphere
  57564. */
  57565. set photoTexture(value: Texture);
  57566. /**
  57567. * Gets the current video mode for the video. It can be:
  57568. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57569. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57570. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57571. */
  57572. get imageMode(): number;
  57573. /**
  57574. * Sets the current video mode for the video. It can be:
  57575. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57576. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57577. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57578. */
  57579. set imageMode(value: number);
  57580. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57581. }
  57582. }
  57583. declare module "babylonjs/Misc/rgbdTextureTools" {
  57584. import "babylonjs/Shaders/rgbdDecode.fragment";
  57585. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57586. import { Texture } from "babylonjs/Materials/Textures/texture";
  57587. /**
  57588. * Class used to host RGBD texture specific utilities
  57589. */
  57590. export class RGBDTextureTools {
  57591. /**
  57592. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57593. * @param texture the texture to expand.
  57594. */
  57595. static ExpandRGBDTexture(texture: Texture): void;
  57596. }
  57597. }
  57598. declare module "babylonjs/Misc/brdfTextureTools" {
  57599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57600. import { Scene } from "babylonjs/scene";
  57601. /**
  57602. * Class used to host texture specific utilities
  57603. */
  57604. export class BRDFTextureTools {
  57605. /**
  57606. * Prevents texture cache collision
  57607. */
  57608. private static _instanceNumber;
  57609. /**
  57610. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57611. * @param scene defines the hosting scene
  57612. * @returns the environment BRDF texture
  57613. */
  57614. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57615. private static _environmentBRDFBase64Texture;
  57616. }
  57617. }
  57618. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57619. import { Nullable } from "babylonjs/types";
  57620. import { Color3 } from "babylonjs/Maths/math.color";
  57621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57622. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57623. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57624. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57625. import { Engine } from "babylonjs/Engines/engine";
  57626. import { Scene } from "babylonjs/scene";
  57627. /**
  57628. * @hidden
  57629. */
  57630. export interface IMaterialClearCoatDefines {
  57631. CLEARCOAT: boolean;
  57632. CLEARCOAT_DEFAULTIOR: boolean;
  57633. CLEARCOAT_TEXTURE: boolean;
  57634. CLEARCOAT_TEXTUREDIRECTUV: number;
  57635. CLEARCOAT_BUMP: boolean;
  57636. CLEARCOAT_BUMPDIRECTUV: number;
  57637. CLEARCOAT_TINT: boolean;
  57638. CLEARCOAT_TINT_TEXTURE: boolean;
  57639. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57640. /** @hidden */
  57641. _areTexturesDirty: boolean;
  57642. }
  57643. /**
  57644. * Define the code related to the clear coat parameters of the pbr material.
  57645. */
  57646. export class PBRClearCoatConfiguration {
  57647. /**
  57648. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57649. * The default fits with a polyurethane material.
  57650. */
  57651. private static readonly _DefaultIndexOfRefraction;
  57652. private _isEnabled;
  57653. /**
  57654. * Defines if the clear coat is enabled in the material.
  57655. */
  57656. isEnabled: boolean;
  57657. /**
  57658. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57659. */
  57660. intensity: number;
  57661. /**
  57662. * Defines the clear coat layer roughness.
  57663. */
  57664. roughness: number;
  57665. private _indexOfRefraction;
  57666. /**
  57667. * Defines the index of refraction of the clear coat.
  57668. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57669. * The default fits with a polyurethane material.
  57670. * Changing the default value is more performance intensive.
  57671. */
  57672. indexOfRefraction: number;
  57673. private _texture;
  57674. /**
  57675. * Stores the clear coat values in a texture.
  57676. */
  57677. texture: Nullable<BaseTexture>;
  57678. private _bumpTexture;
  57679. /**
  57680. * Define the clear coat specific bump texture.
  57681. */
  57682. bumpTexture: Nullable<BaseTexture>;
  57683. private _isTintEnabled;
  57684. /**
  57685. * Defines if the clear coat tint is enabled in the material.
  57686. */
  57687. isTintEnabled: boolean;
  57688. /**
  57689. * Defines the clear coat tint of the material.
  57690. * This is only use if tint is enabled
  57691. */
  57692. tintColor: Color3;
  57693. /**
  57694. * Defines the distance at which the tint color should be found in the
  57695. * clear coat media.
  57696. * This is only use if tint is enabled
  57697. */
  57698. tintColorAtDistance: number;
  57699. /**
  57700. * Defines the clear coat layer thickness.
  57701. * This is only use if tint is enabled
  57702. */
  57703. tintThickness: number;
  57704. private _tintTexture;
  57705. /**
  57706. * Stores the clear tint values in a texture.
  57707. * rgb is tint
  57708. * a is a thickness factor
  57709. */
  57710. tintTexture: Nullable<BaseTexture>;
  57711. /** @hidden */
  57712. private _internalMarkAllSubMeshesAsTexturesDirty;
  57713. /** @hidden */
  57714. _markAllSubMeshesAsTexturesDirty(): void;
  57715. /**
  57716. * Instantiate a new istance of clear coat configuration.
  57717. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57718. */
  57719. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57720. /**
  57721. * Gets wehter the submesh is ready to be used or not.
  57722. * @param defines the list of "defines" to update.
  57723. * @param scene defines the scene the material belongs to.
  57724. * @param engine defines the engine the material belongs to.
  57725. * @param disableBumpMap defines wether the material disables bump or not.
  57726. * @returns - boolean indicating that the submesh is ready or not.
  57727. */
  57728. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57729. /**
  57730. * Checks to see if a texture is used in the material.
  57731. * @param defines the list of "defines" to update.
  57732. * @param scene defines the scene to the material belongs to.
  57733. */
  57734. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57735. /**
  57736. * Binds the material data.
  57737. * @param uniformBuffer defines the Uniform buffer to fill in.
  57738. * @param scene defines the scene the material belongs to.
  57739. * @param engine defines the engine the material belongs to.
  57740. * @param disableBumpMap defines wether the material disables bump or not.
  57741. * @param isFrozen defines wether the material is frozen or not.
  57742. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57743. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57744. */
  57745. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57746. /**
  57747. * Checks to see if a texture is used in the material.
  57748. * @param texture - Base texture to use.
  57749. * @returns - Boolean specifying if a texture is used in the material.
  57750. */
  57751. hasTexture(texture: BaseTexture): boolean;
  57752. /**
  57753. * Returns an array of the actively used textures.
  57754. * @param activeTextures Array of BaseTextures
  57755. */
  57756. getActiveTextures(activeTextures: BaseTexture[]): void;
  57757. /**
  57758. * Returns the animatable textures.
  57759. * @param animatables Array of animatable textures.
  57760. */
  57761. getAnimatables(animatables: IAnimatable[]): void;
  57762. /**
  57763. * Disposes the resources of the material.
  57764. * @param forceDisposeTextures - Forces the disposal of all textures.
  57765. */
  57766. dispose(forceDisposeTextures?: boolean): void;
  57767. /**
  57768. * Get the current class name of the texture useful for serialization or dynamic coding.
  57769. * @returns "PBRClearCoatConfiguration"
  57770. */
  57771. getClassName(): string;
  57772. /**
  57773. * Add fallbacks to the effect fallbacks list.
  57774. * @param defines defines the Base texture to use.
  57775. * @param fallbacks defines the current fallback list.
  57776. * @param currentRank defines the current fallback rank.
  57777. * @returns the new fallback rank.
  57778. */
  57779. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57780. /**
  57781. * Add the required uniforms to the current list.
  57782. * @param uniforms defines the current uniform list.
  57783. */
  57784. static AddUniforms(uniforms: string[]): void;
  57785. /**
  57786. * Add the required samplers to the current list.
  57787. * @param samplers defines the current sampler list.
  57788. */
  57789. static AddSamplers(samplers: string[]): void;
  57790. /**
  57791. * Add the required uniforms to the current buffer.
  57792. * @param uniformBuffer defines the current uniform buffer.
  57793. */
  57794. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57795. /**
  57796. * Makes a duplicate of the current configuration into another one.
  57797. * @param clearCoatConfiguration define the config where to copy the info
  57798. */
  57799. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57800. /**
  57801. * Serializes this clear coat configuration.
  57802. * @returns - An object with the serialized config.
  57803. */
  57804. serialize(): any;
  57805. /**
  57806. * Parses a anisotropy Configuration from a serialized object.
  57807. * @param source - Serialized object.
  57808. * @param scene Defines the scene we are parsing for
  57809. * @param rootUrl Defines the rootUrl to load from
  57810. */
  57811. parse(source: any, scene: Scene, rootUrl: string): void;
  57812. }
  57813. }
  57814. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57815. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57817. import { Vector2 } from "babylonjs/Maths/math.vector";
  57818. import { Scene } from "babylonjs/scene";
  57819. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57820. import { Nullable } from "babylonjs/types";
  57821. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57822. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57823. /**
  57824. * @hidden
  57825. */
  57826. export interface IMaterialAnisotropicDefines {
  57827. ANISOTROPIC: boolean;
  57828. ANISOTROPIC_TEXTURE: boolean;
  57829. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57830. MAINUV1: boolean;
  57831. _areTexturesDirty: boolean;
  57832. _needUVs: boolean;
  57833. }
  57834. /**
  57835. * Define the code related to the anisotropic parameters of the pbr material.
  57836. */
  57837. export class PBRAnisotropicConfiguration {
  57838. private _isEnabled;
  57839. /**
  57840. * Defines if the anisotropy is enabled in the material.
  57841. */
  57842. isEnabled: boolean;
  57843. /**
  57844. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57845. */
  57846. intensity: number;
  57847. /**
  57848. * Defines if the effect is along the tangents, bitangents or in between.
  57849. * By default, the effect is "strectching" the highlights along the tangents.
  57850. */
  57851. direction: Vector2;
  57852. private _texture;
  57853. /**
  57854. * Stores the anisotropy values in a texture.
  57855. * rg is direction (like normal from -1 to 1)
  57856. * b is a intensity
  57857. */
  57858. texture: Nullable<BaseTexture>;
  57859. /** @hidden */
  57860. private _internalMarkAllSubMeshesAsTexturesDirty;
  57861. /** @hidden */
  57862. _markAllSubMeshesAsTexturesDirty(): void;
  57863. /**
  57864. * Instantiate a new istance of anisotropy configuration.
  57865. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57866. */
  57867. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57868. /**
  57869. * Specifies that the submesh is ready to be used.
  57870. * @param defines the list of "defines" to update.
  57871. * @param scene defines the scene the material belongs to.
  57872. * @returns - boolean indicating that the submesh is ready or not.
  57873. */
  57874. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57875. /**
  57876. * Checks to see if a texture is used in the material.
  57877. * @param defines the list of "defines" to update.
  57878. * @param mesh the mesh we are preparing the defines for.
  57879. * @param scene defines the scene the material belongs to.
  57880. */
  57881. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57882. /**
  57883. * Binds the material data.
  57884. * @param uniformBuffer defines the Uniform buffer to fill in.
  57885. * @param scene defines the scene the material belongs to.
  57886. * @param isFrozen defines wether the material is frozen or not.
  57887. */
  57888. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57889. /**
  57890. * Checks to see if a texture is used in the material.
  57891. * @param texture - Base texture to use.
  57892. * @returns - Boolean specifying if a texture is used in the material.
  57893. */
  57894. hasTexture(texture: BaseTexture): boolean;
  57895. /**
  57896. * Returns an array of the actively used textures.
  57897. * @param activeTextures Array of BaseTextures
  57898. */
  57899. getActiveTextures(activeTextures: BaseTexture[]): void;
  57900. /**
  57901. * Returns the animatable textures.
  57902. * @param animatables Array of animatable textures.
  57903. */
  57904. getAnimatables(animatables: IAnimatable[]): void;
  57905. /**
  57906. * Disposes the resources of the material.
  57907. * @param forceDisposeTextures - Forces the disposal of all textures.
  57908. */
  57909. dispose(forceDisposeTextures?: boolean): void;
  57910. /**
  57911. * Get the current class name of the texture useful for serialization or dynamic coding.
  57912. * @returns "PBRAnisotropicConfiguration"
  57913. */
  57914. getClassName(): string;
  57915. /**
  57916. * Add fallbacks to the effect fallbacks list.
  57917. * @param defines defines the Base texture to use.
  57918. * @param fallbacks defines the current fallback list.
  57919. * @param currentRank defines the current fallback rank.
  57920. * @returns the new fallback rank.
  57921. */
  57922. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57923. /**
  57924. * Add the required uniforms to the current list.
  57925. * @param uniforms defines the current uniform list.
  57926. */
  57927. static AddUniforms(uniforms: string[]): void;
  57928. /**
  57929. * Add the required uniforms to the current buffer.
  57930. * @param uniformBuffer defines the current uniform buffer.
  57931. */
  57932. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57933. /**
  57934. * Add the required samplers to the current list.
  57935. * @param samplers defines the current sampler list.
  57936. */
  57937. static AddSamplers(samplers: string[]): void;
  57938. /**
  57939. * Makes a duplicate of the current configuration into another one.
  57940. * @param anisotropicConfiguration define the config where to copy the info
  57941. */
  57942. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57943. /**
  57944. * Serializes this anisotropy configuration.
  57945. * @returns - An object with the serialized config.
  57946. */
  57947. serialize(): any;
  57948. /**
  57949. * Parses a anisotropy Configuration from a serialized object.
  57950. * @param source - Serialized object.
  57951. * @param scene Defines the scene we are parsing for
  57952. * @param rootUrl Defines the rootUrl to load from
  57953. */
  57954. parse(source: any, scene: Scene, rootUrl: string): void;
  57955. }
  57956. }
  57957. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57958. import { Scene } from "babylonjs/scene";
  57959. /**
  57960. * @hidden
  57961. */
  57962. export interface IMaterialBRDFDefines {
  57963. BRDF_V_HEIGHT_CORRELATED: boolean;
  57964. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57965. SPHERICAL_HARMONICS: boolean;
  57966. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57967. /** @hidden */
  57968. _areMiscDirty: boolean;
  57969. }
  57970. /**
  57971. * Define the code related to the BRDF parameters of the pbr material.
  57972. */
  57973. export class PBRBRDFConfiguration {
  57974. /**
  57975. * Default value used for the energy conservation.
  57976. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57977. */
  57978. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57979. /**
  57980. * Default value used for the Smith Visibility Height Correlated mode.
  57981. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57982. */
  57983. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57984. /**
  57985. * Default value used for the IBL diffuse part.
  57986. * This can help switching back to the polynomials mode globally which is a tiny bit
  57987. * less GPU intensive at the drawback of a lower quality.
  57988. */
  57989. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57990. /**
  57991. * Default value used for activating energy conservation for the specular workflow.
  57992. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57993. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57994. */
  57995. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57996. private _useEnergyConservation;
  57997. /**
  57998. * Defines if the material uses energy conservation.
  57999. */
  58000. useEnergyConservation: boolean;
  58001. private _useSmithVisibilityHeightCorrelated;
  58002. /**
  58003. * LEGACY Mode set to false
  58004. * Defines if the material uses height smith correlated visibility term.
  58005. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58006. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58007. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58008. * Not relying on height correlated will also disable energy conservation.
  58009. */
  58010. useSmithVisibilityHeightCorrelated: boolean;
  58011. private _useSphericalHarmonics;
  58012. /**
  58013. * LEGACY Mode set to false
  58014. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58015. * diffuse part of the IBL.
  58016. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58017. * to the ground truth.
  58018. */
  58019. useSphericalHarmonics: boolean;
  58020. private _useSpecularGlossinessInputEnergyConservation;
  58021. /**
  58022. * Defines if the material uses energy conservation, when the specular workflow is active.
  58023. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58024. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58025. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58026. */
  58027. useSpecularGlossinessInputEnergyConservation: boolean;
  58028. /** @hidden */
  58029. private _internalMarkAllSubMeshesAsMiscDirty;
  58030. /** @hidden */
  58031. _markAllSubMeshesAsMiscDirty(): void;
  58032. /**
  58033. * Instantiate a new istance of clear coat configuration.
  58034. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58035. */
  58036. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58037. /**
  58038. * Checks to see if a texture is used in the material.
  58039. * @param defines the list of "defines" to update.
  58040. */
  58041. prepareDefines(defines: IMaterialBRDFDefines): void;
  58042. /**
  58043. * Get the current class name of the texture useful for serialization or dynamic coding.
  58044. * @returns "PBRClearCoatConfiguration"
  58045. */
  58046. getClassName(): string;
  58047. /**
  58048. * Makes a duplicate of the current configuration into another one.
  58049. * @param brdfConfiguration define the config where to copy the info
  58050. */
  58051. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58052. /**
  58053. * Serializes this BRDF configuration.
  58054. * @returns - An object with the serialized config.
  58055. */
  58056. serialize(): any;
  58057. /**
  58058. * Parses a anisotropy Configuration from a serialized object.
  58059. * @param source - Serialized object.
  58060. * @param scene Defines the scene we are parsing for
  58061. * @param rootUrl Defines the rootUrl to load from
  58062. */
  58063. parse(source: any, scene: Scene, rootUrl: string): void;
  58064. }
  58065. }
  58066. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58067. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58068. import { Color3 } from "babylonjs/Maths/math.color";
  58069. import { Scene } from "babylonjs/scene";
  58070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58071. import { Nullable } from "babylonjs/types";
  58072. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58073. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58074. /**
  58075. * @hidden
  58076. */
  58077. export interface IMaterialSheenDefines {
  58078. SHEEN: boolean;
  58079. SHEEN_TEXTURE: boolean;
  58080. SHEEN_TEXTUREDIRECTUV: number;
  58081. SHEEN_LINKWITHALBEDO: boolean;
  58082. SHEEN_ROUGHNESS: boolean;
  58083. SHEEN_ALBEDOSCALING: boolean;
  58084. /** @hidden */
  58085. _areTexturesDirty: boolean;
  58086. }
  58087. /**
  58088. * Define the code related to the Sheen parameters of the pbr material.
  58089. */
  58090. export class PBRSheenConfiguration {
  58091. private _isEnabled;
  58092. /**
  58093. * Defines if the material uses sheen.
  58094. */
  58095. isEnabled: boolean;
  58096. private _linkSheenWithAlbedo;
  58097. /**
  58098. * Defines if the sheen is linked to the sheen color.
  58099. */
  58100. linkSheenWithAlbedo: boolean;
  58101. /**
  58102. * Defines the sheen intensity.
  58103. */
  58104. intensity: number;
  58105. /**
  58106. * Defines the sheen color.
  58107. */
  58108. color: Color3;
  58109. private _texture;
  58110. /**
  58111. * Stores the sheen tint values in a texture.
  58112. * rgb is tint
  58113. * a is a intensity or roughness if roughness has been defined
  58114. */
  58115. texture: Nullable<BaseTexture>;
  58116. private _roughness;
  58117. /**
  58118. * Defines the sheen roughness.
  58119. * It is not taken into account if linkSheenWithAlbedo is true.
  58120. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58121. */
  58122. roughness: Nullable<number>;
  58123. private _albedoScaling;
  58124. /**
  58125. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58126. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58127. * making it easier to setup and tweak the effect
  58128. */
  58129. albedoScaling: boolean;
  58130. /** @hidden */
  58131. private _internalMarkAllSubMeshesAsTexturesDirty;
  58132. /** @hidden */
  58133. _markAllSubMeshesAsTexturesDirty(): void;
  58134. /**
  58135. * Instantiate a new istance of clear coat configuration.
  58136. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58137. */
  58138. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58139. /**
  58140. * Specifies that the submesh is ready to be used.
  58141. * @param defines the list of "defines" to update.
  58142. * @param scene defines the scene the material belongs to.
  58143. * @returns - boolean indicating that the submesh is ready or not.
  58144. */
  58145. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58146. /**
  58147. * Checks to see if a texture is used in the material.
  58148. * @param defines the list of "defines" to update.
  58149. * @param scene defines the scene the material belongs to.
  58150. */
  58151. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58152. /**
  58153. * Binds the material data.
  58154. * @param uniformBuffer defines the Uniform buffer to fill in.
  58155. * @param scene defines the scene the material belongs to.
  58156. * @param isFrozen defines wether the material is frozen or not.
  58157. */
  58158. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58159. /**
  58160. * Checks to see if a texture is used in the material.
  58161. * @param texture - Base texture to use.
  58162. * @returns - Boolean specifying if a texture is used in the material.
  58163. */
  58164. hasTexture(texture: BaseTexture): boolean;
  58165. /**
  58166. * Returns an array of the actively used textures.
  58167. * @param activeTextures Array of BaseTextures
  58168. */
  58169. getActiveTextures(activeTextures: BaseTexture[]): void;
  58170. /**
  58171. * Returns the animatable textures.
  58172. * @param animatables Array of animatable textures.
  58173. */
  58174. getAnimatables(animatables: IAnimatable[]): void;
  58175. /**
  58176. * Disposes the resources of the material.
  58177. * @param forceDisposeTextures - Forces the disposal of all textures.
  58178. */
  58179. dispose(forceDisposeTextures?: boolean): void;
  58180. /**
  58181. * Get the current class name of the texture useful for serialization or dynamic coding.
  58182. * @returns "PBRSheenConfiguration"
  58183. */
  58184. getClassName(): string;
  58185. /**
  58186. * Add fallbacks to the effect fallbacks list.
  58187. * @param defines defines the Base texture to use.
  58188. * @param fallbacks defines the current fallback list.
  58189. * @param currentRank defines the current fallback rank.
  58190. * @returns the new fallback rank.
  58191. */
  58192. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58193. /**
  58194. * Add the required uniforms to the current list.
  58195. * @param uniforms defines the current uniform list.
  58196. */
  58197. static AddUniforms(uniforms: string[]): void;
  58198. /**
  58199. * Add the required uniforms to the current buffer.
  58200. * @param uniformBuffer defines the current uniform buffer.
  58201. */
  58202. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58203. /**
  58204. * Add the required samplers to the current list.
  58205. * @param samplers defines the current sampler list.
  58206. */
  58207. static AddSamplers(samplers: string[]): void;
  58208. /**
  58209. * Makes a duplicate of the current configuration into another one.
  58210. * @param sheenConfiguration define the config where to copy the info
  58211. */
  58212. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58213. /**
  58214. * Serializes this BRDF configuration.
  58215. * @returns - An object with the serialized config.
  58216. */
  58217. serialize(): any;
  58218. /**
  58219. * Parses a anisotropy Configuration from a serialized object.
  58220. * @param source - Serialized object.
  58221. * @param scene Defines the scene we are parsing for
  58222. * @param rootUrl Defines the rootUrl to load from
  58223. */
  58224. parse(source: any, scene: Scene, rootUrl: string): void;
  58225. }
  58226. }
  58227. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58228. import { Nullable } from "babylonjs/types";
  58229. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58230. import { Color3 } from "babylonjs/Maths/math.color";
  58231. import { SmartArray } from "babylonjs/Misc/smartArray";
  58232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58233. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58234. import { Effect } from "babylonjs/Materials/effect";
  58235. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58236. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58237. import { Engine } from "babylonjs/Engines/engine";
  58238. import { Scene } from "babylonjs/scene";
  58239. /**
  58240. * @hidden
  58241. */
  58242. export interface IMaterialSubSurfaceDefines {
  58243. SUBSURFACE: boolean;
  58244. SS_REFRACTION: boolean;
  58245. SS_TRANSLUCENCY: boolean;
  58246. SS_SCATTERING: boolean;
  58247. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58248. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58249. SS_REFRACTIONMAP_3D: boolean;
  58250. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58251. SS_LODINREFRACTIONALPHA: boolean;
  58252. SS_GAMMAREFRACTION: boolean;
  58253. SS_RGBDREFRACTION: boolean;
  58254. SS_LINEARSPECULARREFRACTION: boolean;
  58255. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58256. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58257. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58258. /** @hidden */
  58259. _areTexturesDirty: boolean;
  58260. }
  58261. /**
  58262. * Define the code related to the sub surface parameters of the pbr material.
  58263. */
  58264. export class PBRSubSurfaceConfiguration {
  58265. private _isRefractionEnabled;
  58266. /**
  58267. * Defines if the refraction is enabled in the material.
  58268. */
  58269. isRefractionEnabled: boolean;
  58270. private _isTranslucencyEnabled;
  58271. /**
  58272. * Defines if the translucency is enabled in the material.
  58273. */
  58274. isTranslucencyEnabled: boolean;
  58275. private _isScatteringEnabled;
  58276. /**
  58277. * Defines if the sub surface scattering is enabled in the material.
  58278. */
  58279. isScatteringEnabled: boolean;
  58280. private _scatteringDiffusionProfileIndex;
  58281. /**
  58282. * Diffusion profile for subsurface scattering.
  58283. * Useful for better scattering in the skins or foliages.
  58284. */
  58285. get scatteringDiffusionProfile(): Nullable<Color3>;
  58286. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58287. /**
  58288. * Defines the refraction intensity of the material.
  58289. * The refraction when enabled replaces the Diffuse part of the material.
  58290. * The intensity helps transitionning between diffuse and refraction.
  58291. */
  58292. refractionIntensity: number;
  58293. /**
  58294. * Defines the translucency intensity of the material.
  58295. * When translucency has been enabled, this defines how much of the "translucency"
  58296. * is addded to the diffuse part of the material.
  58297. */
  58298. translucencyIntensity: number;
  58299. /**
  58300. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58301. */
  58302. useAlbedoToTintRefraction: boolean;
  58303. private _thicknessTexture;
  58304. /**
  58305. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58306. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58307. * 0 would mean minimumThickness
  58308. * 1 would mean maximumThickness
  58309. * The other channels might be use as a mask to vary the different effects intensity.
  58310. */
  58311. thicknessTexture: Nullable<BaseTexture>;
  58312. private _refractionTexture;
  58313. /**
  58314. * Defines the texture to use for refraction.
  58315. */
  58316. refractionTexture: Nullable<BaseTexture>;
  58317. private _indexOfRefraction;
  58318. /**
  58319. * Index of refraction of the material base layer.
  58320. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58321. *
  58322. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58323. *
  58324. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58325. */
  58326. indexOfRefraction: number;
  58327. private _volumeIndexOfRefraction;
  58328. /**
  58329. * Index of refraction of the material's volume.
  58330. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58331. *
  58332. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58333. * the volume will use the same IOR as the surface.
  58334. */
  58335. get volumeIndexOfRefraction(): number;
  58336. set volumeIndexOfRefraction(value: number);
  58337. private _invertRefractionY;
  58338. /**
  58339. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58340. */
  58341. invertRefractionY: boolean;
  58342. private _linkRefractionWithTransparency;
  58343. /**
  58344. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58345. * Materials half opaque for instance using refraction could benefit from this control.
  58346. */
  58347. linkRefractionWithTransparency: boolean;
  58348. /**
  58349. * Defines the minimum thickness stored in the thickness map.
  58350. * If no thickness map is defined, this value will be used to simulate thickness.
  58351. */
  58352. minimumThickness: number;
  58353. /**
  58354. * Defines the maximum thickness stored in the thickness map.
  58355. */
  58356. maximumThickness: number;
  58357. /**
  58358. * Defines the volume tint of the material.
  58359. * This is used for both translucency and scattering.
  58360. */
  58361. tintColor: Color3;
  58362. /**
  58363. * Defines the distance at which the tint color should be found in the media.
  58364. * This is used for refraction only.
  58365. */
  58366. tintColorAtDistance: number;
  58367. /**
  58368. * Defines how far each channel transmit through the media.
  58369. * It is defined as a color to simplify it selection.
  58370. */
  58371. diffusionDistance: Color3;
  58372. private _useMaskFromThicknessTexture;
  58373. /**
  58374. * Stores the intensity of the different subsurface effects in the thickness texture.
  58375. * * the green channel is the translucency intensity.
  58376. * * the blue channel is the scattering intensity.
  58377. * * the alpha channel is the refraction intensity.
  58378. */
  58379. useMaskFromThicknessTexture: boolean;
  58380. private _scene;
  58381. /** @hidden */
  58382. private _internalMarkAllSubMeshesAsTexturesDirty;
  58383. private _internalMarkScenePrePassDirty;
  58384. /** @hidden */
  58385. _markAllSubMeshesAsTexturesDirty(): void;
  58386. /** @hidden */
  58387. _markScenePrePassDirty(): void;
  58388. /**
  58389. * Instantiate a new istance of sub surface configuration.
  58390. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58391. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58392. * @param scene The scene
  58393. */
  58394. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58395. /**
  58396. * Gets wehter the submesh is ready to be used or not.
  58397. * @param defines the list of "defines" to update.
  58398. * @param scene defines the scene the material belongs to.
  58399. * @returns - boolean indicating that the submesh is ready or not.
  58400. */
  58401. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58402. /**
  58403. * Checks to see if a texture is used in the material.
  58404. * @param defines the list of "defines" to update.
  58405. * @param scene defines the scene to the material belongs to.
  58406. */
  58407. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58408. /**
  58409. * Binds the material data.
  58410. * @param uniformBuffer defines the Uniform buffer to fill in.
  58411. * @param scene defines the scene the material belongs to.
  58412. * @param engine defines the engine the material belongs to.
  58413. * @param isFrozen defines whether the material is frozen or not.
  58414. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58415. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58416. */
  58417. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58418. /**
  58419. * Unbinds the material from the mesh.
  58420. * @param activeEffect defines the effect that should be unbound from.
  58421. * @returns true if unbound, otherwise false
  58422. */
  58423. unbind(activeEffect: Effect): boolean;
  58424. /**
  58425. * Returns the texture used for refraction or null if none is used.
  58426. * @param scene defines the scene the material belongs to.
  58427. * @returns - Refraction texture if present. If no refraction texture and refraction
  58428. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58429. */
  58430. private _getRefractionTexture;
  58431. /**
  58432. * Returns true if alpha blending should be disabled.
  58433. */
  58434. get disableAlphaBlending(): boolean;
  58435. /**
  58436. * Fills the list of render target textures.
  58437. * @param renderTargets the list of render targets to update
  58438. */
  58439. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58440. /**
  58441. * Checks to see if a texture is used in the material.
  58442. * @param texture - Base texture to use.
  58443. * @returns - Boolean specifying if a texture is used in the material.
  58444. */
  58445. hasTexture(texture: BaseTexture): boolean;
  58446. /**
  58447. * Gets a boolean indicating that current material needs to register RTT
  58448. * @returns true if this uses a render target otherwise false.
  58449. */
  58450. hasRenderTargetTextures(): boolean;
  58451. /**
  58452. * Returns an array of the actively used textures.
  58453. * @param activeTextures Array of BaseTextures
  58454. */
  58455. getActiveTextures(activeTextures: BaseTexture[]): void;
  58456. /**
  58457. * Returns the animatable textures.
  58458. * @param animatables Array of animatable textures.
  58459. */
  58460. getAnimatables(animatables: IAnimatable[]): void;
  58461. /**
  58462. * Disposes the resources of the material.
  58463. * @param forceDisposeTextures - Forces the disposal of all textures.
  58464. */
  58465. dispose(forceDisposeTextures?: boolean): void;
  58466. /**
  58467. * Get the current class name of the texture useful for serialization or dynamic coding.
  58468. * @returns "PBRSubSurfaceConfiguration"
  58469. */
  58470. getClassName(): string;
  58471. /**
  58472. * Add fallbacks to the effect fallbacks list.
  58473. * @param defines defines the Base texture to use.
  58474. * @param fallbacks defines the current fallback list.
  58475. * @param currentRank defines the current fallback rank.
  58476. * @returns the new fallback rank.
  58477. */
  58478. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58479. /**
  58480. * Add the required uniforms to the current list.
  58481. * @param uniforms defines the current uniform list.
  58482. */
  58483. static AddUniforms(uniforms: string[]): void;
  58484. /**
  58485. * Add the required samplers to the current list.
  58486. * @param samplers defines the current sampler list.
  58487. */
  58488. static AddSamplers(samplers: string[]): void;
  58489. /**
  58490. * Add the required uniforms to the current buffer.
  58491. * @param uniformBuffer defines the current uniform buffer.
  58492. */
  58493. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58494. /**
  58495. * Makes a duplicate of the current configuration into another one.
  58496. * @param configuration define the config where to copy the info
  58497. */
  58498. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58499. /**
  58500. * Serializes this Sub Surface configuration.
  58501. * @returns - An object with the serialized config.
  58502. */
  58503. serialize(): any;
  58504. /**
  58505. * Parses a anisotropy Configuration from a serialized object.
  58506. * @param source - Serialized object.
  58507. * @param scene Defines the scene we are parsing for
  58508. * @param rootUrl Defines the rootUrl to load from
  58509. */
  58510. parse(source: any, scene: Scene, rootUrl: string): void;
  58511. }
  58512. }
  58513. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58514. /** @hidden */
  58515. export var pbrFragmentDeclaration: {
  58516. name: string;
  58517. shader: string;
  58518. };
  58519. }
  58520. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58521. /** @hidden */
  58522. export var pbrUboDeclaration: {
  58523. name: string;
  58524. shader: string;
  58525. };
  58526. }
  58527. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58528. /** @hidden */
  58529. export var pbrFragmentExtraDeclaration: {
  58530. name: string;
  58531. shader: string;
  58532. };
  58533. }
  58534. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58535. /** @hidden */
  58536. export var pbrFragmentSamplersDeclaration: {
  58537. name: string;
  58538. shader: string;
  58539. };
  58540. }
  58541. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58542. /** @hidden */
  58543. export var importanceSampling: {
  58544. name: string;
  58545. shader: string;
  58546. };
  58547. }
  58548. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58549. /** @hidden */
  58550. export var pbrHelperFunctions: {
  58551. name: string;
  58552. shader: string;
  58553. };
  58554. }
  58555. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58556. /** @hidden */
  58557. export var harmonicsFunctions: {
  58558. name: string;
  58559. shader: string;
  58560. };
  58561. }
  58562. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58563. /** @hidden */
  58564. export var pbrDirectLightingSetupFunctions: {
  58565. name: string;
  58566. shader: string;
  58567. };
  58568. }
  58569. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58570. /** @hidden */
  58571. export var pbrDirectLightingFalloffFunctions: {
  58572. name: string;
  58573. shader: string;
  58574. };
  58575. }
  58576. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58577. /** @hidden */
  58578. export var pbrBRDFFunctions: {
  58579. name: string;
  58580. shader: string;
  58581. };
  58582. }
  58583. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58584. /** @hidden */
  58585. export var hdrFilteringFunctions: {
  58586. name: string;
  58587. shader: string;
  58588. };
  58589. }
  58590. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58591. /** @hidden */
  58592. export var pbrDirectLightingFunctions: {
  58593. name: string;
  58594. shader: string;
  58595. };
  58596. }
  58597. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58598. /** @hidden */
  58599. export var pbrIBLFunctions: {
  58600. name: string;
  58601. shader: string;
  58602. };
  58603. }
  58604. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58605. /** @hidden */
  58606. export var pbrBlockAlbedoOpacity: {
  58607. name: string;
  58608. shader: string;
  58609. };
  58610. }
  58611. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58612. /** @hidden */
  58613. export var pbrBlockReflectivity: {
  58614. name: string;
  58615. shader: string;
  58616. };
  58617. }
  58618. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58619. /** @hidden */
  58620. export var pbrBlockAmbientOcclusion: {
  58621. name: string;
  58622. shader: string;
  58623. };
  58624. }
  58625. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58626. /** @hidden */
  58627. export var pbrBlockAlphaFresnel: {
  58628. name: string;
  58629. shader: string;
  58630. };
  58631. }
  58632. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58633. /** @hidden */
  58634. export var pbrBlockAnisotropic: {
  58635. name: string;
  58636. shader: string;
  58637. };
  58638. }
  58639. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58640. /** @hidden */
  58641. export var pbrBlockReflection: {
  58642. name: string;
  58643. shader: string;
  58644. };
  58645. }
  58646. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58647. /** @hidden */
  58648. export var pbrBlockSheen: {
  58649. name: string;
  58650. shader: string;
  58651. };
  58652. }
  58653. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58654. /** @hidden */
  58655. export var pbrBlockClearcoat: {
  58656. name: string;
  58657. shader: string;
  58658. };
  58659. }
  58660. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58661. /** @hidden */
  58662. export var pbrBlockSubSurface: {
  58663. name: string;
  58664. shader: string;
  58665. };
  58666. }
  58667. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58668. /** @hidden */
  58669. export var pbrBlockNormalGeometric: {
  58670. name: string;
  58671. shader: string;
  58672. };
  58673. }
  58674. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58675. /** @hidden */
  58676. export var pbrBlockNormalFinal: {
  58677. name: string;
  58678. shader: string;
  58679. };
  58680. }
  58681. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58682. /** @hidden */
  58683. export var pbrBlockLightmapInit: {
  58684. name: string;
  58685. shader: string;
  58686. };
  58687. }
  58688. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58689. /** @hidden */
  58690. export var pbrBlockGeometryInfo: {
  58691. name: string;
  58692. shader: string;
  58693. };
  58694. }
  58695. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58696. /** @hidden */
  58697. export var pbrBlockReflectance0: {
  58698. name: string;
  58699. shader: string;
  58700. };
  58701. }
  58702. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58703. /** @hidden */
  58704. export var pbrBlockReflectance: {
  58705. name: string;
  58706. shader: string;
  58707. };
  58708. }
  58709. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58710. /** @hidden */
  58711. export var pbrBlockDirectLighting: {
  58712. name: string;
  58713. shader: string;
  58714. };
  58715. }
  58716. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58717. /** @hidden */
  58718. export var pbrBlockFinalLitComponents: {
  58719. name: string;
  58720. shader: string;
  58721. };
  58722. }
  58723. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58724. /** @hidden */
  58725. export var pbrBlockFinalUnlitComponents: {
  58726. name: string;
  58727. shader: string;
  58728. };
  58729. }
  58730. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58731. /** @hidden */
  58732. export var pbrBlockFinalColorComposition: {
  58733. name: string;
  58734. shader: string;
  58735. };
  58736. }
  58737. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58738. /** @hidden */
  58739. export var pbrBlockImageProcessing: {
  58740. name: string;
  58741. shader: string;
  58742. };
  58743. }
  58744. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58745. /** @hidden */
  58746. export var pbrDebug: {
  58747. name: string;
  58748. shader: string;
  58749. };
  58750. }
  58751. declare module "babylonjs/Shaders/pbr.fragment" {
  58752. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58753. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58754. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58755. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58756. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58757. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58758. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58759. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58760. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58761. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58762. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58763. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58764. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58765. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58766. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58767. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58768. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58769. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58770. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58771. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58772. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58773. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58774. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58775. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58776. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58777. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58778. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58779. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58780. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58781. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58782. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58783. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58784. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58785. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58786. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58787. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58788. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58789. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58790. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58791. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58792. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58793. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58794. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58795. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58796. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58797. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58798. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58799. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58800. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58801. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58802. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58803. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58804. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58805. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58806. /** @hidden */
  58807. export var pbrPixelShader: {
  58808. name: string;
  58809. shader: string;
  58810. };
  58811. }
  58812. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58813. /** @hidden */
  58814. export var pbrVertexDeclaration: {
  58815. name: string;
  58816. shader: string;
  58817. };
  58818. }
  58819. declare module "babylonjs/Shaders/pbr.vertex" {
  58820. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58821. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58822. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58823. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58824. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58825. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58826. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58827. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58828. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58829. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58830. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58831. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58832. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58833. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58834. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58835. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58836. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58837. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58838. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58839. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58840. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58841. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58842. /** @hidden */
  58843. export var pbrVertexShader: {
  58844. name: string;
  58845. shader: string;
  58846. };
  58847. }
  58848. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58849. import { Nullable } from "babylonjs/types";
  58850. import { Scene } from "babylonjs/scene";
  58851. import { Matrix } from "babylonjs/Maths/math.vector";
  58852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58854. import { Mesh } from "babylonjs/Meshes/mesh";
  58855. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58856. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58857. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58858. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58859. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58860. import { Color3 } from "babylonjs/Maths/math.color";
  58861. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58862. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58863. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58864. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58866. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58867. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58868. import "babylonjs/Shaders/pbr.fragment";
  58869. import "babylonjs/Shaders/pbr.vertex";
  58870. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58871. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58872. /**
  58873. * Manages the defines for the PBR Material.
  58874. * @hidden
  58875. */
  58876. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58877. PBR: boolean;
  58878. NUM_SAMPLES: string;
  58879. REALTIME_FILTERING: boolean;
  58880. MAINUV1: boolean;
  58881. MAINUV2: boolean;
  58882. UV1: boolean;
  58883. UV2: boolean;
  58884. ALBEDO: boolean;
  58885. GAMMAALBEDO: boolean;
  58886. ALBEDODIRECTUV: number;
  58887. VERTEXCOLOR: boolean;
  58888. DETAIL: boolean;
  58889. DETAILDIRECTUV: number;
  58890. DETAIL_NORMALBLENDMETHOD: number;
  58891. AMBIENT: boolean;
  58892. AMBIENTDIRECTUV: number;
  58893. AMBIENTINGRAYSCALE: boolean;
  58894. OPACITY: boolean;
  58895. VERTEXALPHA: boolean;
  58896. OPACITYDIRECTUV: number;
  58897. OPACITYRGB: boolean;
  58898. ALPHATEST: boolean;
  58899. DEPTHPREPASS: boolean;
  58900. ALPHABLEND: boolean;
  58901. ALPHAFROMALBEDO: boolean;
  58902. ALPHATESTVALUE: string;
  58903. SPECULAROVERALPHA: boolean;
  58904. RADIANCEOVERALPHA: boolean;
  58905. ALPHAFRESNEL: boolean;
  58906. LINEARALPHAFRESNEL: boolean;
  58907. PREMULTIPLYALPHA: boolean;
  58908. EMISSIVE: boolean;
  58909. EMISSIVEDIRECTUV: number;
  58910. REFLECTIVITY: boolean;
  58911. REFLECTIVITYDIRECTUV: number;
  58912. SPECULARTERM: boolean;
  58913. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58914. MICROSURFACEAUTOMATIC: boolean;
  58915. LODBASEDMICROSFURACE: boolean;
  58916. MICROSURFACEMAP: boolean;
  58917. MICROSURFACEMAPDIRECTUV: number;
  58918. METALLICWORKFLOW: boolean;
  58919. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58920. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58921. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58922. AOSTOREINMETALMAPRED: boolean;
  58923. METALLIC_REFLECTANCE: boolean;
  58924. METALLIC_REFLECTANCEDIRECTUV: number;
  58925. ENVIRONMENTBRDF: boolean;
  58926. ENVIRONMENTBRDF_RGBD: boolean;
  58927. NORMAL: boolean;
  58928. TANGENT: boolean;
  58929. BUMP: boolean;
  58930. BUMPDIRECTUV: number;
  58931. OBJECTSPACE_NORMALMAP: boolean;
  58932. PARALLAX: boolean;
  58933. PARALLAXOCCLUSION: boolean;
  58934. NORMALXYSCALE: boolean;
  58935. LIGHTMAP: boolean;
  58936. LIGHTMAPDIRECTUV: number;
  58937. USELIGHTMAPASSHADOWMAP: boolean;
  58938. GAMMALIGHTMAP: boolean;
  58939. RGBDLIGHTMAP: boolean;
  58940. REFLECTION: boolean;
  58941. REFLECTIONMAP_3D: boolean;
  58942. REFLECTIONMAP_SPHERICAL: boolean;
  58943. REFLECTIONMAP_PLANAR: boolean;
  58944. REFLECTIONMAP_CUBIC: boolean;
  58945. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58946. REFLECTIONMAP_PROJECTION: boolean;
  58947. REFLECTIONMAP_SKYBOX: boolean;
  58948. REFLECTIONMAP_EXPLICIT: boolean;
  58949. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58950. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58951. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58952. INVERTCUBICMAP: boolean;
  58953. USESPHERICALFROMREFLECTIONMAP: boolean;
  58954. USEIRRADIANCEMAP: boolean;
  58955. SPHERICAL_HARMONICS: boolean;
  58956. USESPHERICALINVERTEX: boolean;
  58957. REFLECTIONMAP_OPPOSITEZ: boolean;
  58958. LODINREFLECTIONALPHA: boolean;
  58959. GAMMAREFLECTION: boolean;
  58960. RGBDREFLECTION: boolean;
  58961. LINEARSPECULARREFLECTION: boolean;
  58962. RADIANCEOCCLUSION: boolean;
  58963. HORIZONOCCLUSION: boolean;
  58964. INSTANCES: boolean;
  58965. THIN_INSTANCES: boolean;
  58966. PREPASS: boolean;
  58967. SCENE_MRT_COUNT: number;
  58968. NUM_BONE_INFLUENCERS: number;
  58969. BonesPerMesh: number;
  58970. BONETEXTURE: boolean;
  58971. NONUNIFORMSCALING: boolean;
  58972. MORPHTARGETS: boolean;
  58973. MORPHTARGETS_NORMAL: boolean;
  58974. MORPHTARGETS_TANGENT: boolean;
  58975. MORPHTARGETS_UV: boolean;
  58976. NUM_MORPH_INFLUENCERS: number;
  58977. IMAGEPROCESSING: boolean;
  58978. VIGNETTE: boolean;
  58979. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58980. VIGNETTEBLENDMODEOPAQUE: boolean;
  58981. TONEMAPPING: boolean;
  58982. TONEMAPPING_ACES: boolean;
  58983. CONTRAST: boolean;
  58984. COLORCURVES: boolean;
  58985. COLORGRADING: boolean;
  58986. COLORGRADING3D: boolean;
  58987. SAMPLER3DGREENDEPTH: boolean;
  58988. SAMPLER3DBGRMAP: boolean;
  58989. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58990. EXPOSURE: boolean;
  58991. MULTIVIEW: boolean;
  58992. USEPHYSICALLIGHTFALLOFF: boolean;
  58993. USEGLTFLIGHTFALLOFF: boolean;
  58994. TWOSIDEDLIGHTING: boolean;
  58995. SHADOWFLOAT: boolean;
  58996. CLIPPLANE: boolean;
  58997. CLIPPLANE2: boolean;
  58998. CLIPPLANE3: boolean;
  58999. CLIPPLANE4: boolean;
  59000. CLIPPLANE5: boolean;
  59001. CLIPPLANE6: boolean;
  59002. POINTSIZE: boolean;
  59003. FOG: boolean;
  59004. LOGARITHMICDEPTH: boolean;
  59005. FORCENORMALFORWARD: boolean;
  59006. SPECULARAA: boolean;
  59007. CLEARCOAT: boolean;
  59008. CLEARCOAT_DEFAULTIOR: boolean;
  59009. CLEARCOAT_TEXTURE: boolean;
  59010. CLEARCOAT_TEXTUREDIRECTUV: number;
  59011. CLEARCOAT_BUMP: boolean;
  59012. CLEARCOAT_BUMPDIRECTUV: number;
  59013. CLEARCOAT_TINT: boolean;
  59014. CLEARCOAT_TINT_TEXTURE: boolean;
  59015. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59016. ANISOTROPIC: boolean;
  59017. ANISOTROPIC_TEXTURE: boolean;
  59018. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59019. BRDF_V_HEIGHT_CORRELATED: boolean;
  59020. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59021. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59022. SHEEN: boolean;
  59023. SHEEN_TEXTURE: boolean;
  59024. SHEEN_TEXTUREDIRECTUV: number;
  59025. SHEEN_LINKWITHALBEDO: boolean;
  59026. SHEEN_ROUGHNESS: boolean;
  59027. SHEEN_ALBEDOSCALING: boolean;
  59028. SUBSURFACE: boolean;
  59029. SS_REFRACTION: boolean;
  59030. SS_TRANSLUCENCY: boolean;
  59031. SS_SCATTERING: boolean;
  59032. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59033. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59034. SS_REFRACTIONMAP_3D: boolean;
  59035. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59036. SS_LODINREFRACTIONALPHA: boolean;
  59037. SS_GAMMAREFRACTION: boolean;
  59038. SS_RGBDREFRACTION: boolean;
  59039. SS_LINEARSPECULARREFRACTION: boolean;
  59040. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59041. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59042. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59043. UNLIT: boolean;
  59044. DEBUGMODE: number;
  59045. /**
  59046. * Initializes the PBR Material defines.
  59047. */
  59048. constructor();
  59049. /**
  59050. * Resets the PBR Material defines.
  59051. */
  59052. reset(): void;
  59053. }
  59054. /**
  59055. * The Physically based material base class of BJS.
  59056. *
  59057. * This offers the main features of a standard PBR material.
  59058. * For more information, please refer to the documentation :
  59059. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59060. */
  59061. export abstract class PBRBaseMaterial extends PushMaterial {
  59062. /**
  59063. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59064. */
  59065. static readonly PBRMATERIAL_OPAQUE: number;
  59066. /**
  59067. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59068. */
  59069. static readonly PBRMATERIAL_ALPHATEST: number;
  59070. /**
  59071. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59072. */
  59073. static readonly PBRMATERIAL_ALPHABLEND: number;
  59074. /**
  59075. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59076. * They are also discarded below the alpha cutoff threshold to improve performances.
  59077. */
  59078. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59079. /**
  59080. * Defines the default value of how much AO map is occluding the analytical lights
  59081. * (point spot...).
  59082. */
  59083. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59084. /**
  59085. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59086. */
  59087. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59088. /**
  59089. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59090. * to enhance interoperability with other engines.
  59091. */
  59092. static readonly LIGHTFALLOFF_GLTF: number;
  59093. /**
  59094. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59095. * to enhance interoperability with other materials.
  59096. */
  59097. static readonly LIGHTFALLOFF_STANDARD: number;
  59098. /**
  59099. * Intensity of the direct lights e.g. the four lights available in your scene.
  59100. * This impacts both the direct diffuse and specular highlights.
  59101. */
  59102. protected _directIntensity: number;
  59103. /**
  59104. * Intensity of the emissive part of the material.
  59105. * This helps controlling the emissive effect without modifying the emissive color.
  59106. */
  59107. protected _emissiveIntensity: number;
  59108. /**
  59109. * Intensity of the environment e.g. how much the environment will light the object
  59110. * either through harmonics for rough material or through the refelction for shiny ones.
  59111. */
  59112. protected _environmentIntensity: number;
  59113. /**
  59114. * This is a special control allowing the reduction of the specular highlights coming from the
  59115. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59116. */
  59117. protected _specularIntensity: number;
  59118. /**
  59119. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59120. */
  59121. private _lightingInfos;
  59122. /**
  59123. * Debug Control allowing disabling the bump map on this material.
  59124. */
  59125. protected _disableBumpMap: boolean;
  59126. /**
  59127. * AKA Diffuse Texture in standard nomenclature.
  59128. */
  59129. protected _albedoTexture: Nullable<BaseTexture>;
  59130. /**
  59131. * AKA Occlusion Texture in other nomenclature.
  59132. */
  59133. protected _ambientTexture: Nullable<BaseTexture>;
  59134. /**
  59135. * AKA Occlusion Texture Intensity in other nomenclature.
  59136. */
  59137. protected _ambientTextureStrength: number;
  59138. /**
  59139. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59140. * 1 means it completely occludes it
  59141. * 0 mean it has no impact
  59142. */
  59143. protected _ambientTextureImpactOnAnalyticalLights: number;
  59144. /**
  59145. * Stores the alpha values in a texture.
  59146. */
  59147. protected _opacityTexture: Nullable<BaseTexture>;
  59148. /**
  59149. * Stores the reflection values in a texture.
  59150. */
  59151. protected _reflectionTexture: Nullable<BaseTexture>;
  59152. /**
  59153. * Stores the emissive values in a texture.
  59154. */
  59155. protected _emissiveTexture: Nullable<BaseTexture>;
  59156. /**
  59157. * AKA Specular texture in other nomenclature.
  59158. */
  59159. protected _reflectivityTexture: Nullable<BaseTexture>;
  59160. /**
  59161. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59162. */
  59163. protected _metallicTexture: Nullable<BaseTexture>;
  59164. /**
  59165. * Specifies the metallic scalar of the metallic/roughness workflow.
  59166. * Can also be used to scale the metalness values of the metallic texture.
  59167. */
  59168. protected _metallic: Nullable<number>;
  59169. /**
  59170. * Specifies the roughness scalar of the metallic/roughness workflow.
  59171. * Can also be used to scale the roughness values of the metallic texture.
  59172. */
  59173. protected _roughness: Nullable<number>;
  59174. /**
  59175. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59176. * By default the indexOfrefraction is used to compute F0;
  59177. *
  59178. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59179. *
  59180. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59181. * F90 = metallicReflectanceColor;
  59182. */
  59183. protected _metallicF0Factor: number;
  59184. /**
  59185. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59186. * By default the F90 is always 1;
  59187. *
  59188. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59189. *
  59190. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59191. * F90 = metallicReflectanceColor;
  59192. */
  59193. protected _metallicReflectanceColor: Color3;
  59194. /**
  59195. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59196. * This is multiply against the scalar values defined in the material.
  59197. */
  59198. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59199. /**
  59200. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59201. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59202. */
  59203. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59204. /**
  59205. * Stores surface normal data used to displace a mesh in a texture.
  59206. */
  59207. protected _bumpTexture: Nullable<BaseTexture>;
  59208. /**
  59209. * Stores the pre-calculated light information of a mesh in a texture.
  59210. */
  59211. protected _lightmapTexture: Nullable<BaseTexture>;
  59212. /**
  59213. * The color of a material in ambient lighting.
  59214. */
  59215. protected _ambientColor: Color3;
  59216. /**
  59217. * AKA Diffuse Color in other nomenclature.
  59218. */
  59219. protected _albedoColor: Color3;
  59220. /**
  59221. * AKA Specular Color in other nomenclature.
  59222. */
  59223. protected _reflectivityColor: Color3;
  59224. /**
  59225. * The color applied when light is reflected from a material.
  59226. */
  59227. protected _reflectionColor: Color3;
  59228. /**
  59229. * The color applied when light is emitted from a material.
  59230. */
  59231. protected _emissiveColor: Color3;
  59232. /**
  59233. * AKA Glossiness in other nomenclature.
  59234. */
  59235. protected _microSurface: number;
  59236. /**
  59237. * Specifies that the material will use the light map as a show map.
  59238. */
  59239. protected _useLightmapAsShadowmap: boolean;
  59240. /**
  59241. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59242. * makes the reflect vector face the model (under horizon).
  59243. */
  59244. protected _useHorizonOcclusion: boolean;
  59245. /**
  59246. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59247. * too much the area relying on ambient texture to define their ambient occlusion.
  59248. */
  59249. protected _useRadianceOcclusion: boolean;
  59250. /**
  59251. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59252. */
  59253. protected _useAlphaFromAlbedoTexture: boolean;
  59254. /**
  59255. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59256. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59257. */
  59258. protected _useSpecularOverAlpha: boolean;
  59259. /**
  59260. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59261. */
  59262. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59263. /**
  59264. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59265. */
  59266. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59267. /**
  59268. * Specifies if the metallic texture contains the roughness information in its green channel.
  59269. */
  59270. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59271. /**
  59272. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59273. */
  59274. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59275. /**
  59276. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59277. */
  59278. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59279. /**
  59280. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59281. */
  59282. protected _useAmbientInGrayScale: boolean;
  59283. /**
  59284. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59285. * The material will try to infer what glossiness each pixel should be.
  59286. */
  59287. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59288. /**
  59289. * Defines the falloff type used in this material.
  59290. * It by default is Physical.
  59291. */
  59292. protected _lightFalloff: number;
  59293. /**
  59294. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59295. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59296. */
  59297. protected _useRadianceOverAlpha: boolean;
  59298. /**
  59299. * Allows using an object space normal map (instead of tangent space).
  59300. */
  59301. protected _useObjectSpaceNormalMap: boolean;
  59302. /**
  59303. * Allows using the bump map in parallax mode.
  59304. */
  59305. protected _useParallax: boolean;
  59306. /**
  59307. * Allows using the bump map in parallax occlusion mode.
  59308. */
  59309. protected _useParallaxOcclusion: boolean;
  59310. /**
  59311. * Controls the scale bias of the parallax mode.
  59312. */
  59313. protected _parallaxScaleBias: number;
  59314. /**
  59315. * If sets to true, disables all the lights affecting the material.
  59316. */
  59317. protected _disableLighting: boolean;
  59318. /**
  59319. * Number of Simultaneous lights allowed on the material.
  59320. */
  59321. protected _maxSimultaneousLights: number;
  59322. /**
  59323. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59324. */
  59325. protected _invertNormalMapX: boolean;
  59326. /**
  59327. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59328. */
  59329. protected _invertNormalMapY: boolean;
  59330. /**
  59331. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59332. */
  59333. protected _twoSidedLighting: boolean;
  59334. /**
  59335. * Defines the alpha limits in alpha test mode.
  59336. */
  59337. protected _alphaCutOff: number;
  59338. /**
  59339. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59340. */
  59341. protected _forceAlphaTest: boolean;
  59342. /**
  59343. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59344. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59345. */
  59346. protected _useAlphaFresnel: boolean;
  59347. /**
  59348. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59349. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59350. */
  59351. protected _useLinearAlphaFresnel: boolean;
  59352. /**
  59353. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59354. * from cos thetav and roughness:
  59355. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59356. */
  59357. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59358. /**
  59359. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59360. */
  59361. protected _forceIrradianceInFragment: boolean;
  59362. private _realTimeFiltering;
  59363. /**
  59364. * Enables realtime filtering on the texture.
  59365. */
  59366. get realTimeFiltering(): boolean;
  59367. set realTimeFiltering(b: boolean);
  59368. private _realTimeFilteringQuality;
  59369. /**
  59370. * Quality switch for realtime filtering
  59371. */
  59372. get realTimeFilteringQuality(): number;
  59373. set realTimeFilteringQuality(n: number);
  59374. /**
  59375. * Can this material render to several textures at once
  59376. */
  59377. get canRenderToMRT(): boolean;
  59378. /**
  59379. * Force normal to face away from face.
  59380. */
  59381. protected _forceNormalForward: boolean;
  59382. /**
  59383. * Enables specular anti aliasing in the PBR shader.
  59384. * It will both interacts on the Geometry for analytical and IBL lighting.
  59385. * It also prefilter the roughness map based on the bump values.
  59386. */
  59387. protected _enableSpecularAntiAliasing: boolean;
  59388. /**
  59389. * Default configuration related to image processing available in the PBR Material.
  59390. */
  59391. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59392. /**
  59393. * Keep track of the image processing observer to allow dispose and replace.
  59394. */
  59395. private _imageProcessingObserver;
  59396. /**
  59397. * Attaches a new image processing configuration to the PBR Material.
  59398. * @param configuration
  59399. */
  59400. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59401. /**
  59402. * Stores the available render targets.
  59403. */
  59404. private _renderTargets;
  59405. /**
  59406. * Sets the global ambient color for the material used in lighting calculations.
  59407. */
  59408. private _globalAmbientColor;
  59409. /**
  59410. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59411. */
  59412. private _useLogarithmicDepth;
  59413. /**
  59414. * If set to true, no lighting calculations will be applied.
  59415. */
  59416. private _unlit;
  59417. private _debugMode;
  59418. /**
  59419. * @hidden
  59420. * This is reserved for the inspector.
  59421. * Defines the material debug mode.
  59422. * It helps seeing only some components of the material while troubleshooting.
  59423. */
  59424. debugMode: number;
  59425. /**
  59426. * @hidden
  59427. * This is reserved for the inspector.
  59428. * Specify from where on screen the debug mode should start.
  59429. * The value goes from -1 (full screen) to 1 (not visible)
  59430. * It helps with side by side comparison against the final render
  59431. * This defaults to -1
  59432. */
  59433. private debugLimit;
  59434. /**
  59435. * @hidden
  59436. * This is reserved for the inspector.
  59437. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59438. * You can use the factor to better multiply the final value.
  59439. */
  59440. private debugFactor;
  59441. /**
  59442. * Defines the clear coat layer parameters for the material.
  59443. */
  59444. readonly clearCoat: PBRClearCoatConfiguration;
  59445. /**
  59446. * Defines the anisotropic parameters for the material.
  59447. */
  59448. readonly anisotropy: PBRAnisotropicConfiguration;
  59449. /**
  59450. * Defines the BRDF parameters for the material.
  59451. */
  59452. readonly brdf: PBRBRDFConfiguration;
  59453. /**
  59454. * Defines the Sheen parameters for the material.
  59455. */
  59456. readonly sheen: PBRSheenConfiguration;
  59457. /**
  59458. * Defines the SubSurface parameters for the material.
  59459. */
  59460. readonly subSurface: PBRSubSurfaceConfiguration;
  59461. /**
  59462. * Defines the detail map parameters for the material.
  59463. */
  59464. readonly detailMap: DetailMapConfiguration;
  59465. protected _rebuildInParallel: boolean;
  59466. /**
  59467. * Instantiates a new PBRMaterial instance.
  59468. *
  59469. * @param name The material name
  59470. * @param scene The scene the material will be use in.
  59471. */
  59472. constructor(name: string, scene: Scene);
  59473. /**
  59474. * Gets a boolean indicating that current material needs to register RTT
  59475. */
  59476. get hasRenderTargetTextures(): boolean;
  59477. /**
  59478. * Gets the name of the material class.
  59479. */
  59480. getClassName(): string;
  59481. /**
  59482. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59483. */
  59484. get useLogarithmicDepth(): boolean;
  59485. /**
  59486. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59487. */
  59488. set useLogarithmicDepth(value: boolean);
  59489. /**
  59490. * Returns true if alpha blending should be disabled.
  59491. */
  59492. protected get _disableAlphaBlending(): boolean;
  59493. /**
  59494. * Specifies whether or not this material should be rendered in alpha blend mode.
  59495. */
  59496. needAlphaBlending(): boolean;
  59497. /**
  59498. * Specifies whether or not this material should be rendered in alpha test mode.
  59499. */
  59500. needAlphaTesting(): boolean;
  59501. /**
  59502. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59503. */
  59504. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59505. /**
  59506. * Gets the texture used for the alpha test.
  59507. */
  59508. getAlphaTestTexture(): Nullable<BaseTexture>;
  59509. /**
  59510. * Specifies that the submesh is ready to be used.
  59511. * @param mesh - BJS mesh.
  59512. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59513. * @param useInstances - Specifies that instances should be used.
  59514. * @returns - boolean indicating that the submesh is ready or not.
  59515. */
  59516. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59517. /**
  59518. * Specifies if the material uses metallic roughness workflow.
  59519. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59520. */
  59521. isMetallicWorkflow(): boolean;
  59522. private _prepareEffect;
  59523. private _prepareDefines;
  59524. /**
  59525. * Force shader compilation
  59526. */
  59527. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59528. /**
  59529. * Initializes the uniform buffer layout for the shader.
  59530. */
  59531. buildUniformLayout(): void;
  59532. /**
  59533. * Unbinds the material from the mesh
  59534. */
  59535. unbind(): void;
  59536. /**
  59537. * Binds the submesh data.
  59538. * @param world - The world matrix.
  59539. * @param mesh - The BJS mesh.
  59540. * @param subMesh - A submesh of the BJS mesh.
  59541. */
  59542. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59543. /**
  59544. * Returns the animatable textures.
  59545. * @returns - Array of animatable textures.
  59546. */
  59547. getAnimatables(): IAnimatable[];
  59548. /**
  59549. * Returns the texture used for reflections.
  59550. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59551. */
  59552. private _getReflectionTexture;
  59553. /**
  59554. * Returns an array of the actively used textures.
  59555. * @returns - Array of BaseTextures
  59556. */
  59557. getActiveTextures(): BaseTexture[];
  59558. /**
  59559. * Checks to see if a texture is used in the material.
  59560. * @param texture - Base texture to use.
  59561. * @returns - Boolean specifying if a texture is used in the material.
  59562. */
  59563. hasTexture(texture: BaseTexture): boolean;
  59564. /**
  59565. * Sets the required values to the prepass renderer.
  59566. * @param prePassRenderer defines the prepass renderer to setup
  59567. */
  59568. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59569. /**
  59570. * Disposes the resources of the material.
  59571. * @param forceDisposeEffect - Forces the disposal of effects.
  59572. * @param forceDisposeTextures - Forces the disposal of all textures.
  59573. */
  59574. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59575. }
  59576. }
  59577. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59578. import { Nullable } from "babylonjs/types";
  59579. import { Scene } from "babylonjs/scene";
  59580. import { Color3 } from "babylonjs/Maths/math.color";
  59581. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59582. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59584. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59585. /**
  59586. * The Physically based material of BJS.
  59587. *
  59588. * This offers the main features of a standard PBR material.
  59589. * For more information, please refer to the documentation :
  59590. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59591. */
  59592. export class PBRMaterial extends PBRBaseMaterial {
  59593. /**
  59594. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59595. */
  59596. static readonly PBRMATERIAL_OPAQUE: number;
  59597. /**
  59598. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59599. */
  59600. static readonly PBRMATERIAL_ALPHATEST: number;
  59601. /**
  59602. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59603. */
  59604. static readonly PBRMATERIAL_ALPHABLEND: number;
  59605. /**
  59606. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59607. * They are also discarded below the alpha cutoff threshold to improve performances.
  59608. */
  59609. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59610. /**
  59611. * Defines the default value of how much AO map is occluding the analytical lights
  59612. * (point spot...).
  59613. */
  59614. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59615. /**
  59616. * Intensity of the direct lights e.g. the four lights available in your scene.
  59617. * This impacts both the direct diffuse and specular highlights.
  59618. */
  59619. directIntensity: number;
  59620. /**
  59621. * Intensity of the emissive part of the material.
  59622. * This helps controlling the emissive effect without modifying the emissive color.
  59623. */
  59624. emissiveIntensity: number;
  59625. /**
  59626. * Intensity of the environment e.g. how much the environment will light the object
  59627. * either through harmonics for rough material or through the refelction for shiny ones.
  59628. */
  59629. environmentIntensity: number;
  59630. /**
  59631. * This is a special control allowing the reduction of the specular highlights coming from the
  59632. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59633. */
  59634. specularIntensity: number;
  59635. /**
  59636. * Debug Control allowing disabling the bump map on this material.
  59637. */
  59638. disableBumpMap: boolean;
  59639. /**
  59640. * AKA Diffuse Texture in standard nomenclature.
  59641. */
  59642. albedoTexture: BaseTexture;
  59643. /**
  59644. * AKA Occlusion Texture in other nomenclature.
  59645. */
  59646. ambientTexture: BaseTexture;
  59647. /**
  59648. * AKA Occlusion Texture Intensity in other nomenclature.
  59649. */
  59650. ambientTextureStrength: number;
  59651. /**
  59652. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59653. * 1 means it completely occludes it
  59654. * 0 mean it has no impact
  59655. */
  59656. ambientTextureImpactOnAnalyticalLights: number;
  59657. /**
  59658. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59659. */
  59660. opacityTexture: BaseTexture;
  59661. /**
  59662. * Stores the reflection values in a texture.
  59663. */
  59664. reflectionTexture: Nullable<BaseTexture>;
  59665. /**
  59666. * Stores the emissive values in a texture.
  59667. */
  59668. emissiveTexture: BaseTexture;
  59669. /**
  59670. * AKA Specular texture in other nomenclature.
  59671. */
  59672. reflectivityTexture: BaseTexture;
  59673. /**
  59674. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59675. */
  59676. metallicTexture: BaseTexture;
  59677. /**
  59678. * Specifies the metallic scalar of the metallic/roughness workflow.
  59679. * Can also be used to scale the metalness values of the metallic texture.
  59680. */
  59681. metallic: Nullable<number>;
  59682. /**
  59683. * Specifies the roughness scalar of the metallic/roughness workflow.
  59684. * Can also be used to scale the roughness values of the metallic texture.
  59685. */
  59686. roughness: Nullable<number>;
  59687. /**
  59688. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59689. * By default the indexOfrefraction is used to compute F0;
  59690. *
  59691. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59692. *
  59693. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59694. * F90 = metallicReflectanceColor;
  59695. */
  59696. metallicF0Factor: number;
  59697. /**
  59698. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59699. * By default the F90 is always 1;
  59700. *
  59701. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59702. *
  59703. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59704. * F90 = metallicReflectanceColor;
  59705. */
  59706. metallicReflectanceColor: Color3;
  59707. /**
  59708. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59709. * This is multiply against the scalar values defined in the material.
  59710. */
  59711. metallicReflectanceTexture: Nullable<BaseTexture>;
  59712. /**
  59713. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59714. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59715. */
  59716. microSurfaceTexture: BaseTexture;
  59717. /**
  59718. * Stores surface normal data used to displace a mesh in a texture.
  59719. */
  59720. bumpTexture: BaseTexture;
  59721. /**
  59722. * Stores the pre-calculated light information of a mesh in a texture.
  59723. */
  59724. lightmapTexture: BaseTexture;
  59725. /**
  59726. * Stores the refracted light information in a texture.
  59727. */
  59728. get refractionTexture(): Nullable<BaseTexture>;
  59729. set refractionTexture(value: Nullable<BaseTexture>);
  59730. /**
  59731. * The color of a material in ambient lighting.
  59732. */
  59733. ambientColor: Color3;
  59734. /**
  59735. * AKA Diffuse Color in other nomenclature.
  59736. */
  59737. albedoColor: Color3;
  59738. /**
  59739. * AKA Specular Color in other nomenclature.
  59740. */
  59741. reflectivityColor: Color3;
  59742. /**
  59743. * The color reflected from the material.
  59744. */
  59745. reflectionColor: Color3;
  59746. /**
  59747. * The color emitted from the material.
  59748. */
  59749. emissiveColor: Color3;
  59750. /**
  59751. * AKA Glossiness in other nomenclature.
  59752. */
  59753. microSurface: number;
  59754. /**
  59755. * Index of refraction of the material base layer.
  59756. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59757. *
  59758. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59759. *
  59760. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59761. */
  59762. get indexOfRefraction(): number;
  59763. set indexOfRefraction(value: number);
  59764. /**
  59765. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59766. */
  59767. get invertRefractionY(): boolean;
  59768. set invertRefractionY(value: boolean);
  59769. /**
  59770. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59771. * Materials half opaque for instance using refraction could benefit from this control.
  59772. */
  59773. get linkRefractionWithTransparency(): boolean;
  59774. set linkRefractionWithTransparency(value: boolean);
  59775. /**
  59776. * If true, the light map contains occlusion information instead of lighting info.
  59777. */
  59778. useLightmapAsShadowmap: boolean;
  59779. /**
  59780. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59781. */
  59782. useAlphaFromAlbedoTexture: boolean;
  59783. /**
  59784. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59785. */
  59786. forceAlphaTest: boolean;
  59787. /**
  59788. * Defines the alpha limits in alpha test mode.
  59789. */
  59790. alphaCutOff: number;
  59791. /**
  59792. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59793. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59794. */
  59795. useSpecularOverAlpha: boolean;
  59796. /**
  59797. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59798. */
  59799. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59800. /**
  59801. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59802. */
  59803. useRoughnessFromMetallicTextureAlpha: boolean;
  59804. /**
  59805. * Specifies if the metallic texture contains the roughness information in its green channel.
  59806. */
  59807. useRoughnessFromMetallicTextureGreen: boolean;
  59808. /**
  59809. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59810. */
  59811. useMetallnessFromMetallicTextureBlue: boolean;
  59812. /**
  59813. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59814. */
  59815. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59816. /**
  59817. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59818. */
  59819. useAmbientInGrayScale: boolean;
  59820. /**
  59821. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59822. * The material will try to infer what glossiness each pixel should be.
  59823. */
  59824. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59825. /**
  59826. * BJS is using an harcoded light falloff based on a manually sets up range.
  59827. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59828. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59829. */
  59830. get usePhysicalLightFalloff(): boolean;
  59831. /**
  59832. * BJS is using an harcoded light falloff based on a manually sets up range.
  59833. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59834. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59835. */
  59836. set usePhysicalLightFalloff(value: boolean);
  59837. /**
  59838. * In order to support the falloff compatibility with gltf, a special mode has been added
  59839. * to reproduce the gltf light falloff.
  59840. */
  59841. get useGLTFLightFalloff(): boolean;
  59842. /**
  59843. * In order to support the falloff compatibility with gltf, a special mode has been added
  59844. * to reproduce the gltf light falloff.
  59845. */
  59846. set useGLTFLightFalloff(value: boolean);
  59847. /**
  59848. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59849. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59850. */
  59851. useRadianceOverAlpha: boolean;
  59852. /**
  59853. * Allows using an object space normal map (instead of tangent space).
  59854. */
  59855. useObjectSpaceNormalMap: boolean;
  59856. /**
  59857. * Allows using the bump map in parallax mode.
  59858. */
  59859. useParallax: boolean;
  59860. /**
  59861. * Allows using the bump map in parallax occlusion mode.
  59862. */
  59863. useParallaxOcclusion: boolean;
  59864. /**
  59865. * Controls the scale bias of the parallax mode.
  59866. */
  59867. parallaxScaleBias: number;
  59868. /**
  59869. * If sets to true, disables all the lights affecting the material.
  59870. */
  59871. disableLighting: boolean;
  59872. /**
  59873. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59874. */
  59875. forceIrradianceInFragment: boolean;
  59876. /**
  59877. * Number of Simultaneous lights allowed on the material.
  59878. */
  59879. maxSimultaneousLights: number;
  59880. /**
  59881. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59882. */
  59883. invertNormalMapX: boolean;
  59884. /**
  59885. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59886. */
  59887. invertNormalMapY: boolean;
  59888. /**
  59889. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59890. */
  59891. twoSidedLighting: boolean;
  59892. /**
  59893. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59894. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59895. */
  59896. useAlphaFresnel: boolean;
  59897. /**
  59898. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59899. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59900. */
  59901. useLinearAlphaFresnel: boolean;
  59902. /**
  59903. * Let user defines the brdf lookup texture used for IBL.
  59904. * A default 8bit version is embedded but you could point at :
  59905. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59906. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59907. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59908. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59909. */
  59910. environmentBRDFTexture: Nullable<BaseTexture>;
  59911. /**
  59912. * Force normal to face away from face.
  59913. */
  59914. forceNormalForward: boolean;
  59915. /**
  59916. * Enables specular anti aliasing in the PBR shader.
  59917. * It will both interacts on the Geometry for analytical and IBL lighting.
  59918. * It also prefilter the roughness map based on the bump values.
  59919. */
  59920. enableSpecularAntiAliasing: boolean;
  59921. /**
  59922. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59923. * makes the reflect vector face the model (under horizon).
  59924. */
  59925. useHorizonOcclusion: boolean;
  59926. /**
  59927. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59928. * too much the area relying on ambient texture to define their ambient occlusion.
  59929. */
  59930. useRadianceOcclusion: boolean;
  59931. /**
  59932. * If set to true, no lighting calculations will be applied.
  59933. */
  59934. unlit: boolean;
  59935. /**
  59936. * Gets the image processing configuration used either in this material.
  59937. */
  59938. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59939. /**
  59940. * Sets the Default image processing configuration used either in the this material.
  59941. *
  59942. * If sets to null, the scene one is in use.
  59943. */
  59944. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59945. /**
  59946. * Gets wether the color curves effect is enabled.
  59947. */
  59948. get cameraColorCurvesEnabled(): boolean;
  59949. /**
  59950. * Sets wether the color curves effect is enabled.
  59951. */
  59952. set cameraColorCurvesEnabled(value: boolean);
  59953. /**
  59954. * Gets wether the color grading effect is enabled.
  59955. */
  59956. get cameraColorGradingEnabled(): boolean;
  59957. /**
  59958. * Gets wether the color grading effect is enabled.
  59959. */
  59960. set cameraColorGradingEnabled(value: boolean);
  59961. /**
  59962. * Gets wether tonemapping is enabled or not.
  59963. */
  59964. get cameraToneMappingEnabled(): boolean;
  59965. /**
  59966. * Sets wether tonemapping is enabled or not
  59967. */
  59968. set cameraToneMappingEnabled(value: boolean);
  59969. /**
  59970. * The camera exposure used on this material.
  59971. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59972. * This corresponds to a photographic exposure.
  59973. */
  59974. get cameraExposure(): number;
  59975. /**
  59976. * The camera exposure used on this material.
  59977. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59978. * This corresponds to a photographic exposure.
  59979. */
  59980. set cameraExposure(value: number);
  59981. /**
  59982. * Gets The camera contrast used on this material.
  59983. */
  59984. get cameraContrast(): number;
  59985. /**
  59986. * Sets The camera contrast used on this material.
  59987. */
  59988. set cameraContrast(value: number);
  59989. /**
  59990. * Gets the Color Grading 2D Lookup Texture.
  59991. */
  59992. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59993. /**
  59994. * Sets the Color Grading 2D Lookup Texture.
  59995. */
  59996. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59997. /**
  59998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60000. * 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;
  60001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60002. */
  60003. get cameraColorCurves(): Nullable<ColorCurves>;
  60004. /**
  60005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60007. * 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;
  60008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60009. */
  60010. set cameraColorCurves(value: Nullable<ColorCurves>);
  60011. /**
  60012. * Instantiates a new PBRMaterial instance.
  60013. *
  60014. * @param name The material name
  60015. * @param scene The scene the material will be use in.
  60016. */
  60017. constructor(name: string, scene: Scene);
  60018. /**
  60019. * Returns the name of this material class.
  60020. */
  60021. getClassName(): string;
  60022. /**
  60023. * Makes a duplicate of the current material.
  60024. * @param name - name to use for the new material.
  60025. */
  60026. clone(name: string): PBRMaterial;
  60027. /**
  60028. * Serializes this PBR Material.
  60029. * @returns - An object with the serialized material.
  60030. */
  60031. serialize(): any;
  60032. /**
  60033. * Parses a PBR Material from a serialized object.
  60034. * @param source - Serialized object.
  60035. * @param scene - BJS scene instance.
  60036. * @param rootUrl - url for the scene object
  60037. * @returns - PBRMaterial
  60038. */
  60039. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60040. }
  60041. }
  60042. declare module "babylonjs/Misc/dds" {
  60043. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60044. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60045. import { Nullable } from "babylonjs/types";
  60046. import { Scene } from "babylonjs/scene";
  60047. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60048. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60049. /**
  60050. * Direct draw surface info
  60051. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60052. */
  60053. export interface DDSInfo {
  60054. /**
  60055. * Width of the texture
  60056. */
  60057. width: number;
  60058. /**
  60059. * Width of the texture
  60060. */
  60061. height: number;
  60062. /**
  60063. * Number of Mipmaps for the texture
  60064. * @see https://en.wikipedia.org/wiki/Mipmap
  60065. */
  60066. mipmapCount: number;
  60067. /**
  60068. * If the textures format is a known fourCC format
  60069. * @see https://www.fourcc.org/
  60070. */
  60071. isFourCC: boolean;
  60072. /**
  60073. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60074. */
  60075. isRGB: boolean;
  60076. /**
  60077. * If the texture is a lumincance format
  60078. */
  60079. isLuminance: boolean;
  60080. /**
  60081. * If this is a cube texture
  60082. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60083. */
  60084. isCube: boolean;
  60085. /**
  60086. * If the texture is a compressed format eg. FOURCC_DXT1
  60087. */
  60088. isCompressed: boolean;
  60089. /**
  60090. * The dxgiFormat of the texture
  60091. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60092. */
  60093. dxgiFormat: number;
  60094. /**
  60095. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60096. */
  60097. textureType: number;
  60098. /**
  60099. * Sphericle polynomial created for the dds texture
  60100. */
  60101. sphericalPolynomial?: SphericalPolynomial;
  60102. }
  60103. /**
  60104. * Class used to provide DDS decompression tools
  60105. */
  60106. export class DDSTools {
  60107. /**
  60108. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60109. */
  60110. static StoreLODInAlphaChannel: boolean;
  60111. /**
  60112. * Gets DDS information from an array buffer
  60113. * @param data defines the array buffer view to read data from
  60114. * @returns the DDS information
  60115. */
  60116. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60117. private static _FloatView;
  60118. private static _Int32View;
  60119. private static _ToHalfFloat;
  60120. private static _FromHalfFloat;
  60121. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60122. private static _GetHalfFloatRGBAArrayBuffer;
  60123. private static _GetFloatRGBAArrayBuffer;
  60124. private static _GetFloatAsUIntRGBAArrayBuffer;
  60125. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60126. private static _GetRGBAArrayBuffer;
  60127. private static _ExtractLongWordOrder;
  60128. private static _GetRGBArrayBuffer;
  60129. private static _GetLuminanceArrayBuffer;
  60130. /**
  60131. * Uploads DDS Levels to a Babylon Texture
  60132. * @hidden
  60133. */
  60134. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60135. }
  60136. module "babylonjs/Engines/thinEngine" {
  60137. interface ThinEngine {
  60138. /**
  60139. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60140. * @param rootUrl defines the url where the file to load is located
  60141. * @param scene defines the current scene
  60142. * @param lodScale defines scale to apply to the mip map selection
  60143. * @param lodOffset defines offset to apply to the mip map selection
  60144. * @param onLoad defines an optional callback raised when the texture is loaded
  60145. * @param onError defines an optional callback raised if there is an issue to load the texture
  60146. * @param format defines the format of the data
  60147. * @param forcedExtension defines the extension to use to pick the right loader
  60148. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60149. * @returns the cube texture as an InternalTexture
  60150. */
  60151. 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;
  60152. }
  60153. }
  60154. }
  60155. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60156. import { Nullable } from "babylonjs/types";
  60157. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60158. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60159. /**
  60160. * Implementation of the DDS Texture Loader.
  60161. * @hidden
  60162. */
  60163. export class _DDSTextureLoader implements IInternalTextureLoader {
  60164. /**
  60165. * Defines wether the loader supports cascade loading the different faces.
  60166. */
  60167. readonly supportCascades: boolean;
  60168. /**
  60169. * This returns if the loader support the current file information.
  60170. * @param extension defines the file extension of the file being loaded
  60171. * @returns true if the loader can load the specified file
  60172. */
  60173. canLoad(extension: string): boolean;
  60174. /**
  60175. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60176. * @param data contains the texture data
  60177. * @param texture defines the BabylonJS internal texture
  60178. * @param createPolynomials will be true if polynomials have been requested
  60179. * @param onLoad defines the callback to trigger once the texture is ready
  60180. * @param onError defines the callback to trigger in case of error
  60181. */
  60182. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60183. /**
  60184. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60185. * @param data contains the texture data
  60186. * @param texture defines the BabylonJS internal texture
  60187. * @param callback defines the method to call once ready to upload
  60188. */
  60189. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60190. }
  60191. }
  60192. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60193. import { Nullable } from "babylonjs/types";
  60194. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60195. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60196. /**
  60197. * Implementation of the ENV Texture Loader.
  60198. * @hidden
  60199. */
  60200. export class _ENVTextureLoader implements IInternalTextureLoader {
  60201. /**
  60202. * Defines wether the loader supports cascade loading the different faces.
  60203. */
  60204. readonly supportCascades: boolean;
  60205. /**
  60206. * This returns if the loader support the current file information.
  60207. * @param extension defines the file extension of the file being loaded
  60208. * @returns true if the loader can load the specified file
  60209. */
  60210. canLoad(extension: string): boolean;
  60211. /**
  60212. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60213. * @param data contains the texture data
  60214. * @param texture defines the BabylonJS internal texture
  60215. * @param createPolynomials will be true if polynomials have been requested
  60216. * @param onLoad defines the callback to trigger once the texture is ready
  60217. * @param onError defines the callback to trigger in case of error
  60218. */
  60219. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60220. /**
  60221. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60222. * @param data contains the texture data
  60223. * @param texture defines the BabylonJS internal texture
  60224. * @param callback defines the method to call once ready to upload
  60225. */
  60226. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60227. }
  60228. }
  60229. declare module "babylonjs/Misc/khronosTextureContainer" {
  60230. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60231. /**
  60232. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60233. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60234. */
  60235. export class KhronosTextureContainer {
  60236. /** contents of the KTX container file */
  60237. data: ArrayBufferView;
  60238. private static HEADER_LEN;
  60239. private static COMPRESSED_2D;
  60240. private static COMPRESSED_3D;
  60241. private static TEX_2D;
  60242. private static TEX_3D;
  60243. /**
  60244. * Gets the openGL type
  60245. */
  60246. glType: number;
  60247. /**
  60248. * Gets the openGL type size
  60249. */
  60250. glTypeSize: number;
  60251. /**
  60252. * Gets the openGL format
  60253. */
  60254. glFormat: number;
  60255. /**
  60256. * Gets the openGL internal format
  60257. */
  60258. glInternalFormat: number;
  60259. /**
  60260. * Gets the base internal format
  60261. */
  60262. glBaseInternalFormat: number;
  60263. /**
  60264. * Gets image width in pixel
  60265. */
  60266. pixelWidth: number;
  60267. /**
  60268. * Gets image height in pixel
  60269. */
  60270. pixelHeight: number;
  60271. /**
  60272. * Gets image depth in pixels
  60273. */
  60274. pixelDepth: number;
  60275. /**
  60276. * Gets the number of array elements
  60277. */
  60278. numberOfArrayElements: number;
  60279. /**
  60280. * Gets the number of faces
  60281. */
  60282. numberOfFaces: number;
  60283. /**
  60284. * Gets the number of mipmap levels
  60285. */
  60286. numberOfMipmapLevels: number;
  60287. /**
  60288. * Gets the bytes of key value data
  60289. */
  60290. bytesOfKeyValueData: number;
  60291. /**
  60292. * Gets the load type
  60293. */
  60294. loadType: number;
  60295. /**
  60296. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60297. */
  60298. isInvalid: boolean;
  60299. /**
  60300. * Creates a new KhronosTextureContainer
  60301. * @param data contents of the KTX container file
  60302. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60303. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60304. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60305. */
  60306. constructor(
  60307. /** contents of the KTX container file */
  60308. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60309. /**
  60310. * Uploads KTX content to a Babylon Texture.
  60311. * It is assumed that the texture has already been created & is currently bound
  60312. * @hidden
  60313. */
  60314. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60315. private _upload2DCompressedLevels;
  60316. /**
  60317. * Checks if the given data starts with a KTX file identifier.
  60318. * @param data the data to check
  60319. * @returns true if the data is a KTX file or false otherwise
  60320. */
  60321. static IsValid(data: ArrayBufferView): boolean;
  60322. }
  60323. }
  60324. declare module "babylonjs/Misc/workerPool" {
  60325. import { IDisposable } from "babylonjs/scene";
  60326. /**
  60327. * Helper class to push actions to a pool of workers.
  60328. */
  60329. export class WorkerPool implements IDisposable {
  60330. private _workerInfos;
  60331. private _pendingActions;
  60332. /**
  60333. * Constructor
  60334. * @param workers Array of workers to use for actions
  60335. */
  60336. constructor(workers: Array<Worker>);
  60337. /**
  60338. * Terminates all workers and clears any pending actions.
  60339. */
  60340. dispose(): void;
  60341. /**
  60342. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60343. * pended until a worker has completed its action.
  60344. * @param action The action to perform. Call onComplete when the action is complete.
  60345. */
  60346. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60347. private _execute;
  60348. }
  60349. }
  60350. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60351. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60352. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60353. /**
  60354. * Class for loading KTX2 files
  60355. * @hidden
  60356. */
  60357. export class KhronosTextureContainer2 {
  60358. private static _WorkerPoolPromise?;
  60359. private static _Initialized;
  60360. private static _Ktx2Decoder;
  60361. /**
  60362. * URL to use when loading the KTX2 decoder module
  60363. */
  60364. static JSModuleURL: string;
  60365. /**
  60366. * Default number of workers used to handle data decoding
  60367. */
  60368. static DefaultNumWorkers: number;
  60369. private static GetDefaultNumWorkers;
  60370. private _engine;
  60371. private static _CreateWorkerPool;
  60372. /**
  60373. * Constructor
  60374. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60375. */
  60376. constructor(engine: ThinEngine, numWorkers?: number);
  60377. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60378. /**
  60379. * Stop all async operations and release resources.
  60380. */
  60381. dispose(): void;
  60382. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60383. /**
  60384. * Checks if the given data starts with a KTX2 file identifier.
  60385. * @param data the data to check
  60386. * @returns true if the data is a KTX2 file or false otherwise
  60387. */
  60388. static IsValid(data: ArrayBufferView): boolean;
  60389. }
  60390. export function workerFunc(): void;
  60391. }
  60392. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60393. import { Nullable } from "babylonjs/types";
  60394. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60395. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60396. /**
  60397. * Implementation of the KTX Texture Loader.
  60398. * @hidden
  60399. */
  60400. export class _KTXTextureLoader implements IInternalTextureLoader {
  60401. /**
  60402. * Defines wether the loader supports cascade loading the different faces.
  60403. */
  60404. readonly supportCascades: boolean;
  60405. /**
  60406. * This returns if the loader support the current file information.
  60407. * @param extension defines the file extension of the file being loaded
  60408. * @param mimeType defines the optional mime type of the file being loaded
  60409. * @returns true if the loader can load the specified file
  60410. */
  60411. canLoad(extension: string, mimeType?: string): boolean;
  60412. /**
  60413. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60414. * @param data contains the texture data
  60415. * @param texture defines the BabylonJS internal texture
  60416. * @param createPolynomials will be true if polynomials have been requested
  60417. * @param onLoad defines the callback to trigger once the texture is ready
  60418. * @param onError defines the callback to trigger in case of error
  60419. */
  60420. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60421. /**
  60422. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60423. * @param data contains the texture data
  60424. * @param texture defines the BabylonJS internal texture
  60425. * @param callback defines the method to call once ready to upload
  60426. */
  60427. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60428. }
  60429. }
  60430. declare module "babylonjs/Helpers/sceneHelpers" {
  60431. import { Nullable } from "babylonjs/types";
  60432. import { Mesh } from "babylonjs/Meshes/mesh";
  60433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60434. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60435. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60436. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60437. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60438. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60439. import "babylonjs/Meshes/Builders/boxBuilder";
  60440. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60441. /** @hidden */
  60442. export var _forceSceneHelpersToBundle: boolean;
  60443. module "babylonjs/scene" {
  60444. interface Scene {
  60445. /**
  60446. * Creates a default light for the scene.
  60447. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60448. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60449. */
  60450. createDefaultLight(replace?: boolean): void;
  60451. /**
  60452. * Creates a default camera for the scene.
  60453. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60454. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60455. * @param replace has default false, when true replaces the active camera in the scene
  60456. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60457. */
  60458. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60459. /**
  60460. * Creates a default camera and a default light.
  60461. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60462. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60463. * @param replace has the default false, when true replaces the active camera/light in the scene
  60464. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60465. */
  60466. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60467. /**
  60468. * Creates a new sky box
  60469. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60470. * @param environmentTexture defines the texture to use as environment texture
  60471. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60472. * @param scale defines the overall scale of the skybox
  60473. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60474. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60475. * @returns a new mesh holding the sky box
  60476. */
  60477. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60478. /**
  60479. * Creates a new environment
  60480. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60481. * @param options defines the options you can use to configure the environment
  60482. * @returns the new EnvironmentHelper
  60483. */
  60484. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60485. /**
  60486. * Creates a new VREXperienceHelper
  60487. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60488. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60489. * @returns a new VREXperienceHelper
  60490. */
  60491. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60492. /**
  60493. * Creates a new WebXRDefaultExperience
  60494. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60495. * @param options experience options
  60496. * @returns a promise for a new WebXRDefaultExperience
  60497. */
  60498. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60499. }
  60500. }
  60501. }
  60502. declare module "babylonjs/Helpers/videoDome" {
  60503. import { Scene } from "babylonjs/scene";
  60504. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60505. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60506. /**
  60507. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60508. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60509. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60510. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60511. */
  60512. export class VideoDome extends TextureDome<VideoTexture> {
  60513. /**
  60514. * Define the video source as a Monoscopic panoramic 360 video.
  60515. */
  60516. static readonly MODE_MONOSCOPIC: number;
  60517. /**
  60518. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60519. */
  60520. static readonly MODE_TOPBOTTOM: number;
  60521. /**
  60522. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60523. */
  60524. static readonly MODE_SIDEBYSIDE: number;
  60525. /**
  60526. * Get the video texture associated with this video dome
  60527. */
  60528. get videoTexture(): VideoTexture;
  60529. /**
  60530. * Get the video mode of this dome
  60531. */
  60532. get videoMode(): number;
  60533. /**
  60534. * Set the video mode of this dome.
  60535. * @see textureMode
  60536. */
  60537. set videoMode(value: number);
  60538. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60539. }
  60540. }
  60541. declare module "babylonjs/Helpers/index" {
  60542. export * from "babylonjs/Helpers/environmentHelper";
  60543. export * from "babylonjs/Helpers/photoDome";
  60544. export * from "babylonjs/Helpers/sceneHelpers";
  60545. export * from "babylonjs/Helpers/videoDome";
  60546. }
  60547. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60548. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60549. import { IDisposable } from "babylonjs/scene";
  60550. import { Engine } from "babylonjs/Engines/engine";
  60551. /**
  60552. * This class can be used to get instrumentation data from a Babylon engine
  60553. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60554. */
  60555. export class EngineInstrumentation implements IDisposable {
  60556. /**
  60557. * Define the instrumented engine.
  60558. */
  60559. engine: Engine;
  60560. private _captureGPUFrameTime;
  60561. private _gpuFrameTimeToken;
  60562. private _gpuFrameTime;
  60563. private _captureShaderCompilationTime;
  60564. private _shaderCompilationTime;
  60565. private _onBeginFrameObserver;
  60566. private _onEndFrameObserver;
  60567. private _onBeforeShaderCompilationObserver;
  60568. private _onAfterShaderCompilationObserver;
  60569. /**
  60570. * Gets the perf counter used for GPU frame time
  60571. */
  60572. get gpuFrameTimeCounter(): PerfCounter;
  60573. /**
  60574. * Gets the GPU frame time capture status
  60575. */
  60576. get captureGPUFrameTime(): boolean;
  60577. /**
  60578. * Enable or disable the GPU frame time capture
  60579. */
  60580. set captureGPUFrameTime(value: boolean);
  60581. /**
  60582. * Gets the perf counter used for shader compilation time
  60583. */
  60584. get shaderCompilationTimeCounter(): PerfCounter;
  60585. /**
  60586. * Gets the shader compilation time capture status
  60587. */
  60588. get captureShaderCompilationTime(): boolean;
  60589. /**
  60590. * Enable or disable the shader compilation time capture
  60591. */
  60592. set captureShaderCompilationTime(value: boolean);
  60593. /**
  60594. * Instantiates a new engine instrumentation.
  60595. * This class can be used to get instrumentation data from a Babylon engine
  60596. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60597. * @param engine Defines the engine to instrument
  60598. */
  60599. constructor(
  60600. /**
  60601. * Define the instrumented engine.
  60602. */
  60603. engine: Engine);
  60604. /**
  60605. * Dispose and release associated resources.
  60606. */
  60607. dispose(): void;
  60608. }
  60609. }
  60610. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60611. import { Scene, IDisposable } from "babylonjs/scene";
  60612. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60613. /**
  60614. * This class can be used to get instrumentation data from a Babylon engine
  60615. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60616. */
  60617. export class SceneInstrumentation implements IDisposable {
  60618. /**
  60619. * Defines the scene to instrument
  60620. */
  60621. scene: Scene;
  60622. private _captureActiveMeshesEvaluationTime;
  60623. private _activeMeshesEvaluationTime;
  60624. private _captureRenderTargetsRenderTime;
  60625. private _renderTargetsRenderTime;
  60626. private _captureFrameTime;
  60627. private _frameTime;
  60628. private _captureRenderTime;
  60629. private _renderTime;
  60630. private _captureInterFrameTime;
  60631. private _interFrameTime;
  60632. private _captureParticlesRenderTime;
  60633. private _particlesRenderTime;
  60634. private _captureSpritesRenderTime;
  60635. private _spritesRenderTime;
  60636. private _capturePhysicsTime;
  60637. private _physicsTime;
  60638. private _captureAnimationsTime;
  60639. private _animationsTime;
  60640. private _captureCameraRenderTime;
  60641. private _cameraRenderTime;
  60642. private _onBeforeActiveMeshesEvaluationObserver;
  60643. private _onAfterActiveMeshesEvaluationObserver;
  60644. private _onBeforeRenderTargetsRenderObserver;
  60645. private _onAfterRenderTargetsRenderObserver;
  60646. private _onAfterRenderObserver;
  60647. private _onBeforeDrawPhaseObserver;
  60648. private _onAfterDrawPhaseObserver;
  60649. private _onBeforeAnimationsObserver;
  60650. private _onBeforeParticlesRenderingObserver;
  60651. private _onAfterParticlesRenderingObserver;
  60652. private _onBeforeSpritesRenderingObserver;
  60653. private _onAfterSpritesRenderingObserver;
  60654. private _onBeforePhysicsObserver;
  60655. private _onAfterPhysicsObserver;
  60656. private _onAfterAnimationsObserver;
  60657. private _onBeforeCameraRenderObserver;
  60658. private _onAfterCameraRenderObserver;
  60659. /**
  60660. * Gets the perf counter used for active meshes evaluation time
  60661. */
  60662. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60663. /**
  60664. * Gets the active meshes evaluation time capture status
  60665. */
  60666. get captureActiveMeshesEvaluationTime(): boolean;
  60667. /**
  60668. * Enable or disable the active meshes evaluation time capture
  60669. */
  60670. set captureActiveMeshesEvaluationTime(value: boolean);
  60671. /**
  60672. * Gets the perf counter used for render targets render time
  60673. */
  60674. get renderTargetsRenderTimeCounter(): PerfCounter;
  60675. /**
  60676. * Gets the render targets render time capture status
  60677. */
  60678. get captureRenderTargetsRenderTime(): boolean;
  60679. /**
  60680. * Enable or disable the render targets render time capture
  60681. */
  60682. set captureRenderTargetsRenderTime(value: boolean);
  60683. /**
  60684. * Gets the perf counter used for particles render time
  60685. */
  60686. get particlesRenderTimeCounter(): PerfCounter;
  60687. /**
  60688. * Gets the particles render time capture status
  60689. */
  60690. get captureParticlesRenderTime(): boolean;
  60691. /**
  60692. * Enable or disable the particles render time capture
  60693. */
  60694. set captureParticlesRenderTime(value: boolean);
  60695. /**
  60696. * Gets the perf counter used for sprites render time
  60697. */
  60698. get spritesRenderTimeCounter(): PerfCounter;
  60699. /**
  60700. * Gets the sprites render time capture status
  60701. */
  60702. get captureSpritesRenderTime(): boolean;
  60703. /**
  60704. * Enable or disable the sprites render time capture
  60705. */
  60706. set captureSpritesRenderTime(value: boolean);
  60707. /**
  60708. * Gets the perf counter used for physics time
  60709. */
  60710. get physicsTimeCounter(): PerfCounter;
  60711. /**
  60712. * Gets the physics time capture status
  60713. */
  60714. get capturePhysicsTime(): boolean;
  60715. /**
  60716. * Enable or disable the physics time capture
  60717. */
  60718. set capturePhysicsTime(value: boolean);
  60719. /**
  60720. * Gets the perf counter used for animations time
  60721. */
  60722. get animationsTimeCounter(): PerfCounter;
  60723. /**
  60724. * Gets the animations time capture status
  60725. */
  60726. get captureAnimationsTime(): boolean;
  60727. /**
  60728. * Enable or disable the animations time capture
  60729. */
  60730. set captureAnimationsTime(value: boolean);
  60731. /**
  60732. * Gets the perf counter used for frame time capture
  60733. */
  60734. get frameTimeCounter(): PerfCounter;
  60735. /**
  60736. * Gets the frame time capture status
  60737. */
  60738. get captureFrameTime(): boolean;
  60739. /**
  60740. * Enable or disable the frame time capture
  60741. */
  60742. set captureFrameTime(value: boolean);
  60743. /**
  60744. * Gets the perf counter used for inter-frames time capture
  60745. */
  60746. get interFrameTimeCounter(): PerfCounter;
  60747. /**
  60748. * Gets the inter-frames time capture status
  60749. */
  60750. get captureInterFrameTime(): boolean;
  60751. /**
  60752. * Enable or disable the inter-frames time capture
  60753. */
  60754. set captureInterFrameTime(value: boolean);
  60755. /**
  60756. * Gets the perf counter used for render time capture
  60757. */
  60758. get renderTimeCounter(): PerfCounter;
  60759. /**
  60760. * Gets the render time capture status
  60761. */
  60762. get captureRenderTime(): boolean;
  60763. /**
  60764. * Enable or disable the render time capture
  60765. */
  60766. set captureRenderTime(value: boolean);
  60767. /**
  60768. * Gets the perf counter used for camera render time capture
  60769. */
  60770. get cameraRenderTimeCounter(): PerfCounter;
  60771. /**
  60772. * Gets the camera render time capture status
  60773. */
  60774. get captureCameraRenderTime(): boolean;
  60775. /**
  60776. * Enable or disable the camera render time capture
  60777. */
  60778. set captureCameraRenderTime(value: boolean);
  60779. /**
  60780. * Gets the perf counter used for draw calls
  60781. */
  60782. get drawCallsCounter(): PerfCounter;
  60783. /**
  60784. * Instantiates a new scene instrumentation.
  60785. * This class can be used to get instrumentation data from a Babylon engine
  60786. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60787. * @param scene Defines the scene to instrument
  60788. */
  60789. constructor(
  60790. /**
  60791. * Defines the scene to instrument
  60792. */
  60793. scene: Scene);
  60794. /**
  60795. * Dispose and release associated resources.
  60796. */
  60797. dispose(): void;
  60798. }
  60799. }
  60800. declare module "babylonjs/Instrumentation/index" {
  60801. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60802. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60803. export * from "babylonjs/Instrumentation/timeToken";
  60804. }
  60805. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60806. /** @hidden */
  60807. export var glowMapGenerationPixelShader: {
  60808. name: string;
  60809. shader: string;
  60810. };
  60811. }
  60812. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60813. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60816. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60818. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60819. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60820. /** @hidden */
  60821. export var glowMapGenerationVertexShader: {
  60822. name: string;
  60823. shader: string;
  60824. };
  60825. }
  60826. declare module "babylonjs/Layers/effectLayer" {
  60827. import { Observable } from "babylonjs/Misc/observable";
  60828. import { Nullable } from "babylonjs/types";
  60829. import { Camera } from "babylonjs/Cameras/camera";
  60830. import { Scene } from "babylonjs/scene";
  60831. import { ISize } from "babylonjs/Maths/math.size";
  60832. import { Color4 } from "babylonjs/Maths/math.color";
  60833. import { Engine } from "babylonjs/Engines/engine";
  60834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60836. import { Mesh } from "babylonjs/Meshes/mesh";
  60837. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60839. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60840. import { Effect } from "babylonjs/Materials/effect";
  60841. import { Material } from "babylonjs/Materials/material";
  60842. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60843. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60844. /**
  60845. * Effect layer options. This helps customizing the behaviour
  60846. * of the effect layer.
  60847. */
  60848. export interface IEffectLayerOptions {
  60849. /**
  60850. * Multiplication factor apply to the canvas size to compute the render target size
  60851. * used to generated the objects (the smaller the faster).
  60852. */
  60853. mainTextureRatio: number;
  60854. /**
  60855. * Enforces a fixed size texture to ensure effect stability across devices.
  60856. */
  60857. mainTextureFixedSize?: number;
  60858. /**
  60859. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60860. */
  60861. alphaBlendingMode: number;
  60862. /**
  60863. * The camera attached to the layer.
  60864. */
  60865. camera: Nullable<Camera>;
  60866. /**
  60867. * The rendering group to draw the layer in.
  60868. */
  60869. renderingGroupId: number;
  60870. }
  60871. /**
  60872. * The effect layer Helps adding post process effect blended with the main pass.
  60873. *
  60874. * This can be for instance use to generate glow or higlight effects on the scene.
  60875. *
  60876. * The effect layer class can not be used directly and is intented to inherited from to be
  60877. * customized per effects.
  60878. */
  60879. export abstract class EffectLayer {
  60880. private _vertexBuffers;
  60881. private _indexBuffer;
  60882. private _cachedDefines;
  60883. private _effectLayerMapGenerationEffect;
  60884. private _effectLayerOptions;
  60885. private _mergeEffect;
  60886. protected _scene: Scene;
  60887. protected _engine: Engine;
  60888. protected _maxSize: number;
  60889. protected _mainTextureDesiredSize: ISize;
  60890. protected _mainTexture: RenderTargetTexture;
  60891. protected _shouldRender: boolean;
  60892. protected _postProcesses: PostProcess[];
  60893. protected _textures: BaseTexture[];
  60894. protected _emissiveTextureAndColor: {
  60895. texture: Nullable<BaseTexture>;
  60896. color: Color4;
  60897. };
  60898. /**
  60899. * The name of the layer
  60900. */
  60901. name: string;
  60902. /**
  60903. * The clear color of the texture used to generate the glow map.
  60904. */
  60905. neutralColor: Color4;
  60906. /**
  60907. * Specifies whether the highlight layer is enabled or not.
  60908. */
  60909. isEnabled: boolean;
  60910. /**
  60911. * Gets the camera attached to the layer.
  60912. */
  60913. get camera(): Nullable<Camera>;
  60914. /**
  60915. * Gets the rendering group id the layer should render in.
  60916. */
  60917. get renderingGroupId(): number;
  60918. set renderingGroupId(renderingGroupId: number);
  60919. /**
  60920. * An event triggered when the effect layer has been disposed.
  60921. */
  60922. onDisposeObservable: Observable<EffectLayer>;
  60923. /**
  60924. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60925. */
  60926. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60927. /**
  60928. * An event triggered when the generated texture is being merged in the scene.
  60929. */
  60930. onBeforeComposeObservable: Observable<EffectLayer>;
  60931. /**
  60932. * An event triggered when the mesh is rendered into the effect render target.
  60933. */
  60934. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60935. /**
  60936. * An event triggered after the mesh has been rendered into the effect render target.
  60937. */
  60938. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60939. /**
  60940. * An event triggered when the generated texture has been merged in the scene.
  60941. */
  60942. onAfterComposeObservable: Observable<EffectLayer>;
  60943. /**
  60944. * An event triggered when the efffect layer changes its size.
  60945. */
  60946. onSizeChangedObservable: Observable<EffectLayer>;
  60947. /** @hidden */
  60948. static _SceneComponentInitialization: (scene: Scene) => void;
  60949. /**
  60950. * Instantiates a new effect Layer and references it in the scene.
  60951. * @param name The name of the layer
  60952. * @param scene The scene to use the layer in
  60953. */
  60954. constructor(
  60955. /** The Friendly of the effect in the scene */
  60956. name: string, scene: Scene);
  60957. /**
  60958. * Get the effect name of the layer.
  60959. * @return The effect name
  60960. */
  60961. abstract getEffectName(): string;
  60962. /**
  60963. * Checks for the readiness of the element composing the layer.
  60964. * @param subMesh the mesh to check for
  60965. * @param useInstances specify whether or not to use instances to render the mesh
  60966. * @return true if ready otherwise, false
  60967. */
  60968. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60969. /**
  60970. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60971. * @returns true if the effect requires stencil during the main canvas render pass.
  60972. */
  60973. abstract needStencil(): boolean;
  60974. /**
  60975. * Create the merge effect. This is the shader use to blit the information back
  60976. * to the main canvas at the end of the scene rendering.
  60977. * @returns The effect containing the shader used to merge the effect on the main canvas
  60978. */
  60979. protected abstract _createMergeEffect(): Effect;
  60980. /**
  60981. * Creates the render target textures and post processes used in the effect layer.
  60982. */
  60983. protected abstract _createTextureAndPostProcesses(): void;
  60984. /**
  60985. * Implementation specific of rendering the generating effect on the main canvas.
  60986. * @param effect The effect used to render through
  60987. */
  60988. protected abstract _internalRender(effect: Effect): void;
  60989. /**
  60990. * Sets the required values for both the emissive texture and and the main color.
  60991. */
  60992. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60993. /**
  60994. * Free any resources and references associated to a mesh.
  60995. * Internal use
  60996. * @param mesh The mesh to free.
  60997. */
  60998. abstract _disposeMesh(mesh: Mesh): void;
  60999. /**
  61000. * Serializes this layer (Glow or Highlight for example)
  61001. * @returns a serialized layer object
  61002. */
  61003. abstract serialize?(): any;
  61004. /**
  61005. * Initializes the effect layer with the required options.
  61006. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61007. */
  61008. protected _init(options: Partial<IEffectLayerOptions>): void;
  61009. /**
  61010. * Generates the index buffer of the full screen quad blending to the main canvas.
  61011. */
  61012. private _generateIndexBuffer;
  61013. /**
  61014. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61015. */
  61016. private _generateVertexBuffer;
  61017. /**
  61018. * Sets the main texture desired size which is the closest power of two
  61019. * of the engine canvas size.
  61020. */
  61021. private _setMainTextureSize;
  61022. /**
  61023. * Creates the main texture for the effect layer.
  61024. */
  61025. protected _createMainTexture(): void;
  61026. /**
  61027. * Adds specific effects defines.
  61028. * @param defines The defines to add specifics to.
  61029. */
  61030. protected _addCustomEffectDefines(defines: string[]): void;
  61031. /**
  61032. * Checks for the readiness of the element composing the layer.
  61033. * @param subMesh the mesh to check for
  61034. * @param useInstances specify whether or not to use instances to render the mesh
  61035. * @param emissiveTexture the associated emissive texture used to generate the glow
  61036. * @return true if ready otherwise, false
  61037. */
  61038. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61039. /**
  61040. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61041. */
  61042. render(): void;
  61043. /**
  61044. * Determine if a given mesh will be used in the current effect.
  61045. * @param mesh mesh to test
  61046. * @returns true if the mesh will be used
  61047. */
  61048. hasMesh(mesh: AbstractMesh): boolean;
  61049. /**
  61050. * Returns true if the layer contains information to display, otherwise false.
  61051. * @returns true if the glow layer should be rendered
  61052. */
  61053. shouldRender(): boolean;
  61054. /**
  61055. * Returns true if the mesh should render, otherwise false.
  61056. * @param mesh The mesh to render
  61057. * @returns true if it should render otherwise false
  61058. */
  61059. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61060. /**
  61061. * Returns true if the mesh can be rendered, otherwise false.
  61062. * @param mesh The mesh to render
  61063. * @param material The material used on the mesh
  61064. * @returns true if it can be rendered otherwise false
  61065. */
  61066. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61067. /**
  61068. * Returns true if the mesh should render, otherwise false.
  61069. * @param mesh The mesh to render
  61070. * @returns true if it should render otherwise false
  61071. */
  61072. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61073. /**
  61074. * Renders the submesh passed in parameter to the generation map.
  61075. */
  61076. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61077. /**
  61078. * Defines whether the current material of the mesh should be use to render the effect.
  61079. * @param mesh defines the current mesh to render
  61080. */
  61081. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61082. /**
  61083. * Rebuild the required buffers.
  61084. * @hidden Internal use only.
  61085. */
  61086. _rebuild(): void;
  61087. /**
  61088. * Dispose only the render target textures and post process.
  61089. */
  61090. private _disposeTextureAndPostProcesses;
  61091. /**
  61092. * Dispose the highlight layer and free resources.
  61093. */
  61094. dispose(): void;
  61095. /**
  61096. * Gets the class name of the effect layer
  61097. * @returns the string with the class name of the effect layer
  61098. */
  61099. getClassName(): string;
  61100. /**
  61101. * Creates an effect layer from parsed effect layer data
  61102. * @param parsedEffectLayer defines effect layer data
  61103. * @param scene defines the current scene
  61104. * @param rootUrl defines the root URL containing the effect layer information
  61105. * @returns a parsed effect Layer
  61106. */
  61107. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61108. }
  61109. }
  61110. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61111. import { Scene } from "babylonjs/scene";
  61112. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61113. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61114. import { AbstractScene } from "babylonjs/abstractScene";
  61115. module "babylonjs/abstractScene" {
  61116. interface AbstractScene {
  61117. /**
  61118. * The list of effect layers (highlights/glow) added to the scene
  61119. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61120. * @see https://doc.babylonjs.com/how_to/glow_layer
  61121. */
  61122. effectLayers: Array<EffectLayer>;
  61123. /**
  61124. * Removes the given effect layer from this scene.
  61125. * @param toRemove defines the effect layer to remove
  61126. * @returns the index of the removed effect layer
  61127. */
  61128. removeEffectLayer(toRemove: EffectLayer): number;
  61129. /**
  61130. * Adds the given effect layer to this scene
  61131. * @param newEffectLayer defines the effect layer to add
  61132. */
  61133. addEffectLayer(newEffectLayer: EffectLayer): void;
  61134. }
  61135. }
  61136. /**
  61137. * Defines the layer scene component responsible to manage any effect layers
  61138. * in a given scene.
  61139. */
  61140. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61141. /**
  61142. * The component name helpfull to identify the component in the list of scene components.
  61143. */
  61144. readonly name: string;
  61145. /**
  61146. * The scene the component belongs to.
  61147. */
  61148. scene: Scene;
  61149. private _engine;
  61150. private _renderEffects;
  61151. private _needStencil;
  61152. private _previousStencilState;
  61153. /**
  61154. * Creates a new instance of the component for the given scene
  61155. * @param scene Defines the scene to register the component in
  61156. */
  61157. constructor(scene: Scene);
  61158. /**
  61159. * Registers the component in a given scene
  61160. */
  61161. register(): void;
  61162. /**
  61163. * Rebuilds the elements related to this component in case of
  61164. * context lost for instance.
  61165. */
  61166. rebuild(): void;
  61167. /**
  61168. * Serializes the component data to the specified json object
  61169. * @param serializationObject The object to serialize to
  61170. */
  61171. serialize(serializationObject: any): void;
  61172. /**
  61173. * Adds all the elements from the container to the scene
  61174. * @param container the container holding the elements
  61175. */
  61176. addFromContainer(container: AbstractScene): void;
  61177. /**
  61178. * Removes all the elements in the container from the scene
  61179. * @param container contains the elements to remove
  61180. * @param dispose if the removed element should be disposed (default: false)
  61181. */
  61182. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61183. /**
  61184. * Disposes the component and the associated ressources.
  61185. */
  61186. dispose(): void;
  61187. private _isReadyForMesh;
  61188. private _renderMainTexture;
  61189. private _setStencil;
  61190. private _setStencilBack;
  61191. private _draw;
  61192. private _drawCamera;
  61193. private _drawRenderingGroup;
  61194. }
  61195. }
  61196. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61197. /** @hidden */
  61198. export var glowMapMergePixelShader: {
  61199. name: string;
  61200. shader: string;
  61201. };
  61202. }
  61203. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61204. /** @hidden */
  61205. export var glowMapMergeVertexShader: {
  61206. name: string;
  61207. shader: string;
  61208. };
  61209. }
  61210. declare module "babylonjs/Layers/glowLayer" {
  61211. import { Nullable } from "babylonjs/types";
  61212. import { Camera } from "babylonjs/Cameras/camera";
  61213. import { Scene } from "babylonjs/scene";
  61214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61216. import { Mesh } from "babylonjs/Meshes/mesh";
  61217. import { Texture } from "babylonjs/Materials/Textures/texture";
  61218. import { Effect } from "babylonjs/Materials/effect";
  61219. import { Material } from "babylonjs/Materials/material";
  61220. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61221. import { Color4 } from "babylonjs/Maths/math.color";
  61222. import "babylonjs/Shaders/glowMapMerge.fragment";
  61223. import "babylonjs/Shaders/glowMapMerge.vertex";
  61224. import "babylonjs/Layers/effectLayerSceneComponent";
  61225. module "babylonjs/abstractScene" {
  61226. interface AbstractScene {
  61227. /**
  61228. * Return a the first highlight layer of the scene with a given name.
  61229. * @param name The name of the highlight layer to look for.
  61230. * @return The highlight layer if found otherwise null.
  61231. */
  61232. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61233. }
  61234. }
  61235. /**
  61236. * Glow layer options. This helps customizing the behaviour
  61237. * of the glow layer.
  61238. */
  61239. export interface IGlowLayerOptions {
  61240. /**
  61241. * Multiplication factor apply to the canvas size to compute the render target size
  61242. * used to generated the glowing objects (the smaller the faster).
  61243. */
  61244. mainTextureRatio: number;
  61245. /**
  61246. * Enforces a fixed size texture to ensure resize independant blur.
  61247. */
  61248. mainTextureFixedSize?: number;
  61249. /**
  61250. * How big is the kernel of the blur texture.
  61251. */
  61252. blurKernelSize: number;
  61253. /**
  61254. * The camera attached to the layer.
  61255. */
  61256. camera: Nullable<Camera>;
  61257. /**
  61258. * Enable MSAA by chosing the number of samples.
  61259. */
  61260. mainTextureSamples?: number;
  61261. /**
  61262. * The rendering group to draw the layer in.
  61263. */
  61264. renderingGroupId: number;
  61265. }
  61266. /**
  61267. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61268. *
  61269. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61270. *
  61271. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61272. */
  61273. export class GlowLayer extends EffectLayer {
  61274. /**
  61275. * Effect Name of the layer.
  61276. */
  61277. static readonly EffectName: string;
  61278. /**
  61279. * The default blur kernel size used for the glow.
  61280. */
  61281. static DefaultBlurKernelSize: number;
  61282. /**
  61283. * The default texture size ratio used for the glow.
  61284. */
  61285. static DefaultTextureRatio: number;
  61286. /**
  61287. * Sets the kernel size of the blur.
  61288. */
  61289. set blurKernelSize(value: number);
  61290. /**
  61291. * Gets the kernel size of the blur.
  61292. */
  61293. get blurKernelSize(): number;
  61294. /**
  61295. * Sets the glow intensity.
  61296. */
  61297. set intensity(value: number);
  61298. /**
  61299. * Gets the glow intensity.
  61300. */
  61301. get intensity(): number;
  61302. private _options;
  61303. private _intensity;
  61304. private _horizontalBlurPostprocess1;
  61305. private _verticalBlurPostprocess1;
  61306. private _horizontalBlurPostprocess2;
  61307. private _verticalBlurPostprocess2;
  61308. private _blurTexture1;
  61309. private _blurTexture2;
  61310. private _postProcesses1;
  61311. private _postProcesses2;
  61312. private _includedOnlyMeshes;
  61313. private _excludedMeshes;
  61314. private _meshesUsingTheirOwnMaterials;
  61315. /**
  61316. * Callback used to let the user override the color selection on a per mesh basis
  61317. */
  61318. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61319. /**
  61320. * Callback used to let the user override the texture selection on a per mesh basis
  61321. */
  61322. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61323. /**
  61324. * Instantiates a new glow Layer and references it to the scene.
  61325. * @param name The name of the layer
  61326. * @param scene The scene to use the layer in
  61327. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61328. */
  61329. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61330. /**
  61331. * Get the effect name of the layer.
  61332. * @return The effect name
  61333. */
  61334. getEffectName(): string;
  61335. /**
  61336. * Create the merge effect. This is the shader use to blit the information back
  61337. * to the main canvas at the end of the scene rendering.
  61338. */
  61339. protected _createMergeEffect(): Effect;
  61340. /**
  61341. * Creates the render target textures and post processes used in the glow layer.
  61342. */
  61343. protected _createTextureAndPostProcesses(): void;
  61344. /**
  61345. * Checks for the readiness of the element composing the layer.
  61346. * @param subMesh the mesh to check for
  61347. * @param useInstances specify wether or not to use instances to render the mesh
  61348. * @param emissiveTexture the associated emissive texture used to generate the glow
  61349. * @return true if ready otherwise, false
  61350. */
  61351. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61352. /**
  61353. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61354. */
  61355. needStencil(): boolean;
  61356. /**
  61357. * Returns true if the mesh can be rendered, otherwise false.
  61358. * @param mesh The mesh to render
  61359. * @param material The material used on the mesh
  61360. * @returns true if it can be rendered otherwise false
  61361. */
  61362. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61363. /**
  61364. * Implementation specific of rendering the generating effect on the main canvas.
  61365. * @param effect The effect used to render through
  61366. */
  61367. protected _internalRender(effect: Effect): void;
  61368. /**
  61369. * Sets the required values for both the emissive texture and and the main color.
  61370. */
  61371. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61372. /**
  61373. * Returns true if the mesh should render, otherwise false.
  61374. * @param mesh The mesh to render
  61375. * @returns true if it should render otherwise false
  61376. */
  61377. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61378. /**
  61379. * Adds specific effects defines.
  61380. * @param defines The defines to add specifics to.
  61381. */
  61382. protected _addCustomEffectDefines(defines: string[]): void;
  61383. /**
  61384. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61385. * @param mesh The mesh to exclude from the glow layer
  61386. */
  61387. addExcludedMesh(mesh: Mesh): void;
  61388. /**
  61389. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61390. * @param mesh The mesh to remove
  61391. */
  61392. removeExcludedMesh(mesh: Mesh): void;
  61393. /**
  61394. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61395. * @param mesh The mesh to include in the glow layer
  61396. */
  61397. addIncludedOnlyMesh(mesh: Mesh): void;
  61398. /**
  61399. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61400. * @param mesh The mesh to remove
  61401. */
  61402. removeIncludedOnlyMesh(mesh: Mesh): void;
  61403. /**
  61404. * Determine if a given mesh will be used in the glow layer
  61405. * @param mesh The mesh to test
  61406. * @returns true if the mesh will be highlighted by the current glow layer
  61407. */
  61408. hasMesh(mesh: AbstractMesh): boolean;
  61409. /**
  61410. * Defines whether the current material of the mesh should be use to render the effect.
  61411. * @param mesh defines the current mesh to render
  61412. */
  61413. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61414. /**
  61415. * Add a mesh to be rendered through its own material and not with emissive only.
  61416. * @param mesh The mesh for which we need to use its material
  61417. */
  61418. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61419. /**
  61420. * Remove a mesh from being rendered through its own material and not with emissive only.
  61421. * @param mesh The mesh for which we need to not use its material
  61422. */
  61423. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61424. /**
  61425. * Free any resources and references associated to a mesh.
  61426. * Internal use
  61427. * @param mesh The mesh to free.
  61428. * @hidden
  61429. */
  61430. _disposeMesh(mesh: Mesh): void;
  61431. /**
  61432. * Gets the class name of the effect layer
  61433. * @returns the string with the class name of the effect layer
  61434. */
  61435. getClassName(): string;
  61436. /**
  61437. * Serializes this glow layer
  61438. * @returns a serialized glow layer object
  61439. */
  61440. serialize(): any;
  61441. /**
  61442. * Creates a Glow Layer from parsed glow layer data
  61443. * @param parsedGlowLayer defines glow layer data
  61444. * @param scene defines the current scene
  61445. * @param rootUrl defines the root URL containing the glow layer information
  61446. * @returns a parsed Glow Layer
  61447. */
  61448. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61449. }
  61450. }
  61451. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61452. /** @hidden */
  61453. export var glowBlurPostProcessPixelShader: {
  61454. name: string;
  61455. shader: string;
  61456. };
  61457. }
  61458. declare module "babylonjs/Layers/highlightLayer" {
  61459. import { Observable } from "babylonjs/Misc/observable";
  61460. import { Nullable } from "babylonjs/types";
  61461. import { Camera } from "babylonjs/Cameras/camera";
  61462. import { Scene } from "babylonjs/scene";
  61463. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61465. import { Mesh } from "babylonjs/Meshes/mesh";
  61466. import { Effect } from "babylonjs/Materials/effect";
  61467. import { Material } from "babylonjs/Materials/material";
  61468. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61469. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61470. import "babylonjs/Shaders/glowMapMerge.fragment";
  61471. import "babylonjs/Shaders/glowMapMerge.vertex";
  61472. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61473. module "babylonjs/abstractScene" {
  61474. interface AbstractScene {
  61475. /**
  61476. * Return a the first highlight layer of the scene with a given name.
  61477. * @param name The name of the highlight layer to look for.
  61478. * @return The highlight layer if found otherwise null.
  61479. */
  61480. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61481. }
  61482. }
  61483. /**
  61484. * Highlight layer options. This helps customizing the behaviour
  61485. * of the highlight layer.
  61486. */
  61487. export interface IHighlightLayerOptions {
  61488. /**
  61489. * Multiplication factor apply to the canvas size to compute the render target size
  61490. * used to generated the glowing objects (the smaller the faster).
  61491. */
  61492. mainTextureRatio: number;
  61493. /**
  61494. * Enforces a fixed size texture to ensure resize independant blur.
  61495. */
  61496. mainTextureFixedSize?: number;
  61497. /**
  61498. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61499. * of the picture to blur (the smaller the faster).
  61500. */
  61501. blurTextureSizeRatio: number;
  61502. /**
  61503. * How big in texel of the blur texture is the vertical blur.
  61504. */
  61505. blurVerticalSize: number;
  61506. /**
  61507. * How big in texel of the blur texture is the horizontal blur.
  61508. */
  61509. blurHorizontalSize: number;
  61510. /**
  61511. * Alpha blending mode used to apply the blur. Default is combine.
  61512. */
  61513. alphaBlendingMode: number;
  61514. /**
  61515. * The camera attached to the layer.
  61516. */
  61517. camera: Nullable<Camera>;
  61518. /**
  61519. * Should we display highlight as a solid stroke?
  61520. */
  61521. isStroke?: boolean;
  61522. /**
  61523. * The rendering group to draw the layer in.
  61524. */
  61525. renderingGroupId: number;
  61526. }
  61527. /**
  61528. * The highlight layer Helps adding a glow effect around a mesh.
  61529. *
  61530. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61531. * glowy meshes to your scene.
  61532. *
  61533. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61534. */
  61535. export class HighlightLayer extends EffectLayer {
  61536. name: string;
  61537. /**
  61538. * Effect Name of the highlight layer.
  61539. */
  61540. static readonly EffectName: string;
  61541. /**
  61542. * The neutral color used during the preparation of the glow effect.
  61543. * This is black by default as the blend operation is a blend operation.
  61544. */
  61545. static NeutralColor: Color4;
  61546. /**
  61547. * Stencil value used for glowing meshes.
  61548. */
  61549. static GlowingMeshStencilReference: number;
  61550. /**
  61551. * Stencil value used for the other meshes in the scene.
  61552. */
  61553. static NormalMeshStencilReference: number;
  61554. /**
  61555. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61556. */
  61557. innerGlow: boolean;
  61558. /**
  61559. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61560. */
  61561. outerGlow: boolean;
  61562. /**
  61563. * Specifies the horizontal size of the blur.
  61564. */
  61565. set blurHorizontalSize(value: number);
  61566. /**
  61567. * Specifies the vertical size of the blur.
  61568. */
  61569. set blurVerticalSize(value: number);
  61570. /**
  61571. * Gets the horizontal size of the blur.
  61572. */
  61573. get blurHorizontalSize(): number;
  61574. /**
  61575. * Gets the vertical size of the blur.
  61576. */
  61577. get blurVerticalSize(): number;
  61578. /**
  61579. * An event triggered when the highlight layer is being blurred.
  61580. */
  61581. onBeforeBlurObservable: Observable<HighlightLayer>;
  61582. /**
  61583. * An event triggered when the highlight layer has been blurred.
  61584. */
  61585. onAfterBlurObservable: Observable<HighlightLayer>;
  61586. private _instanceGlowingMeshStencilReference;
  61587. private _options;
  61588. private _downSamplePostprocess;
  61589. private _horizontalBlurPostprocess;
  61590. private _verticalBlurPostprocess;
  61591. private _blurTexture;
  61592. private _meshes;
  61593. private _excludedMeshes;
  61594. /**
  61595. * Instantiates a new highlight Layer and references it to the scene..
  61596. * @param name The name of the layer
  61597. * @param scene The scene to use the layer in
  61598. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61599. */
  61600. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61601. /**
  61602. * Get the effect name of the layer.
  61603. * @return The effect name
  61604. */
  61605. getEffectName(): string;
  61606. /**
  61607. * Create the merge effect. This is the shader use to blit the information back
  61608. * to the main canvas at the end of the scene rendering.
  61609. */
  61610. protected _createMergeEffect(): Effect;
  61611. /**
  61612. * Creates the render target textures and post processes used in the highlight layer.
  61613. */
  61614. protected _createTextureAndPostProcesses(): void;
  61615. /**
  61616. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61617. */
  61618. needStencil(): boolean;
  61619. /**
  61620. * Checks for the readiness of the element composing the layer.
  61621. * @param subMesh the mesh to check for
  61622. * @param useInstances specify wether or not to use instances to render the mesh
  61623. * @param emissiveTexture the associated emissive texture used to generate the glow
  61624. * @return true if ready otherwise, false
  61625. */
  61626. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61627. /**
  61628. * Implementation specific of rendering the generating effect on the main canvas.
  61629. * @param effect The effect used to render through
  61630. */
  61631. protected _internalRender(effect: Effect): void;
  61632. /**
  61633. * Returns true if the layer contains information to display, otherwise false.
  61634. */
  61635. shouldRender(): boolean;
  61636. /**
  61637. * Returns true if the mesh should render, otherwise false.
  61638. * @param mesh The mesh to render
  61639. * @returns true if it should render otherwise false
  61640. */
  61641. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61642. /**
  61643. * Returns true if the mesh can be rendered, otherwise false.
  61644. * @param mesh The mesh to render
  61645. * @param material The material used on the mesh
  61646. * @returns true if it can be rendered otherwise false
  61647. */
  61648. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61649. /**
  61650. * Adds specific effects defines.
  61651. * @param defines The defines to add specifics to.
  61652. */
  61653. protected _addCustomEffectDefines(defines: string[]): void;
  61654. /**
  61655. * Sets the required values for both the emissive texture and and the main color.
  61656. */
  61657. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61658. /**
  61659. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61660. * @param mesh The mesh to exclude from the highlight layer
  61661. */
  61662. addExcludedMesh(mesh: Mesh): void;
  61663. /**
  61664. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61665. * @param mesh The mesh to highlight
  61666. */
  61667. removeExcludedMesh(mesh: Mesh): void;
  61668. /**
  61669. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61670. * @param mesh mesh to test
  61671. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61672. */
  61673. hasMesh(mesh: AbstractMesh): boolean;
  61674. /**
  61675. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61676. * @param mesh The mesh to highlight
  61677. * @param color The color of the highlight
  61678. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61679. */
  61680. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61681. /**
  61682. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61683. * @param mesh The mesh to highlight
  61684. */
  61685. removeMesh(mesh: Mesh): void;
  61686. /**
  61687. * Remove all the meshes currently referenced in the highlight layer
  61688. */
  61689. removeAllMeshes(): void;
  61690. /**
  61691. * Force the stencil to the normal expected value for none glowing parts
  61692. */
  61693. private _defaultStencilReference;
  61694. /**
  61695. * Free any resources and references associated to a mesh.
  61696. * Internal use
  61697. * @param mesh The mesh to free.
  61698. * @hidden
  61699. */
  61700. _disposeMesh(mesh: Mesh): void;
  61701. /**
  61702. * Dispose the highlight layer and free resources.
  61703. */
  61704. dispose(): void;
  61705. /**
  61706. * Gets the class name of the effect layer
  61707. * @returns the string with the class name of the effect layer
  61708. */
  61709. getClassName(): string;
  61710. /**
  61711. * Serializes this Highlight layer
  61712. * @returns a serialized Highlight layer object
  61713. */
  61714. serialize(): any;
  61715. /**
  61716. * Creates a Highlight layer from parsed Highlight layer data
  61717. * @param parsedHightlightLayer defines the Highlight layer data
  61718. * @param scene defines the current scene
  61719. * @param rootUrl defines the root URL containing the Highlight layer information
  61720. * @returns a parsed Highlight layer
  61721. */
  61722. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61723. }
  61724. }
  61725. declare module "babylonjs/Layers/layerSceneComponent" {
  61726. import { Scene } from "babylonjs/scene";
  61727. import { ISceneComponent } from "babylonjs/sceneComponent";
  61728. import { Layer } from "babylonjs/Layers/layer";
  61729. import { AbstractScene } from "babylonjs/abstractScene";
  61730. module "babylonjs/abstractScene" {
  61731. interface AbstractScene {
  61732. /**
  61733. * The list of layers (background and foreground) of the scene
  61734. */
  61735. layers: Array<Layer>;
  61736. }
  61737. }
  61738. /**
  61739. * Defines the layer scene component responsible to manage any layers
  61740. * in a given scene.
  61741. */
  61742. export class LayerSceneComponent implements ISceneComponent {
  61743. /**
  61744. * The component name helpfull to identify the component in the list of scene components.
  61745. */
  61746. readonly name: string;
  61747. /**
  61748. * The scene the component belongs to.
  61749. */
  61750. scene: Scene;
  61751. private _engine;
  61752. /**
  61753. * Creates a new instance of the component for the given scene
  61754. * @param scene Defines the scene to register the component in
  61755. */
  61756. constructor(scene: Scene);
  61757. /**
  61758. * Registers the component in a given scene
  61759. */
  61760. register(): void;
  61761. /**
  61762. * Rebuilds the elements related to this component in case of
  61763. * context lost for instance.
  61764. */
  61765. rebuild(): void;
  61766. /**
  61767. * Disposes the component and the associated ressources.
  61768. */
  61769. dispose(): void;
  61770. private _draw;
  61771. private _drawCameraPredicate;
  61772. private _drawCameraBackground;
  61773. private _drawCameraForeground;
  61774. private _drawRenderTargetPredicate;
  61775. private _drawRenderTargetBackground;
  61776. private _drawRenderTargetForeground;
  61777. /**
  61778. * Adds all the elements from the container to the scene
  61779. * @param container the container holding the elements
  61780. */
  61781. addFromContainer(container: AbstractScene): void;
  61782. /**
  61783. * Removes all the elements in the container from the scene
  61784. * @param container contains the elements to remove
  61785. * @param dispose if the removed element should be disposed (default: false)
  61786. */
  61787. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61788. }
  61789. }
  61790. declare module "babylonjs/Shaders/layer.fragment" {
  61791. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61792. /** @hidden */
  61793. export var layerPixelShader: {
  61794. name: string;
  61795. shader: string;
  61796. };
  61797. }
  61798. declare module "babylonjs/Shaders/layer.vertex" {
  61799. /** @hidden */
  61800. export var layerVertexShader: {
  61801. name: string;
  61802. shader: string;
  61803. };
  61804. }
  61805. declare module "babylonjs/Layers/layer" {
  61806. import { Observable } from "babylonjs/Misc/observable";
  61807. import { Nullable } from "babylonjs/types";
  61808. import { Scene } from "babylonjs/scene";
  61809. import { Vector2 } from "babylonjs/Maths/math.vector";
  61810. import { Color4 } from "babylonjs/Maths/math.color";
  61811. import { Texture } from "babylonjs/Materials/Textures/texture";
  61812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61813. import "babylonjs/Shaders/layer.fragment";
  61814. import "babylonjs/Shaders/layer.vertex";
  61815. /**
  61816. * This represents a full screen 2d layer.
  61817. * This can be useful to display a picture in the background of your scene for instance.
  61818. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61819. */
  61820. export class Layer {
  61821. /**
  61822. * Define the name of the layer.
  61823. */
  61824. name: string;
  61825. /**
  61826. * Define the texture the layer should display.
  61827. */
  61828. texture: Nullable<Texture>;
  61829. /**
  61830. * Is the layer in background or foreground.
  61831. */
  61832. isBackground: boolean;
  61833. /**
  61834. * Define the color of the layer (instead of texture).
  61835. */
  61836. color: Color4;
  61837. /**
  61838. * Define the scale of the layer in order to zoom in out of the texture.
  61839. */
  61840. scale: Vector2;
  61841. /**
  61842. * Define an offset for the layer in order to shift the texture.
  61843. */
  61844. offset: Vector2;
  61845. /**
  61846. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61847. */
  61848. alphaBlendingMode: number;
  61849. /**
  61850. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61851. * Alpha test will not mix with the background color in case of transparency.
  61852. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61853. */
  61854. alphaTest: boolean;
  61855. /**
  61856. * Define a mask to restrict the layer to only some of the scene cameras.
  61857. */
  61858. layerMask: number;
  61859. /**
  61860. * Define the list of render target the layer is visible into.
  61861. */
  61862. renderTargetTextures: RenderTargetTexture[];
  61863. /**
  61864. * Define if the layer is only used in renderTarget or if it also
  61865. * renders in the main frame buffer of the canvas.
  61866. */
  61867. renderOnlyInRenderTargetTextures: boolean;
  61868. private _scene;
  61869. private _vertexBuffers;
  61870. private _indexBuffer;
  61871. private _effect;
  61872. private _previousDefines;
  61873. /**
  61874. * An event triggered when the layer is disposed.
  61875. */
  61876. onDisposeObservable: Observable<Layer>;
  61877. private _onDisposeObserver;
  61878. /**
  61879. * Back compatibility with callback before the onDisposeObservable existed.
  61880. * The set callback will be triggered when the layer has been disposed.
  61881. */
  61882. set onDispose(callback: () => void);
  61883. /**
  61884. * An event triggered before rendering the scene
  61885. */
  61886. onBeforeRenderObservable: Observable<Layer>;
  61887. private _onBeforeRenderObserver;
  61888. /**
  61889. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61890. * The set callback will be triggered just before rendering the layer.
  61891. */
  61892. set onBeforeRender(callback: () => void);
  61893. /**
  61894. * An event triggered after rendering the scene
  61895. */
  61896. onAfterRenderObservable: Observable<Layer>;
  61897. private _onAfterRenderObserver;
  61898. /**
  61899. * Back compatibility with callback before the onAfterRenderObservable existed.
  61900. * The set callback will be triggered just after rendering the layer.
  61901. */
  61902. set onAfterRender(callback: () => void);
  61903. /**
  61904. * Instantiates a new layer.
  61905. * This represents a full screen 2d layer.
  61906. * This can be useful to display a picture in the background of your scene for instance.
  61907. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61908. * @param name Define the name of the layer in the scene
  61909. * @param imgUrl Define the url of the texture to display in the layer
  61910. * @param scene Define the scene the layer belongs to
  61911. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61912. * @param color Defines a color for the layer
  61913. */
  61914. constructor(
  61915. /**
  61916. * Define the name of the layer.
  61917. */
  61918. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61919. private _createIndexBuffer;
  61920. /** @hidden */
  61921. _rebuild(): void;
  61922. /**
  61923. * Renders the layer in the scene.
  61924. */
  61925. render(): void;
  61926. /**
  61927. * Disposes and releases the associated ressources.
  61928. */
  61929. dispose(): void;
  61930. }
  61931. }
  61932. declare module "babylonjs/Layers/index" {
  61933. export * from "babylonjs/Layers/effectLayer";
  61934. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61935. export * from "babylonjs/Layers/glowLayer";
  61936. export * from "babylonjs/Layers/highlightLayer";
  61937. export * from "babylonjs/Layers/layer";
  61938. export * from "babylonjs/Layers/layerSceneComponent";
  61939. }
  61940. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61941. /** @hidden */
  61942. export var lensFlarePixelShader: {
  61943. name: string;
  61944. shader: string;
  61945. };
  61946. }
  61947. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61948. /** @hidden */
  61949. export var lensFlareVertexShader: {
  61950. name: string;
  61951. shader: string;
  61952. };
  61953. }
  61954. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61955. import { Scene } from "babylonjs/scene";
  61956. import { Vector3 } from "babylonjs/Maths/math.vector";
  61957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61958. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61959. import "babylonjs/Shaders/lensFlare.fragment";
  61960. import "babylonjs/Shaders/lensFlare.vertex";
  61961. import { Viewport } from "babylonjs/Maths/math.viewport";
  61962. /**
  61963. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61964. * It is usually composed of several `lensFlare`.
  61965. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61966. */
  61967. export class LensFlareSystem {
  61968. /**
  61969. * Define the name of the lens flare system
  61970. */
  61971. name: string;
  61972. /**
  61973. * List of lens flares used in this system.
  61974. */
  61975. lensFlares: LensFlare[];
  61976. /**
  61977. * Define a limit from the border the lens flare can be visible.
  61978. */
  61979. borderLimit: number;
  61980. /**
  61981. * Define a viewport border we do not want to see the lens flare in.
  61982. */
  61983. viewportBorder: number;
  61984. /**
  61985. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61986. */
  61987. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61988. /**
  61989. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61990. */
  61991. layerMask: number;
  61992. /**
  61993. * Define the id of the lens flare system in the scene.
  61994. * (equal to name by default)
  61995. */
  61996. id: string;
  61997. private _scene;
  61998. private _emitter;
  61999. private _vertexBuffers;
  62000. private _indexBuffer;
  62001. private _effect;
  62002. private _positionX;
  62003. private _positionY;
  62004. private _isEnabled;
  62005. /** @hidden */
  62006. static _SceneComponentInitialization: (scene: Scene) => void;
  62007. /**
  62008. * Instantiates a lens flare system.
  62009. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62010. * It is usually composed of several `lensFlare`.
  62011. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62012. * @param name Define the name of the lens flare system in the scene
  62013. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62014. * @param scene Define the scene the lens flare system belongs to
  62015. */
  62016. constructor(
  62017. /**
  62018. * Define the name of the lens flare system
  62019. */
  62020. name: string, emitter: any, scene: Scene);
  62021. /**
  62022. * Define if the lens flare system is enabled.
  62023. */
  62024. get isEnabled(): boolean;
  62025. set isEnabled(value: boolean);
  62026. /**
  62027. * Get the scene the effects belongs to.
  62028. * @returns the scene holding the lens flare system
  62029. */
  62030. getScene(): Scene;
  62031. /**
  62032. * Get the emitter of the lens flare system.
  62033. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62034. * @returns the emitter of the lens flare system
  62035. */
  62036. getEmitter(): any;
  62037. /**
  62038. * Set the emitter of the lens flare system.
  62039. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62040. * @param newEmitter Define the new emitter of the system
  62041. */
  62042. setEmitter(newEmitter: any): void;
  62043. /**
  62044. * Get the lens flare system emitter position.
  62045. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62046. * @returns the position
  62047. */
  62048. getEmitterPosition(): Vector3;
  62049. /**
  62050. * @hidden
  62051. */
  62052. computeEffectivePosition(globalViewport: Viewport): boolean;
  62053. /** @hidden */
  62054. _isVisible(): boolean;
  62055. /**
  62056. * @hidden
  62057. */
  62058. render(): boolean;
  62059. /**
  62060. * Dispose and release the lens flare with its associated resources.
  62061. */
  62062. dispose(): void;
  62063. /**
  62064. * Parse a lens flare system from a JSON repressentation
  62065. * @param parsedLensFlareSystem Define the JSON to parse
  62066. * @param scene Define the scene the parsed system should be instantiated in
  62067. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62068. * @returns the parsed system
  62069. */
  62070. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62071. /**
  62072. * Serialize the current Lens Flare System into a JSON representation.
  62073. * @returns the serialized JSON
  62074. */
  62075. serialize(): any;
  62076. }
  62077. }
  62078. declare module "babylonjs/LensFlares/lensFlare" {
  62079. import { Nullable } from "babylonjs/types";
  62080. import { Color3 } from "babylonjs/Maths/math.color";
  62081. import { Texture } from "babylonjs/Materials/Textures/texture";
  62082. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62083. /**
  62084. * This represents one of the lens effect in a `lensFlareSystem`.
  62085. * It controls one of the indiviual texture used in the effect.
  62086. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62087. */
  62088. export class LensFlare {
  62089. /**
  62090. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62091. */
  62092. size: number;
  62093. /**
  62094. * 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.
  62095. */
  62096. position: number;
  62097. /**
  62098. * Define the lens color.
  62099. */
  62100. color: Color3;
  62101. /**
  62102. * Define the lens texture.
  62103. */
  62104. texture: Nullable<Texture>;
  62105. /**
  62106. * Define the alpha mode to render this particular lens.
  62107. */
  62108. alphaMode: number;
  62109. private _system;
  62110. /**
  62111. * Creates a new Lens Flare.
  62112. * This represents one of the lens effect in a `lensFlareSystem`.
  62113. * It controls one of the indiviual texture used in the effect.
  62114. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62115. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62116. * @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.
  62117. * @param color Define the lens color
  62118. * @param imgUrl Define the lens texture url
  62119. * @param system Define the `lensFlareSystem` this flare is part of
  62120. * @returns The newly created Lens Flare
  62121. */
  62122. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62123. /**
  62124. * Instantiates a new Lens Flare.
  62125. * This represents one of the lens effect in a `lensFlareSystem`.
  62126. * It controls one of the indiviual texture used in the effect.
  62127. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62128. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62129. * @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.
  62130. * @param color Define the lens color
  62131. * @param imgUrl Define the lens texture url
  62132. * @param system Define the `lensFlareSystem` this flare is part of
  62133. */
  62134. constructor(
  62135. /**
  62136. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62137. */
  62138. size: number,
  62139. /**
  62140. * 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.
  62141. */
  62142. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62143. /**
  62144. * Dispose and release the lens flare with its associated resources.
  62145. */
  62146. dispose(): void;
  62147. }
  62148. }
  62149. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62150. import { Nullable } from "babylonjs/types";
  62151. import { Scene } from "babylonjs/scene";
  62152. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62153. import { AbstractScene } from "babylonjs/abstractScene";
  62154. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62155. module "babylonjs/abstractScene" {
  62156. interface AbstractScene {
  62157. /**
  62158. * The list of lens flare system added to the scene
  62159. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62160. */
  62161. lensFlareSystems: Array<LensFlareSystem>;
  62162. /**
  62163. * Removes the given lens flare system from this scene.
  62164. * @param toRemove The lens flare system to remove
  62165. * @returns The index of the removed lens flare system
  62166. */
  62167. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62168. /**
  62169. * Adds the given lens flare system to this scene
  62170. * @param newLensFlareSystem The lens flare system to add
  62171. */
  62172. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62173. /**
  62174. * Gets a lens flare system using its name
  62175. * @param name defines the name to look for
  62176. * @returns the lens flare system or null if not found
  62177. */
  62178. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62179. /**
  62180. * Gets a lens flare system using its id
  62181. * @param id defines the id to look for
  62182. * @returns the lens flare system or null if not found
  62183. */
  62184. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62185. }
  62186. }
  62187. /**
  62188. * Defines the lens flare scene component responsible to manage any lens flares
  62189. * in a given scene.
  62190. */
  62191. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62192. /**
  62193. * The component name helpfull to identify the component in the list of scene components.
  62194. */
  62195. readonly name: string;
  62196. /**
  62197. * The scene the component belongs to.
  62198. */
  62199. scene: Scene;
  62200. /**
  62201. * Creates a new instance of the component for the given scene
  62202. * @param scene Defines the scene to register the component in
  62203. */
  62204. constructor(scene: Scene);
  62205. /**
  62206. * Registers the component in a given scene
  62207. */
  62208. register(): void;
  62209. /**
  62210. * Rebuilds the elements related to this component in case of
  62211. * context lost for instance.
  62212. */
  62213. rebuild(): void;
  62214. /**
  62215. * Adds all the elements from the container to the scene
  62216. * @param container the container holding the elements
  62217. */
  62218. addFromContainer(container: AbstractScene): void;
  62219. /**
  62220. * Removes all the elements in the container from the scene
  62221. * @param container contains the elements to remove
  62222. * @param dispose if the removed element should be disposed (default: false)
  62223. */
  62224. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62225. /**
  62226. * Serializes the component data to the specified json object
  62227. * @param serializationObject The object to serialize to
  62228. */
  62229. serialize(serializationObject: any): void;
  62230. /**
  62231. * Disposes the component and the associated ressources.
  62232. */
  62233. dispose(): void;
  62234. private _draw;
  62235. }
  62236. }
  62237. declare module "babylonjs/LensFlares/index" {
  62238. export * from "babylonjs/LensFlares/lensFlare";
  62239. export * from "babylonjs/LensFlares/lensFlareSystem";
  62240. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62241. }
  62242. declare module "babylonjs/Shaders/depth.fragment" {
  62243. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62244. /** @hidden */
  62245. export var depthPixelShader: {
  62246. name: string;
  62247. shader: string;
  62248. };
  62249. }
  62250. declare module "babylonjs/Shaders/depth.vertex" {
  62251. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62253. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62254. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62256. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62257. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62258. /** @hidden */
  62259. export var depthVertexShader: {
  62260. name: string;
  62261. shader: string;
  62262. };
  62263. }
  62264. declare module "babylonjs/Rendering/depthRenderer" {
  62265. import { Nullable } from "babylonjs/types";
  62266. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62267. import { Scene } from "babylonjs/scene";
  62268. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62269. import { Camera } from "babylonjs/Cameras/camera";
  62270. import "babylonjs/Shaders/depth.fragment";
  62271. import "babylonjs/Shaders/depth.vertex";
  62272. /**
  62273. * This represents a depth renderer in Babylon.
  62274. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62275. */
  62276. export class DepthRenderer {
  62277. private _scene;
  62278. private _depthMap;
  62279. private _effect;
  62280. private readonly _storeNonLinearDepth;
  62281. private readonly _clearColor;
  62282. /** Get if the depth renderer is using packed depth or not */
  62283. readonly isPacked: boolean;
  62284. private _cachedDefines;
  62285. private _camera;
  62286. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62287. enabled: boolean;
  62288. /**
  62289. * Specifiess that the depth renderer will only be used within
  62290. * the camera it is created for.
  62291. * This can help forcing its rendering during the camera processing.
  62292. */
  62293. useOnlyInActiveCamera: boolean;
  62294. /** @hidden */
  62295. static _SceneComponentInitialization: (scene: Scene) => void;
  62296. /**
  62297. * Instantiates a depth renderer
  62298. * @param scene The scene the renderer belongs to
  62299. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62300. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62301. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62302. */
  62303. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62304. /**
  62305. * Creates the depth rendering effect and checks if the effect is ready.
  62306. * @param subMesh The submesh to be used to render the depth map of
  62307. * @param useInstances If multiple world instances should be used
  62308. * @returns if the depth renderer is ready to render the depth map
  62309. */
  62310. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62311. /**
  62312. * Gets the texture which the depth map will be written to.
  62313. * @returns The depth map texture
  62314. */
  62315. getDepthMap(): RenderTargetTexture;
  62316. /**
  62317. * Disposes of the depth renderer.
  62318. */
  62319. dispose(): void;
  62320. }
  62321. }
  62322. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62323. /** @hidden */
  62324. export var minmaxReduxPixelShader: {
  62325. name: string;
  62326. shader: string;
  62327. };
  62328. }
  62329. declare module "babylonjs/Misc/minMaxReducer" {
  62330. import { Nullable } from "babylonjs/types";
  62331. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62332. import { Camera } from "babylonjs/Cameras/camera";
  62333. import { Observer } from "babylonjs/Misc/observable";
  62334. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62335. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62336. import { Observable } from "babylonjs/Misc/observable";
  62337. import "babylonjs/Shaders/minmaxRedux.fragment";
  62338. /**
  62339. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62340. * and maximum values from all values of the texture.
  62341. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62342. * The source values are read from the red channel of the texture.
  62343. */
  62344. export class MinMaxReducer {
  62345. /**
  62346. * Observable triggered when the computation has been performed
  62347. */
  62348. onAfterReductionPerformed: Observable<{
  62349. min: number;
  62350. max: number;
  62351. }>;
  62352. protected _camera: Camera;
  62353. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62354. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62355. protected _postProcessManager: PostProcessManager;
  62356. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62357. protected _forceFullscreenViewport: boolean;
  62358. /**
  62359. * Creates a min/max reducer
  62360. * @param camera The camera to use for the post processes
  62361. */
  62362. constructor(camera: Camera);
  62363. /**
  62364. * Gets the texture used to read the values from.
  62365. */
  62366. get sourceTexture(): Nullable<RenderTargetTexture>;
  62367. /**
  62368. * Sets the source texture to read the values from.
  62369. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62370. * because in such textures '1' value must not be taken into account to compute the maximum
  62371. * as this value is used to clear the texture.
  62372. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62373. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62374. * @param depthRedux Indicates if the texture is a depth texture or not
  62375. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62376. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62377. */
  62378. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62379. /**
  62380. * Defines the refresh rate of the computation.
  62381. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62382. */
  62383. get refreshRate(): number;
  62384. set refreshRate(value: number);
  62385. protected _activated: boolean;
  62386. /**
  62387. * Gets the activation status of the reducer
  62388. */
  62389. get activated(): boolean;
  62390. /**
  62391. * Activates the reduction computation.
  62392. * When activated, the observers registered in onAfterReductionPerformed are
  62393. * called after the compuation is performed
  62394. */
  62395. activate(): void;
  62396. /**
  62397. * Deactivates the reduction computation.
  62398. */
  62399. deactivate(): void;
  62400. /**
  62401. * Disposes the min/max reducer
  62402. * @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.
  62403. */
  62404. dispose(disposeAll?: boolean): void;
  62405. }
  62406. }
  62407. declare module "babylonjs/Misc/depthReducer" {
  62408. import { Nullable } from "babylonjs/types";
  62409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62410. import { Camera } from "babylonjs/Cameras/camera";
  62411. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62412. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62413. /**
  62414. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62415. */
  62416. export class DepthReducer extends MinMaxReducer {
  62417. private _depthRenderer;
  62418. private _depthRendererId;
  62419. /**
  62420. * Gets the depth renderer used for the computation.
  62421. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62422. */
  62423. get depthRenderer(): Nullable<DepthRenderer>;
  62424. /**
  62425. * Creates a depth reducer
  62426. * @param camera The camera used to render the depth texture
  62427. */
  62428. constructor(camera: Camera);
  62429. /**
  62430. * Sets the depth renderer to use to generate the depth map
  62431. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62432. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62433. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62434. */
  62435. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62436. /** @hidden */
  62437. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62438. /**
  62439. * Activates the reduction computation.
  62440. * When activated, the observers registered in onAfterReductionPerformed are
  62441. * called after the compuation is performed
  62442. */
  62443. activate(): void;
  62444. /**
  62445. * Deactivates the reduction computation.
  62446. */
  62447. deactivate(): void;
  62448. /**
  62449. * Disposes the depth reducer
  62450. * @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.
  62451. */
  62452. dispose(disposeAll?: boolean): void;
  62453. }
  62454. }
  62455. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62456. import { Nullable } from "babylonjs/types";
  62457. import { Scene } from "babylonjs/scene";
  62458. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62461. import { Effect } from "babylonjs/Materials/effect";
  62462. import "babylonjs/Shaders/shadowMap.fragment";
  62463. import "babylonjs/Shaders/shadowMap.vertex";
  62464. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62465. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62466. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62467. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62468. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62469. /**
  62470. * A CSM implementation allowing casting shadows on large scenes.
  62471. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62472. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62473. */
  62474. export class CascadedShadowGenerator extends ShadowGenerator {
  62475. private static readonly frustumCornersNDCSpace;
  62476. /**
  62477. * Name of the CSM class
  62478. */
  62479. static CLASSNAME: string;
  62480. /**
  62481. * Defines the default number of cascades used by the CSM.
  62482. */
  62483. static readonly DEFAULT_CASCADES_COUNT: number;
  62484. /**
  62485. * Defines the minimum number of cascades used by the CSM.
  62486. */
  62487. static readonly MIN_CASCADES_COUNT: number;
  62488. /**
  62489. * Defines the maximum number of cascades used by the CSM.
  62490. */
  62491. static readonly MAX_CASCADES_COUNT: number;
  62492. protected _validateFilter(filter: number): number;
  62493. /**
  62494. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62495. */
  62496. penumbraDarkness: number;
  62497. private _numCascades;
  62498. /**
  62499. * Gets or set the number of cascades used by the CSM.
  62500. */
  62501. get numCascades(): number;
  62502. set numCascades(value: number);
  62503. /**
  62504. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62505. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62506. */
  62507. stabilizeCascades: boolean;
  62508. private _freezeShadowCastersBoundingInfo;
  62509. private _freezeShadowCastersBoundingInfoObservable;
  62510. /**
  62511. * Enables or disables the shadow casters bounding info computation.
  62512. * If your shadow casters don't move, you can disable this feature.
  62513. * If it is enabled, the bounding box computation is done every frame.
  62514. */
  62515. get freezeShadowCastersBoundingInfo(): boolean;
  62516. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62517. private _scbiMin;
  62518. private _scbiMax;
  62519. protected _computeShadowCastersBoundingInfo(): void;
  62520. protected _shadowCastersBoundingInfo: BoundingInfo;
  62521. /**
  62522. * Gets or sets the shadow casters bounding info.
  62523. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62524. * so that the system won't overwrite the bounds you provide
  62525. */
  62526. get shadowCastersBoundingInfo(): BoundingInfo;
  62527. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62528. protected _breaksAreDirty: boolean;
  62529. protected _minDistance: number;
  62530. protected _maxDistance: number;
  62531. /**
  62532. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62533. *
  62534. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62535. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62536. * @param min minimal distance for the breaks (default to 0.)
  62537. * @param max maximal distance for the breaks (default to 1.)
  62538. */
  62539. setMinMaxDistance(min: number, max: number): void;
  62540. /** Gets the minimal distance used in the cascade break computation */
  62541. get minDistance(): number;
  62542. /** Gets the maximal distance used in the cascade break computation */
  62543. get maxDistance(): number;
  62544. /**
  62545. * Gets the class name of that object
  62546. * @returns "CascadedShadowGenerator"
  62547. */
  62548. getClassName(): string;
  62549. private _cascadeMinExtents;
  62550. private _cascadeMaxExtents;
  62551. /**
  62552. * Gets a cascade minimum extents
  62553. * @param cascadeIndex index of the cascade
  62554. * @returns the minimum cascade extents
  62555. */
  62556. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62557. /**
  62558. * Gets a cascade maximum extents
  62559. * @param cascadeIndex index of the cascade
  62560. * @returns the maximum cascade extents
  62561. */
  62562. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62563. private _cascades;
  62564. private _currentLayer;
  62565. private _viewSpaceFrustumsZ;
  62566. private _viewMatrices;
  62567. private _projectionMatrices;
  62568. private _transformMatrices;
  62569. private _transformMatricesAsArray;
  62570. private _frustumLengths;
  62571. private _lightSizeUVCorrection;
  62572. private _depthCorrection;
  62573. private _frustumCornersWorldSpace;
  62574. private _frustumCenter;
  62575. private _shadowCameraPos;
  62576. private _shadowMaxZ;
  62577. /**
  62578. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62579. * It defaults to camera.maxZ
  62580. */
  62581. get shadowMaxZ(): number;
  62582. /**
  62583. * Sets the shadow max z distance.
  62584. */
  62585. set shadowMaxZ(value: number);
  62586. protected _debug: boolean;
  62587. /**
  62588. * Gets or sets the debug flag.
  62589. * When enabled, the cascades are materialized by different colors on the screen.
  62590. */
  62591. get debug(): boolean;
  62592. set debug(dbg: boolean);
  62593. private _depthClamp;
  62594. /**
  62595. * Gets or sets the depth clamping value.
  62596. *
  62597. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62598. * to account for the shadow casters far away.
  62599. *
  62600. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62601. */
  62602. get depthClamp(): boolean;
  62603. set depthClamp(value: boolean);
  62604. private _cascadeBlendPercentage;
  62605. /**
  62606. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62607. * It defaults to 0.1 (10% blending).
  62608. */
  62609. get cascadeBlendPercentage(): number;
  62610. set cascadeBlendPercentage(value: number);
  62611. private _lambda;
  62612. /**
  62613. * Gets or set the lambda parameter.
  62614. * This parameter is used to split the camera frustum and create the cascades.
  62615. * 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.
  62616. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62617. */
  62618. get lambda(): number;
  62619. set lambda(value: number);
  62620. /**
  62621. * Gets the view matrix corresponding to a given cascade
  62622. * @param cascadeNum cascade to retrieve the view matrix from
  62623. * @returns the cascade view matrix
  62624. */
  62625. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62626. /**
  62627. * Gets the projection matrix corresponding to a given cascade
  62628. * @param cascadeNum cascade to retrieve the projection matrix from
  62629. * @returns the cascade projection matrix
  62630. */
  62631. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62632. /**
  62633. * Gets the transformation matrix corresponding to a given cascade
  62634. * @param cascadeNum cascade to retrieve the transformation matrix from
  62635. * @returns the cascade transformation matrix
  62636. */
  62637. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62638. private _depthRenderer;
  62639. /**
  62640. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62641. *
  62642. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62643. *
  62644. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62645. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62646. * @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
  62647. */
  62648. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62649. private _depthReducer;
  62650. private _autoCalcDepthBounds;
  62651. /**
  62652. * Gets or sets the autoCalcDepthBounds property.
  62653. *
  62654. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62655. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62656. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62657. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62658. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62659. */
  62660. get autoCalcDepthBounds(): boolean;
  62661. set autoCalcDepthBounds(value: boolean);
  62662. /**
  62663. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62664. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62665. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62666. * for setting the refresh rate on the renderer yourself!
  62667. */
  62668. get autoCalcDepthBoundsRefreshRate(): number;
  62669. set autoCalcDepthBoundsRefreshRate(value: number);
  62670. /**
  62671. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62672. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62673. * you change the camera near/far planes!
  62674. */
  62675. splitFrustum(): void;
  62676. private _splitFrustum;
  62677. private _computeMatrices;
  62678. private _computeFrustumInWorldSpace;
  62679. private _computeCascadeFrustum;
  62680. /**
  62681. * Support test.
  62682. */
  62683. static get IsSupported(): boolean;
  62684. /** @hidden */
  62685. static _SceneComponentInitialization: (scene: Scene) => void;
  62686. /**
  62687. * Creates a Cascaded Shadow Generator object.
  62688. * A ShadowGenerator is the required tool to use the shadows.
  62689. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62690. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62691. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62692. * @param light The directional light object generating the shadows.
  62693. * @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.
  62694. */
  62695. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62696. protected _initializeGenerator(): void;
  62697. protected _createTargetRenderTexture(): void;
  62698. protected _initializeShadowMap(): void;
  62699. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62700. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62701. /**
  62702. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62703. * @param defines Defines of the material we want to update
  62704. * @param lightIndex Index of the light in the enabled light list of the material
  62705. */
  62706. prepareDefines(defines: any, lightIndex: number): void;
  62707. /**
  62708. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62709. * defined in the generator but impacting the effect).
  62710. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62711. * @param effect The effect we are binfing the information for
  62712. */
  62713. bindShadowLight(lightIndex: string, effect: Effect): void;
  62714. /**
  62715. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62716. * (eq to view projection * shadow projection matrices)
  62717. * @returns The transform matrix used to create the shadow map
  62718. */
  62719. getTransformMatrix(): Matrix;
  62720. /**
  62721. * Disposes the ShadowGenerator.
  62722. * Returns nothing.
  62723. */
  62724. dispose(): void;
  62725. /**
  62726. * Serializes the shadow generator setup to a json object.
  62727. * @returns The serialized JSON object
  62728. */
  62729. serialize(): any;
  62730. /**
  62731. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62732. * @param parsedShadowGenerator The JSON object to parse
  62733. * @param scene The scene to create the shadow map for
  62734. * @returns The parsed shadow generator
  62735. */
  62736. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62737. }
  62738. }
  62739. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62740. import { Scene } from "babylonjs/scene";
  62741. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62742. import { AbstractScene } from "babylonjs/abstractScene";
  62743. /**
  62744. * Defines the shadow generator component responsible to manage any shadow generators
  62745. * in a given scene.
  62746. */
  62747. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62748. /**
  62749. * The component name helpfull to identify the component in the list of scene components.
  62750. */
  62751. readonly name: string;
  62752. /**
  62753. * The scene the component belongs to.
  62754. */
  62755. scene: Scene;
  62756. /**
  62757. * Creates a new instance of the component for the given scene
  62758. * @param scene Defines the scene to register the component in
  62759. */
  62760. constructor(scene: Scene);
  62761. /**
  62762. * Registers the component in a given scene
  62763. */
  62764. register(): void;
  62765. /**
  62766. * Rebuilds the elements related to this component in case of
  62767. * context lost for instance.
  62768. */
  62769. rebuild(): void;
  62770. /**
  62771. * Serializes the component data to the specified json object
  62772. * @param serializationObject The object to serialize to
  62773. */
  62774. serialize(serializationObject: any): void;
  62775. /**
  62776. * Adds all the elements from the container to the scene
  62777. * @param container the container holding the elements
  62778. */
  62779. addFromContainer(container: AbstractScene): void;
  62780. /**
  62781. * Removes all the elements in the container from the scene
  62782. * @param container contains the elements to remove
  62783. * @param dispose if the removed element should be disposed (default: false)
  62784. */
  62785. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62786. /**
  62787. * Rebuilds the elements related to this component in case of
  62788. * context lost for instance.
  62789. */
  62790. dispose(): void;
  62791. private _gatherRenderTargets;
  62792. }
  62793. }
  62794. declare module "babylonjs/Lights/Shadows/index" {
  62795. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62796. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62797. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62798. }
  62799. declare module "babylonjs/Lights/pointLight" {
  62800. import { Scene } from "babylonjs/scene";
  62801. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62803. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62804. import { Effect } from "babylonjs/Materials/effect";
  62805. /**
  62806. * A point light is a light defined by an unique point in world space.
  62807. * The light is emitted in every direction from this point.
  62808. * A good example of a point light is a standard light bulb.
  62809. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62810. */
  62811. export class PointLight extends ShadowLight {
  62812. private _shadowAngle;
  62813. /**
  62814. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62815. * This specifies what angle the shadow will use to be created.
  62816. *
  62817. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62818. */
  62819. get shadowAngle(): number;
  62820. /**
  62821. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62822. * This specifies what angle the shadow will use to be created.
  62823. *
  62824. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62825. */
  62826. set shadowAngle(value: number);
  62827. /**
  62828. * Gets the direction if it has been set.
  62829. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62830. */
  62831. get direction(): Vector3;
  62832. /**
  62833. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62834. */
  62835. set direction(value: Vector3);
  62836. /**
  62837. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62838. * A PointLight emits the light in every direction.
  62839. * It can cast shadows.
  62840. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62841. * ```javascript
  62842. * var pointLight = new PointLight("pl", camera.position, scene);
  62843. * ```
  62844. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62845. * @param name The light friendly name
  62846. * @param position The position of the point light in the scene
  62847. * @param scene The scene the lights belongs to
  62848. */
  62849. constructor(name: string, position: Vector3, scene: Scene);
  62850. /**
  62851. * Returns the string "PointLight"
  62852. * @returns the class name
  62853. */
  62854. getClassName(): string;
  62855. /**
  62856. * Returns the integer 0.
  62857. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62858. */
  62859. getTypeID(): number;
  62860. /**
  62861. * Specifies wether or not the shadowmap should be a cube texture.
  62862. * @returns true if the shadowmap needs to be a cube texture.
  62863. */
  62864. needCube(): boolean;
  62865. /**
  62866. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62867. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62868. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62869. */
  62870. getShadowDirection(faceIndex?: number): Vector3;
  62871. /**
  62872. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62873. * - fov = PI / 2
  62874. * - aspect ratio : 1.0
  62875. * - z-near and far equal to the active camera minZ and maxZ.
  62876. * Returns the PointLight.
  62877. */
  62878. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62879. protected _buildUniformLayout(): void;
  62880. /**
  62881. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62882. * @param effect The effect to update
  62883. * @param lightIndex The index of the light in the effect to update
  62884. * @returns The point light
  62885. */
  62886. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62887. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62888. /**
  62889. * Prepares the list of defines specific to the light type.
  62890. * @param defines the list of defines
  62891. * @param lightIndex defines the index of the light for the effect
  62892. */
  62893. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62894. }
  62895. }
  62896. declare module "babylonjs/Lights/index" {
  62897. export * from "babylonjs/Lights/light";
  62898. export * from "babylonjs/Lights/shadowLight";
  62899. export * from "babylonjs/Lights/Shadows/index";
  62900. export * from "babylonjs/Lights/directionalLight";
  62901. export * from "babylonjs/Lights/hemisphericLight";
  62902. export * from "babylonjs/Lights/pointLight";
  62903. export * from "babylonjs/Lights/spotLight";
  62904. }
  62905. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62906. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62907. /**
  62908. * Header information of HDR texture files.
  62909. */
  62910. export interface HDRInfo {
  62911. /**
  62912. * The height of the texture in pixels.
  62913. */
  62914. height: number;
  62915. /**
  62916. * The width of the texture in pixels.
  62917. */
  62918. width: number;
  62919. /**
  62920. * The index of the beginning of the data in the binary file.
  62921. */
  62922. dataPosition: number;
  62923. }
  62924. /**
  62925. * This groups tools to convert HDR texture to native colors array.
  62926. */
  62927. export class HDRTools {
  62928. private static Ldexp;
  62929. private static Rgbe2float;
  62930. private static readStringLine;
  62931. /**
  62932. * Reads header information from an RGBE texture stored in a native array.
  62933. * More information on this format are available here:
  62934. * https://en.wikipedia.org/wiki/RGBE_image_format
  62935. *
  62936. * @param uint8array The binary file stored in native array.
  62937. * @return The header information.
  62938. */
  62939. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62940. /**
  62941. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62942. * This RGBE texture needs to store the information as a panorama.
  62943. *
  62944. * More information on this format are available here:
  62945. * https://en.wikipedia.org/wiki/RGBE_image_format
  62946. *
  62947. * @param buffer The binary file stored in an array buffer.
  62948. * @param size The expected size of the extracted cubemap.
  62949. * @return The Cube Map information.
  62950. */
  62951. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62952. /**
  62953. * Returns the pixels data extracted from an RGBE texture.
  62954. * This pixels will be stored left to right up to down in the R G B order in one array.
  62955. *
  62956. * More information on this format are available here:
  62957. * https://en.wikipedia.org/wiki/RGBE_image_format
  62958. *
  62959. * @param uint8array The binary file stored in an array buffer.
  62960. * @param hdrInfo The header information of the file.
  62961. * @return The pixels data in RGB right to left up to down order.
  62962. */
  62963. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62964. private static RGBE_ReadPixels_RLE;
  62965. private static RGBE_ReadPixels_NOT_RLE;
  62966. }
  62967. }
  62968. declare module "babylonjs/Materials/effectRenderer" {
  62969. import { Nullable } from "babylonjs/types";
  62970. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62971. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62972. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62973. import { Viewport } from "babylonjs/Maths/math.viewport";
  62974. import { Observable } from "babylonjs/Misc/observable";
  62975. import { Effect } from "babylonjs/Materials/effect";
  62976. import "babylonjs/Shaders/postprocess.vertex";
  62977. /**
  62978. * Effect Render Options
  62979. */
  62980. export interface IEffectRendererOptions {
  62981. /**
  62982. * Defines the vertices positions.
  62983. */
  62984. positions?: number[];
  62985. /**
  62986. * Defines the indices.
  62987. */
  62988. indices?: number[];
  62989. }
  62990. /**
  62991. * Helper class to render one or more effects.
  62992. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62993. */
  62994. export class EffectRenderer {
  62995. private engine;
  62996. private static _DefaultOptions;
  62997. private _vertexBuffers;
  62998. private _indexBuffer;
  62999. private _fullscreenViewport;
  63000. /**
  63001. * Creates an effect renderer
  63002. * @param engine the engine to use for rendering
  63003. * @param options defines the options of the effect renderer
  63004. */
  63005. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63006. /**
  63007. * Sets the current viewport in normalized coordinates 0-1
  63008. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63009. */
  63010. setViewport(viewport?: Viewport): void;
  63011. /**
  63012. * Binds the embedded attributes buffer to the effect.
  63013. * @param effect Defines the effect to bind the attributes for
  63014. */
  63015. bindBuffers(effect: Effect): void;
  63016. /**
  63017. * Sets the current effect wrapper to use during draw.
  63018. * The effect needs to be ready before calling this api.
  63019. * This also sets the default full screen position attribute.
  63020. * @param effectWrapper Defines the effect to draw with
  63021. */
  63022. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63023. /**
  63024. * Restores engine states
  63025. */
  63026. restoreStates(): void;
  63027. /**
  63028. * Draws a full screen quad.
  63029. */
  63030. draw(): void;
  63031. private isRenderTargetTexture;
  63032. /**
  63033. * renders one or more effects to a specified texture
  63034. * @param effectWrapper the effect to renderer
  63035. * @param outputTexture texture to draw to, if null it will render to the screen.
  63036. */
  63037. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63038. /**
  63039. * Disposes of the effect renderer
  63040. */
  63041. dispose(): void;
  63042. }
  63043. /**
  63044. * Options to create an EffectWrapper
  63045. */
  63046. interface EffectWrapperCreationOptions {
  63047. /**
  63048. * Engine to use to create the effect
  63049. */
  63050. engine: ThinEngine;
  63051. /**
  63052. * Fragment shader for the effect
  63053. */
  63054. fragmentShader: string;
  63055. /**
  63056. * Use the shader store instead of direct source code
  63057. */
  63058. useShaderStore?: boolean;
  63059. /**
  63060. * Vertex shader for the effect
  63061. */
  63062. vertexShader?: string;
  63063. /**
  63064. * Attributes to use in the shader
  63065. */
  63066. attributeNames?: Array<string>;
  63067. /**
  63068. * Uniforms to use in the shader
  63069. */
  63070. uniformNames?: Array<string>;
  63071. /**
  63072. * Texture sampler names to use in the shader
  63073. */
  63074. samplerNames?: Array<string>;
  63075. /**
  63076. * Defines to use in the shader
  63077. */
  63078. defines?: Array<string>;
  63079. /**
  63080. * Callback when effect is compiled
  63081. */
  63082. onCompiled?: Nullable<(effect: Effect) => void>;
  63083. /**
  63084. * The friendly name of the effect displayed in Spector.
  63085. */
  63086. name?: string;
  63087. }
  63088. /**
  63089. * Wraps an effect to be used for rendering
  63090. */
  63091. export class EffectWrapper {
  63092. /**
  63093. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63094. */
  63095. onApplyObservable: Observable<{}>;
  63096. /**
  63097. * The underlying effect
  63098. */
  63099. effect: Effect;
  63100. /**
  63101. * Creates an effect to be renderer
  63102. * @param creationOptions options to create the effect
  63103. */
  63104. constructor(creationOptions: EffectWrapperCreationOptions);
  63105. /**
  63106. * Disposes of the effect wrapper
  63107. */
  63108. dispose(): void;
  63109. }
  63110. }
  63111. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63112. /** @hidden */
  63113. export var hdrFilteringVertexShader: {
  63114. name: string;
  63115. shader: string;
  63116. };
  63117. }
  63118. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63119. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63120. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63121. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63122. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63123. /** @hidden */
  63124. export var hdrFilteringPixelShader: {
  63125. name: string;
  63126. shader: string;
  63127. };
  63128. }
  63129. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63131. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63132. import { Nullable } from "babylonjs/types";
  63133. import "babylonjs/Shaders/hdrFiltering.vertex";
  63134. import "babylonjs/Shaders/hdrFiltering.fragment";
  63135. /**
  63136. * Options for texture filtering
  63137. */
  63138. interface IHDRFilteringOptions {
  63139. /**
  63140. * Scales pixel intensity for the input HDR map.
  63141. */
  63142. hdrScale?: number;
  63143. /**
  63144. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63145. */
  63146. quality?: number;
  63147. }
  63148. /**
  63149. * Filters HDR maps to get correct renderings of PBR reflections
  63150. */
  63151. export class HDRFiltering {
  63152. private _engine;
  63153. private _effectRenderer;
  63154. private _effectWrapper;
  63155. private _lodGenerationOffset;
  63156. private _lodGenerationScale;
  63157. /**
  63158. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63159. * you care about baking speed.
  63160. */
  63161. quality: number;
  63162. /**
  63163. * Scales pixel intensity for the input HDR map.
  63164. */
  63165. hdrScale: number;
  63166. /**
  63167. * Instantiates HDR filter for reflection maps
  63168. *
  63169. * @param engine Thin engine
  63170. * @param options Options
  63171. */
  63172. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63173. private _createRenderTarget;
  63174. private _prefilterInternal;
  63175. private _createEffect;
  63176. /**
  63177. * Get a value indicating if the filter is ready to be used
  63178. * @param texture Texture to filter
  63179. * @returns true if the filter is ready
  63180. */
  63181. isReady(texture: BaseTexture): boolean;
  63182. /**
  63183. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63184. * Prefiltering will be invoked at the end of next rendering pass.
  63185. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63186. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63187. * @param texture Texture to filter
  63188. * @param onFinished Callback when filtering is done
  63189. * @return Promise called when prefiltering is done
  63190. */
  63191. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63192. }
  63193. }
  63194. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63195. import { Nullable } from "babylonjs/types";
  63196. import { Scene } from "babylonjs/scene";
  63197. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63200. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63201. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63202. /**
  63203. * This represents a texture coming from an HDR input.
  63204. *
  63205. * The only supported format is currently panorama picture stored in RGBE format.
  63206. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63207. */
  63208. export class HDRCubeTexture extends BaseTexture {
  63209. private static _facesMapping;
  63210. private _generateHarmonics;
  63211. private _noMipmap;
  63212. private _prefilterOnLoad;
  63213. private _textureMatrix;
  63214. private _size;
  63215. private _onLoad;
  63216. private _onError;
  63217. /**
  63218. * The texture URL.
  63219. */
  63220. url: string;
  63221. protected _isBlocking: boolean;
  63222. /**
  63223. * Sets wether or not the texture is blocking during loading.
  63224. */
  63225. set isBlocking(value: boolean);
  63226. /**
  63227. * Gets wether or not the texture is blocking during loading.
  63228. */
  63229. get isBlocking(): boolean;
  63230. protected _rotationY: number;
  63231. /**
  63232. * Sets texture matrix rotation angle around Y axis in radians.
  63233. */
  63234. set rotationY(value: number);
  63235. /**
  63236. * Gets texture matrix rotation angle around Y axis radians.
  63237. */
  63238. get rotationY(): number;
  63239. /**
  63240. * Gets or sets the center of the bounding box associated with the cube texture
  63241. * It must define where the camera used to render the texture was set
  63242. */
  63243. boundingBoxPosition: Vector3;
  63244. private _boundingBoxSize;
  63245. /**
  63246. * Gets or sets the size of the bounding box associated with the cube texture
  63247. * When defined, the cubemap will switch to local mode
  63248. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63249. * @example https://www.babylonjs-playground.com/#RNASML
  63250. */
  63251. set boundingBoxSize(value: Vector3);
  63252. get boundingBoxSize(): Vector3;
  63253. /**
  63254. * Instantiates an HDRTexture from the following parameters.
  63255. *
  63256. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63257. * @param sceneOrEngine The scene or engine the texture will be used in
  63258. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63259. * @param noMipmap Forces to not generate the mipmap if true
  63260. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63261. * @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)
  63262. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63263. */
  63264. 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>);
  63265. /**
  63266. * Get the current class name of the texture useful for serialization or dynamic coding.
  63267. * @returns "HDRCubeTexture"
  63268. */
  63269. getClassName(): string;
  63270. /**
  63271. * Occurs when the file is raw .hdr file.
  63272. */
  63273. private loadTexture;
  63274. clone(): HDRCubeTexture;
  63275. delayLoad(): void;
  63276. /**
  63277. * Get the texture reflection matrix used to rotate/transform the reflection.
  63278. * @returns the reflection matrix
  63279. */
  63280. getReflectionTextureMatrix(): Matrix;
  63281. /**
  63282. * Set the texture reflection matrix used to rotate/transform the reflection.
  63283. * @param value Define the reflection matrix to set
  63284. */
  63285. setReflectionTextureMatrix(value: Matrix): void;
  63286. /**
  63287. * Parses a JSON representation of an HDR Texture in order to create the texture
  63288. * @param parsedTexture Define the JSON representation
  63289. * @param scene Define the scene the texture should be created in
  63290. * @param rootUrl Define the root url in case we need to load relative dependencies
  63291. * @returns the newly created texture after parsing
  63292. */
  63293. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63294. serialize(): any;
  63295. }
  63296. }
  63297. declare module "babylonjs/Physics/physicsEngine" {
  63298. import { Nullable } from "babylonjs/types";
  63299. import { Vector3 } from "babylonjs/Maths/math.vector";
  63300. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63301. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63302. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63303. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63304. /**
  63305. * Class used to control physics engine
  63306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63307. */
  63308. export class PhysicsEngine implements IPhysicsEngine {
  63309. private _physicsPlugin;
  63310. /**
  63311. * Global value used to control the smallest number supported by the simulation
  63312. */
  63313. static Epsilon: number;
  63314. private _impostors;
  63315. private _joints;
  63316. private _subTimeStep;
  63317. /**
  63318. * Gets the gravity vector used by the simulation
  63319. */
  63320. gravity: Vector3;
  63321. /**
  63322. * Factory used to create the default physics plugin.
  63323. * @returns The default physics plugin
  63324. */
  63325. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63326. /**
  63327. * Creates a new Physics Engine
  63328. * @param gravity defines the gravity vector used by the simulation
  63329. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63330. */
  63331. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63332. /**
  63333. * Sets the gravity vector used by the simulation
  63334. * @param gravity defines the gravity vector to use
  63335. */
  63336. setGravity(gravity: Vector3): void;
  63337. /**
  63338. * Set the time step of the physics engine.
  63339. * Default is 1/60.
  63340. * To slow it down, enter 1/600 for example.
  63341. * To speed it up, 1/30
  63342. * @param newTimeStep defines the new timestep to apply to this world.
  63343. */
  63344. setTimeStep(newTimeStep?: number): void;
  63345. /**
  63346. * Get the time step of the physics engine.
  63347. * @returns the current time step
  63348. */
  63349. getTimeStep(): number;
  63350. /**
  63351. * Set the sub time step of the physics engine.
  63352. * Default is 0 meaning there is no sub steps
  63353. * To increase physics resolution precision, set a small value (like 1 ms)
  63354. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63355. */
  63356. setSubTimeStep(subTimeStep?: number): void;
  63357. /**
  63358. * Get the sub time step of the physics engine.
  63359. * @returns the current sub time step
  63360. */
  63361. getSubTimeStep(): number;
  63362. /**
  63363. * Release all resources
  63364. */
  63365. dispose(): void;
  63366. /**
  63367. * Gets the name of the current physics plugin
  63368. * @returns the name of the plugin
  63369. */
  63370. getPhysicsPluginName(): string;
  63371. /**
  63372. * Adding a new impostor for the impostor tracking.
  63373. * This will be done by the impostor itself.
  63374. * @param impostor the impostor to add
  63375. */
  63376. addImpostor(impostor: PhysicsImpostor): void;
  63377. /**
  63378. * Remove an impostor from the engine.
  63379. * This impostor and its mesh will not longer be updated by the physics engine.
  63380. * @param impostor the impostor to remove
  63381. */
  63382. removeImpostor(impostor: PhysicsImpostor): void;
  63383. /**
  63384. * Add a joint to the physics engine
  63385. * @param mainImpostor defines the main impostor to which the joint is added.
  63386. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63387. * @param joint defines the joint that will connect both impostors.
  63388. */
  63389. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63390. /**
  63391. * Removes a joint from the simulation
  63392. * @param mainImpostor defines the impostor used with the joint
  63393. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63394. * @param joint defines the joint to remove
  63395. */
  63396. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63397. /**
  63398. * Called by the scene. No need to call it.
  63399. * @param delta defines the timespam between frames
  63400. */
  63401. _step(delta: number): void;
  63402. /**
  63403. * Gets the current plugin used to run the simulation
  63404. * @returns current plugin
  63405. */
  63406. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63407. /**
  63408. * Gets the list of physic impostors
  63409. * @returns an array of PhysicsImpostor
  63410. */
  63411. getImpostors(): Array<PhysicsImpostor>;
  63412. /**
  63413. * Gets the impostor for a physics enabled object
  63414. * @param object defines the object impersonated by the impostor
  63415. * @returns the PhysicsImpostor or null if not found
  63416. */
  63417. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63418. /**
  63419. * Gets the impostor for a physics body object
  63420. * @param body defines physics body used by the impostor
  63421. * @returns the PhysicsImpostor or null if not found
  63422. */
  63423. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63424. /**
  63425. * Does a raycast in the physics world
  63426. * @param from when should the ray start?
  63427. * @param to when should the ray end?
  63428. * @returns PhysicsRaycastResult
  63429. */
  63430. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63431. }
  63432. }
  63433. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63434. import { Nullable } from "babylonjs/types";
  63435. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63437. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63438. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63439. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63440. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63441. /** @hidden */
  63442. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63443. private _useDeltaForWorldStep;
  63444. world: any;
  63445. name: string;
  63446. private _physicsMaterials;
  63447. private _fixedTimeStep;
  63448. private _cannonRaycastResult;
  63449. private _raycastResult;
  63450. private _physicsBodysToRemoveAfterStep;
  63451. private _firstFrame;
  63452. BJSCANNON: any;
  63453. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63454. setGravity(gravity: Vector3): void;
  63455. setTimeStep(timeStep: number): void;
  63456. getTimeStep(): number;
  63457. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63458. private _removeMarkedPhysicsBodiesFromWorld;
  63459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63460. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63461. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63462. private _processChildMeshes;
  63463. removePhysicsBody(impostor: PhysicsImpostor): void;
  63464. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63465. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63466. private _addMaterial;
  63467. private _checkWithEpsilon;
  63468. private _createShape;
  63469. private _createHeightmap;
  63470. private _minus90X;
  63471. private _plus90X;
  63472. private _tmpPosition;
  63473. private _tmpDeltaPosition;
  63474. private _tmpUnityRotation;
  63475. private _updatePhysicsBodyTransformation;
  63476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63477. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63478. isSupported(): boolean;
  63479. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63480. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63481. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63482. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63483. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63484. getBodyMass(impostor: PhysicsImpostor): number;
  63485. getBodyFriction(impostor: PhysicsImpostor): number;
  63486. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63487. getBodyRestitution(impostor: PhysicsImpostor): number;
  63488. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63489. sleepBody(impostor: PhysicsImpostor): void;
  63490. wakeUpBody(impostor: PhysicsImpostor): void;
  63491. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63492. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63493. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63494. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63495. getRadius(impostor: PhysicsImpostor): number;
  63496. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63497. dispose(): void;
  63498. private _extendNamespace;
  63499. /**
  63500. * Does a raycast in the physics world
  63501. * @param from when should the ray start?
  63502. * @param to when should the ray end?
  63503. * @returns PhysicsRaycastResult
  63504. */
  63505. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63506. }
  63507. }
  63508. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63509. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63510. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63511. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63513. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63514. import { Nullable } from "babylonjs/types";
  63515. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63516. /** @hidden */
  63517. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63518. private _useDeltaForWorldStep;
  63519. world: any;
  63520. name: string;
  63521. BJSOIMO: any;
  63522. private _raycastResult;
  63523. private _fixedTimeStep;
  63524. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63525. setGravity(gravity: Vector3): void;
  63526. setTimeStep(timeStep: number): void;
  63527. getTimeStep(): number;
  63528. private _tmpImpostorsArray;
  63529. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63530. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63531. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63532. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63533. private _tmpPositionVector;
  63534. removePhysicsBody(impostor: PhysicsImpostor): void;
  63535. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63536. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63537. isSupported(): boolean;
  63538. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63539. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63540. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63541. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63542. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63543. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63544. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63545. getBodyMass(impostor: PhysicsImpostor): number;
  63546. getBodyFriction(impostor: PhysicsImpostor): number;
  63547. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63548. getBodyRestitution(impostor: PhysicsImpostor): number;
  63549. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63550. sleepBody(impostor: PhysicsImpostor): void;
  63551. wakeUpBody(impostor: PhysicsImpostor): void;
  63552. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63553. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63554. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63555. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63556. getRadius(impostor: PhysicsImpostor): number;
  63557. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63558. dispose(): void;
  63559. /**
  63560. * Does a raycast in the physics world
  63561. * @param from when should the ray start?
  63562. * @param to when should the ray end?
  63563. * @returns PhysicsRaycastResult
  63564. */
  63565. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63566. }
  63567. }
  63568. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63569. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63570. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63571. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63572. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63573. import { Nullable } from "babylonjs/types";
  63574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63575. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63576. /**
  63577. * AmmoJS Physics plugin
  63578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63579. * @see https://github.com/kripken/ammo.js/
  63580. */
  63581. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63582. private _useDeltaForWorldStep;
  63583. /**
  63584. * Reference to the Ammo library
  63585. */
  63586. bjsAMMO: any;
  63587. /**
  63588. * Created ammoJS world which physics bodies are added to
  63589. */
  63590. world: any;
  63591. /**
  63592. * Name of the plugin
  63593. */
  63594. name: string;
  63595. private _timeStep;
  63596. private _fixedTimeStep;
  63597. private _maxSteps;
  63598. private _tmpQuaternion;
  63599. private _tmpAmmoTransform;
  63600. private _tmpAmmoQuaternion;
  63601. private _tmpAmmoConcreteContactResultCallback;
  63602. private _collisionConfiguration;
  63603. private _dispatcher;
  63604. private _overlappingPairCache;
  63605. private _solver;
  63606. private _softBodySolver;
  63607. private _tmpAmmoVectorA;
  63608. private _tmpAmmoVectorB;
  63609. private _tmpAmmoVectorC;
  63610. private _tmpAmmoVectorD;
  63611. private _tmpContactCallbackResult;
  63612. private _tmpAmmoVectorRCA;
  63613. private _tmpAmmoVectorRCB;
  63614. private _raycastResult;
  63615. private static readonly DISABLE_COLLISION_FLAG;
  63616. private static readonly KINEMATIC_FLAG;
  63617. private static readonly DISABLE_DEACTIVATION_FLAG;
  63618. /**
  63619. * Initializes the ammoJS plugin
  63620. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63621. * @param ammoInjection can be used to inject your own ammo reference
  63622. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63623. */
  63624. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63625. /**
  63626. * Sets the gravity of the physics world (m/(s^2))
  63627. * @param gravity Gravity to set
  63628. */
  63629. setGravity(gravity: Vector3): void;
  63630. /**
  63631. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63632. * @param timeStep timestep to use in seconds
  63633. */
  63634. setTimeStep(timeStep: number): void;
  63635. /**
  63636. * 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)
  63637. * @param fixedTimeStep fixedTimeStep to use in seconds
  63638. */
  63639. setFixedTimeStep(fixedTimeStep: number): void;
  63640. /**
  63641. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63642. * @param maxSteps the maximum number of steps by the physics engine per frame
  63643. */
  63644. setMaxSteps(maxSteps: number): void;
  63645. /**
  63646. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63647. * @returns the current timestep in seconds
  63648. */
  63649. getTimeStep(): number;
  63650. /**
  63651. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63652. */
  63653. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63654. private _isImpostorInContact;
  63655. private _isImpostorPairInContact;
  63656. private _stepSimulation;
  63657. /**
  63658. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63659. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63660. * After the step the babylon meshes are set to the position of the physics imposters
  63661. * @param delta amount of time to step forward
  63662. * @param impostors array of imposters to update before/after the step
  63663. */
  63664. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63665. /**
  63666. * Update babylon mesh to match physics world object
  63667. * @param impostor imposter to match
  63668. */
  63669. private _afterSoftStep;
  63670. /**
  63671. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63672. * @param impostor imposter to match
  63673. */
  63674. private _ropeStep;
  63675. /**
  63676. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63677. * @param impostor imposter to match
  63678. */
  63679. private _softbodyOrClothStep;
  63680. private _tmpMatrix;
  63681. /**
  63682. * Applies an impulse on the imposter
  63683. * @param impostor imposter to apply impulse to
  63684. * @param force amount of force to be applied to the imposter
  63685. * @param contactPoint the location to apply the impulse on the imposter
  63686. */
  63687. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63688. /**
  63689. * Applies a force on the imposter
  63690. * @param impostor imposter to apply force
  63691. * @param force amount of force to be applied to the imposter
  63692. * @param contactPoint the location to apply the force on the imposter
  63693. */
  63694. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63695. /**
  63696. * Creates a physics body using the plugin
  63697. * @param impostor the imposter to create the physics body on
  63698. */
  63699. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63700. /**
  63701. * Removes the physics body from the imposter and disposes of the body's memory
  63702. * @param impostor imposter to remove the physics body from
  63703. */
  63704. removePhysicsBody(impostor: PhysicsImpostor): void;
  63705. /**
  63706. * Generates a joint
  63707. * @param impostorJoint the imposter joint to create the joint with
  63708. */
  63709. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63710. /**
  63711. * Removes a joint
  63712. * @param impostorJoint the imposter joint to remove the joint from
  63713. */
  63714. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63715. private _addMeshVerts;
  63716. /**
  63717. * Initialise the soft body vertices to match its object's (mesh) vertices
  63718. * Softbody vertices (nodes) are in world space and to match this
  63719. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63720. * @param impostor to create the softbody for
  63721. */
  63722. private _softVertexData;
  63723. /**
  63724. * Create an impostor's soft body
  63725. * @param impostor to create the softbody for
  63726. */
  63727. private _createSoftbody;
  63728. /**
  63729. * Create cloth for an impostor
  63730. * @param impostor to create the softbody for
  63731. */
  63732. private _createCloth;
  63733. /**
  63734. * Create rope for an impostor
  63735. * @param impostor to create the softbody for
  63736. */
  63737. private _createRope;
  63738. /**
  63739. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63740. * @param impostor to create the custom physics shape for
  63741. */
  63742. private _createCustom;
  63743. private _addHullVerts;
  63744. private _createShape;
  63745. /**
  63746. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63747. * @param impostor imposter containing the physics body and babylon object
  63748. */
  63749. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63750. /**
  63751. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63752. * @param impostor imposter containing the physics body and babylon object
  63753. * @param newPosition new position
  63754. * @param newRotation new rotation
  63755. */
  63756. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63757. /**
  63758. * If this plugin is supported
  63759. * @returns true if its supported
  63760. */
  63761. isSupported(): boolean;
  63762. /**
  63763. * Sets the linear velocity of the physics body
  63764. * @param impostor imposter to set the velocity on
  63765. * @param velocity velocity to set
  63766. */
  63767. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63768. /**
  63769. * Sets the angular velocity of the physics body
  63770. * @param impostor imposter to set the velocity on
  63771. * @param velocity velocity to set
  63772. */
  63773. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63774. /**
  63775. * gets the linear velocity
  63776. * @param impostor imposter to get linear velocity from
  63777. * @returns linear velocity
  63778. */
  63779. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63780. /**
  63781. * gets the angular velocity
  63782. * @param impostor imposter to get angular velocity from
  63783. * @returns angular velocity
  63784. */
  63785. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63786. /**
  63787. * Sets the mass of physics body
  63788. * @param impostor imposter to set the mass on
  63789. * @param mass mass to set
  63790. */
  63791. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63792. /**
  63793. * Gets the mass of the physics body
  63794. * @param impostor imposter to get the mass from
  63795. * @returns mass
  63796. */
  63797. getBodyMass(impostor: PhysicsImpostor): number;
  63798. /**
  63799. * Gets friction of the impostor
  63800. * @param impostor impostor to get friction from
  63801. * @returns friction value
  63802. */
  63803. getBodyFriction(impostor: PhysicsImpostor): number;
  63804. /**
  63805. * Sets friction of the impostor
  63806. * @param impostor impostor to set friction on
  63807. * @param friction friction value
  63808. */
  63809. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63810. /**
  63811. * Gets restitution of the impostor
  63812. * @param impostor impostor to get restitution from
  63813. * @returns restitution value
  63814. */
  63815. getBodyRestitution(impostor: PhysicsImpostor): number;
  63816. /**
  63817. * Sets resitution of the impostor
  63818. * @param impostor impostor to set resitution on
  63819. * @param restitution resitution value
  63820. */
  63821. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63822. /**
  63823. * Gets pressure inside the impostor
  63824. * @param impostor impostor to get pressure from
  63825. * @returns pressure value
  63826. */
  63827. getBodyPressure(impostor: PhysicsImpostor): number;
  63828. /**
  63829. * Sets pressure inside a soft body impostor
  63830. * Cloth and rope must remain 0 pressure
  63831. * @param impostor impostor to set pressure on
  63832. * @param pressure pressure value
  63833. */
  63834. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63835. /**
  63836. * Gets stiffness of the impostor
  63837. * @param impostor impostor to get stiffness from
  63838. * @returns pressure value
  63839. */
  63840. getBodyStiffness(impostor: PhysicsImpostor): number;
  63841. /**
  63842. * Sets stiffness of the impostor
  63843. * @param impostor impostor to set stiffness on
  63844. * @param stiffness stiffness value from 0 to 1
  63845. */
  63846. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63847. /**
  63848. * Gets velocityIterations of the impostor
  63849. * @param impostor impostor to get velocity iterations from
  63850. * @returns velocityIterations value
  63851. */
  63852. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63853. /**
  63854. * Sets velocityIterations of the impostor
  63855. * @param impostor impostor to set velocity iterations on
  63856. * @param velocityIterations velocityIterations value
  63857. */
  63858. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63859. /**
  63860. * Gets positionIterations of the impostor
  63861. * @param impostor impostor to get position iterations from
  63862. * @returns positionIterations value
  63863. */
  63864. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63865. /**
  63866. * Sets positionIterations of the impostor
  63867. * @param impostor impostor to set position on
  63868. * @param positionIterations positionIterations value
  63869. */
  63870. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63871. /**
  63872. * Append an anchor to a cloth object
  63873. * @param impostor is the cloth impostor to add anchor to
  63874. * @param otherImpostor is the rigid impostor to anchor to
  63875. * @param width ratio across width from 0 to 1
  63876. * @param height ratio up height from 0 to 1
  63877. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63878. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63879. */
  63880. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63881. /**
  63882. * Append an hook to a rope object
  63883. * @param impostor is the rope impostor to add hook to
  63884. * @param otherImpostor is the rigid impostor to hook to
  63885. * @param length ratio along the rope from 0 to 1
  63886. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63887. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63888. */
  63889. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63890. /**
  63891. * Sleeps the physics body and stops it from being active
  63892. * @param impostor impostor to sleep
  63893. */
  63894. sleepBody(impostor: PhysicsImpostor): void;
  63895. /**
  63896. * Activates the physics body
  63897. * @param impostor impostor to activate
  63898. */
  63899. wakeUpBody(impostor: PhysicsImpostor): void;
  63900. /**
  63901. * Updates the distance parameters of the joint
  63902. * @param joint joint to update
  63903. * @param maxDistance maximum distance of the joint
  63904. * @param minDistance minimum distance of the joint
  63905. */
  63906. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63907. /**
  63908. * Sets a motor on the joint
  63909. * @param joint joint to set motor on
  63910. * @param speed speed of the motor
  63911. * @param maxForce maximum force of the motor
  63912. * @param motorIndex index of the motor
  63913. */
  63914. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63915. /**
  63916. * Sets the motors limit
  63917. * @param joint joint to set limit on
  63918. * @param upperLimit upper limit
  63919. * @param lowerLimit lower limit
  63920. */
  63921. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63922. /**
  63923. * Syncs the position and rotation of a mesh with the impostor
  63924. * @param mesh mesh to sync
  63925. * @param impostor impostor to update the mesh with
  63926. */
  63927. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63928. /**
  63929. * Gets the radius of the impostor
  63930. * @param impostor impostor to get radius from
  63931. * @returns the radius
  63932. */
  63933. getRadius(impostor: PhysicsImpostor): number;
  63934. /**
  63935. * Gets the box size of the impostor
  63936. * @param impostor impostor to get box size from
  63937. * @param result the resulting box size
  63938. */
  63939. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63940. /**
  63941. * Disposes of the impostor
  63942. */
  63943. dispose(): void;
  63944. /**
  63945. * Does a raycast in the physics world
  63946. * @param from when should the ray start?
  63947. * @param to when should the ray end?
  63948. * @returns PhysicsRaycastResult
  63949. */
  63950. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63951. }
  63952. }
  63953. declare module "babylonjs/Probes/reflectionProbe" {
  63954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63955. import { Vector3 } from "babylonjs/Maths/math.vector";
  63956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63957. import { Nullable } from "babylonjs/types";
  63958. import { Scene } from "babylonjs/scene";
  63959. module "babylonjs/abstractScene" {
  63960. interface AbstractScene {
  63961. /**
  63962. * The list of reflection probes added to the scene
  63963. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63964. */
  63965. reflectionProbes: Array<ReflectionProbe>;
  63966. /**
  63967. * Removes the given reflection probe from this scene.
  63968. * @param toRemove The reflection probe to remove
  63969. * @returns The index of the removed reflection probe
  63970. */
  63971. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63972. /**
  63973. * Adds the given reflection probe to this scene.
  63974. * @param newReflectionProbe The reflection probe to add
  63975. */
  63976. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63977. }
  63978. }
  63979. /**
  63980. * Class used to generate realtime reflection / refraction cube textures
  63981. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63982. */
  63983. export class ReflectionProbe {
  63984. /** defines the name of the probe */
  63985. name: string;
  63986. private _scene;
  63987. private _renderTargetTexture;
  63988. private _projectionMatrix;
  63989. private _viewMatrix;
  63990. private _target;
  63991. private _add;
  63992. private _attachedMesh;
  63993. private _invertYAxis;
  63994. /** Gets or sets probe position (center of the cube map) */
  63995. position: Vector3;
  63996. /**
  63997. * Creates a new reflection probe
  63998. * @param name defines the name of the probe
  63999. * @param size defines the texture resolution (for each face)
  64000. * @param scene defines the hosting scene
  64001. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64002. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64003. */
  64004. constructor(
  64005. /** defines the name of the probe */
  64006. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64007. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64008. get samples(): number;
  64009. set samples(value: number);
  64010. /** Gets or sets the refresh rate to use (on every frame by default) */
  64011. get refreshRate(): number;
  64012. set refreshRate(value: number);
  64013. /**
  64014. * Gets the hosting scene
  64015. * @returns a Scene
  64016. */
  64017. getScene(): Scene;
  64018. /** Gets the internal CubeTexture used to render to */
  64019. get cubeTexture(): RenderTargetTexture;
  64020. /** Gets the list of meshes to render */
  64021. get renderList(): Nullable<AbstractMesh[]>;
  64022. /**
  64023. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64024. * @param mesh defines the mesh to attach to
  64025. */
  64026. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64027. /**
  64028. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64029. * @param renderingGroupId The rendering group id corresponding to its index
  64030. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64031. */
  64032. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64033. /**
  64034. * Clean all associated resources
  64035. */
  64036. dispose(): void;
  64037. /**
  64038. * Converts the reflection probe information to a readable string for debug purpose.
  64039. * @param fullDetails Supports for multiple levels of logging within scene loading
  64040. * @returns the human readable reflection probe info
  64041. */
  64042. toString(fullDetails?: boolean): string;
  64043. /**
  64044. * Get the class name of the relfection probe.
  64045. * @returns "ReflectionProbe"
  64046. */
  64047. getClassName(): string;
  64048. /**
  64049. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64050. * @returns The JSON representation of the texture
  64051. */
  64052. serialize(): any;
  64053. /**
  64054. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64055. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64056. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64057. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64058. * @returns The parsed reflection probe if successful
  64059. */
  64060. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64061. }
  64062. }
  64063. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64064. /** @hidden */
  64065. export var _BabylonLoaderRegistered: boolean;
  64066. /**
  64067. * Helps setting up some configuration for the babylon file loader.
  64068. */
  64069. export class BabylonFileLoaderConfiguration {
  64070. /**
  64071. * The loader does not allow injecting custom physix engine into the plugins.
  64072. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64073. * So you could set this variable to your engine import to make it work.
  64074. */
  64075. static LoaderInjectedPhysicsEngine: any;
  64076. }
  64077. }
  64078. declare module "babylonjs/Loading/Plugins/index" {
  64079. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64080. }
  64081. declare module "babylonjs/Loading/index" {
  64082. export * from "babylonjs/Loading/loadingScreen";
  64083. export * from "babylonjs/Loading/Plugins/index";
  64084. export * from "babylonjs/Loading/sceneLoader";
  64085. export * from "babylonjs/Loading/sceneLoaderFlags";
  64086. }
  64087. declare module "babylonjs/Materials/Background/index" {
  64088. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64089. }
  64090. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64091. import { Scene } from "babylonjs/scene";
  64092. import { Color3 } from "babylonjs/Maths/math.color";
  64093. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64095. /**
  64096. * The Physically based simple base material of BJS.
  64097. *
  64098. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64099. * It is used as the base class for both the specGloss and metalRough conventions.
  64100. */
  64101. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64102. /**
  64103. * Number of Simultaneous lights allowed on the material.
  64104. */
  64105. maxSimultaneousLights: number;
  64106. /**
  64107. * If sets to true, disables all the lights affecting the material.
  64108. */
  64109. disableLighting: boolean;
  64110. /**
  64111. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64112. */
  64113. environmentTexture: BaseTexture;
  64114. /**
  64115. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64116. */
  64117. invertNormalMapX: boolean;
  64118. /**
  64119. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64120. */
  64121. invertNormalMapY: boolean;
  64122. /**
  64123. * Normal map used in the model.
  64124. */
  64125. normalTexture: BaseTexture;
  64126. /**
  64127. * Emissivie color used to self-illuminate the model.
  64128. */
  64129. emissiveColor: Color3;
  64130. /**
  64131. * Emissivie texture used to self-illuminate the model.
  64132. */
  64133. emissiveTexture: BaseTexture;
  64134. /**
  64135. * Occlusion Channel Strenght.
  64136. */
  64137. occlusionStrength: number;
  64138. /**
  64139. * Occlusion Texture of the material (adding extra occlusion effects).
  64140. */
  64141. occlusionTexture: BaseTexture;
  64142. /**
  64143. * Defines the alpha limits in alpha test mode.
  64144. */
  64145. alphaCutOff: number;
  64146. /**
  64147. * Gets the current double sided mode.
  64148. */
  64149. get doubleSided(): boolean;
  64150. /**
  64151. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64152. */
  64153. set doubleSided(value: boolean);
  64154. /**
  64155. * Stores the pre-calculated light information of a mesh in a texture.
  64156. */
  64157. lightmapTexture: BaseTexture;
  64158. /**
  64159. * If true, the light map contains occlusion information instead of lighting info.
  64160. */
  64161. useLightmapAsShadowmap: boolean;
  64162. /**
  64163. * Instantiates a new PBRMaterial instance.
  64164. *
  64165. * @param name The material name
  64166. * @param scene The scene the material will be use in.
  64167. */
  64168. constructor(name: string, scene: Scene);
  64169. getClassName(): string;
  64170. }
  64171. }
  64172. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64173. import { Scene } from "babylonjs/scene";
  64174. import { Color3 } from "babylonjs/Maths/math.color";
  64175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64176. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64177. /**
  64178. * The PBR material of BJS following the metal roughness convention.
  64179. *
  64180. * This fits to the PBR convention in the GLTF definition:
  64181. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64182. */
  64183. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64184. /**
  64185. * The base color has two different interpretations depending on the value of metalness.
  64186. * When the material is a metal, the base color is the specific measured reflectance value
  64187. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64188. * of the material.
  64189. */
  64190. baseColor: Color3;
  64191. /**
  64192. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64193. * well as opacity information in the alpha channel.
  64194. */
  64195. baseTexture: BaseTexture;
  64196. /**
  64197. * Specifies the metallic scalar value of the material.
  64198. * Can also be used to scale the metalness values of the metallic texture.
  64199. */
  64200. metallic: number;
  64201. /**
  64202. * Specifies the roughness scalar value of the material.
  64203. * Can also be used to scale the roughness values of the metallic texture.
  64204. */
  64205. roughness: number;
  64206. /**
  64207. * Texture containing both the metallic value in the B channel and the
  64208. * roughness value in the G channel to keep better precision.
  64209. */
  64210. metallicRoughnessTexture: BaseTexture;
  64211. /**
  64212. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64213. *
  64214. * @param name The material name
  64215. * @param scene The scene the material will be use in.
  64216. */
  64217. constructor(name: string, scene: Scene);
  64218. /**
  64219. * Return the currrent class name of the material.
  64220. */
  64221. getClassName(): string;
  64222. /**
  64223. * Makes a duplicate of the current material.
  64224. * @param name - name to use for the new material.
  64225. */
  64226. clone(name: string): PBRMetallicRoughnessMaterial;
  64227. /**
  64228. * Serialize the material to a parsable JSON object.
  64229. */
  64230. serialize(): any;
  64231. /**
  64232. * Parses a JSON object correponding to the serialize function.
  64233. */
  64234. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64235. }
  64236. }
  64237. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64238. import { Scene } from "babylonjs/scene";
  64239. import { Color3 } from "babylonjs/Maths/math.color";
  64240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64241. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64242. /**
  64243. * The PBR material of BJS following the specular glossiness convention.
  64244. *
  64245. * This fits to the PBR convention in the GLTF definition:
  64246. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64247. */
  64248. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64249. /**
  64250. * Specifies the diffuse color of the material.
  64251. */
  64252. diffuseColor: Color3;
  64253. /**
  64254. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64255. * channel.
  64256. */
  64257. diffuseTexture: BaseTexture;
  64258. /**
  64259. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64260. */
  64261. specularColor: Color3;
  64262. /**
  64263. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64264. */
  64265. glossiness: number;
  64266. /**
  64267. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64268. */
  64269. specularGlossinessTexture: BaseTexture;
  64270. /**
  64271. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64272. *
  64273. * @param name The material name
  64274. * @param scene The scene the material will be use in.
  64275. */
  64276. constructor(name: string, scene: Scene);
  64277. /**
  64278. * Return the currrent class name of the material.
  64279. */
  64280. getClassName(): string;
  64281. /**
  64282. * Makes a duplicate of the current material.
  64283. * @param name - name to use for the new material.
  64284. */
  64285. clone(name: string): PBRSpecularGlossinessMaterial;
  64286. /**
  64287. * Serialize the material to a parsable JSON object.
  64288. */
  64289. serialize(): any;
  64290. /**
  64291. * Parses a JSON object correponding to the serialize function.
  64292. */
  64293. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64294. }
  64295. }
  64296. declare module "babylonjs/Materials/PBR/index" {
  64297. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64298. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64299. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64300. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64301. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64302. }
  64303. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64304. import { Nullable } from "babylonjs/types";
  64305. import { Scene } from "babylonjs/scene";
  64306. import { Matrix } from "babylonjs/Maths/math.vector";
  64307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64308. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64309. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64310. /**
  64311. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64312. * It can help converting any input color in a desired output one. This can then be used to create effects
  64313. * from sepia, black and white to sixties or futuristic rendering...
  64314. *
  64315. * The only supported format is currently 3dl.
  64316. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64317. */
  64318. export class ColorGradingTexture extends BaseTexture {
  64319. /**
  64320. * The texture URL.
  64321. */
  64322. url: string;
  64323. /**
  64324. * Empty line regex stored for GC.
  64325. */
  64326. private static _noneEmptyLineRegex;
  64327. private _textureMatrix;
  64328. private _onLoad;
  64329. /**
  64330. * Instantiates a ColorGradingTexture from the following parameters.
  64331. *
  64332. * @param url The location of the color gradind data (currently only supporting 3dl)
  64333. * @param sceneOrEngine The scene or engine the texture will be used in
  64334. * @param onLoad defines a callback triggered when the texture has been loaded
  64335. */
  64336. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64337. /**
  64338. * Fires the onload event from the constructor if requested.
  64339. */
  64340. private _triggerOnLoad;
  64341. /**
  64342. * Returns the texture matrix used in most of the material.
  64343. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64344. */
  64345. getTextureMatrix(): Matrix;
  64346. /**
  64347. * Occurs when the file being loaded is a .3dl LUT file.
  64348. */
  64349. private load3dlTexture;
  64350. /**
  64351. * Starts the loading process of the texture.
  64352. */
  64353. private loadTexture;
  64354. /**
  64355. * Clones the color gradind texture.
  64356. */
  64357. clone(): ColorGradingTexture;
  64358. /**
  64359. * Called during delayed load for textures.
  64360. */
  64361. delayLoad(): void;
  64362. /**
  64363. * Parses a color grading texture serialized by Babylon.
  64364. * @param parsedTexture The texture information being parsedTexture
  64365. * @param scene The scene to load the texture in
  64366. * @param rootUrl The root url of the data assets to load
  64367. * @return A color gradind texture
  64368. */
  64369. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64370. /**
  64371. * Serializes the LUT texture to json format.
  64372. */
  64373. serialize(): any;
  64374. }
  64375. }
  64376. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64378. import { Scene } from "babylonjs/scene";
  64379. import { Nullable } from "babylonjs/types";
  64380. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64381. /**
  64382. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64383. */
  64384. export class EquiRectangularCubeTexture extends BaseTexture {
  64385. /** The six faces of the cube. */
  64386. private static _FacesMapping;
  64387. private _noMipmap;
  64388. private _onLoad;
  64389. private _onError;
  64390. /** The size of the cubemap. */
  64391. private _size;
  64392. /** The buffer of the image. */
  64393. private _buffer;
  64394. /** The width of the input image. */
  64395. private _width;
  64396. /** The height of the input image. */
  64397. private _height;
  64398. /** The URL to the image. */
  64399. url: string;
  64400. /**
  64401. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64402. * @param url The location of the image
  64403. * @param scene The scene the texture will be used in
  64404. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64405. * @param noMipmap Forces to not generate the mipmap if true
  64406. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64407. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64408. * @param onLoad — defines a callback called when texture is loaded
  64409. * @param onError — defines a callback called if there is an error
  64410. */
  64411. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64412. /**
  64413. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64414. */
  64415. private loadImage;
  64416. /**
  64417. * Convert the image buffer into a cubemap and create a CubeTexture.
  64418. */
  64419. private loadTexture;
  64420. /**
  64421. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64422. * @param buffer The ArrayBuffer that should be converted.
  64423. * @returns The buffer as Float32Array.
  64424. */
  64425. private getFloat32ArrayFromArrayBuffer;
  64426. /**
  64427. * Get the current class name of the texture useful for serialization or dynamic coding.
  64428. * @returns "EquiRectangularCubeTexture"
  64429. */
  64430. getClassName(): string;
  64431. /**
  64432. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64433. * @returns A clone of the current EquiRectangularCubeTexture.
  64434. */
  64435. clone(): EquiRectangularCubeTexture;
  64436. }
  64437. }
  64438. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64439. import { Nullable } from "babylonjs/types";
  64440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64441. import { Matrix } from "babylonjs/Maths/math.vector";
  64442. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64443. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64444. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64445. import { Scene } from "babylonjs/scene";
  64446. /**
  64447. * Defines the options related to the creation of an HtmlElementTexture
  64448. */
  64449. export interface IHtmlElementTextureOptions {
  64450. /**
  64451. * Defines wether mip maps should be created or not.
  64452. */
  64453. generateMipMaps?: boolean;
  64454. /**
  64455. * Defines the sampling mode of the texture.
  64456. */
  64457. samplingMode?: number;
  64458. /**
  64459. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64460. */
  64461. engine: Nullable<ThinEngine>;
  64462. /**
  64463. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64464. */
  64465. scene: Nullable<Scene>;
  64466. }
  64467. /**
  64468. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64469. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64470. * is automatically managed.
  64471. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64472. * in your application.
  64473. *
  64474. * As the update is not automatic, you need to call them manually.
  64475. */
  64476. export class HtmlElementTexture extends BaseTexture {
  64477. /**
  64478. * The texture URL.
  64479. */
  64480. element: HTMLVideoElement | HTMLCanvasElement;
  64481. private static readonly DefaultOptions;
  64482. private _textureMatrix;
  64483. private _isVideo;
  64484. private _generateMipMaps;
  64485. private _samplingMode;
  64486. /**
  64487. * Instantiates a HtmlElementTexture from the following parameters.
  64488. *
  64489. * @param name Defines the name of the texture
  64490. * @param element Defines the video or canvas the texture is filled with
  64491. * @param options Defines the other none mandatory texture creation options
  64492. */
  64493. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64494. private _createInternalTexture;
  64495. /**
  64496. * Returns the texture matrix used in most of the material.
  64497. */
  64498. getTextureMatrix(): Matrix;
  64499. /**
  64500. * Updates the content of the texture.
  64501. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64502. */
  64503. update(invertY?: Nullable<boolean>): void;
  64504. }
  64505. }
  64506. declare module "babylonjs/Misc/tga" {
  64507. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64508. /**
  64509. * Based on jsTGALoader - Javascript loader for TGA file
  64510. * By Vincent Thibault
  64511. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64512. */
  64513. export class TGATools {
  64514. private static _TYPE_INDEXED;
  64515. private static _TYPE_RGB;
  64516. private static _TYPE_GREY;
  64517. private static _TYPE_RLE_INDEXED;
  64518. private static _TYPE_RLE_RGB;
  64519. private static _TYPE_RLE_GREY;
  64520. private static _ORIGIN_MASK;
  64521. private static _ORIGIN_SHIFT;
  64522. private static _ORIGIN_BL;
  64523. private static _ORIGIN_BR;
  64524. private static _ORIGIN_UL;
  64525. private static _ORIGIN_UR;
  64526. /**
  64527. * Gets the header of a TGA file
  64528. * @param data defines the TGA data
  64529. * @returns the header
  64530. */
  64531. static GetTGAHeader(data: Uint8Array): any;
  64532. /**
  64533. * Uploads TGA content to a Babylon Texture
  64534. * @hidden
  64535. */
  64536. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64537. /** @hidden */
  64538. 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;
  64539. /** @hidden */
  64540. 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;
  64541. /** @hidden */
  64542. 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;
  64543. /** @hidden */
  64544. 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;
  64545. /** @hidden */
  64546. 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;
  64547. /** @hidden */
  64548. 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;
  64549. }
  64550. }
  64551. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64552. import { Nullable } from "babylonjs/types";
  64553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64554. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64555. /**
  64556. * Implementation of the TGA Texture Loader.
  64557. * @hidden
  64558. */
  64559. export class _TGATextureLoader implements IInternalTextureLoader {
  64560. /**
  64561. * Defines wether the loader supports cascade loading the different faces.
  64562. */
  64563. readonly supportCascades: boolean;
  64564. /**
  64565. * This returns if the loader support the current file information.
  64566. * @param extension defines the file extension of the file being loaded
  64567. * @returns true if the loader can load the specified file
  64568. */
  64569. canLoad(extension: string): boolean;
  64570. /**
  64571. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64572. * @param data contains the texture data
  64573. * @param texture defines the BabylonJS internal texture
  64574. * @param createPolynomials will be true if polynomials have been requested
  64575. * @param onLoad defines the callback to trigger once the texture is ready
  64576. * @param onError defines the callback to trigger in case of error
  64577. */
  64578. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64579. /**
  64580. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64581. * @param data contains the texture data
  64582. * @param texture defines the BabylonJS internal texture
  64583. * @param callback defines the method to call once ready to upload
  64584. */
  64585. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64586. }
  64587. }
  64588. declare module "babylonjs/Misc/basis" {
  64589. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64590. /**
  64591. * Info about the .basis files
  64592. */
  64593. class BasisFileInfo {
  64594. /**
  64595. * If the file has alpha
  64596. */
  64597. hasAlpha: boolean;
  64598. /**
  64599. * Info about each image of the basis file
  64600. */
  64601. images: Array<{
  64602. levels: Array<{
  64603. width: number;
  64604. height: number;
  64605. transcodedPixels: ArrayBufferView;
  64606. }>;
  64607. }>;
  64608. }
  64609. /**
  64610. * Result of transcoding a basis file
  64611. */
  64612. class TranscodeResult {
  64613. /**
  64614. * Info about the .basis file
  64615. */
  64616. fileInfo: BasisFileInfo;
  64617. /**
  64618. * Format to use when loading the file
  64619. */
  64620. format: number;
  64621. }
  64622. /**
  64623. * Configuration options for the Basis transcoder
  64624. */
  64625. export class BasisTranscodeConfiguration {
  64626. /**
  64627. * Supported compression formats used to determine the supported output format of the transcoder
  64628. */
  64629. supportedCompressionFormats?: {
  64630. /**
  64631. * etc1 compression format
  64632. */
  64633. etc1?: boolean;
  64634. /**
  64635. * s3tc compression format
  64636. */
  64637. s3tc?: boolean;
  64638. /**
  64639. * pvrtc compression format
  64640. */
  64641. pvrtc?: boolean;
  64642. /**
  64643. * etc2 compression format
  64644. */
  64645. etc2?: boolean;
  64646. };
  64647. /**
  64648. * If mipmap levels should be loaded for transcoded images (Default: true)
  64649. */
  64650. loadMipmapLevels?: boolean;
  64651. /**
  64652. * Index of a single image to load (Default: all images)
  64653. */
  64654. loadSingleImage?: number;
  64655. }
  64656. /**
  64657. * Used to load .Basis files
  64658. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64659. */
  64660. export class BasisTools {
  64661. private static _IgnoreSupportedFormats;
  64662. /**
  64663. * URL to use when loading the basis transcoder
  64664. */
  64665. static JSModuleURL: string;
  64666. /**
  64667. * URL to use when loading the wasm module for the transcoder
  64668. */
  64669. static WasmModuleURL: string;
  64670. /**
  64671. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64672. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64673. * @returns internal format corresponding to the Basis format
  64674. */
  64675. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64676. private static _WorkerPromise;
  64677. private static _Worker;
  64678. private static _actionId;
  64679. private static _CreateWorkerAsync;
  64680. /**
  64681. * Transcodes a loaded image file to compressed pixel data
  64682. * @param data image data to transcode
  64683. * @param config configuration options for the transcoding
  64684. * @returns a promise resulting in the transcoded image
  64685. */
  64686. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64687. /**
  64688. * Loads a texture from the transcode result
  64689. * @param texture texture load to
  64690. * @param transcodeResult the result of transcoding the basis file to load from
  64691. */
  64692. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64693. }
  64694. }
  64695. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64696. import { Nullable } from "babylonjs/types";
  64697. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64698. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64699. /**
  64700. * Loader for .basis file format
  64701. */
  64702. export class _BasisTextureLoader implements IInternalTextureLoader {
  64703. /**
  64704. * Defines whether the loader supports cascade loading the different faces.
  64705. */
  64706. readonly supportCascades: boolean;
  64707. /**
  64708. * This returns if the loader support the current file information.
  64709. * @param extension defines the file extension of the file being loaded
  64710. * @returns true if the loader can load the specified file
  64711. */
  64712. canLoad(extension: string): boolean;
  64713. /**
  64714. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64715. * @param data contains the texture data
  64716. * @param texture defines the BabylonJS internal texture
  64717. * @param createPolynomials will be true if polynomials have been requested
  64718. * @param onLoad defines the callback to trigger once the texture is ready
  64719. * @param onError defines the callback to trigger in case of error
  64720. */
  64721. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64722. /**
  64723. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64724. * @param data contains the texture data
  64725. * @param texture defines the BabylonJS internal texture
  64726. * @param callback defines the method to call once ready to upload
  64727. */
  64728. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64729. }
  64730. }
  64731. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64732. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64733. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64734. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64735. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64736. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64737. }
  64738. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64739. import { Vector2 } from "babylonjs/Maths/math.vector";
  64740. /**
  64741. * Defines the basic options interface of a TexturePacker Frame
  64742. */
  64743. export interface ITexturePackerFrame {
  64744. /**
  64745. * The frame ID
  64746. */
  64747. id: number;
  64748. /**
  64749. * The frames Scale
  64750. */
  64751. scale: Vector2;
  64752. /**
  64753. * The Frames offset
  64754. */
  64755. offset: Vector2;
  64756. }
  64757. /**
  64758. * This is a support class for frame Data on texture packer sets.
  64759. */
  64760. export class TexturePackerFrame implements ITexturePackerFrame {
  64761. /**
  64762. * The frame ID
  64763. */
  64764. id: number;
  64765. /**
  64766. * The frames Scale
  64767. */
  64768. scale: Vector2;
  64769. /**
  64770. * The Frames offset
  64771. */
  64772. offset: Vector2;
  64773. /**
  64774. * Initializes a texture package frame.
  64775. * @param id The numerical frame identifier
  64776. * @param scale Scalar Vector2 for UV frame
  64777. * @param offset Vector2 for the frame position in UV units.
  64778. * @returns TexturePackerFrame
  64779. */
  64780. constructor(id: number, scale: Vector2, offset: Vector2);
  64781. }
  64782. }
  64783. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64785. import { Scene } from "babylonjs/scene";
  64786. import { Nullable } from "babylonjs/types";
  64787. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64788. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64789. /**
  64790. * Defines the basic options interface of a TexturePacker
  64791. */
  64792. export interface ITexturePackerOptions {
  64793. /**
  64794. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64795. */
  64796. map?: string[];
  64797. /**
  64798. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64799. */
  64800. uvsIn?: string;
  64801. /**
  64802. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64803. */
  64804. uvsOut?: string;
  64805. /**
  64806. * number representing the layout style. Defaults to LAYOUT_STRIP
  64807. */
  64808. layout?: number;
  64809. /**
  64810. * number of columns if using custom column count layout(2). This defaults to 4.
  64811. */
  64812. colnum?: number;
  64813. /**
  64814. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64815. */
  64816. updateInputMeshes?: boolean;
  64817. /**
  64818. * boolean flag to dispose all the source textures. Defaults to true.
  64819. */
  64820. disposeSources?: boolean;
  64821. /**
  64822. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64823. */
  64824. fillBlanks?: boolean;
  64825. /**
  64826. * string value representing the context fill style color. Defaults to 'black'.
  64827. */
  64828. customFillColor?: string;
  64829. /**
  64830. * Width and Height Value of each Frame in the TexturePacker Sets
  64831. */
  64832. frameSize?: number;
  64833. /**
  64834. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64835. */
  64836. paddingRatio?: number;
  64837. /**
  64838. * Number that declares the fill method for the padding gutter.
  64839. */
  64840. paddingMode?: number;
  64841. /**
  64842. * If in SUBUV_COLOR padding mode what color to use.
  64843. */
  64844. paddingColor?: Color3 | Color4;
  64845. }
  64846. /**
  64847. * Defines the basic interface of a TexturePacker JSON File
  64848. */
  64849. export interface ITexturePackerJSON {
  64850. /**
  64851. * The frame ID
  64852. */
  64853. name: string;
  64854. /**
  64855. * The base64 channel data
  64856. */
  64857. sets: any;
  64858. /**
  64859. * The options of the Packer
  64860. */
  64861. options: ITexturePackerOptions;
  64862. /**
  64863. * The frame data of the Packer
  64864. */
  64865. frames: Array<number>;
  64866. }
  64867. /**
  64868. * This is a support class that generates a series of packed texture sets.
  64869. * @see https://doc.babylonjs.com/babylon101/materials
  64870. */
  64871. export class TexturePacker {
  64872. /** Packer Layout Constant 0 */
  64873. static readonly LAYOUT_STRIP: number;
  64874. /** Packer Layout Constant 1 */
  64875. static readonly LAYOUT_POWER2: number;
  64876. /** Packer Layout Constant 2 */
  64877. static readonly LAYOUT_COLNUM: number;
  64878. /** Packer Layout Constant 0 */
  64879. static readonly SUBUV_WRAP: number;
  64880. /** Packer Layout Constant 1 */
  64881. static readonly SUBUV_EXTEND: number;
  64882. /** Packer Layout Constant 2 */
  64883. static readonly SUBUV_COLOR: number;
  64884. /** The Name of the Texture Package */
  64885. name: string;
  64886. /** The scene scope of the TexturePacker */
  64887. scene: Scene;
  64888. /** The Meshes to target */
  64889. meshes: AbstractMesh[];
  64890. /** Arguments passed with the Constructor */
  64891. options: ITexturePackerOptions;
  64892. /** The promise that is started upon initialization */
  64893. promise: Nullable<Promise<TexturePacker | string>>;
  64894. /** The Container object for the channel sets that are generated */
  64895. sets: object;
  64896. /** The Container array for the frames that are generated */
  64897. frames: TexturePackerFrame[];
  64898. /** The expected number of textures the system is parsing. */
  64899. private _expecting;
  64900. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64901. private _paddingValue;
  64902. /**
  64903. * Initializes a texture package series from an array of meshes or a single mesh.
  64904. * @param name The name of the package
  64905. * @param meshes The target meshes to compose the package from
  64906. * @param options The arguments that texture packer should follow while building.
  64907. * @param scene The scene which the textures are scoped to.
  64908. * @returns TexturePacker
  64909. */
  64910. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64911. /**
  64912. * Starts the package process
  64913. * @param resolve The promises resolution function
  64914. * @returns TexturePacker
  64915. */
  64916. private _createFrames;
  64917. /**
  64918. * Calculates the Size of the Channel Sets
  64919. * @returns Vector2
  64920. */
  64921. private _calculateSize;
  64922. /**
  64923. * Calculates the UV data for the frames.
  64924. * @param baseSize the base frameSize
  64925. * @param padding the base frame padding
  64926. * @param dtSize size of the Dynamic Texture for that channel
  64927. * @param dtUnits is 1/dtSize
  64928. * @param update flag to update the input meshes
  64929. */
  64930. private _calculateMeshUVFrames;
  64931. /**
  64932. * Calculates the frames Offset.
  64933. * @param index of the frame
  64934. * @returns Vector2
  64935. */
  64936. private _getFrameOffset;
  64937. /**
  64938. * Updates a Mesh to the frame data
  64939. * @param mesh that is the target
  64940. * @param frameID or the frame index
  64941. */
  64942. private _updateMeshUV;
  64943. /**
  64944. * Updates a Meshes materials to use the texture packer channels
  64945. * @param m is the mesh to target
  64946. * @param force all channels on the packer to be set.
  64947. */
  64948. private _updateTextureReferences;
  64949. /**
  64950. * Public method to set a Mesh to a frame
  64951. * @param m that is the target
  64952. * @param frameID or the frame index
  64953. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64954. */
  64955. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64956. /**
  64957. * Starts the async promise to compile the texture packer.
  64958. * @returns Promise<void>
  64959. */
  64960. processAsync(): Promise<void>;
  64961. /**
  64962. * Disposes all textures associated with this packer
  64963. */
  64964. dispose(): void;
  64965. /**
  64966. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64967. * @param imageType is the image type to use.
  64968. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64969. */
  64970. download(imageType?: string, quality?: number): void;
  64971. /**
  64972. * Public method to load a texturePacker JSON file.
  64973. * @param data of the JSON file in string format.
  64974. */
  64975. updateFromJSON(data: string): void;
  64976. }
  64977. }
  64978. declare module "babylonjs/Materials/Textures/Packer/index" {
  64979. export * from "babylonjs/Materials/Textures/Packer/packer";
  64980. export * from "babylonjs/Materials/Textures/Packer/frame";
  64981. }
  64982. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64983. import { Scene } from "babylonjs/scene";
  64984. import { Texture } from "babylonjs/Materials/Textures/texture";
  64985. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64986. /**
  64987. * 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.
  64988. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64989. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64990. */
  64991. export class CustomProceduralTexture extends ProceduralTexture {
  64992. private _animate;
  64993. private _time;
  64994. private _config;
  64995. private _texturePath;
  64996. /**
  64997. * Instantiates a new Custom Procedural Texture.
  64998. * 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.
  64999. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65000. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65001. * @param name Define the name of the texture
  65002. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65003. * @param size Define the size of the texture to create
  65004. * @param scene Define the scene the texture belongs to
  65005. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65006. * @param generateMipMaps Define if the texture should creates mip maps or not
  65007. */
  65008. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65009. private _loadJson;
  65010. /**
  65011. * Is the texture ready to be used ? (rendered at least once)
  65012. * @returns true if ready, otherwise, false.
  65013. */
  65014. isReady(): boolean;
  65015. /**
  65016. * Render the texture to its associated render target.
  65017. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65018. */
  65019. render(useCameraPostProcess?: boolean): void;
  65020. /**
  65021. * Update the list of dependant textures samplers in the shader.
  65022. */
  65023. updateTextures(): void;
  65024. /**
  65025. * Update the uniform values of the procedural texture in the shader.
  65026. */
  65027. updateShaderUniforms(): void;
  65028. /**
  65029. * Define if the texture animates or not.
  65030. */
  65031. get animate(): boolean;
  65032. set animate(value: boolean);
  65033. }
  65034. }
  65035. declare module "babylonjs/Shaders/noise.fragment" {
  65036. /** @hidden */
  65037. export var noisePixelShader: {
  65038. name: string;
  65039. shader: string;
  65040. };
  65041. }
  65042. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65043. import { Nullable } from "babylonjs/types";
  65044. import { Scene } from "babylonjs/scene";
  65045. import { Texture } from "babylonjs/Materials/Textures/texture";
  65046. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65047. import "babylonjs/Shaders/noise.fragment";
  65048. /**
  65049. * Class used to generate noise procedural textures
  65050. */
  65051. export class NoiseProceduralTexture extends ProceduralTexture {
  65052. /** Gets or sets the start time (default is 0) */
  65053. time: number;
  65054. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65055. brightness: number;
  65056. /** Defines the number of octaves to process */
  65057. octaves: number;
  65058. /** Defines the level of persistence (0.8 by default) */
  65059. persistence: number;
  65060. /** Gets or sets animation speed factor (default is 1) */
  65061. animationSpeedFactor: number;
  65062. /**
  65063. * Creates a new NoiseProceduralTexture
  65064. * @param name defines the name fo the texture
  65065. * @param size defines the size of the texture (default is 256)
  65066. * @param scene defines the hosting scene
  65067. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65068. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65069. */
  65070. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65071. private _updateShaderUniforms;
  65072. protected _getDefines(): string;
  65073. /** Generate the current state of the procedural texture */
  65074. render(useCameraPostProcess?: boolean): void;
  65075. /**
  65076. * Serializes this noise procedural texture
  65077. * @returns a serialized noise procedural texture object
  65078. */
  65079. serialize(): any;
  65080. /**
  65081. * Clone the texture.
  65082. * @returns the cloned texture
  65083. */
  65084. clone(): NoiseProceduralTexture;
  65085. /**
  65086. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65087. * @param parsedTexture defines parsed texture data
  65088. * @param scene defines the current scene
  65089. * @param rootUrl defines the root URL containing noise procedural texture information
  65090. * @returns a parsed NoiseProceduralTexture
  65091. */
  65092. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65093. }
  65094. }
  65095. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65096. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65097. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65098. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65099. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65100. }
  65101. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65102. import { Nullable } from "babylonjs/types";
  65103. import { Scene } from "babylonjs/scene";
  65104. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65106. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65107. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65108. /**
  65109. * Raw cube texture where the raw buffers are passed in
  65110. */
  65111. export class RawCubeTexture extends CubeTexture {
  65112. /**
  65113. * Creates a cube texture where the raw buffers are passed in.
  65114. * @param scene defines the scene the texture is attached to
  65115. * @param data defines the array of data to use to create each face
  65116. * @param size defines the size of the textures
  65117. * @param format defines the format of the data
  65118. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65119. * @param generateMipMaps defines if the engine should generate the mip levels
  65120. * @param invertY defines if data must be stored with Y axis inverted
  65121. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65122. * @param compression defines the compression used (null by default)
  65123. */
  65124. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65125. /**
  65126. * Updates the raw cube texture.
  65127. * @param data defines the data to store
  65128. * @param format defines the data format
  65129. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65130. * @param invertY defines if data must be stored with Y axis inverted
  65131. * @param compression defines the compression used (null by default)
  65132. * @param level defines which level of the texture to update
  65133. */
  65134. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65135. /**
  65136. * Updates a raw cube texture with RGBD encoded data.
  65137. * @param data defines the array of data [mipmap][face] to use to create each face
  65138. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65139. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65140. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65141. * @returns a promsie that resolves when the operation is complete
  65142. */
  65143. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65144. /**
  65145. * Clones the raw cube texture.
  65146. * @return a new cube texture
  65147. */
  65148. clone(): CubeTexture;
  65149. /** @hidden */
  65150. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65151. }
  65152. }
  65153. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65154. import { Scene } from "babylonjs/scene";
  65155. import { Texture } from "babylonjs/Materials/Textures/texture";
  65156. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65157. /**
  65158. * Class used to store 2D array textures containing user data
  65159. */
  65160. export class RawTexture2DArray extends Texture {
  65161. /** Gets or sets the texture format to use */
  65162. format: number;
  65163. /**
  65164. * Create a new RawTexture2DArray
  65165. * @param data defines the data of the texture
  65166. * @param width defines the width of the texture
  65167. * @param height defines the height of the texture
  65168. * @param depth defines the number of layers of the texture
  65169. * @param format defines the texture format to use
  65170. * @param scene defines the hosting scene
  65171. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65172. * @param invertY defines if texture must be stored with Y axis inverted
  65173. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65174. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65175. */
  65176. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65177. /** Gets or sets the texture format to use */
  65178. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65179. /**
  65180. * Update the texture with new data
  65181. * @param data defines the data to store in the texture
  65182. */
  65183. update(data: ArrayBufferView): void;
  65184. }
  65185. }
  65186. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65187. import { Scene } from "babylonjs/scene";
  65188. import { Texture } from "babylonjs/Materials/Textures/texture";
  65189. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65190. /**
  65191. * Class used to store 3D textures containing user data
  65192. */
  65193. export class RawTexture3D extends Texture {
  65194. /** Gets or sets the texture format to use */
  65195. format: number;
  65196. /**
  65197. * Create a new RawTexture3D
  65198. * @param data defines the data of the texture
  65199. * @param width defines the width of the texture
  65200. * @param height defines the height of the texture
  65201. * @param depth defines the depth of the texture
  65202. * @param format defines the texture format to use
  65203. * @param scene defines the hosting scene
  65204. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65205. * @param invertY defines if texture must be stored with Y axis inverted
  65206. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65207. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65208. */
  65209. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65210. /** Gets or sets the texture format to use */
  65211. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65212. /**
  65213. * Update the texture with new data
  65214. * @param data defines the data to store in the texture
  65215. */
  65216. update(data: ArrayBufferView): void;
  65217. }
  65218. }
  65219. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65220. import { Scene } from "babylonjs/scene";
  65221. import { Plane } from "babylonjs/Maths/math.plane";
  65222. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65223. /**
  65224. * Creates a refraction texture used by refraction channel of the standard material.
  65225. * It is like a mirror but to see through a material.
  65226. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65227. */
  65228. export class RefractionTexture extends RenderTargetTexture {
  65229. /**
  65230. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65231. * 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.
  65232. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65233. */
  65234. refractionPlane: Plane;
  65235. /**
  65236. * Define how deep under the surface we should see.
  65237. */
  65238. depth: number;
  65239. /**
  65240. * Creates a refraction texture used by refraction channel of the standard material.
  65241. * It is like a mirror but to see through a material.
  65242. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65243. * @param name Define the texture name
  65244. * @param size Define the size of the underlying texture
  65245. * @param scene Define the scene the refraction belongs to
  65246. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65247. */
  65248. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65249. /**
  65250. * Clone the refraction texture.
  65251. * @returns the cloned texture
  65252. */
  65253. clone(): RefractionTexture;
  65254. /**
  65255. * Serialize the texture to a JSON representation you could use in Parse later on
  65256. * @returns the serialized JSON representation
  65257. */
  65258. serialize(): any;
  65259. }
  65260. }
  65261. declare module "babylonjs/Materials/Textures/index" {
  65262. export * from "babylonjs/Materials/Textures/baseTexture";
  65263. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65264. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65265. export * from "babylonjs/Materials/Textures/cubeTexture";
  65266. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65267. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65268. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65269. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65270. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65271. export * from "babylonjs/Materials/Textures/internalTexture";
  65272. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65273. export * from "babylonjs/Materials/Textures/Loaders/index";
  65274. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65275. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65276. export * from "babylonjs/Materials/Textures/Packer/index";
  65277. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65278. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65279. export * from "babylonjs/Materials/Textures/rawTexture";
  65280. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65281. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65282. export * from "babylonjs/Materials/Textures/refractionTexture";
  65283. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65284. export * from "babylonjs/Materials/Textures/texture";
  65285. export * from "babylonjs/Materials/Textures/videoTexture";
  65286. }
  65287. declare module "babylonjs/Materials/Node/Enums/index" {
  65288. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65289. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65290. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65291. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65292. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65293. }
  65294. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65298. import { Mesh } from "babylonjs/Meshes/mesh";
  65299. import { Effect } from "babylonjs/Materials/effect";
  65300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65301. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65302. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65303. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65304. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65305. /**
  65306. * Block used to add support for vertex skinning (bones)
  65307. */
  65308. export class BonesBlock extends NodeMaterialBlock {
  65309. /**
  65310. * Creates a new BonesBlock
  65311. * @param name defines the block name
  65312. */
  65313. constructor(name: string);
  65314. /**
  65315. * Initialize the block and prepare the context for build
  65316. * @param state defines the state that will be used for the build
  65317. */
  65318. initialize(state: NodeMaterialBuildState): void;
  65319. /**
  65320. * Gets the current class name
  65321. * @returns the class name
  65322. */
  65323. getClassName(): string;
  65324. /**
  65325. * Gets the matrix indices input component
  65326. */
  65327. get matricesIndices(): NodeMaterialConnectionPoint;
  65328. /**
  65329. * Gets the matrix weights input component
  65330. */
  65331. get matricesWeights(): NodeMaterialConnectionPoint;
  65332. /**
  65333. * Gets the extra matrix indices input component
  65334. */
  65335. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65336. /**
  65337. * Gets the extra matrix weights input component
  65338. */
  65339. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65340. /**
  65341. * Gets the world input component
  65342. */
  65343. get world(): NodeMaterialConnectionPoint;
  65344. /**
  65345. * Gets the output component
  65346. */
  65347. get output(): NodeMaterialConnectionPoint;
  65348. autoConfigure(material: NodeMaterial): void;
  65349. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65350. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65352. protected _buildBlock(state: NodeMaterialBuildState): this;
  65353. }
  65354. }
  65355. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65360. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65361. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65362. /**
  65363. * Block used to add support for instances
  65364. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65365. */
  65366. export class InstancesBlock extends NodeMaterialBlock {
  65367. /**
  65368. * Creates a new InstancesBlock
  65369. * @param name defines the block name
  65370. */
  65371. constructor(name: string);
  65372. /**
  65373. * Gets the current class name
  65374. * @returns the class name
  65375. */
  65376. getClassName(): string;
  65377. /**
  65378. * Gets the first world row input component
  65379. */
  65380. get world0(): NodeMaterialConnectionPoint;
  65381. /**
  65382. * Gets the second world row input component
  65383. */
  65384. get world1(): NodeMaterialConnectionPoint;
  65385. /**
  65386. * Gets the third world row input component
  65387. */
  65388. get world2(): NodeMaterialConnectionPoint;
  65389. /**
  65390. * Gets the forth world row input component
  65391. */
  65392. get world3(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the world input component
  65395. */
  65396. get world(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the output component
  65399. */
  65400. get output(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Gets the isntanceID component
  65403. */
  65404. get instanceID(): NodeMaterialConnectionPoint;
  65405. autoConfigure(material: NodeMaterial): void;
  65406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65407. protected _buildBlock(state: NodeMaterialBuildState): this;
  65408. }
  65409. }
  65410. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65415. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65416. import { Effect } from "babylonjs/Materials/effect";
  65417. import { Mesh } from "babylonjs/Meshes/mesh";
  65418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65419. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65420. /**
  65421. * Block used to add morph targets support to vertex shader
  65422. */
  65423. export class MorphTargetsBlock extends NodeMaterialBlock {
  65424. private _repeatableContentAnchor;
  65425. /**
  65426. * Create a new MorphTargetsBlock
  65427. * @param name defines the block name
  65428. */
  65429. constructor(name: string);
  65430. /**
  65431. * Gets the current class name
  65432. * @returns the class name
  65433. */
  65434. getClassName(): string;
  65435. /**
  65436. * Gets the position input component
  65437. */
  65438. get position(): NodeMaterialConnectionPoint;
  65439. /**
  65440. * Gets the normal input component
  65441. */
  65442. get normal(): NodeMaterialConnectionPoint;
  65443. /**
  65444. * Gets the tangent input component
  65445. */
  65446. get tangent(): NodeMaterialConnectionPoint;
  65447. /**
  65448. * Gets the tangent input component
  65449. */
  65450. get uv(): NodeMaterialConnectionPoint;
  65451. /**
  65452. * Gets the position output component
  65453. */
  65454. get positionOutput(): NodeMaterialConnectionPoint;
  65455. /**
  65456. * Gets the normal output component
  65457. */
  65458. get normalOutput(): NodeMaterialConnectionPoint;
  65459. /**
  65460. * Gets the tangent output component
  65461. */
  65462. get tangentOutput(): NodeMaterialConnectionPoint;
  65463. /**
  65464. * Gets the tangent output component
  65465. */
  65466. get uvOutput(): NodeMaterialConnectionPoint;
  65467. initialize(state: NodeMaterialBuildState): void;
  65468. autoConfigure(material: NodeMaterial): void;
  65469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65470. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65471. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65472. protected _buildBlock(state: NodeMaterialBuildState): this;
  65473. }
  65474. }
  65475. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65479. import { Nullable } from "babylonjs/types";
  65480. import { Scene } from "babylonjs/scene";
  65481. import { Effect } from "babylonjs/Materials/effect";
  65482. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65483. import { Mesh } from "babylonjs/Meshes/mesh";
  65484. import { Light } from "babylonjs/Lights/light";
  65485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65486. /**
  65487. * Block used to get data information from a light
  65488. */
  65489. export class LightInformationBlock extends NodeMaterialBlock {
  65490. private _lightDataUniformName;
  65491. private _lightColorUniformName;
  65492. private _lightTypeDefineName;
  65493. /**
  65494. * Gets or sets the light associated with this block
  65495. */
  65496. light: Nullable<Light>;
  65497. /**
  65498. * Creates a new LightInformationBlock
  65499. * @param name defines the block name
  65500. */
  65501. constructor(name: string);
  65502. /**
  65503. * Gets the current class name
  65504. * @returns the class name
  65505. */
  65506. getClassName(): string;
  65507. /**
  65508. * Gets the world position input component
  65509. */
  65510. get worldPosition(): NodeMaterialConnectionPoint;
  65511. /**
  65512. * Gets the direction output component
  65513. */
  65514. get direction(): NodeMaterialConnectionPoint;
  65515. /**
  65516. * Gets the direction output component
  65517. */
  65518. get color(): NodeMaterialConnectionPoint;
  65519. /**
  65520. * Gets the direction output component
  65521. */
  65522. get intensity(): NodeMaterialConnectionPoint;
  65523. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65525. protected _buildBlock(state: NodeMaterialBuildState): this;
  65526. serialize(): any;
  65527. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65528. }
  65529. }
  65530. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65531. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65532. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65533. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65534. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65535. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65536. }
  65537. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65542. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65543. import { Effect } from "babylonjs/Materials/effect";
  65544. import { Mesh } from "babylonjs/Meshes/mesh";
  65545. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65546. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65547. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65548. /**
  65549. * Block used to add image processing support to fragment shader
  65550. */
  65551. export class ImageProcessingBlock extends NodeMaterialBlock {
  65552. /**
  65553. * Create a new ImageProcessingBlock
  65554. * @param name defines the block name
  65555. */
  65556. constructor(name: string);
  65557. /**
  65558. * Gets the current class name
  65559. * @returns the class name
  65560. */
  65561. getClassName(): string;
  65562. /**
  65563. * Gets the color input component
  65564. */
  65565. get color(): NodeMaterialConnectionPoint;
  65566. /**
  65567. * Gets the output component
  65568. */
  65569. get output(): NodeMaterialConnectionPoint;
  65570. /**
  65571. * Initialize the block and prepare the context for build
  65572. * @param state defines the state that will be used for the build
  65573. */
  65574. initialize(state: NodeMaterialBuildState): void;
  65575. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65578. protected _buildBlock(state: NodeMaterialBuildState): this;
  65579. }
  65580. }
  65581. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65585. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65587. import { Effect } from "babylonjs/Materials/effect";
  65588. import { Mesh } from "babylonjs/Meshes/mesh";
  65589. import { Scene } from "babylonjs/scene";
  65590. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65591. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65592. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65593. /**
  65594. * Block used to pertub normals based on a normal map
  65595. */
  65596. export class PerturbNormalBlock extends NodeMaterialBlock {
  65597. private _tangentSpaceParameterName;
  65598. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65599. invertX: boolean;
  65600. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65601. invertY: boolean;
  65602. /**
  65603. * Create a new PerturbNormalBlock
  65604. * @param name defines the block name
  65605. */
  65606. constructor(name: string);
  65607. /**
  65608. * Gets the current class name
  65609. * @returns the class name
  65610. */
  65611. getClassName(): string;
  65612. /**
  65613. * Gets the world position input component
  65614. */
  65615. get worldPosition(): NodeMaterialConnectionPoint;
  65616. /**
  65617. * Gets the world normal input component
  65618. */
  65619. get worldNormal(): NodeMaterialConnectionPoint;
  65620. /**
  65621. * Gets the world tangent input component
  65622. */
  65623. get worldTangent(): NodeMaterialConnectionPoint;
  65624. /**
  65625. * Gets the uv input component
  65626. */
  65627. get uv(): NodeMaterialConnectionPoint;
  65628. /**
  65629. * Gets the normal map color input component
  65630. */
  65631. get normalMapColor(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the strength input component
  65634. */
  65635. get strength(): NodeMaterialConnectionPoint;
  65636. /**
  65637. * Gets the output component
  65638. */
  65639. get output(): NodeMaterialConnectionPoint;
  65640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65642. autoConfigure(material: NodeMaterial): void;
  65643. protected _buildBlock(state: NodeMaterialBuildState): this;
  65644. protected _dumpPropertiesCode(): string;
  65645. serialize(): any;
  65646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65647. }
  65648. }
  65649. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65653. /**
  65654. * Block used to discard a pixel if a value is smaller than a cutoff
  65655. */
  65656. export class DiscardBlock extends NodeMaterialBlock {
  65657. /**
  65658. * Create a new DiscardBlock
  65659. * @param name defines the block name
  65660. */
  65661. constructor(name: string);
  65662. /**
  65663. * Gets the current class name
  65664. * @returns the class name
  65665. */
  65666. getClassName(): string;
  65667. /**
  65668. * Gets the color input component
  65669. */
  65670. get value(): NodeMaterialConnectionPoint;
  65671. /**
  65672. * Gets the cutoff input component
  65673. */
  65674. get cutoff(): NodeMaterialConnectionPoint;
  65675. protected _buildBlock(state: NodeMaterialBuildState): this;
  65676. }
  65677. }
  65678. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65682. /**
  65683. * Block used to test if the fragment shader is front facing
  65684. */
  65685. export class FrontFacingBlock extends NodeMaterialBlock {
  65686. /**
  65687. * Creates a new FrontFacingBlock
  65688. * @param name defines the block name
  65689. */
  65690. constructor(name: string);
  65691. /**
  65692. * Gets the current class name
  65693. * @returns the class name
  65694. */
  65695. getClassName(): string;
  65696. /**
  65697. * Gets the output component
  65698. */
  65699. get output(): NodeMaterialConnectionPoint;
  65700. protected _buildBlock(state: NodeMaterialBuildState): this;
  65701. }
  65702. }
  65703. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65707. /**
  65708. * Block used to get the derivative value on x and y of a given input
  65709. */
  65710. export class DerivativeBlock extends NodeMaterialBlock {
  65711. /**
  65712. * Create a new DerivativeBlock
  65713. * @param name defines the block name
  65714. */
  65715. constructor(name: string);
  65716. /**
  65717. * Gets the current class name
  65718. * @returns the class name
  65719. */
  65720. getClassName(): string;
  65721. /**
  65722. * Gets the input component
  65723. */
  65724. get input(): NodeMaterialConnectionPoint;
  65725. /**
  65726. * Gets the derivative output on x
  65727. */
  65728. get dx(): NodeMaterialConnectionPoint;
  65729. /**
  65730. * Gets the derivative output on y
  65731. */
  65732. get dy(): NodeMaterialConnectionPoint;
  65733. protected _buildBlock(state: NodeMaterialBuildState): this;
  65734. }
  65735. }
  65736. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65740. /**
  65741. * Block used to make gl_FragCoord available
  65742. */
  65743. export class FragCoordBlock extends NodeMaterialBlock {
  65744. /**
  65745. * Creates a new FragCoordBlock
  65746. * @param name defines the block name
  65747. */
  65748. constructor(name: string);
  65749. /**
  65750. * Gets the current class name
  65751. * @returns the class name
  65752. */
  65753. getClassName(): string;
  65754. /**
  65755. * Gets the xy component
  65756. */
  65757. get xy(): NodeMaterialConnectionPoint;
  65758. /**
  65759. * Gets the xyz component
  65760. */
  65761. get xyz(): NodeMaterialConnectionPoint;
  65762. /**
  65763. * Gets the xyzw component
  65764. */
  65765. get xyzw(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the x component
  65768. */
  65769. get x(): NodeMaterialConnectionPoint;
  65770. /**
  65771. * Gets the y component
  65772. */
  65773. get y(): NodeMaterialConnectionPoint;
  65774. /**
  65775. * Gets the z component
  65776. */
  65777. get z(): NodeMaterialConnectionPoint;
  65778. /**
  65779. * Gets the w component
  65780. */
  65781. get output(): NodeMaterialConnectionPoint;
  65782. protected writeOutputs(state: NodeMaterialBuildState): string;
  65783. protected _buildBlock(state: NodeMaterialBuildState): this;
  65784. }
  65785. }
  65786. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65790. import { Effect } from "babylonjs/Materials/effect";
  65791. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65792. import { Mesh } from "babylonjs/Meshes/mesh";
  65793. /**
  65794. * Block used to get the screen sizes
  65795. */
  65796. export class ScreenSizeBlock extends NodeMaterialBlock {
  65797. private _varName;
  65798. private _scene;
  65799. /**
  65800. * Creates a new ScreenSizeBlock
  65801. * @param name defines the block name
  65802. */
  65803. constructor(name: string);
  65804. /**
  65805. * Gets the current class name
  65806. * @returns the class name
  65807. */
  65808. getClassName(): string;
  65809. /**
  65810. * Gets the xy component
  65811. */
  65812. get xy(): NodeMaterialConnectionPoint;
  65813. /**
  65814. * Gets the x component
  65815. */
  65816. get x(): NodeMaterialConnectionPoint;
  65817. /**
  65818. * Gets the y component
  65819. */
  65820. get y(): NodeMaterialConnectionPoint;
  65821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65822. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65823. protected _buildBlock(state: NodeMaterialBuildState): this;
  65824. }
  65825. }
  65826. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65827. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65828. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65829. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65830. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65831. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65832. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65833. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65834. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65835. }
  65836. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65839. import { Mesh } from "babylonjs/Meshes/mesh";
  65840. import { Effect } from "babylonjs/Materials/effect";
  65841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65843. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65844. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65845. /**
  65846. * Block used to add support for scene fog
  65847. */
  65848. export class FogBlock extends NodeMaterialBlock {
  65849. private _fogDistanceName;
  65850. private _fogParameters;
  65851. /**
  65852. * Create a new FogBlock
  65853. * @param name defines the block name
  65854. */
  65855. constructor(name: string);
  65856. /**
  65857. * Gets the current class name
  65858. * @returns the class name
  65859. */
  65860. getClassName(): string;
  65861. /**
  65862. * Gets the world position input component
  65863. */
  65864. get worldPosition(): NodeMaterialConnectionPoint;
  65865. /**
  65866. * Gets the view input component
  65867. */
  65868. get view(): NodeMaterialConnectionPoint;
  65869. /**
  65870. * Gets the color input component
  65871. */
  65872. get input(): NodeMaterialConnectionPoint;
  65873. /**
  65874. * Gets the fog color input component
  65875. */
  65876. get fogColor(): NodeMaterialConnectionPoint;
  65877. /**
  65878. * Gets the output component
  65879. */
  65880. get output(): NodeMaterialConnectionPoint;
  65881. autoConfigure(material: NodeMaterial): void;
  65882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65884. protected _buildBlock(state: NodeMaterialBuildState): this;
  65885. }
  65886. }
  65887. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65892. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65893. import { Effect } from "babylonjs/Materials/effect";
  65894. import { Mesh } from "babylonjs/Meshes/mesh";
  65895. import { Light } from "babylonjs/Lights/light";
  65896. import { Nullable } from "babylonjs/types";
  65897. import { Scene } from "babylonjs/scene";
  65898. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65899. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65900. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65901. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65902. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65903. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65904. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65905. /**
  65906. * Block used to add light in the fragment shader
  65907. */
  65908. export class LightBlock extends NodeMaterialBlock {
  65909. private _lightId;
  65910. /**
  65911. * Gets or sets the light associated with this block
  65912. */
  65913. light: Nullable<Light>;
  65914. /**
  65915. * Create a new LightBlock
  65916. * @param name defines the block name
  65917. */
  65918. constructor(name: string);
  65919. /**
  65920. * Gets the current class name
  65921. * @returns the class name
  65922. */
  65923. getClassName(): string;
  65924. /**
  65925. * Gets the world position input component
  65926. */
  65927. get worldPosition(): NodeMaterialConnectionPoint;
  65928. /**
  65929. * Gets the world normal input component
  65930. */
  65931. get worldNormal(): NodeMaterialConnectionPoint;
  65932. /**
  65933. * Gets the camera (or eye) position component
  65934. */
  65935. get cameraPosition(): NodeMaterialConnectionPoint;
  65936. /**
  65937. * Gets the glossiness component
  65938. */
  65939. get glossiness(): NodeMaterialConnectionPoint;
  65940. /**
  65941. * Gets the glossinness power component
  65942. */
  65943. get glossPower(): NodeMaterialConnectionPoint;
  65944. /**
  65945. * Gets the diffuse color component
  65946. */
  65947. get diffuseColor(): NodeMaterialConnectionPoint;
  65948. /**
  65949. * Gets the specular color component
  65950. */
  65951. get specularColor(): NodeMaterialConnectionPoint;
  65952. /**
  65953. * Gets the diffuse output component
  65954. */
  65955. get diffuseOutput(): NodeMaterialConnectionPoint;
  65956. /**
  65957. * Gets the specular output component
  65958. */
  65959. get specularOutput(): NodeMaterialConnectionPoint;
  65960. /**
  65961. * Gets the shadow output component
  65962. */
  65963. get shadow(): NodeMaterialConnectionPoint;
  65964. autoConfigure(material: NodeMaterial): void;
  65965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65966. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65967. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65968. private _injectVertexCode;
  65969. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65970. serialize(): any;
  65971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65972. }
  65973. }
  65974. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65976. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65977. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65978. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65979. /**
  65980. * Block used to read a reflection texture from a sampler
  65981. */
  65982. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65983. /**
  65984. * Create a new ReflectionTextureBlock
  65985. * @param name defines the block name
  65986. */
  65987. constructor(name: string);
  65988. /**
  65989. * Gets the current class name
  65990. * @returns the class name
  65991. */
  65992. getClassName(): string;
  65993. /**
  65994. * Gets the world position input component
  65995. */
  65996. get position(): NodeMaterialConnectionPoint;
  65997. /**
  65998. * Gets the world position input component
  65999. */
  66000. get worldPosition(): NodeMaterialConnectionPoint;
  66001. /**
  66002. * Gets the world normal input component
  66003. */
  66004. get worldNormal(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the world input component
  66007. */
  66008. get world(): NodeMaterialConnectionPoint;
  66009. /**
  66010. * Gets the camera (or eye) position component
  66011. */
  66012. get cameraPosition(): NodeMaterialConnectionPoint;
  66013. /**
  66014. * Gets the view input component
  66015. */
  66016. get view(): NodeMaterialConnectionPoint;
  66017. /**
  66018. * Gets the rgb output component
  66019. */
  66020. get rgb(): NodeMaterialConnectionPoint;
  66021. /**
  66022. * Gets the rgba output component
  66023. */
  66024. get rgba(): NodeMaterialConnectionPoint;
  66025. /**
  66026. * Gets the r output component
  66027. */
  66028. get r(): NodeMaterialConnectionPoint;
  66029. /**
  66030. * Gets the g output component
  66031. */
  66032. get g(): NodeMaterialConnectionPoint;
  66033. /**
  66034. * Gets the b output component
  66035. */
  66036. get b(): NodeMaterialConnectionPoint;
  66037. /**
  66038. * Gets the a output component
  66039. */
  66040. get a(): NodeMaterialConnectionPoint;
  66041. autoConfigure(material: NodeMaterial): void;
  66042. protected _buildBlock(state: NodeMaterialBuildState): this;
  66043. }
  66044. }
  66045. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66046. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66047. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66048. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66049. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66050. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66051. }
  66052. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66053. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66054. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66055. }
  66056. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66060. /**
  66061. * Block used to add 2 vectors
  66062. */
  66063. export class AddBlock extends NodeMaterialBlock {
  66064. /**
  66065. * Creates a new AddBlock
  66066. * @param name defines the block name
  66067. */
  66068. constructor(name: string);
  66069. /**
  66070. * Gets the current class name
  66071. * @returns the class name
  66072. */
  66073. getClassName(): string;
  66074. /**
  66075. * Gets the left operand input component
  66076. */
  66077. get left(): NodeMaterialConnectionPoint;
  66078. /**
  66079. * Gets the right operand input component
  66080. */
  66081. get right(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the output component
  66084. */
  66085. get output(): NodeMaterialConnectionPoint;
  66086. protected _buildBlock(state: NodeMaterialBuildState): this;
  66087. }
  66088. }
  66089. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66093. /**
  66094. * Block used to scale a vector by a float
  66095. */
  66096. export class ScaleBlock extends NodeMaterialBlock {
  66097. /**
  66098. * Creates a new ScaleBlock
  66099. * @param name defines the block name
  66100. */
  66101. constructor(name: string);
  66102. /**
  66103. * Gets the current class name
  66104. * @returns the class name
  66105. */
  66106. getClassName(): string;
  66107. /**
  66108. * Gets the input component
  66109. */
  66110. get input(): NodeMaterialConnectionPoint;
  66111. /**
  66112. * Gets the factor input component
  66113. */
  66114. get factor(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the output component
  66117. */
  66118. get output(): NodeMaterialConnectionPoint;
  66119. protected _buildBlock(state: NodeMaterialBuildState): this;
  66120. }
  66121. }
  66122. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66126. import { Scene } from "babylonjs/scene";
  66127. /**
  66128. * Block used to clamp a float
  66129. */
  66130. export class ClampBlock extends NodeMaterialBlock {
  66131. /** Gets or sets the minimum range */
  66132. minimum: number;
  66133. /** Gets or sets the maximum range */
  66134. maximum: number;
  66135. /**
  66136. * Creates a new ClampBlock
  66137. * @param name defines the block name
  66138. */
  66139. constructor(name: string);
  66140. /**
  66141. * Gets the current class name
  66142. * @returns the class name
  66143. */
  66144. getClassName(): string;
  66145. /**
  66146. * Gets the value input component
  66147. */
  66148. get value(): NodeMaterialConnectionPoint;
  66149. /**
  66150. * Gets the output component
  66151. */
  66152. get output(): NodeMaterialConnectionPoint;
  66153. protected _buildBlock(state: NodeMaterialBuildState): this;
  66154. protected _dumpPropertiesCode(): string;
  66155. serialize(): any;
  66156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66157. }
  66158. }
  66159. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66163. /**
  66164. * Block used to apply a cross product between 2 vectors
  66165. */
  66166. export class CrossBlock extends NodeMaterialBlock {
  66167. /**
  66168. * Creates a new CrossBlock
  66169. * @param name defines the block name
  66170. */
  66171. constructor(name: string);
  66172. /**
  66173. * Gets the current class name
  66174. * @returns the class name
  66175. */
  66176. getClassName(): string;
  66177. /**
  66178. * Gets the left operand input component
  66179. */
  66180. get left(): NodeMaterialConnectionPoint;
  66181. /**
  66182. * Gets the right operand input component
  66183. */
  66184. get right(): NodeMaterialConnectionPoint;
  66185. /**
  66186. * Gets the output component
  66187. */
  66188. get output(): NodeMaterialConnectionPoint;
  66189. protected _buildBlock(state: NodeMaterialBuildState): this;
  66190. }
  66191. }
  66192. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66196. /**
  66197. * Block used to apply a dot product between 2 vectors
  66198. */
  66199. export class DotBlock extends NodeMaterialBlock {
  66200. /**
  66201. * Creates a new DotBlock
  66202. * @param name defines the block name
  66203. */
  66204. constructor(name: string);
  66205. /**
  66206. * Gets the current class name
  66207. * @returns the class name
  66208. */
  66209. getClassName(): string;
  66210. /**
  66211. * Gets the left operand input component
  66212. */
  66213. get left(): NodeMaterialConnectionPoint;
  66214. /**
  66215. * Gets the right operand input component
  66216. */
  66217. get right(): NodeMaterialConnectionPoint;
  66218. /**
  66219. * Gets the output component
  66220. */
  66221. get output(): NodeMaterialConnectionPoint;
  66222. protected _buildBlock(state: NodeMaterialBuildState): this;
  66223. }
  66224. }
  66225. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66229. /**
  66230. * Block used to normalize a vector
  66231. */
  66232. export class NormalizeBlock extends NodeMaterialBlock {
  66233. /**
  66234. * Creates a new NormalizeBlock
  66235. * @param name defines the block name
  66236. */
  66237. constructor(name: string);
  66238. /**
  66239. * Gets the current class name
  66240. * @returns the class name
  66241. */
  66242. getClassName(): string;
  66243. /**
  66244. * Gets the input component
  66245. */
  66246. get input(): NodeMaterialConnectionPoint;
  66247. /**
  66248. * Gets the output component
  66249. */
  66250. get output(): NodeMaterialConnectionPoint;
  66251. protected _buildBlock(state: NodeMaterialBuildState): this;
  66252. }
  66253. }
  66254. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  66255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66258. import { Scene } from "babylonjs/scene";
  66259. /**
  66260. * Operations supported by the Trigonometry block
  66261. */
  66262. export enum TrigonometryBlockOperations {
  66263. /** Cos */
  66264. Cos = 0,
  66265. /** Sin */
  66266. Sin = 1,
  66267. /** Abs */
  66268. Abs = 2,
  66269. /** Exp */
  66270. Exp = 3,
  66271. /** Exp2 */
  66272. Exp2 = 4,
  66273. /** Round */
  66274. Round = 5,
  66275. /** Floor */
  66276. Floor = 6,
  66277. /** Ceiling */
  66278. Ceiling = 7,
  66279. /** Square root */
  66280. Sqrt = 8,
  66281. /** Log */
  66282. Log = 9,
  66283. /** Tangent */
  66284. Tan = 10,
  66285. /** Arc tangent */
  66286. ArcTan = 11,
  66287. /** Arc cosinus */
  66288. ArcCos = 12,
  66289. /** Arc sinus */
  66290. ArcSin = 13,
  66291. /** Fraction */
  66292. Fract = 14,
  66293. /** Sign */
  66294. Sign = 15,
  66295. /** To radians (from degrees) */
  66296. Radians = 16,
  66297. /** To degrees (from radians) */
  66298. Degrees = 17
  66299. }
  66300. /**
  66301. * Block used to apply trigonometry operation to floats
  66302. */
  66303. export class TrigonometryBlock extends NodeMaterialBlock {
  66304. /**
  66305. * Gets or sets the operation applied by the block
  66306. */
  66307. operation: TrigonometryBlockOperations;
  66308. /**
  66309. * Creates a new TrigonometryBlock
  66310. * @param name defines the block name
  66311. */
  66312. constructor(name: string);
  66313. /**
  66314. * Gets the current class name
  66315. * @returns the class name
  66316. */
  66317. getClassName(): string;
  66318. /**
  66319. * Gets the input component
  66320. */
  66321. get input(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Gets the output component
  66324. */
  66325. get output(): NodeMaterialConnectionPoint;
  66326. protected _buildBlock(state: NodeMaterialBuildState): this;
  66327. serialize(): any;
  66328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66329. protected _dumpPropertiesCode(): string;
  66330. }
  66331. }
  66332. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66336. /**
  66337. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66338. */
  66339. export class ColorMergerBlock extends NodeMaterialBlock {
  66340. /**
  66341. * Create a new ColorMergerBlock
  66342. * @param name defines the block name
  66343. */
  66344. constructor(name: string);
  66345. /**
  66346. * Gets the current class name
  66347. * @returns the class name
  66348. */
  66349. getClassName(): string;
  66350. /**
  66351. * Gets the rgb component (input)
  66352. */
  66353. get rgbIn(): NodeMaterialConnectionPoint;
  66354. /**
  66355. * Gets the r component (input)
  66356. */
  66357. get r(): NodeMaterialConnectionPoint;
  66358. /**
  66359. * Gets the g component (input)
  66360. */
  66361. get g(): NodeMaterialConnectionPoint;
  66362. /**
  66363. * Gets the b component (input)
  66364. */
  66365. get b(): NodeMaterialConnectionPoint;
  66366. /**
  66367. * Gets the a component (input)
  66368. */
  66369. get a(): NodeMaterialConnectionPoint;
  66370. /**
  66371. * Gets the rgba component (output)
  66372. */
  66373. get rgba(): NodeMaterialConnectionPoint;
  66374. /**
  66375. * Gets the rgb component (output)
  66376. */
  66377. get rgbOut(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the rgb component (output)
  66380. * @deprecated Please use rgbOut instead.
  66381. */
  66382. get rgb(): NodeMaterialConnectionPoint;
  66383. protected _buildBlock(state: NodeMaterialBuildState): this;
  66384. }
  66385. }
  66386. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66390. /**
  66391. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66392. */
  66393. export class VectorSplitterBlock extends NodeMaterialBlock {
  66394. /**
  66395. * Create a new VectorSplitterBlock
  66396. * @param name defines the block name
  66397. */
  66398. constructor(name: string);
  66399. /**
  66400. * Gets the current class name
  66401. * @returns the class name
  66402. */
  66403. getClassName(): string;
  66404. /**
  66405. * Gets the xyzw component (input)
  66406. */
  66407. get xyzw(): NodeMaterialConnectionPoint;
  66408. /**
  66409. * Gets the xyz component (input)
  66410. */
  66411. get xyzIn(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the xy component (input)
  66414. */
  66415. get xyIn(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the xyz component (output)
  66418. */
  66419. get xyzOut(): NodeMaterialConnectionPoint;
  66420. /**
  66421. * Gets the xy component (output)
  66422. */
  66423. get xyOut(): NodeMaterialConnectionPoint;
  66424. /**
  66425. * Gets the x component (output)
  66426. */
  66427. get x(): NodeMaterialConnectionPoint;
  66428. /**
  66429. * Gets the y component (output)
  66430. */
  66431. get y(): NodeMaterialConnectionPoint;
  66432. /**
  66433. * Gets the z component (output)
  66434. */
  66435. get z(): NodeMaterialConnectionPoint;
  66436. /**
  66437. * Gets the w component (output)
  66438. */
  66439. get w(): NodeMaterialConnectionPoint;
  66440. protected _inputRename(name: string): string;
  66441. protected _outputRename(name: string): string;
  66442. protected _buildBlock(state: NodeMaterialBuildState): this;
  66443. }
  66444. }
  66445. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66449. /**
  66450. * Block used to lerp between 2 values
  66451. */
  66452. export class LerpBlock extends NodeMaterialBlock {
  66453. /**
  66454. * Creates a new LerpBlock
  66455. * @param name defines the block name
  66456. */
  66457. constructor(name: string);
  66458. /**
  66459. * Gets the current class name
  66460. * @returns the class name
  66461. */
  66462. getClassName(): string;
  66463. /**
  66464. * Gets the left operand input component
  66465. */
  66466. get left(): NodeMaterialConnectionPoint;
  66467. /**
  66468. * Gets the right operand input component
  66469. */
  66470. get right(): NodeMaterialConnectionPoint;
  66471. /**
  66472. * Gets the gradient operand input component
  66473. */
  66474. get gradient(): NodeMaterialConnectionPoint;
  66475. /**
  66476. * Gets the output component
  66477. */
  66478. get output(): NodeMaterialConnectionPoint;
  66479. protected _buildBlock(state: NodeMaterialBuildState): this;
  66480. }
  66481. }
  66482. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66486. /**
  66487. * Block used to divide 2 vectors
  66488. */
  66489. export class DivideBlock extends NodeMaterialBlock {
  66490. /**
  66491. * Creates a new DivideBlock
  66492. * @param name defines the block name
  66493. */
  66494. constructor(name: string);
  66495. /**
  66496. * Gets the current class name
  66497. * @returns the class name
  66498. */
  66499. getClassName(): string;
  66500. /**
  66501. * Gets the left operand input component
  66502. */
  66503. get left(): NodeMaterialConnectionPoint;
  66504. /**
  66505. * Gets the right operand input component
  66506. */
  66507. get right(): NodeMaterialConnectionPoint;
  66508. /**
  66509. * Gets the output component
  66510. */
  66511. get output(): NodeMaterialConnectionPoint;
  66512. protected _buildBlock(state: NodeMaterialBuildState): this;
  66513. }
  66514. }
  66515. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66519. /**
  66520. * Block used to subtract 2 vectors
  66521. */
  66522. export class SubtractBlock extends NodeMaterialBlock {
  66523. /**
  66524. * Creates a new SubtractBlock
  66525. * @param name defines the block name
  66526. */
  66527. constructor(name: string);
  66528. /**
  66529. * Gets the current class name
  66530. * @returns the class name
  66531. */
  66532. getClassName(): string;
  66533. /**
  66534. * Gets the left operand input component
  66535. */
  66536. get left(): NodeMaterialConnectionPoint;
  66537. /**
  66538. * Gets the right operand input component
  66539. */
  66540. get right(): NodeMaterialConnectionPoint;
  66541. /**
  66542. * Gets the output component
  66543. */
  66544. get output(): NodeMaterialConnectionPoint;
  66545. protected _buildBlock(state: NodeMaterialBuildState): this;
  66546. }
  66547. }
  66548. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66552. /**
  66553. * Block used to step a value
  66554. */
  66555. export class StepBlock extends NodeMaterialBlock {
  66556. /**
  66557. * Creates a new StepBlock
  66558. * @param name defines the block name
  66559. */
  66560. constructor(name: string);
  66561. /**
  66562. * Gets the current class name
  66563. * @returns the class name
  66564. */
  66565. getClassName(): string;
  66566. /**
  66567. * Gets the value operand input component
  66568. */
  66569. get value(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the edge operand input component
  66572. */
  66573. get edge(): NodeMaterialConnectionPoint;
  66574. /**
  66575. * Gets the output component
  66576. */
  66577. get output(): NodeMaterialConnectionPoint;
  66578. protected _buildBlock(state: NodeMaterialBuildState): this;
  66579. }
  66580. }
  66581. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66585. /**
  66586. * Block used to get the opposite (1 - x) of a value
  66587. */
  66588. export class OneMinusBlock extends NodeMaterialBlock {
  66589. /**
  66590. * Creates a new OneMinusBlock
  66591. * @param name defines the block name
  66592. */
  66593. constructor(name: string);
  66594. /**
  66595. * Gets the current class name
  66596. * @returns the class name
  66597. */
  66598. getClassName(): string;
  66599. /**
  66600. * Gets the input component
  66601. */
  66602. get input(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the output component
  66605. */
  66606. get output(): NodeMaterialConnectionPoint;
  66607. protected _buildBlock(state: NodeMaterialBuildState): this;
  66608. }
  66609. }
  66610. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66614. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66615. /**
  66616. * Block used to get the view direction
  66617. */
  66618. export class ViewDirectionBlock extends NodeMaterialBlock {
  66619. /**
  66620. * Creates a new ViewDirectionBlock
  66621. * @param name defines the block name
  66622. */
  66623. constructor(name: string);
  66624. /**
  66625. * Gets the current class name
  66626. * @returns the class name
  66627. */
  66628. getClassName(): string;
  66629. /**
  66630. * Gets the world position component
  66631. */
  66632. get worldPosition(): NodeMaterialConnectionPoint;
  66633. /**
  66634. * Gets the camera position component
  66635. */
  66636. get cameraPosition(): NodeMaterialConnectionPoint;
  66637. /**
  66638. * Gets the output component
  66639. */
  66640. get output(): NodeMaterialConnectionPoint;
  66641. autoConfigure(material: NodeMaterial): void;
  66642. protected _buildBlock(state: NodeMaterialBuildState): this;
  66643. }
  66644. }
  66645. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66649. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66650. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66651. /**
  66652. * Block used to compute fresnel value
  66653. */
  66654. export class FresnelBlock extends NodeMaterialBlock {
  66655. /**
  66656. * Create a new FresnelBlock
  66657. * @param name defines the block name
  66658. */
  66659. constructor(name: string);
  66660. /**
  66661. * Gets the current class name
  66662. * @returns the class name
  66663. */
  66664. getClassName(): string;
  66665. /**
  66666. * Gets the world normal input component
  66667. */
  66668. get worldNormal(): NodeMaterialConnectionPoint;
  66669. /**
  66670. * Gets the view direction input component
  66671. */
  66672. get viewDirection(): NodeMaterialConnectionPoint;
  66673. /**
  66674. * Gets the bias input component
  66675. */
  66676. get bias(): NodeMaterialConnectionPoint;
  66677. /**
  66678. * Gets the camera (or eye) position component
  66679. */
  66680. get power(): NodeMaterialConnectionPoint;
  66681. /**
  66682. * Gets the fresnel output component
  66683. */
  66684. get fresnel(): NodeMaterialConnectionPoint;
  66685. autoConfigure(material: NodeMaterial): void;
  66686. protected _buildBlock(state: NodeMaterialBuildState): this;
  66687. }
  66688. }
  66689. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66693. /**
  66694. * Block used to get the max of 2 values
  66695. */
  66696. export class MaxBlock extends NodeMaterialBlock {
  66697. /**
  66698. * Creates a new MaxBlock
  66699. * @param name defines the block name
  66700. */
  66701. constructor(name: string);
  66702. /**
  66703. * Gets the current class name
  66704. * @returns the class name
  66705. */
  66706. getClassName(): string;
  66707. /**
  66708. * Gets the left operand input component
  66709. */
  66710. get left(): NodeMaterialConnectionPoint;
  66711. /**
  66712. * Gets the right operand input component
  66713. */
  66714. get right(): NodeMaterialConnectionPoint;
  66715. /**
  66716. * Gets the output component
  66717. */
  66718. get output(): NodeMaterialConnectionPoint;
  66719. protected _buildBlock(state: NodeMaterialBuildState): this;
  66720. }
  66721. }
  66722. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66726. /**
  66727. * Block used to get the min of 2 values
  66728. */
  66729. export class MinBlock extends NodeMaterialBlock {
  66730. /**
  66731. * Creates a new MinBlock
  66732. * @param name defines the block name
  66733. */
  66734. constructor(name: string);
  66735. /**
  66736. * Gets the current class name
  66737. * @returns the class name
  66738. */
  66739. getClassName(): string;
  66740. /**
  66741. * Gets the left operand input component
  66742. */
  66743. get left(): NodeMaterialConnectionPoint;
  66744. /**
  66745. * Gets the right operand input component
  66746. */
  66747. get right(): NodeMaterialConnectionPoint;
  66748. /**
  66749. * Gets the output component
  66750. */
  66751. get output(): NodeMaterialConnectionPoint;
  66752. protected _buildBlock(state: NodeMaterialBuildState): this;
  66753. }
  66754. }
  66755. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66759. /**
  66760. * Block used to get the distance between 2 values
  66761. */
  66762. export class DistanceBlock extends NodeMaterialBlock {
  66763. /**
  66764. * Creates a new DistanceBlock
  66765. * @param name defines the block name
  66766. */
  66767. constructor(name: string);
  66768. /**
  66769. * Gets the current class name
  66770. * @returns the class name
  66771. */
  66772. getClassName(): string;
  66773. /**
  66774. * Gets the left operand input component
  66775. */
  66776. get left(): NodeMaterialConnectionPoint;
  66777. /**
  66778. * Gets the right operand input component
  66779. */
  66780. get right(): NodeMaterialConnectionPoint;
  66781. /**
  66782. * Gets the output component
  66783. */
  66784. get output(): NodeMaterialConnectionPoint;
  66785. protected _buildBlock(state: NodeMaterialBuildState): this;
  66786. }
  66787. }
  66788. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66791. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66792. /**
  66793. * Block used to get the length of a vector
  66794. */
  66795. export class LengthBlock extends NodeMaterialBlock {
  66796. /**
  66797. * Creates a new LengthBlock
  66798. * @param name defines the block name
  66799. */
  66800. constructor(name: string);
  66801. /**
  66802. * Gets the current class name
  66803. * @returns the class name
  66804. */
  66805. getClassName(): string;
  66806. /**
  66807. * Gets the value input component
  66808. */
  66809. get value(): NodeMaterialConnectionPoint;
  66810. /**
  66811. * Gets the output component
  66812. */
  66813. get output(): NodeMaterialConnectionPoint;
  66814. protected _buildBlock(state: NodeMaterialBuildState): this;
  66815. }
  66816. }
  66817. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66821. /**
  66822. * Block used to get negative version of a value (i.e. x * -1)
  66823. */
  66824. export class NegateBlock extends NodeMaterialBlock {
  66825. /**
  66826. * Creates a new NegateBlock
  66827. * @param name defines the block name
  66828. */
  66829. constructor(name: string);
  66830. /**
  66831. * Gets the current class name
  66832. * @returns the class name
  66833. */
  66834. getClassName(): string;
  66835. /**
  66836. * Gets the value input component
  66837. */
  66838. get value(): NodeMaterialConnectionPoint;
  66839. /**
  66840. * Gets the output component
  66841. */
  66842. get output(): NodeMaterialConnectionPoint;
  66843. protected _buildBlock(state: NodeMaterialBuildState): this;
  66844. }
  66845. }
  66846. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66850. /**
  66851. * Block used to get the value of the first parameter raised to the power of the second
  66852. */
  66853. export class PowBlock extends NodeMaterialBlock {
  66854. /**
  66855. * Creates a new PowBlock
  66856. * @param name defines the block name
  66857. */
  66858. constructor(name: string);
  66859. /**
  66860. * Gets the current class name
  66861. * @returns the class name
  66862. */
  66863. getClassName(): string;
  66864. /**
  66865. * Gets the value operand input component
  66866. */
  66867. get value(): NodeMaterialConnectionPoint;
  66868. /**
  66869. * Gets the power operand input component
  66870. */
  66871. get power(): NodeMaterialConnectionPoint;
  66872. /**
  66873. * Gets the output component
  66874. */
  66875. get output(): NodeMaterialConnectionPoint;
  66876. protected _buildBlock(state: NodeMaterialBuildState): this;
  66877. }
  66878. }
  66879. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66883. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66884. /**
  66885. * Block used to get a random number
  66886. */
  66887. export class RandomNumberBlock extends NodeMaterialBlock {
  66888. /**
  66889. * Creates a new RandomNumberBlock
  66890. * @param name defines the block name
  66891. */
  66892. constructor(name: string);
  66893. /**
  66894. * Gets the current class name
  66895. * @returns the class name
  66896. */
  66897. getClassName(): string;
  66898. /**
  66899. * Gets the seed input component
  66900. */
  66901. get seed(): NodeMaterialConnectionPoint;
  66902. /**
  66903. * Gets the output component
  66904. */
  66905. get output(): NodeMaterialConnectionPoint;
  66906. protected _buildBlock(state: NodeMaterialBuildState): this;
  66907. }
  66908. }
  66909. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66913. /**
  66914. * Block used to compute arc tangent of 2 values
  66915. */
  66916. export class ArcTan2Block extends NodeMaterialBlock {
  66917. /**
  66918. * Creates a new ArcTan2Block
  66919. * @param name defines the block name
  66920. */
  66921. constructor(name: string);
  66922. /**
  66923. * Gets the current class name
  66924. * @returns the class name
  66925. */
  66926. getClassName(): string;
  66927. /**
  66928. * Gets the x operand input component
  66929. */
  66930. get x(): NodeMaterialConnectionPoint;
  66931. /**
  66932. * Gets the y operand input component
  66933. */
  66934. get y(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the output component
  66937. */
  66938. get output(): NodeMaterialConnectionPoint;
  66939. protected _buildBlock(state: NodeMaterialBuildState): this;
  66940. }
  66941. }
  66942. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66946. /**
  66947. * Block used to smooth step a value
  66948. */
  66949. export class SmoothStepBlock extends NodeMaterialBlock {
  66950. /**
  66951. * Creates a new SmoothStepBlock
  66952. * @param name defines the block name
  66953. */
  66954. constructor(name: string);
  66955. /**
  66956. * Gets the current class name
  66957. * @returns the class name
  66958. */
  66959. getClassName(): string;
  66960. /**
  66961. * Gets the value operand input component
  66962. */
  66963. get value(): NodeMaterialConnectionPoint;
  66964. /**
  66965. * Gets the first edge operand input component
  66966. */
  66967. get edge0(): NodeMaterialConnectionPoint;
  66968. /**
  66969. * Gets the second edge operand input component
  66970. */
  66971. get edge1(): NodeMaterialConnectionPoint;
  66972. /**
  66973. * Gets the output component
  66974. */
  66975. get output(): NodeMaterialConnectionPoint;
  66976. protected _buildBlock(state: NodeMaterialBuildState): this;
  66977. }
  66978. }
  66979. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66983. /**
  66984. * Block used to get the reciprocal (1 / x) of a value
  66985. */
  66986. export class ReciprocalBlock extends NodeMaterialBlock {
  66987. /**
  66988. * Creates a new ReciprocalBlock
  66989. * @param name defines the block name
  66990. */
  66991. constructor(name: string);
  66992. /**
  66993. * Gets the current class name
  66994. * @returns the class name
  66995. */
  66996. getClassName(): string;
  66997. /**
  66998. * Gets the input component
  66999. */
  67000. get input(): NodeMaterialConnectionPoint;
  67001. /**
  67002. * Gets the output component
  67003. */
  67004. get output(): NodeMaterialConnectionPoint;
  67005. protected _buildBlock(state: NodeMaterialBuildState): this;
  67006. }
  67007. }
  67008. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67009. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67012. /**
  67013. * Block used to replace a color by another one
  67014. */
  67015. export class ReplaceColorBlock extends NodeMaterialBlock {
  67016. /**
  67017. * Creates a new ReplaceColorBlock
  67018. * @param name defines the block name
  67019. */
  67020. constructor(name: string);
  67021. /**
  67022. * Gets the current class name
  67023. * @returns the class name
  67024. */
  67025. getClassName(): string;
  67026. /**
  67027. * Gets the value input component
  67028. */
  67029. get value(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the reference input component
  67032. */
  67033. get reference(): NodeMaterialConnectionPoint;
  67034. /**
  67035. * Gets the distance input component
  67036. */
  67037. get distance(): NodeMaterialConnectionPoint;
  67038. /**
  67039. * Gets the replacement input component
  67040. */
  67041. get replacement(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the output component
  67044. */
  67045. get output(): NodeMaterialConnectionPoint;
  67046. protected _buildBlock(state: NodeMaterialBuildState): this;
  67047. }
  67048. }
  67049. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67053. /**
  67054. * Block used to posterize a value
  67055. * @see https://en.wikipedia.org/wiki/Posterization
  67056. */
  67057. export class PosterizeBlock extends NodeMaterialBlock {
  67058. /**
  67059. * Creates a new PosterizeBlock
  67060. * @param name defines the block name
  67061. */
  67062. constructor(name: string);
  67063. /**
  67064. * Gets the current class name
  67065. * @returns the class name
  67066. */
  67067. getClassName(): string;
  67068. /**
  67069. * Gets the value input component
  67070. */
  67071. get value(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the steps input component
  67074. */
  67075. get steps(): NodeMaterialConnectionPoint;
  67076. /**
  67077. * Gets the output component
  67078. */
  67079. get output(): NodeMaterialConnectionPoint;
  67080. protected _buildBlock(state: NodeMaterialBuildState): this;
  67081. }
  67082. }
  67083. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67087. import { Scene } from "babylonjs/scene";
  67088. /**
  67089. * Operations supported by the Wave block
  67090. */
  67091. export enum WaveBlockKind {
  67092. /** SawTooth */
  67093. SawTooth = 0,
  67094. /** Square */
  67095. Square = 1,
  67096. /** Triangle */
  67097. Triangle = 2
  67098. }
  67099. /**
  67100. * Block used to apply wave operation to floats
  67101. */
  67102. export class WaveBlock extends NodeMaterialBlock {
  67103. /**
  67104. * Gets or sets the kibnd of wave to be applied by the block
  67105. */
  67106. kind: WaveBlockKind;
  67107. /**
  67108. * Creates a new WaveBlock
  67109. * @param name defines the block name
  67110. */
  67111. constructor(name: string);
  67112. /**
  67113. * Gets the current class name
  67114. * @returns the class name
  67115. */
  67116. getClassName(): string;
  67117. /**
  67118. * Gets the input component
  67119. */
  67120. get input(): NodeMaterialConnectionPoint;
  67121. /**
  67122. * Gets the output component
  67123. */
  67124. get output(): NodeMaterialConnectionPoint;
  67125. protected _buildBlock(state: NodeMaterialBuildState): this;
  67126. serialize(): any;
  67127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67128. }
  67129. }
  67130. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67134. import { Color3 } from "babylonjs/Maths/math.color";
  67135. import { Scene } from "babylonjs/scene";
  67136. /**
  67137. * Class used to store a color step for the GradientBlock
  67138. */
  67139. export class GradientBlockColorStep {
  67140. /**
  67141. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  67142. */
  67143. step: number;
  67144. /**
  67145. * Gets or sets the color associated with this step
  67146. */
  67147. color: Color3;
  67148. /**
  67149. * Creates a new GradientBlockColorStep
  67150. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67151. * @param color defines the color associated with this step
  67152. */
  67153. constructor(
  67154. /**
  67155. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  67156. */
  67157. step: number,
  67158. /**
  67159. * Gets or sets the color associated with this step
  67160. */
  67161. color: Color3);
  67162. }
  67163. /**
  67164. * Block used to return a color from a gradient based on an input value between 0 and 1
  67165. */
  67166. export class GradientBlock extends NodeMaterialBlock {
  67167. /**
  67168. * Gets or sets the list of color steps
  67169. */
  67170. colorSteps: GradientBlockColorStep[];
  67171. /**
  67172. * Creates a new GradientBlock
  67173. * @param name defines the block name
  67174. */
  67175. constructor(name: string);
  67176. /**
  67177. * Gets the current class name
  67178. * @returns the class name
  67179. */
  67180. getClassName(): string;
  67181. /**
  67182. * Gets the gradient input component
  67183. */
  67184. get gradient(): NodeMaterialConnectionPoint;
  67185. /**
  67186. * Gets the output component
  67187. */
  67188. get output(): NodeMaterialConnectionPoint;
  67189. private _writeColorConstant;
  67190. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67191. serialize(): any;
  67192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67193. protected _dumpPropertiesCode(): string;
  67194. }
  67195. }
  67196. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67200. /**
  67201. * Block used to normalize lerp between 2 values
  67202. */
  67203. export class NLerpBlock extends NodeMaterialBlock {
  67204. /**
  67205. * Creates a new NLerpBlock
  67206. * @param name defines the block name
  67207. */
  67208. constructor(name: string);
  67209. /**
  67210. * Gets the current class name
  67211. * @returns the class name
  67212. */
  67213. getClassName(): string;
  67214. /**
  67215. * Gets the left operand input component
  67216. */
  67217. get left(): NodeMaterialConnectionPoint;
  67218. /**
  67219. * Gets the right operand input component
  67220. */
  67221. get right(): NodeMaterialConnectionPoint;
  67222. /**
  67223. * Gets the gradient operand input component
  67224. */
  67225. get gradient(): NodeMaterialConnectionPoint;
  67226. /**
  67227. * Gets the output component
  67228. */
  67229. get output(): NodeMaterialConnectionPoint;
  67230. protected _buildBlock(state: NodeMaterialBuildState): this;
  67231. }
  67232. }
  67233. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67237. import { Scene } from "babylonjs/scene";
  67238. /**
  67239. * block used to Generate a Worley Noise 3D Noise Pattern
  67240. */
  67241. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67242. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67243. manhattanDistance: boolean;
  67244. /**
  67245. * Creates a new WorleyNoise3DBlock
  67246. * @param name defines the block name
  67247. */
  67248. constructor(name: string);
  67249. /**
  67250. * Gets the current class name
  67251. * @returns the class name
  67252. */
  67253. getClassName(): string;
  67254. /**
  67255. * Gets the seed input component
  67256. */
  67257. get seed(): NodeMaterialConnectionPoint;
  67258. /**
  67259. * Gets the jitter input component
  67260. */
  67261. get jitter(): NodeMaterialConnectionPoint;
  67262. /**
  67263. * Gets the output component
  67264. */
  67265. get output(): NodeMaterialConnectionPoint;
  67266. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67267. /**
  67268. * Exposes the properties to the UI?
  67269. */
  67270. protected _dumpPropertiesCode(): string;
  67271. /**
  67272. * Exposes the properties to the Seralize?
  67273. */
  67274. serialize(): any;
  67275. /**
  67276. * Exposes the properties to the deseralize?
  67277. */
  67278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67279. }
  67280. }
  67281. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67285. /**
  67286. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67287. */
  67288. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67289. /**
  67290. * Creates a new SimplexPerlin3DBlock
  67291. * @param name defines the block name
  67292. */
  67293. constructor(name: string);
  67294. /**
  67295. * Gets the current class name
  67296. * @returns the class name
  67297. */
  67298. getClassName(): string;
  67299. /**
  67300. * Gets the seed operand input component
  67301. */
  67302. get seed(): NodeMaterialConnectionPoint;
  67303. /**
  67304. * Gets the output component
  67305. */
  67306. get output(): NodeMaterialConnectionPoint;
  67307. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67308. }
  67309. }
  67310. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67314. /**
  67315. * Block used to blend normals
  67316. */
  67317. export class NormalBlendBlock extends NodeMaterialBlock {
  67318. /**
  67319. * Creates a new NormalBlendBlock
  67320. * @param name defines the block name
  67321. */
  67322. constructor(name: string);
  67323. /**
  67324. * Gets the current class name
  67325. * @returns the class name
  67326. */
  67327. getClassName(): string;
  67328. /**
  67329. * Gets the first input component
  67330. */
  67331. get normalMap0(): NodeMaterialConnectionPoint;
  67332. /**
  67333. * Gets the second input component
  67334. */
  67335. get normalMap1(): NodeMaterialConnectionPoint;
  67336. /**
  67337. * Gets the output component
  67338. */
  67339. get output(): NodeMaterialConnectionPoint;
  67340. protected _buildBlock(state: NodeMaterialBuildState): this;
  67341. }
  67342. }
  67343. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67344. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67345. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67346. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67347. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67348. /**
  67349. * Block used to rotate a 2d vector by a given angle
  67350. */
  67351. export class Rotate2dBlock extends NodeMaterialBlock {
  67352. /**
  67353. * Creates a new Rotate2dBlock
  67354. * @param name defines the block name
  67355. */
  67356. constructor(name: string);
  67357. /**
  67358. * Gets the current class name
  67359. * @returns the class name
  67360. */
  67361. getClassName(): string;
  67362. /**
  67363. * Gets the input vector
  67364. */
  67365. get input(): NodeMaterialConnectionPoint;
  67366. /**
  67367. * Gets the input angle
  67368. */
  67369. get angle(): NodeMaterialConnectionPoint;
  67370. /**
  67371. * Gets the output component
  67372. */
  67373. get output(): NodeMaterialConnectionPoint;
  67374. autoConfigure(material: NodeMaterial): void;
  67375. protected _buildBlock(state: NodeMaterialBuildState): this;
  67376. }
  67377. }
  67378. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67382. /**
  67383. * Block used to get the reflected vector from a direction and a normal
  67384. */
  67385. export class ReflectBlock extends NodeMaterialBlock {
  67386. /**
  67387. * Creates a new ReflectBlock
  67388. * @param name defines the block name
  67389. */
  67390. constructor(name: string);
  67391. /**
  67392. * Gets the current class name
  67393. * @returns the class name
  67394. */
  67395. getClassName(): string;
  67396. /**
  67397. * Gets the incident component
  67398. */
  67399. get incident(): NodeMaterialConnectionPoint;
  67400. /**
  67401. * Gets the normal component
  67402. */
  67403. get normal(): NodeMaterialConnectionPoint;
  67404. /**
  67405. * Gets the output component
  67406. */
  67407. get output(): NodeMaterialConnectionPoint;
  67408. protected _buildBlock(state: NodeMaterialBuildState): this;
  67409. }
  67410. }
  67411. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67415. /**
  67416. * Block used to get the refracted vector from a direction and a normal
  67417. */
  67418. export class RefractBlock extends NodeMaterialBlock {
  67419. /**
  67420. * Creates a new RefractBlock
  67421. * @param name defines the block name
  67422. */
  67423. constructor(name: string);
  67424. /**
  67425. * Gets the current class name
  67426. * @returns the class name
  67427. */
  67428. getClassName(): string;
  67429. /**
  67430. * Gets the incident component
  67431. */
  67432. get incident(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the normal component
  67435. */
  67436. get normal(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the index of refraction component
  67439. */
  67440. get ior(): NodeMaterialConnectionPoint;
  67441. /**
  67442. * Gets the output component
  67443. */
  67444. get output(): NodeMaterialConnectionPoint;
  67445. protected _buildBlock(state: NodeMaterialBuildState): this;
  67446. }
  67447. }
  67448. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67452. /**
  67453. * Block used to desaturate a color
  67454. */
  67455. export class DesaturateBlock extends NodeMaterialBlock {
  67456. /**
  67457. * Creates a new DesaturateBlock
  67458. * @param name defines the block name
  67459. */
  67460. constructor(name: string);
  67461. /**
  67462. * Gets the current class name
  67463. * @returns the class name
  67464. */
  67465. getClassName(): string;
  67466. /**
  67467. * Gets the color operand input component
  67468. */
  67469. get color(): NodeMaterialConnectionPoint;
  67470. /**
  67471. * Gets the level operand input component
  67472. */
  67473. get level(): NodeMaterialConnectionPoint;
  67474. /**
  67475. * Gets the output component
  67476. */
  67477. get output(): NodeMaterialConnectionPoint;
  67478. protected _buildBlock(state: NodeMaterialBuildState): this;
  67479. }
  67480. }
  67481. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67485. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67486. import { Nullable } from "babylonjs/types";
  67487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67488. import { Scene } from "babylonjs/scene";
  67489. /**
  67490. * Block used to implement the ambient occlusion module of the PBR material
  67491. */
  67492. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67493. /**
  67494. * Create a new AmbientOcclusionBlock
  67495. * @param name defines the block name
  67496. */
  67497. constructor(name: string);
  67498. /**
  67499. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67500. */
  67501. useAmbientInGrayScale: boolean;
  67502. /**
  67503. * Initialize the block and prepare the context for build
  67504. * @param state defines the state that will be used for the build
  67505. */
  67506. initialize(state: NodeMaterialBuildState): void;
  67507. /**
  67508. * Gets the current class name
  67509. * @returns the class name
  67510. */
  67511. getClassName(): string;
  67512. /**
  67513. * Gets the texture input component
  67514. */
  67515. get texture(): NodeMaterialConnectionPoint;
  67516. /**
  67517. * Gets the texture intensity component
  67518. */
  67519. get intensity(): NodeMaterialConnectionPoint;
  67520. /**
  67521. * Gets the direct light intensity input component
  67522. */
  67523. get directLightIntensity(): NodeMaterialConnectionPoint;
  67524. /**
  67525. * Gets the ambient occlusion object output component
  67526. */
  67527. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the main code of the block (fragment side)
  67530. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67531. * @returns the shader code
  67532. */
  67533. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67535. protected _buildBlock(state: NodeMaterialBuildState): this;
  67536. protected _dumpPropertiesCode(): string;
  67537. serialize(): any;
  67538. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67539. }
  67540. }
  67541. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67544. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67545. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67547. import { Nullable } from "babylonjs/types";
  67548. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67549. import { Mesh } from "babylonjs/Meshes/mesh";
  67550. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67551. import { Effect } from "babylonjs/Materials/effect";
  67552. import { Scene } from "babylonjs/scene";
  67553. /**
  67554. * Block used to implement the reflection module of the PBR material
  67555. */
  67556. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67557. /** @hidden */
  67558. _defineLODReflectionAlpha: string;
  67559. /** @hidden */
  67560. _defineLinearSpecularReflection: string;
  67561. private _vEnvironmentIrradianceName;
  67562. /** @hidden */
  67563. _vReflectionMicrosurfaceInfosName: string;
  67564. /** @hidden */
  67565. _vReflectionInfosName: string;
  67566. /** @hidden */
  67567. _vReflectionFilteringInfoName: string;
  67568. private _scene;
  67569. /**
  67570. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67571. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67572. * It's less burden on the user side in the editor part.
  67573. */
  67574. /** @hidden */
  67575. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67576. /** @hidden */
  67577. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67578. /** @hidden */
  67579. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67580. /**
  67581. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67582. * diffuse part of the IBL.
  67583. */
  67584. useSphericalHarmonics: boolean;
  67585. /**
  67586. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67587. */
  67588. forceIrradianceInFragment: boolean;
  67589. /**
  67590. * Create a new ReflectionBlock
  67591. * @param name defines the block name
  67592. */
  67593. constructor(name: string);
  67594. /**
  67595. * Gets the current class name
  67596. * @returns the class name
  67597. */
  67598. getClassName(): string;
  67599. /**
  67600. * Gets the position input component
  67601. */
  67602. get position(): NodeMaterialConnectionPoint;
  67603. /**
  67604. * Gets the world position input component
  67605. */
  67606. get worldPosition(): NodeMaterialConnectionPoint;
  67607. /**
  67608. * Gets the world normal input component
  67609. */
  67610. get worldNormal(): NodeMaterialConnectionPoint;
  67611. /**
  67612. * Gets the world input component
  67613. */
  67614. get world(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the camera (or eye) position component
  67617. */
  67618. get cameraPosition(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the view input component
  67621. */
  67622. get view(): NodeMaterialConnectionPoint;
  67623. /**
  67624. * Gets the color input component
  67625. */
  67626. get color(): NodeMaterialConnectionPoint;
  67627. /**
  67628. * Gets the reflection object output component
  67629. */
  67630. get reflection(): NodeMaterialConnectionPoint;
  67631. /**
  67632. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67633. */
  67634. get hasTexture(): boolean;
  67635. /**
  67636. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67637. */
  67638. get reflectionColor(): string;
  67639. protected _getTexture(): Nullable<BaseTexture>;
  67640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67642. /**
  67643. * Gets the code to inject in the vertex shader
  67644. * @param state current state of the node material building
  67645. * @returns the shader code
  67646. */
  67647. handleVertexSide(state: NodeMaterialBuildState): string;
  67648. /**
  67649. * Gets the main code of the block (fragment side)
  67650. * @param state current state of the node material building
  67651. * @param normalVarName name of the existing variable corresponding to the normal
  67652. * @returns the shader code
  67653. */
  67654. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67655. protected _buildBlock(state: NodeMaterialBuildState): this;
  67656. protected _dumpPropertiesCode(): string;
  67657. serialize(): any;
  67658. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67659. }
  67660. }
  67661. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67665. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67667. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67668. import { Scene } from "babylonjs/scene";
  67669. import { Nullable } from "babylonjs/types";
  67670. /**
  67671. * Block used to implement the sheen module of the PBR material
  67672. */
  67673. export class SheenBlock extends NodeMaterialBlock {
  67674. /**
  67675. * Create a new SheenBlock
  67676. * @param name defines the block name
  67677. */
  67678. constructor(name: string);
  67679. /**
  67680. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67681. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67682. * making it easier to setup and tweak the effect
  67683. */
  67684. albedoScaling: boolean;
  67685. /**
  67686. * Defines if the sheen is linked to the sheen color.
  67687. */
  67688. linkSheenWithAlbedo: boolean;
  67689. /**
  67690. * Initialize the block and prepare the context for build
  67691. * @param state defines the state that will be used for the build
  67692. */
  67693. initialize(state: NodeMaterialBuildState): void;
  67694. /**
  67695. * Gets the current class name
  67696. * @returns the class name
  67697. */
  67698. getClassName(): string;
  67699. /**
  67700. * Gets the intensity input component
  67701. */
  67702. get intensity(): NodeMaterialConnectionPoint;
  67703. /**
  67704. * Gets the color input component
  67705. */
  67706. get color(): NodeMaterialConnectionPoint;
  67707. /**
  67708. * Gets the roughness input component
  67709. */
  67710. get roughness(): NodeMaterialConnectionPoint;
  67711. /**
  67712. * Gets the sheen object output component
  67713. */
  67714. get sheen(): NodeMaterialConnectionPoint;
  67715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67716. /**
  67717. * Gets the main code of the block (fragment side)
  67718. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67719. * @returns the shader code
  67720. */
  67721. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67722. protected _buildBlock(state: NodeMaterialBuildState): this;
  67723. protected _dumpPropertiesCode(): string;
  67724. serialize(): any;
  67725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67726. }
  67727. }
  67728. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67729. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67731. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67733. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67734. import { Scene } from "babylonjs/scene";
  67735. import { Nullable } from "babylonjs/types";
  67736. import { Mesh } from "babylonjs/Meshes/mesh";
  67737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67738. import { Effect } from "babylonjs/Materials/effect";
  67739. /**
  67740. * Block used to implement the reflectivity module of the PBR material
  67741. */
  67742. export class ReflectivityBlock extends NodeMaterialBlock {
  67743. private _metallicReflectanceColor;
  67744. private _metallicF0Factor;
  67745. /** @hidden */
  67746. _vMetallicReflectanceFactorsName: string;
  67747. /**
  67748. * The property below is set by the main PBR block prior to calling methods of this class.
  67749. */
  67750. /** @hidden */
  67751. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67752. /**
  67753. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67754. */
  67755. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67756. /**
  67757. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67758. */
  67759. useMetallnessFromMetallicTextureBlue: boolean;
  67760. /**
  67761. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67762. */
  67763. useRoughnessFromMetallicTextureAlpha: boolean;
  67764. /**
  67765. * Specifies if the metallic texture contains the roughness information in its green channel.
  67766. */
  67767. useRoughnessFromMetallicTextureGreen: boolean;
  67768. /**
  67769. * Create a new ReflectivityBlock
  67770. * @param name defines the block name
  67771. */
  67772. constructor(name: string);
  67773. /**
  67774. * Initialize the block and prepare the context for build
  67775. * @param state defines the state that will be used for the build
  67776. */
  67777. initialize(state: NodeMaterialBuildState): void;
  67778. /**
  67779. * Gets the current class name
  67780. * @returns the class name
  67781. */
  67782. getClassName(): string;
  67783. /**
  67784. * Gets the metallic input component
  67785. */
  67786. get metallic(): NodeMaterialConnectionPoint;
  67787. /**
  67788. * Gets the roughness input component
  67789. */
  67790. get roughness(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Gets the texture input component
  67793. */
  67794. get texture(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the reflectivity object output component
  67797. */
  67798. get reflectivity(): NodeMaterialConnectionPoint;
  67799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67800. /**
  67801. * Gets the main code of the block (fragment side)
  67802. * @param state current state of the node material building
  67803. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67804. * @returns the shader code
  67805. */
  67806. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67807. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67808. protected _buildBlock(state: NodeMaterialBuildState): this;
  67809. protected _dumpPropertiesCode(): string;
  67810. serialize(): any;
  67811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67812. }
  67813. }
  67814. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67815. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67820. /**
  67821. * Block used to implement the anisotropy module of the PBR material
  67822. */
  67823. export class AnisotropyBlock extends NodeMaterialBlock {
  67824. /**
  67825. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67826. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67827. * It's less burden on the user side in the editor part.
  67828. */
  67829. /** @hidden */
  67830. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67831. /** @hidden */
  67832. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67833. /**
  67834. * Create a new AnisotropyBlock
  67835. * @param name defines the block name
  67836. */
  67837. constructor(name: string);
  67838. /**
  67839. * Initialize the block and prepare the context for build
  67840. * @param state defines the state that will be used for the build
  67841. */
  67842. initialize(state: NodeMaterialBuildState): void;
  67843. /**
  67844. * Gets the current class name
  67845. * @returns the class name
  67846. */
  67847. getClassName(): string;
  67848. /**
  67849. * Gets the intensity input component
  67850. */
  67851. get intensity(): NodeMaterialConnectionPoint;
  67852. /**
  67853. * Gets the direction input component
  67854. */
  67855. get direction(): NodeMaterialConnectionPoint;
  67856. /**
  67857. * Gets the texture input component
  67858. */
  67859. get texture(): NodeMaterialConnectionPoint;
  67860. /**
  67861. * Gets the uv input component
  67862. */
  67863. get uv(): NodeMaterialConnectionPoint;
  67864. /**
  67865. * Gets the worldTangent input component
  67866. */
  67867. get worldTangent(): NodeMaterialConnectionPoint;
  67868. /**
  67869. * Gets the anisotropy object output component
  67870. */
  67871. get anisotropy(): NodeMaterialConnectionPoint;
  67872. private _generateTBNSpace;
  67873. /**
  67874. * Gets the main code of the block (fragment side)
  67875. * @param state current state of the node material building
  67876. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67877. * @returns the shader code
  67878. */
  67879. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67881. protected _buildBlock(state: NodeMaterialBuildState): this;
  67882. }
  67883. }
  67884. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67888. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67890. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67891. import { Nullable } from "babylonjs/types";
  67892. import { Mesh } from "babylonjs/Meshes/mesh";
  67893. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67894. import { Effect } from "babylonjs/Materials/effect";
  67895. /**
  67896. * Block used to implement the clear coat module of the PBR material
  67897. */
  67898. export class ClearCoatBlock extends NodeMaterialBlock {
  67899. private _scene;
  67900. /**
  67901. * Create a new ClearCoatBlock
  67902. * @param name defines the block name
  67903. */
  67904. constructor(name: string);
  67905. /**
  67906. * Initialize the block and prepare the context for build
  67907. * @param state defines the state that will be used for the build
  67908. */
  67909. initialize(state: NodeMaterialBuildState): void;
  67910. /**
  67911. * Gets the current class name
  67912. * @returns the class name
  67913. */
  67914. getClassName(): string;
  67915. /**
  67916. * Gets the intensity input component
  67917. */
  67918. get intensity(): NodeMaterialConnectionPoint;
  67919. /**
  67920. * Gets the roughness input component
  67921. */
  67922. get roughness(): NodeMaterialConnectionPoint;
  67923. /**
  67924. * Gets the ior input component
  67925. */
  67926. get ior(): NodeMaterialConnectionPoint;
  67927. /**
  67928. * Gets the texture input component
  67929. */
  67930. get texture(): NodeMaterialConnectionPoint;
  67931. /**
  67932. * Gets the bump texture input component
  67933. */
  67934. get bumpTexture(): NodeMaterialConnectionPoint;
  67935. /**
  67936. * Gets the uv input component
  67937. */
  67938. get uv(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the tint color input component
  67941. */
  67942. get tintColor(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the tint "at distance" input component
  67945. */
  67946. get tintAtDistance(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the tint thickness input component
  67949. */
  67950. get tintThickness(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the world tangent input component
  67953. */
  67954. get worldTangent(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the clear coat object output component
  67957. */
  67958. get clearcoat(): NodeMaterialConnectionPoint;
  67959. autoConfigure(material: NodeMaterial): void;
  67960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67962. private _generateTBNSpace;
  67963. /**
  67964. * Gets the main code of the block (fragment side)
  67965. * @param state current state of the node material building
  67966. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67967. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67968. * @param worldPosVarName name of the variable holding the world position
  67969. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67970. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67971. * @param worldNormalVarName name of the variable holding the world normal
  67972. * @returns the shader code
  67973. */
  67974. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67975. protected _buildBlock(state: NodeMaterialBuildState): this;
  67976. }
  67977. }
  67978. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67982. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67984. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67985. import { Nullable } from "babylonjs/types";
  67986. /**
  67987. * Block used to implement the sub surface module of the PBR material
  67988. */
  67989. export class SubSurfaceBlock extends NodeMaterialBlock {
  67990. /**
  67991. * Create a new SubSurfaceBlock
  67992. * @param name defines the block name
  67993. */
  67994. constructor(name: string);
  67995. /**
  67996. * Stores the intensity of the different subsurface effects in the thickness texture.
  67997. * * the green channel is the translucency intensity.
  67998. * * the blue channel is the scattering intensity.
  67999. * * the alpha channel is the refraction intensity.
  68000. */
  68001. useMaskFromThicknessTexture: boolean;
  68002. /**
  68003. * Initialize the block and prepare the context for build
  68004. * @param state defines the state that will be used for the build
  68005. */
  68006. initialize(state: NodeMaterialBuildState): void;
  68007. /**
  68008. * Gets the current class name
  68009. * @returns the class name
  68010. */
  68011. getClassName(): string;
  68012. /**
  68013. * Gets the min thickness input component
  68014. */
  68015. get minThickness(): NodeMaterialConnectionPoint;
  68016. /**
  68017. * Gets the max thickness input component
  68018. */
  68019. get maxThickness(): NodeMaterialConnectionPoint;
  68020. /**
  68021. * Gets the thickness texture component
  68022. */
  68023. get thicknessTexture(): NodeMaterialConnectionPoint;
  68024. /**
  68025. * Gets the tint color input component
  68026. */
  68027. get tintColor(): NodeMaterialConnectionPoint;
  68028. /**
  68029. * Gets the translucency intensity input component
  68030. */
  68031. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68032. /**
  68033. * Gets the translucency diffusion distance input component
  68034. */
  68035. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the refraction object parameters
  68038. */
  68039. get refraction(): NodeMaterialConnectionPoint;
  68040. /**
  68041. * Gets the sub surface object output component
  68042. */
  68043. get subsurface(): NodeMaterialConnectionPoint;
  68044. autoConfigure(material: NodeMaterial): void;
  68045. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68046. /**
  68047. * Gets the main code of the block (fragment side)
  68048. * @param state current state of the node material building
  68049. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68050. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68051. * @param worldPosVarName name of the variable holding the world position
  68052. * @returns the shader code
  68053. */
  68054. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68055. protected _buildBlock(state: NodeMaterialBuildState): this;
  68056. }
  68057. }
  68058. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68062. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68063. import { Light } from "babylonjs/Lights/light";
  68064. import { Nullable } from "babylonjs/types";
  68065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68066. import { Effect } from "babylonjs/Materials/effect";
  68067. import { Mesh } from "babylonjs/Meshes/mesh";
  68068. import { Scene } from "babylonjs/scene";
  68069. /**
  68070. * Block used to implement the PBR metallic/roughness model
  68071. */
  68072. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68073. /**
  68074. * Gets or sets the light associated with this block
  68075. */
  68076. light: Nullable<Light>;
  68077. private _lightId;
  68078. private _scene;
  68079. private _environmentBRDFTexture;
  68080. private _environmentBrdfSamplerName;
  68081. private _vNormalWName;
  68082. private _invertNormalName;
  68083. /**
  68084. * Create a new ReflectionBlock
  68085. * @param name defines the block name
  68086. */
  68087. constructor(name: string);
  68088. /**
  68089. * Intensity of the direct lights e.g. the four lights available in your scene.
  68090. * This impacts both the direct diffuse and specular highlights.
  68091. */
  68092. directIntensity: number;
  68093. /**
  68094. * Intensity of the environment e.g. how much the environment will light the object
  68095. * either through harmonics for rough material or through the refelction for shiny ones.
  68096. */
  68097. environmentIntensity: number;
  68098. /**
  68099. * This is a special control allowing the reduction of the specular highlights coming from the
  68100. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68101. */
  68102. specularIntensity: number;
  68103. /**
  68104. * Defines the falloff type used in this material.
  68105. * It by default is Physical.
  68106. */
  68107. lightFalloff: number;
  68108. /**
  68109. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68110. */
  68111. useAlphaFromAlbedoTexture: boolean;
  68112. /**
  68113. * Specifies that alpha test should be used
  68114. */
  68115. useAlphaTest: boolean;
  68116. /**
  68117. * Defines the alpha limits in alpha test mode.
  68118. */
  68119. alphaTestCutoff: number;
  68120. /**
  68121. * Specifies that alpha blending should be used
  68122. */
  68123. useAlphaBlending: boolean;
  68124. /**
  68125. * Defines if the alpha value should be determined via the rgb values.
  68126. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68127. */
  68128. opacityRGB: boolean;
  68129. /**
  68130. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68131. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68132. */
  68133. useRadianceOverAlpha: boolean;
  68134. /**
  68135. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68136. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68137. */
  68138. useSpecularOverAlpha: boolean;
  68139. /**
  68140. * Enables specular anti aliasing in the PBR shader.
  68141. * It will both interacts on the Geometry for analytical and IBL lighting.
  68142. * It also prefilter the roughness map based on the bump values.
  68143. */
  68144. enableSpecularAntiAliasing: boolean;
  68145. /**
  68146. * Enables realtime filtering on the texture.
  68147. */
  68148. realTimeFiltering: boolean;
  68149. /**
  68150. * Quality switch for realtime filtering
  68151. */
  68152. realTimeFilteringQuality: number;
  68153. /**
  68154. * Defines if the material uses energy conservation.
  68155. */
  68156. useEnergyConservation: boolean;
  68157. /**
  68158. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68159. * too much the area relying on ambient texture to define their ambient occlusion.
  68160. */
  68161. useRadianceOcclusion: boolean;
  68162. /**
  68163. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68164. * makes the reflect vector face the model (under horizon).
  68165. */
  68166. useHorizonOcclusion: boolean;
  68167. /**
  68168. * If set to true, no lighting calculations will be applied.
  68169. */
  68170. unlit: boolean;
  68171. /**
  68172. * Force normal to face away from face.
  68173. */
  68174. forceNormalForward: boolean;
  68175. /**
  68176. * Defines the material debug mode.
  68177. * It helps seeing only some components of the material while troubleshooting.
  68178. */
  68179. debugMode: number;
  68180. /**
  68181. * Specify from where on screen the debug mode should start.
  68182. * The value goes from -1 (full screen) to 1 (not visible)
  68183. * It helps with side by side comparison against the final render
  68184. * This defaults to 0
  68185. */
  68186. debugLimit: number;
  68187. /**
  68188. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68189. * You can use the factor to better multiply the final value.
  68190. */
  68191. debugFactor: number;
  68192. /**
  68193. * Initialize the block and prepare the context for build
  68194. * @param state defines the state that will be used for the build
  68195. */
  68196. initialize(state: NodeMaterialBuildState): void;
  68197. /**
  68198. * Gets the current class name
  68199. * @returns the class name
  68200. */
  68201. getClassName(): string;
  68202. /**
  68203. * Gets the world position input component
  68204. */
  68205. get worldPosition(): NodeMaterialConnectionPoint;
  68206. /**
  68207. * Gets the world normal input component
  68208. */
  68209. get worldNormal(): NodeMaterialConnectionPoint;
  68210. /**
  68211. * Gets the perturbed normal input component
  68212. */
  68213. get perturbedNormal(): NodeMaterialConnectionPoint;
  68214. /**
  68215. * Gets the camera position input component
  68216. */
  68217. get cameraPosition(): NodeMaterialConnectionPoint;
  68218. /**
  68219. * Gets the base color input component
  68220. */
  68221. get baseColor(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the opacity texture input component
  68224. */
  68225. get opacityTexture(): NodeMaterialConnectionPoint;
  68226. /**
  68227. * Gets the ambient color input component
  68228. */
  68229. get ambientColor(): NodeMaterialConnectionPoint;
  68230. /**
  68231. * Gets the reflectivity object parameters
  68232. */
  68233. get reflectivity(): NodeMaterialConnectionPoint;
  68234. /**
  68235. * Gets the ambient occlusion object parameters
  68236. */
  68237. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68238. /**
  68239. * Gets the reflection object parameters
  68240. */
  68241. get reflection(): NodeMaterialConnectionPoint;
  68242. /**
  68243. * Gets the sheen object parameters
  68244. */
  68245. get sheen(): NodeMaterialConnectionPoint;
  68246. /**
  68247. * Gets the clear coat object parameters
  68248. */
  68249. get clearcoat(): NodeMaterialConnectionPoint;
  68250. /**
  68251. * Gets the sub surface object parameters
  68252. */
  68253. get subsurface(): NodeMaterialConnectionPoint;
  68254. /**
  68255. * Gets the anisotropy object parameters
  68256. */
  68257. get anisotropy(): NodeMaterialConnectionPoint;
  68258. /**
  68259. * Gets the ambient output component
  68260. */
  68261. get ambient(): NodeMaterialConnectionPoint;
  68262. /**
  68263. * Gets the diffuse output component
  68264. */
  68265. get diffuse(): NodeMaterialConnectionPoint;
  68266. /**
  68267. * Gets the specular output component
  68268. */
  68269. get specular(): NodeMaterialConnectionPoint;
  68270. /**
  68271. * Gets the sheen output component
  68272. */
  68273. get sheenDir(): NodeMaterialConnectionPoint;
  68274. /**
  68275. * Gets the clear coat output component
  68276. */
  68277. get clearcoatDir(): NodeMaterialConnectionPoint;
  68278. /**
  68279. * Gets the indirect diffuse output component
  68280. */
  68281. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68282. /**
  68283. * Gets the indirect specular output component
  68284. */
  68285. get specularIndirect(): NodeMaterialConnectionPoint;
  68286. /**
  68287. * Gets the indirect sheen output component
  68288. */
  68289. get sheenIndirect(): NodeMaterialConnectionPoint;
  68290. /**
  68291. * Gets the indirect clear coat output component
  68292. */
  68293. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68294. /**
  68295. * Gets the refraction output component
  68296. */
  68297. get refraction(): NodeMaterialConnectionPoint;
  68298. /**
  68299. * Gets the global lighting output component
  68300. */
  68301. get lighting(): NodeMaterialConnectionPoint;
  68302. /**
  68303. * Gets the shadow output component
  68304. */
  68305. get shadow(): NodeMaterialConnectionPoint;
  68306. /**
  68307. * Gets the alpha output component
  68308. */
  68309. get alpha(): NodeMaterialConnectionPoint;
  68310. autoConfigure(material: NodeMaterial): void;
  68311. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68312. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68314. private _injectVertexCode;
  68315. /**
  68316. * Gets the code corresponding to the albedo/opacity module
  68317. * @returns the shader code
  68318. */
  68319. getAlbedoOpacityCode(): string;
  68320. protected _buildBlock(state: NodeMaterialBuildState): this;
  68321. protected _dumpPropertiesCode(): string;
  68322. serialize(): any;
  68323. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68324. }
  68325. }
  68326. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68327. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68328. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68329. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68330. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68331. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68332. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68333. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68334. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68335. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68336. }
  68337. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68338. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68339. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68340. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68341. }
  68342. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68346. /**
  68347. * Block used to compute value of one parameter modulo another
  68348. */
  68349. export class ModBlock extends NodeMaterialBlock {
  68350. /**
  68351. * Creates a new ModBlock
  68352. * @param name defines the block name
  68353. */
  68354. constructor(name: string);
  68355. /**
  68356. * Gets the current class name
  68357. * @returns the class name
  68358. */
  68359. getClassName(): string;
  68360. /**
  68361. * Gets the left operand input component
  68362. */
  68363. get left(): NodeMaterialConnectionPoint;
  68364. /**
  68365. * Gets the right operand input component
  68366. */
  68367. get right(): NodeMaterialConnectionPoint;
  68368. /**
  68369. * Gets the output component
  68370. */
  68371. get output(): NodeMaterialConnectionPoint;
  68372. protected _buildBlock(state: NodeMaterialBuildState): this;
  68373. }
  68374. }
  68375. declare module "babylonjs/Materials/Node/Blocks/index" {
  68376. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68377. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68378. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68379. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68380. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68381. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68382. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68383. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68384. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68385. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68386. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68387. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68388. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68389. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68390. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68391. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68392. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68393. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68394. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68395. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68396. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68397. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68398. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68399. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68400. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68401. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68402. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68403. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68404. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68405. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68406. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68407. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68408. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68409. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68410. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68411. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68412. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68413. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68414. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68415. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68416. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68417. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68418. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68419. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68420. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68421. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68422. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68423. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68424. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68425. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68426. }
  68427. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68428. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68429. }
  68430. declare module "babylonjs/Materials/Node/index" {
  68431. export * from "babylonjs/Materials/Node/Enums/index";
  68432. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68433. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68434. export * from "babylonjs/Materials/Node/nodeMaterial";
  68435. export * from "babylonjs/Materials/Node/Blocks/index";
  68436. export * from "babylonjs/Materials/Node/Optimizers/index";
  68437. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68438. }
  68439. declare module "babylonjs/Materials/index" {
  68440. export * from "babylonjs/Materials/Background/index";
  68441. export * from "babylonjs/Materials/colorCurves";
  68442. export * from "babylonjs/Materials/iEffectFallbacks";
  68443. export * from "babylonjs/Materials/effectFallbacks";
  68444. export * from "babylonjs/Materials/effect";
  68445. export * from "babylonjs/Materials/fresnelParameters";
  68446. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68447. export * from "babylonjs/Materials/material";
  68448. export * from "babylonjs/Materials/materialDefines";
  68449. export * from "babylonjs/Materials/thinMaterialHelper";
  68450. export * from "babylonjs/Materials/materialHelper";
  68451. export * from "babylonjs/Materials/multiMaterial";
  68452. export * from "babylonjs/Materials/PBR/index";
  68453. export * from "babylonjs/Materials/pushMaterial";
  68454. export * from "babylonjs/Materials/shaderMaterial";
  68455. export * from "babylonjs/Materials/standardMaterial";
  68456. export * from "babylonjs/Materials/Textures/index";
  68457. export * from "babylonjs/Materials/uniformBuffer";
  68458. export * from "babylonjs/Materials/materialFlags";
  68459. export * from "babylonjs/Materials/Node/index";
  68460. export * from "babylonjs/Materials/effectRenderer";
  68461. export * from "babylonjs/Materials/shadowDepthWrapper";
  68462. }
  68463. declare module "babylonjs/Maths/index" {
  68464. export * from "babylonjs/Maths/math.scalar";
  68465. export * from "babylonjs/Maths/math";
  68466. export * from "babylonjs/Maths/sphericalPolynomial";
  68467. }
  68468. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68469. import { IDisposable } from "babylonjs/scene";
  68470. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68471. /**
  68472. * Configuration for Draco compression
  68473. */
  68474. export interface IDracoCompressionConfiguration {
  68475. /**
  68476. * Configuration for the decoder.
  68477. */
  68478. decoder: {
  68479. /**
  68480. * The url to the WebAssembly module.
  68481. */
  68482. wasmUrl?: string;
  68483. /**
  68484. * The url to the WebAssembly binary.
  68485. */
  68486. wasmBinaryUrl?: string;
  68487. /**
  68488. * The url to the fallback JavaScript module.
  68489. */
  68490. fallbackUrl?: string;
  68491. };
  68492. }
  68493. /**
  68494. * Draco compression (https://google.github.io/draco/)
  68495. *
  68496. * This class wraps the Draco module.
  68497. *
  68498. * **Encoder**
  68499. *
  68500. * The encoder is not currently implemented.
  68501. *
  68502. * **Decoder**
  68503. *
  68504. * 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.
  68505. *
  68506. * To update the configuration, use the following code:
  68507. * ```javascript
  68508. * DracoCompression.Configuration = {
  68509. * decoder: {
  68510. * wasmUrl: "<url to the WebAssembly library>",
  68511. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68512. * fallbackUrl: "<url to the fallback JavaScript library>",
  68513. * }
  68514. * };
  68515. * ```
  68516. *
  68517. * 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.
  68518. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68519. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68520. *
  68521. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68522. * ```javascript
  68523. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68524. * ```
  68525. *
  68526. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68527. */
  68528. export class DracoCompression implements IDisposable {
  68529. private _workerPoolPromise?;
  68530. private _decoderModulePromise?;
  68531. /**
  68532. * The configuration. Defaults to the following urls:
  68533. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68534. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68535. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68536. */
  68537. static Configuration: IDracoCompressionConfiguration;
  68538. /**
  68539. * Returns true if the decoder configuration is available.
  68540. */
  68541. static get DecoderAvailable(): boolean;
  68542. /**
  68543. * Default number of workers to create when creating the draco compression object.
  68544. */
  68545. static DefaultNumWorkers: number;
  68546. private static GetDefaultNumWorkers;
  68547. private static _Default;
  68548. /**
  68549. * Default instance for the draco compression object.
  68550. */
  68551. static get Default(): DracoCompression;
  68552. /**
  68553. * Constructor
  68554. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68555. */
  68556. constructor(numWorkers?: number);
  68557. /**
  68558. * Stop all async operations and release resources.
  68559. */
  68560. dispose(): void;
  68561. /**
  68562. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68563. * @returns a promise that resolves when ready
  68564. */
  68565. whenReadyAsync(): Promise<void>;
  68566. /**
  68567. * Decode Draco compressed mesh data to vertex data.
  68568. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68569. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68570. * @returns A promise that resolves with the decoded vertex data
  68571. */
  68572. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68573. [kind: string]: number;
  68574. }): Promise<VertexData>;
  68575. }
  68576. }
  68577. declare module "babylonjs/Meshes/Compression/index" {
  68578. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68579. }
  68580. declare module "babylonjs/Meshes/csg" {
  68581. import { Nullable } from "babylonjs/types";
  68582. import { Scene } from "babylonjs/scene";
  68583. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68584. import { Mesh } from "babylonjs/Meshes/mesh";
  68585. import { Material } from "babylonjs/Materials/material";
  68586. /**
  68587. * Class for building Constructive Solid Geometry
  68588. */
  68589. export class CSG {
  68590. private polygons;
  68591. /**
  68592. * The world matrix
  68593. */
  68594. matrix: Matrix;
  68595. /**
  68596. * Stores the position
  68597. */
  68598. position: Vector3;
  68599. /**
  68600. * Stores the rotation
  68601. */
  68602. rotation: Vector3;
  68603. /**
  68604. * Stores the rotation quaternion
  68605. */
  68606. rotationQuaternion: Nullable<Quaternion>;
  68607. /**
  68608. * Stores the scaling vector
  68609. */
  68610. scaling: Vector3;
  68611. /**
  68612. * Convert the Mesh to CSG
  68613. * @param mesh The Mesh to convert to CSG
  68614. * @returns A new CSG from the Mesh
  68615. */
  68616. static FromMesh(mesh: Mesh): CSG;
  68617. /**
  68618. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68619. * @param polygons Polygons used to construct a CSG solid
  68620. */
  68621. private static FromPolygons;
  68622. /**
  68623. * Clones, or makes a deep copy, of the CSG
  68624. * @returns A new CSG
  68625. */
  68626. clone(): CSG;
  68627. /**
  68628. * Unions this CSG with another CSG
  68629. * @param csg The CSG to union against this CSG
  68630. * @returns The unioned CSG
  68631. */
  68632. union(csg: CSG): CSG;
  68633. /**
  68634. * Unions this CSG with another CSG in place
  68635. * @param csg The CSG to union against this CSG
  68636. */
  68637. unionInPlace(csg: CSG): void;
  68638. /**
  68639. * Subtracts this CSG with another CSG
  68640. * @param csg The CSG to subtract against this CSG
  68641. * @returns A new CSG
  68642. */
  68643. subtract(csg: CSG): CSG;
  68644. /**
  68645. * Subtracts this CSG with another CSG in place
  68646. * @param csg The CSG to subtact against this CSG
  68647. */
  68648. subtractInPlace(csg: CSG): void;
  68649. /**
  68650. * Intersect this CSG with another CSG
  68651. * @param csg The CSG to intersect against this CSG
  68652. * @returns A new CSG
  68653. */
  68654. intersect(csg: CSG): CSG;
  68655. /**
  68656. * Intersects this CSG with another CSG in place
  68657. * @param csg The CSG to intersect against this CSG
  68658. */
  68659. intersectInPlace(csg: CSG): void;
  68660. /**
  68661. * Return a new CSG solid with solid and empty space switched. This solid is
  68662. * not modified.
  68663. * @returns A new CSG solid with solid and empty space switched
  68664. */
  68665. inverse(): CSG;
  68666. /**
  68667. * Inverses the CSG in place
  68668. */
  68669. inverseInPlace(): void;
  68670. /**
  68671. * This is used to keep meshes transformations so they can be restored
  68672. * when we build back a Babylon Mesh
  68673. * NB : All CSG operations are performed in world coordinates
  68674. * @param csg The CSG to copy the transform attributes from
  68675. * @returns This CSG
  68676. */
  68677. copyTransformAttributes(csg: CSG): CSG;
  68678. /**
  68679. * Build Raw mesh from CSG
  68680. * Coordinates here are in world space
  68681. * @param name The name of the mesh geometry
  68682. * @param scene The Scene
  68683. * @param keepSubMeshes Specifies if the submeshes should be kept
  68684. * @returns A new Mesh
  68685. */
  68686. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68687. /**
  68688. * Build Mesh from CSG taking material and transforms into account
  68689. * @param name The name of the Mesh
  68690. * @param material The material of the Mesh
  68691. * @param scene The Scene
  68692. * @param keepSubMeshes Specifies if submeshes should be kept
  68693. * @returns The new Mesh
  68694. */
  68695. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68696. }
  68697. }
  68698. declare module "babylonjs/Meshes/trailMesh" {
  68699. import { Mesh } from "babylonjs/Meshes/mesh";
  68700. import { Scene } from "babylonjs/scene";
  68701. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68702. /**
  68703. * Class used to create a trail following a mesh
  68704. */
  68705. export class TrailMesh extends Mesh {
  68706. private _generator;
  68707. private _autoStart;
  68708. private _running;
  68709. private _diameter;
  68710. private _length;
  68711. private _sectionPolygonPointsCount;
  68712. private _sectionVectors;
  68713. private _sectionNormalVectors;
  68714. private _beforeRenderObserver;
  68715. /**
  68716. * @constructor
  68717. * @param name The value used by scene.getMeshByName() to do a lookup.
  68718. * @param generator The mesh or transform node to generate a trail.
  68719. * @param scene The scene to add this mesh to.
  68720. * @param diameter Diameter of trailing mesh. Default is 1.
  68721. * @param length Length of trailing mesh. Default is 60.
  68722. * @param autoStart Automatically start trailing mesh. Default true.
  68723. */
  68724. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68725. /**
  68726. * "TrailMesh"
  68727. * @returns "TrailMesh"
  68728. */
  68729. getClassName(): string;
  68730. private _createMesh;
  68731. /**
  68732. * Start trailing mesh.
  68733. */
  68734. start(): void;
  68735. /**
  68736. * Stop trailing mesh.
  68737. */
  68738. stop(): void;
  68739. /**
  68740. * Update trailing mesh geometry.
  68741. */
  68742. update(): void;
  68743. /**
  68744. * Returns a new TrailMesh object.
  68745. * @param name is a string, the name given to the new mesh
  68746. * @param newGenerator use new generator object for cloned trail mesh
  68747. * @returns a new mesh
  68748. */
  68749. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68750. /**
  68751. * Serializes this trail mesh
  68752. * @param serializationObject object to write serialization to
  68753. */
  68754. serialize(serializationObject: any): void;
  68755. /**
  68756. * Parses a serialized trail mesh
  68757. * @param parsedMesh the serialized mesh
  68758. * @param scene the scene to create the trail mesh in
  68759. * @returns the created trail mesh
  68760. */
  68761. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68762. }
  68763. }
  68764. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68765. import { Nullable } from "babylonjs/types";
  68766. import { Scene } from "babylonjs/scene";
  68767. import { Vector4 } from "babylonjs/Maths/math.vector";
  68768. import { Color4 } from "babylonjs/Maths/math.color";
  68769. import { Mesh } from "babylonjs/Meshes/mesh";
  68770. /**
  68771. * Class containing static functions to help procedurally build meshes
  68772. */
  68773. export class TiledBoxBuilder {
  68774. /**
  68775. * Creates a box mesh
  68776. * 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)
  68777. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68779. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68781. * @param name defines the name of the mesh
  68782. * @param options defines the options used to create the mesh
  68783. * @param scene defines the hosting scene
  68784. * @returns the box mesh
  68785. */
  68786. static CreateTiledBox(name: string, options: {
  68787. pattern?: number;
  68788. width?: number;
  68789. height?: number;
  68790. depth?: number;
  68791. tileSize?: number;
  68792. tileWidth?: number;
  68793. tileHeight?: number;
  68794. alignHorizontal?: number;
  68795. alignVertical?: number;
  68796. faceUV?: Vector4[];
  68797. faceColors?: Color4[];
  68798. sideOrientation?: number;
  68799. updatable?: boolean;
  68800. }, scene?: Nullable<Scene>): Mesh;
  68801. }
  68802. }
  68803. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68804. import { Vector4 } from "babylonjs/Maths/math.vector";
  68805. import { Mesh } from "babylonjs/Meshes/mesh";
  68806. /**
  68807. * Class containing static functions to help procedurally build meshes
  68808. */
  68809. export class TorusKnotBuilder {
  68810. /**
  68811. * Creates a torus knot mesh
  68812. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68813. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68814. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68815. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68819. * @param name defines the name of the mesh
  68820. * @param options defines the options used to create the mesh
  68821. * @param scene defines the hosting scene
  68822. * @returns the torus knot mesh
  68823. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68824. */
  68825. static CreateTorusKnot(name: string, options: {
  68826. radius?: number;
  68827. tube?: number;
  68828. radialSegments?: number;
  68829. tubularSegments?: number;
  68830. p?: number;
  68831. q?: number;
  68832. updatable?: boolean;
  68833. sideOrientation?: number;
  68834. frontUVs?: Vector4;
  68835. backUVs?: Vector4;
  68836. }, scene: any): Mesh;
  68837. }
  68838. }
  68839. declare module "babylonjs/Meshes/polygonMesh" {
  68840. import { Scene } from "babylonjs/scene";
  68841. import { Vector2 } from "babylonjs/Maths/math.vector";
  68842. import { Mesh } from "babylonjs/Meshes/mesh";
  68843. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68844. import { Path2 } from "babylonjs/Maths/math.path";
  68845. /**
  68846. * Polygon
  68847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68848. */
  68849. export class Polygon {
  68850. /**
  68851. * Creates a rectangle
  68852. * @param xmin bottom X coord
  68853. * @param ymin bottom Y coord
  68854. * @param xmax top X coord
  68855. * @param ymax top Y coord
  68856. * @returns points that make the resulting rectation
  68857. */
  68858. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68859. /**
  68860. * Creates a circle
  68861. * @param radius radius of circle
  68862. * @param cx scale in x
  68863. * @param cy scale in y
  68864. * @param numberOfSides number of sides that make up the circle
  68865. * @returns points that make the resulting circle
  68866. */
  68867. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68868. /**
  68869. * Creates a polygon from input string
  68870. * @param input Input polygon data
  68871. * @returns the parsed points
  68872. */
  68873. static Parse(input: string): Vector2[];
  68874. /**
  68875. * Starts building a polygon from x and y coordinates
  68876. * @param x x coordinate
  68877. * @param y y coordinate
  68878. * @returns the started path2
  68879. */
  68880. static StartingAt(x: number, y: number): Path2;
  68881. }
  68882. /**
  68883. * Builds a polygon
  68884. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68885. */
  68886. export class PolygonMeshBuilder {
  68887. private _points;
  68888. private _outlinepoints;
  68889. private _holes;
  68890. private _name;
  68891. private _scene;
  68892. private _epoints;
  68893. private _eholes;
  68894. private _addToepoint;
  68895. /**
  68896. * Babylon reference to the earcut plugin.
  68897. */
  68898. bjsEarcut: any;
  68899. /**
  68900. * Creates a PolygonMeshBuilder
  68901. * @param name name of the builder
  68902. * @param contours Path of the polygon
  68903. * @param scene scene to add to when creating the mesh
  68904. * @param earcutInjection can be used to inject your own earcut reference
  68905. */
  68906. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68907. /**
  68908. * Adds a whole within the polygon
  68909. * @param hole Array of points defining the hole
  68910. * @returns this
  68911. */
  68912. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68913. /**
  68914. * Creates the polygon
  68915. * @param updatable If the mesh should be updatable
  68916. * @param depth The depth of the mesh created
  68917. * @returns the created mesh
  68918. */
  68919. build(updatable?: boolean, depth?: number): Mesh;
  68920. /**
  68921. * Creates the polygon
  68922. * @param depth The depth of the mesh created
  68923. * @returns the created VertexData
  68924. */
  68925. buildVertexData(depth?: number): VertexData;
  68926. /**
  68927. * Adds a side to the polygon
  68928. * @param positions points that make the polygon
  68929. * @param normals normals of the polygon
  68930. * @param uvs uvs of the polygon
  68931. * @param indices indices of the polygon
  68932. * @param bounds bounds of the polygon
  68933. * @param points points of the polygon
  68934. * @param depth depth of the polygon
  68935. * @param flip flip of the polygon
  68936. */
  68937. private addSide;
  68938. }
  68939. }
  68940. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68941. import { Scene } from "babylonjs/scene";
  68942. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68943. import { Color4 } from "babylonjs/Maths/math.color";
  68944. import { Mesh } from "babylonjs/Meshes/mesh";
  68945. import { Nullable } from "babylonjs/types";
  68946. /**
  68947. * Class containing static functions to help procedurally build meshes
  68948. */
  68949. export class PolygonBuilder {
  68950. /**
  68951. * Creates a polygon mesh
  68952. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68953. * * 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
  68954. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68957. * * Remember you can only change the shape positions, not their number when updating a polygon
  68958. * @param name defines the name of the mesh
  68959. * @param options defines the options used to create the mesh
  68960. * @param scene defines the hosting scene
  68961. * @param earcutInjection can be used to inject your own earcut reference
  68962. * @returns the polygon mesh
  68963. */
  68964. static CreatePolygon(name: string, options: {
  68965. shape: Vector3[];
  68966. holes?: Vector3[][];
  68967. depth?: number;
  68968. faceUV?: Vector4[];
  68969. faceColors?: Color4[];
  68970. updatable?: boolean;
  68971. sideOrientation?: number;
  68972. frontUVs?: Vector4;
  68973. backUVs?: Vector4;
  68974. wrap?: boolean;
  68975. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68976. /**
  68977. * Creates an extruded polygon mesh, with depth in the Y direction.
  68978. * * 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)
  68979. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68980. * @param name defines the name of the mesh
  68981. * @param options defines the options used to create the mesh
  68982. * @param scene defines the hosting scene
  68983. * @param earcutInjection can be used to inject your own earcut reference
  68984. * @returns the polygon mesh
  68985. */
  68986. static ExtrudePolygon(name: string, options: {
  68987. shape: Vector3[];
  68988. holes?: Vector3[][];
  68989. depth?: number;
  68990. faceUV?: Vector4[];
  68991. faceColors?: Color4[];
  68992. updatable?: boolean;
  68993. sideOrientation?: number;
  68994. frontUVs?: Vector4;
  68995. backUVs?: Vector4;
  68996. wrap?: boolean;
  68997. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68998. }
  68999. }
  69000. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69001. import { Scene } from "babylonjs/scene";
  69002. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69003. import { Mesh } from "babylonjs/Meshes/mesh";
  69004. import { Nullable } from "babylonjs/types";
  69005. /**
  69006. * Class containing static functions to help procedurally build meshes
  69007. */
  69008. export class LatheBuilder {
  69009. /**
  69010. * Creates lathe mesh.
  69011. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69012. * * 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
  69013. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69014. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69015. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69016. * * 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
  69017. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69018. * * 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
  69019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69021. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69023. * @param name defines the name of the mesh
  69024. * @param options defines the options used to create the mesh
  69025. * @param scene defines the hosting scene
  69026. * @returns the lathe mesh
  69027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69028. */
  69029. static CreateLathe(name: string, options: {
  69030. shape: Vector3[];
  69031. radius?: number;
  69032. tessellation?: number;
  69033. clip?: number;
  69034. arc?: number;
  69035. closed?: boolean;
  69036. updatable?: boolean;
  69037. sideOrientation?: number;
  69038. frontUVs?: Vector4;
  69039. backUVs?: Vector4;
  69040. cap?: number;
  69041. invertUV?: boolean;
  69042. }, scene?: Nullable<Scene>): Mesh;
  69043. }
  69044. }
  69045. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69046. import { Nullable } from "babylonjs/types";
  69047. import { Scene } from "babylonjs/scene";
  69048. import { Vector4 } from "babylonjs/Maths/math.vector";
  69049. import { Mesh } from "babylonjs/Meshes/mesh";
  69050. /**
  69051. * Class containing static functions to help procedurally build meshes
  69052. */
  69053. export class TiledPlaneBuilder {
  69054. /**
  69055. * Creates a tiled plane mesh
  69056. * * The parameter `pattern` will, depending on value, do nothing or
  69057. * * * flip (reflect about central vertical) alternate tiles across and up
  69058. * * * flip every tile on alternate rows
  69059. * * * rotate (180 degs) alternate tiles across and up
  69060. * * * rotate every tile on alternate rows
  69061. * * * flip and rotate alternate tiles across and up
  69062. * * * flip and rotate every tile on alternate rows
  69063. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69064. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69067. * * 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)
  69068. * * 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)
  69069. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69070. * @param name defines the name of the mesh
  69071. * @param options defines the options used to create the mesh
  69072. * @param scene defines the hosting scene
  69073. * @returns the box mesh
  69074. */
  69075. static CreateTiledPlane(name: string, options: {
  69076. pattern?: number;
  69077. tileSize?: number;
  69078. tileWidth?: number;
  69079. tileHeight?: number;
  69080. size?: number;
  69081. width?: number;
  69082. height?: number;
  69083. alignHorizontal?: number;
  69084. alignVertical?: number;
  69085. sideOrientation?: number;
  69086. frontUVs?: Vector4;
  69087. backUVs?: Vector4;
  69088. updatable?: boolean;
  69089. }, scene?: Nullable<Scene>): Mesh;
  69090. }
  69091. }
  69092. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69093. import { Nullable } from "babylonjs/types";
  69094. import { Scene } from "babylonjs/scene";
  69095. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69096. import { Mesh } from "babylonjs/Meshes/mesh";
  69097. /**
  69098. * Class containing static functions to help procedurally build meshes
  69099. */
  69100. export class TubeBuilder {
  69101. /**
  69102. * Creates a tube mesh.
  69103. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69104. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69105. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69106. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69107. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69108. * * 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)
  69109. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69110. * * 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
  69111. * * 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
  69112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69114. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69116. * @param name defines the name of the mesh
  69117. * @param options defines the options used to create the mesh
  69118. * @param scene defines the hosting scene
  69119. * @returns the tube mesh
  69120. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69121. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69122. */
  69123. static CreateTube(name: string, options: {
  69124. path: Vector3[];
  69125. radius?: number;
  69126. tessellation?: number;
  69127. radiusFunction?: {
  69128. (i: number, distance: number): number;
  69129. };
  69130. cap?: number;
  69131. arc?: number;
  69132. updatable?: boolean;
  69133. sideOrientation?: number;
  69134. frontUVs?: Vector4;
  69135. backUVs?: Vector4;
  69136. instance?: Mesh;
  69137. invertUV?: boolean;
  69138. }, scene?: Nullable<Scene>): Mesh;
  69139. }
  69140. }
  69141. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69142. import { Scene } from "babylonjs/scene";
  69143. import { Vector4 } from "babylonjs/Maths/math.vector";
  69144. import { Mesh } from "babylonjs/Meshes/mesh";
  69145. import { Nullable } from "babylonjs/types";
  69146. /**
  69147. * Class containing static functions to help procedurally build meshes
  69148. */
  69149. export class IcoSphereBuilder {
  69150. /**
  69151. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69152. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69153. * * 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`)
  69154. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69155. * * 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
  69156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69159. * @param name defines the name of the mesh
  69160. * @param options defines the options used to create the mesh
  69161. * @param scene defines the hosting scene
  69162. * @returns the icosahedron mesh
  69163. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69164. */
  69165. static CreateIcoSphere(name: string, options: {
  69166. radius?: number;
  69167. radiusX?: number;
  69168. radiusY?: number;
  69169. radiusZ?: number;
  69170. flat?: boolean;
  69171. subdivisions?: number;
  69172. sideOrientation?: number;
  69173. frontUVs?: Vector4;
  69174. backUVs?: Vector4;
  69175. updatable?: boolean;
  69176. }, scene?: Nullable<Scene>): Mesh;
  69177. }
  69178. }
  69179. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69180. import { Vector3 } from "babylonjs/Maths/math.vector";
  69181. import { Mesh } from "babylonjs/Meshes/mesh";
  69182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69183. /**
  69184. * Class containing static functions to help procedurally build meshes
  69185. */
  69186. export class DecalBuilder {
  69187. /**
  69188. * Creates a decal mesh.
  69189. * 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
  69190. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69191. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69192. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69193. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69194. * @param name defines the name of the mesh
  69195. * @param sourceMesh defines the mesh where the decal must be applied
  69196. * @param options defines the options used to create the mesh
  69197. * @param scene defines the hosting scene
  69198. * @returns the decal mesh
  69199. * @see https://doc.babylonjs.com/how_to/decals
  69200. */
  69201. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69202. position?: Vector3;
  69203. normal?: Vector3;
  69204. size?: Vector3;
  69205. angle?: number;
  69206. }): Mesh;
  69207. }
  69208. }
  69209. declare module "babylonjs/Meshes/meshBuilder" {
  69210. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69211. import { Nullable } from "babylonjs/types";
  69212. import { Scene } from "babylonjs/scene";
  69213. import { Mesh } from "babylonjs/Meshes/mesh";
  69214. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69215. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69217. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69218. import { Plane } from "babylonjs/Maths/math.plane";
  69219. /**
  69220. * Class containing static functions to help procedurally build meshes
  69221. */
  69222. export class MeshBuilder {
  69223. /**
  69224. * Creates a box mesh
  69225. * * The parameter `size` sets the size (float) of each box side (default 1)
  69226. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69227. * * 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)
  69228. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69232. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69233. * @param name defines the name of the mesh
  69234. * @param options defines the options used to create the mesh
  69235. * @param scene defines the hosting scene
  69236. * @returns the box mesh
  69237. */
  69238. static CreateBox(name: string, options: {
  69239. size?: number;
  69240. width?: number;
  69241. height?: number;
  69242. depth?: number;
  69243. faceUV?: Vector4[];
  69244. faceColors?: Color4[];
  69245. sideOrientation?: number;
  69246. frontUVs?: Vector4;
  69247. backUVs?: Vector4;
  69248. wrap?: boolean;
  69249. topBaseAt?: number;
  69250. bottomBaseAt?: number;
  69251. updatable?: boolean;
  69252. }, scene?: Nullable<Scene>): Mesh;
  69253. /**
  69254. * Creates a tiled box mesh
  69255. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69257. * @param name defines the name of the mesh
  69258. * @param options defines the options used to create the mesh
  69259. * @param scene defines the hosting scene
  69260. * @returns the tiled box mesh
  69261. */
  69262. static CreateTiledBox(name: string, options: {
  69263. pattern?: number;
  69264. size?: number;
  69265. width?: number;
  69266. height?: number;
  69267. depth: number;
  69268. tileSize?: number;
  69269. tileWidth?: number;
  69270. tileHeight?: number;
  69271. faceUV?: Vector4[];
  69272. faceColors?: Color4[];
  69273. alignHorizontal?: number;
  69274. alignVertical?: number;
  69275. sideOrientation?: number;
  69276. updatable?: boolean;
  69277. }, scene?: Nullable<Scene>): Mesh;
  69278. /**
  69279. * Creates a sphere mesh
  69280. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69281. * * 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`)
  69282. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69283. * * 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
  69284. * * 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)
  69285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69288. * @param name defines the name of the mesh
  69289. * @param options defines the options used to create the mesh
  69290. * @param scene defines the hosting scene
  69291. * @returns the sphere mesh
  69292. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69293. */
  69294. static CreateSphere(name: string, options: {
  69295. segments?: number;
  69296. diameter?: number;
  69297. diameterX?: number;
  69298. diameterY?: number;
  69299. diameterZ?: number;
  69300. arc?: number;
  69301. slice?: number;
  69302. sideOrientation?: number;
  69303. frontUVs?: Vector4;
  69304. backUVs?: Vector4;
  69305. updatable?: boolean;
  69306. }, scene?: Nullable<Scene>): Mesh;
  69307. /**
  69308. * Creates a plane polygonal mesh. By default, this is a disc
  69309. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69310. * * 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
  69311. * * 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
  69312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69315. * @param name defines the name of the mesh
  69316. * @param options defines the options used to create the mesh
  69317. * @param scene defines the hosting scene
  69318. * @returns the plane polygonal mesh
  69319. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69320. */
  69321. static CreateDisc(name: string, options: {
  69322. radius?: number;
  69323. tessellation?: number;
  69324. arc?: number;
  69325. updatable?: boolean;
  69326. sideOrientation?: number;
  69327. frontUVs?: Vector4;
  69328. backUVs?: Vector4;
  69329. }, scene?: Nullable<Scene>): Mesh;
  69330. /**
  69331. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69332. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69333. * * 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`)
  69334. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69335. * * 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
  69336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69339. * @param name defines the name of the mesh
  69340. * @param options defines the options used to create the mesh
  69341. * @param scene defines the hosting scene
  69342. * @returns the icosahedron mesh
  69343. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69344. */
  69345. static CreateIcoSphere(name: string, options: {
  69346. radius?: number;
  69347. radiusX?: number;
  69348. radiusY?: number;
  69349. radiusZ?: number;
  69350. flat?: boolean;
  69351. subdivisions?: number;
  69352. sideOrientation?: number;
  69353. frontUVs?: Vector4;
  69354. backUVs?: Vector4;
  69355. updatable?: boolean;
  69356. }, scene?: Nullable<Scene>): Mesh;
  69357. /**
  69358. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69359. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69360. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69361. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69362. * * 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
  69363. * * 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
  69364. * * 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
  69365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69368. * * 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
  69369. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69370. * * 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
  69371. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69373. * @param name defines the name of the mesh
  69374. * @param options defines the options used to create the mesh
  69375. * @param scene defines the hosting scene
  69376. * @returns the ribbon mesh
  69377. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69378. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69379. */
  69380. static CreateRibbon(name: string, options: {
  69381. pathArray: Vector3[][];
  69382. closeArray?: boolean;
  69383. closePath?: boolean;
  69384. offset?: number;
  69385. updatable?: boolean;
  69386. sideOrientation?: number;
  69387. frontUVs?: Vector4;
  69388. backUVs?: Vector4;
  69389. instance?: Mesh;
  69390. invertUV?: boolean;
  69391. uvs?: Vector2[];
  69392. colors?: Color4[];
  69393. }, scene?: Nullable<Scene>): Mesh;
  69394. /**
  69395. * Creates a cylinder or a cone mesh
  69396. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69397. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69398. * * 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.
  69399. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69400. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69401. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69402. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69403. * * 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).
  69404. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69405. * * 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).
  69406. * * 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
  69407. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69408. * * 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
  69409. * * 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.
  69410. * * If `enclose` is false, a ring surface is one element.
  69411. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69412. * * 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
  69413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69416. * @param name defines the name of the mesh
  69417. * @param options defines the options used to create the mesh
  69418. * @param scene defines the hosting scene
  69419. * @returns the cylinder mesh
  69420. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69421. */
  69422. static CreateCylinder(name: string, options: {
  69423. height?: number;
  69424. diameterTop?: number;
  69425. diameterBottom?: number;
  69426. diameter?: number;
  69427. tessellation?: number;
  69428. subdivisions?: number;
  69429. arc?: number;
  69430. faceColors?: Color4[];
  69431. faceUV?: Vector4[];
  69432. updatable?: boolean;
  69433. hasRings?: boolean;
  69434. enclose?: boolean;
  69435. cap?: number;
  69436. sideOrientation?: number;
  69437. frontUVs?: Vector4;
  69438. backUVs?: Vector4;
  69439. }, scene?: Nullable<Scene>): Mesh;
  69440. /**
  69441. * Creates a torus mesh
  69442. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69443. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69444. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69448. * @param name defines the name of the mesh
  69449. * @param options defines the options used to create the mesh
  69450. * @param scene defines the hosting scene
  69451. * @returns the torus mesh
  69452. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69453. */
  69454. static CreateTorus(name: string, options: {
  69455. diameter?: number;
  69456. thickness?: number;
  69457. tessellation?: number;
  69458. updatable?: boolean;
  69459. sideOrientation?: number;
  69460. frontUVs?: Vector4;
  69461. backUVs?: Vector4;
  69462. }, scene?: Nullable<Scene>): Mesh;
  69463. /**
  69464. * Creates a torus knot mesh
  69465. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69466. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69467. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69468. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69472. * @param name defines the name of the mesh
  69473. * @param options defines the options used to create the mesh
  69474. * @param scene defines the hosting scene
  69475. * @returns the torus knot mesh
  69476. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69477. */
  69478. static CreateTorusKnot(name: string, options: {
  69479. radius?: number;
  69480. tube?: number;
  69481. radialSegments?: number;
  69482. tubularSegments?: number;
  69483. p?: number;
  69484. q?: number;
  69485. updatable?: boolean;
  69486. sideOrientation?: number;
  69487. frontUVs?: Vector4;
  69488. backUVs?: Vector4;
  69489. }, scene?: Nullable<Scene>): Mesh;
  69490. /**
  69491. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69492. * * 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
  69493. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69494. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69495. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69496. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69497. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69498. * * 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
  69499. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69502. * @param name defines the name of the new line system
  69503. * @param options defines the options used to create the line system
  69504. * @param scene defines the hosting scene
  69505. * @returns a new line system mesh
  69506. */
  69507. static CreateLineSystem(name: string, options: {
  69508. lines: Vector3[][];
  69509. updatable?: boolean;
  69510. instance?: Nullable<LinesMesh>;
  69511. colors?: Nullable<Color4[][]>;
  69512. useVertexAlpha?: boolean;
  69513. }, scene: Nullable<Scene>): LinesMesh;
  69514. /**
  69515. * Creates a line mesh
  69516. * 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
  69517. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69518. * * The parameter `points` is an array successive Vector3
  69519. * * 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
  69520. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69521. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69522. * * When updating an instance, remember that only point positions can change, not the number of points
  69523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69525. * @param name defines the name of the new line system
  69526. * @param options defines the options used to create the line system
  69527. * @param scene defines the hosting scene
  69528. * @returns a new line mesh
  69529. */
  69530. static CreateLines(name: string, options: {
  69531. points: Vector3[];
  69532. updatable?: boolean;
  69533. instance?: Nullable<LinesMesh>;
  69534. colors?: Color4[];
  69535. useVertexAlpha?: boolean;
  69536. }, scene?: Nullable<Scene>): LinesMesh;
  69537. /**
  69538. * Creates a dashed line mesh
  69539. * * 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
  69540. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69541. * * The parameter `points` is an array successive Vector3
  69542. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69543. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69544. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69545. * * 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
  69546. * * When updating an instance, remember that only point positions can change, not the number of points
  69547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69548. * @param name defines the name of the mesh
  69549. * @param options defines the options used to create the mesh
  69550. * @param scene defines the hosting scene
  69551. * @returns the dashed line mesh
  69552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69553. */
  69554. static CreateDashedLines(name: string, options: {
  69555. points: Vector3[];
  69556. dashSize?: number;
  69557. gapSize?: number;
  69558. dashNb?: number;
  69559. updatable?: boolean;
  69560. instance?: LinesMesh;
  69561. }, scene?: Nullable<Scene>): LinesMesh;
  69562. /**
  69563. * 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.
  69564. * * 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.
  69565. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69566. * * 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.
  69567. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69568. * * 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
  69569. * * 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
  69570. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69575. * @param name defines the name of the mesh
  69576. * @param options defines the options used to create the mesh
  69577. * @param scene defines the hosting scene
  69578. * @returns the extruded shape mesh
  69579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69581. */
  69582. static ExtrudeShape(name: string, options: {
  69583. shape: Vector3[];
  69584. path: Vector3[];
  69585. scale?: number;
  69586. rotation?: number;
  69587. cap?: number;
  69588. updatable?: boolean;
  69589. sideOrientation?: number;
  69590. frontUVs?: Vector4;
  69591. backUVs?: Vector4;
  69592. instance?: Mesh;
  69593. invertUV?: boolean;
  69594. }, scene?: Nullable<Scene>): Mesh;
  69595. /**
  69596. * Creates an custom extruded shape mesh.
  69597. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69598. * * 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.
  69599. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69600. * * 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
  69601. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69602. * * 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
  69603. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69604. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69605. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69606. * * 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
  69607. * * 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
  69608. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69611. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69613. * @param name defines the name of the mesh
  69614. * @param options defines the options used to create the mesh
  69615. * @param scene defines the hosting scene
  69616. * @returns the custom extruded shape mesh
  69617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69618. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69620. */
  69621. static ExtrudeShapeCustom(name: string, options: {
  69622. shape: Vector3[];
  69623. path: Vector3[];
  69624. scaleFunction?: any;
  69625. rotationFunction?: any;
  69626. ribbonCloseArray?: boolean;
  69627. ribbonClosePath?: boolean;
  69628. cap?: number;
  69629. updatable?: boolean;
  69630. sideOrientation?: number;
  69631. frontUVs?: Vector4;
  69632. backUVs?: Vector4;
  69633. instance?: Mesh;
  69634. invertUV?: boolean;
  69635. }, scene?: Nullable<Scene>): Mesh;
  69636. /**
  69637. * Creates lathe mesh.
  69638. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69639. * * 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
  69640. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69641. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69642. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69643. * * 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
  69644. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69645. * * 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
  69646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69648. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69650. * @param name defines the name of the mesh
  69651. * @param options defines the options used to create the mesh
  69652. * @param scene defines the hosting scene
  69653. * @returns the lathe mesh
  69654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69655. */
  69656. static CreateLathe(name: string, options: {
  69657. shape: Vector3[];
  69658. radius?: number;
  69659. tessellation?: number;
  69660. clip?: number;
  69661. arc?: number;
  69662. closed?: boolean;
  69663. updatable?: boolean;
  69664. sideOrientation?: number;
  69665. frontUVs?: Vector4;
  69666. backUVs?: Vector4;
  69667. cap?: number;
  69668. invertUV?: boolean;
  69669. }, scene?: Nullable<Scene>): Mesh;
  69670. /**
  69671. * Creates a tiled plane mesh
  69672. * * You can set a limited pattern arrangement with the tiles
  69673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69676. * @param name defines the name of the mesh
  69677. * @param options defines the options used to create the mesh
  69678. * @param scene defines the hosting scene
  69679. * @returns the plane mesh
  69680. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69681. */
  69682. static CreateTiledPlane(name: string, options: {
  69683. pattern?: number;
  69684. tileSize?: number;
  69685. tileWidth?: number;
  69686. tileHeight?: number;
  69687. size?: number;
  69688. width?: number;
  69689. height?: number;
  69690. alignHorizontal?: number;
  69691. alignVertical?: number;
  69692. sideOrientation?: number;
  69693. frontUVs?: Vector4;
  69694. backUVs?: Vector4;
  69695. updatable?: boolean;
  69696. }, scene?: Nullable<Scene>): Mesh;
  69697. /**
  69698. * Creates a plane mesh
  69699. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69700. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69701. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69705. * @param name defines the name of the mesh
  69706. * @param options defines the options used to create the mesh
  69707. * @param scene defines the hosting scene
  69708. * @returns the plane mesh
  69709. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69710. */
  69711. static CreatePlane(name: string, options: {
  69712. size?: number;
  69713. width?: number;
  69714. height?: number;
  69715. sideOrientation?: number;
  69716. frontUVs?: Vector4;
  69717. backUVs?: Vector4;
  69718. updatable?: boolean;
  69719. sourcePlane?: Plane;
  69720. }, scene?: Nullable<Scene>): Mesh;
  69721. /**
  69722. * Creates a ground mesh
  69723. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69724. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69726. * @param name defines the name of the mesh
  69727. * @param options defines the options used to create the mesh
  69728. * @param scene defines the hosting scene
  69729. * @returns the ground mesh
  69730. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69731. */
  69732. static CreateGround(name: string, options: {
  69733. width?: number;
  69734. height?: number;
  69735. subdivisions?: number;
  69736. subdivisionsX?: number;
  69737. subdivisionsY?: number;
  69738. updatable?: boolean;
  69739. }, scene?: Nullable<Scene>): Mesh;
  69740. /**
  69741. * Creates a tiled ground mesh
  69742. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69743. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69744. * * 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
  69745. * * 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
  69746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69747. * @param name defines the name of the mesh
  69748. * @param options defines the options used to create the mesh
  69749. * @param scene defines the hosting scene
  69750. * @returns the tiled ground mesh
  69751. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69752. */
  69753. static CreateTiledGround(name: string, options: {
  69754. xmin: number;
  69755. zmin: number;
  69756. xmax: number;
  69757. zmax: number;
  69758. subdivisions?: {
  69759. w: number;
  69760. h: number;
  69761. };
  69762. precision?: {
  69763. w: number;
  69764. h: number;
  69765. };
  69766. updatable?: boolean;
  69767. }, scene?: Nullable<Scene>): Mesh;
  69768. /**
  69769. * Creates a ground mesh from a height map
  69770. * * The parameter `url` sets the URL of the height map image resource.
  69771. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69772. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69773. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69774. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69775. * * 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.
  69776. * * 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).
  69777. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69779. * @param name defines the name of the mesh
  69780. * @param url defines the url to the height map
  69781. * @param options defines the options used to create the mesh
  69782. * @param scene defines the hosting scene
  69783. * @returns the ground mesh
  69784. * @see https://doc.babylonjs.com/babylon101/height_map
  69785. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69786. */
  69787. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69788. width?: number;
  69789. height?: number;
  69790. subdivisions?: number;
  69791. minHeight?: number;
  69792. maxHeight?: number;
  69793. colorFilter?: Color3;
  69794. alphaFilter?: number;
  69795. updatable?: boolean;
  69796. onReady?: (mesh: GroundMesh) => void;
  69797. }, scene?: Nullable<Scene>): GroundMesh;
  69798. /**
  69799. * Creates a polygon mesh
  69800. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69801. * * 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
  69802. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69805. * * Remember you can only change the shape positions, not their number when updating a polygon
  69806. * @param name defines the name of the mesh
  69807. * @param options defines the options used to create the mesh
  69808. * @param scene defines the hosting scene
  69809. * @param earcutInjection can be used to inject your own earcut reference
  69810. * @returns the polygon mesh
  69811. */
  69812. static CreatePolygon(name: string, options: {
  69813. shape: Vector3[];
  69814. holes?: Vector3[][];
  69815. depth?: number;
  69816. faceUV?: Vector4[];
  69817. faceColors?: Color4[];
  69818. updatable?: boolean;
  69819. sideOrientation?: number;
  69820. frontUVs?: Vector4;
  69821. backUVs?: Vector4;
  69822. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69823. /**
  69824. * Creates an extruded polygon mesh, with depth in the Y direction.
  69825. * * 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)
  69826. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69827. * @param name defines the name of the mesh
  69828. * @param options defines the options used to create the mesh
  69829. * @param scene defines the hosting scene
  69830. * @param earcutInjection can be used to inject your own earcut reference
  69831. * @returns the polygon mesh
  69832. */
  69833. static ExtrudePolygon(name: string, options: {
  69834. shape: Vector3[];
  69835. holes?: Vector3[][];
  69836. depth?: number;
  69837. faceUV?: Vector4[];
  69838. faceColors?: Color4[];
  69839. updatable?: boolean;
  69840. sideOrientation?: number;
  69841. frontUVs?: Vector4;
  69842. backUVs?: Vector4;
  69843. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69844. /**
  69845. * Creates a tube mesh.
  69846. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69847. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69848. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69849. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69850. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69851. * * 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)
  69852. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69853. * * 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
  69854. * * 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
  69855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69859. * @param name defines the name of the mesh
  69860. * @param options defines the options used to create the mesh
  69861. * @param scene defines the hosting scene
  69862. * @returns the tube mesh
  69863. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69864. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69865. */
  69866. static CreateTube(name: string, options: {
  69867. path: Vector3[];
  69868. radius?: number;
  69869. tessellation?: number;
  69870. radiusFunction?: {
  69871. (i: number, distance: number): number;
  69872. };
  69873. cap?: number;
  69874. arc?: number;
  69875. updatable?: boolean;
  69876. sideOrientation?: number;
  69877. frontUVs?: Vector4;
  69878. backUVs?: Vector4;
  69879. instance?: Mesh;
  69880. invertUV?: boolean;
  69881. }, scene?: Nullable<Scene>): Mesh;
  69882. /**
  69883. * Creates a polyhedron mesh
  69884. * * 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
  69885. * * The parameter `size` (positive float, default 1) sets the polygon size
  69886. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69887. * * 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`
  69888. * * 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
  69889. * * 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)`)
  69890. * * 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
  69891. * * 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
  69892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69895. * @param name defines the name of the mesh
  69896. * @param options defines the options used to create the mesh
  69897. * @param scene defines the hosting scene
  69898. * @returns the polyhedron mesh
  69899. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69900. */
  69901. static CreatePolyhedron(name: string, options: {
  69902. type?: number;
  69903. size?: number;
  69904. sizeX?: number;
  69905. sizeY?: number;
  69906. sizeZ?: number;
  69907. custom?: any;
  69908. faceUV?: Vector4[];
  69909. faceColors?: Color4[];
  69910. flat?: boolean;
  69911. updatable?: boolean;
  69912. sideOrientation?: number;
  69913. frontUVs?: Vector4;
  69914. backUVs?: Vector4;
  69915. }, scene?: Nullable<Scene>): Mesh;
  69916. /**
  69917. * Creates a decal mesh.
  69918. * 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
  69919. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69920. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69921. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69922. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69923. * @param name defines the name of the mesh
  69924. * @param sourceMesh defines the mesh where the decal must be applied
  69925. * @param options defines the options used to create the mesh
  69926. * @param scene defines the hosting scene
  69927. * @returns the decal mesh
  69928. * @see https://doc.babylonjs.com/how_to/decals
  69929. */
  69930. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69931. position?: Vector3;
  69932. normal?: Vector3;
  69933. size?: Vector3;
  69934. angle?: number;
  69935. }): Mesh;
  69936. }
  69937. }
  69938. declare module "babylonjs/Meshes/meshSimplification" {
  69939. import { Mesh } from "babylonjs/Meshes/mesh";
  69940. /**
  69941. * A simplifier interface for future simplification implementations
  69942. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69943. */
  69944. export interface ISimplifier {
  69945. /**
  69946. * Simplification of a given mesh according to the given settings.
  69947. * Since this requires computation, it is assumed that the function runs async.
  69948. * @param settings The settings of the simplification, including quality and distance
  69949. * @param successCallback A callback that will be called after the mesh was simplified.
  69950. * @param errorCallback in case of an error, this callback will be called. optional.
  69951. */
  69952. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69953. }
  69954. /**
  69955. * Expected simplification settings.
  69956. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69957. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69958. */
  69959. export interface ISimplificationSettings {
  69960. /**
  69961. * Gets or sets the expected quality
  69962. */
  69963. quality: number;
  69964. /**
  69965. * Gets or sets the distance when this optimized version should be used
  69966. */
  69967. distance: number;
  69968. /**
  69969. * Gets an already optimized mesh
  69970. */
  69971. optimizeMesh?: boolean;
  69972. }
  69973. /**
  69974. * Class used to specify simplification options
  69975. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69976. */
  69977. export class SimplificationSettings implements ISimplificationSettings {
  69978. /** expected quality */
  69979. quality: number;
  69980. /** distance when this optimized version should be used */
  69981. distance: number;
  69982. /** already optimized mesh */
  69983. optimizeMesh?: boolean | undefined;
  69984. /**
  69985. * Creates a SimplificationSettings
  69986. * @param quality expected quality
  69987. * @param distance distance when this optimized version should be used
  69988. * @param optimizeMesh already optimized mesh
  69989. */
  69990. constructor(
  69991. /** expected quality */
  69992. quality: number,
  69993. /** distance when this optimized version should be used */
  69994. distance: number,
  69995. /** already optimized mesh */
  69996. optimizeMesh?: boolean | undefined);
  69997. }
  69998. /**
  69999. * Interface used to define a simplification task
  70000. */
  70001. export interface ISimplificationTask {
  70002. /**
  70003. * Array of settings
  70004. */
  70005. settings: Array<ISimplificationSettings>;
  70006. /**
  70007. * Simplification type
  70008. */
  70009. simplificationType: SimplificationType;
  70010. /**
  70011. * Mesh to simplify
  70012. */
  70013. mesh: Mesh;
  70014. /**
  70015. * Callback called on success
  70016. */
  70017. successCallback?: () => void;
  70018. /**
  70019. * Defines if parallel processing can be used
  70020. */
  70021. parallelProcessing: boolean;
  70022. }
  70023. /**
  70024. * Queue used to order the simplification tasks
  70025. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70026. */
  70027. export class SimplificationQueue {
  70028. private _simplificationArray;
  70029. /**
  70030. * Gets a boolean indicating that the process is still running
  70031. */
  70032. running: boolean;
  70033. /**
  70034. * Creates a new queue
  70035. */
  70036. constructor();
  70037. /**
  70038. * Adds a new simplification task
  70039. * @param task defines a task to add
  70040. */
  70041. addTask(task: ISimplificationTask): void;
  70042. /**
  70043. * Execute next task
  70044. */
  70045. executeNext(): void;
  70046. /**
  70047. * Execute a simplification task
  70048. * @param task defines the task to run
  70049. */
  70050. runSimplification(task: ISimplificationTask): void;
  70051. private getSimplifier;
  70052. }
  70053. /**
  70054. * The implemented types of simplification
  70055. * At the moment only Quadratic Error Decimation is implemented
  70056. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70057. */
  70058. export enum SimplificationType {
  70059. /** Quadratic error decimation */
  70060. QUADRATIC = 0
  70061. }
  70062. /**
  70063. * An implementation of the Quadratic Error simplification algorithm.
  70064. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70065. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70066. * @author RaananW
  70067. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70068. */
  70069. export class QuadraticErrorSimplification implements ISimplifier {
  70070. private _mesh;
  70071. private triangles;
  70072. private vertices;
  70073. private references;
  70074. private _reconstructedMesh;
  70075. /** Gets or sets the number pf sync interations */
  70076. syncIterations: number;
  70077. /** Gets or sets the aggressiveness of the simplifier */
  70078. aggressiveness: number;
  70079. /** Gets or sets the number of allowed iterations for decimation */
  70080. decimationIterations: number;
  70081. /** Gets or sets the espilon to use for bounding box computation */
  70082. boundingBoxEpsilon: number;
  70083. /**
  70084. * Creates a new QuadraticErrorSimplification
  70085. * @param _mesh defines the target mesh
  70086. */
  70087. constructor(_mesh: Mesh);
  70088. /**
  70089. * Simplification of a given mesh according to the given settings.
  70090. * Since this requires computation, it is assumed that the function runs async.
  70091. * @param settings The settings of the simplification, including quality and distance
  70092. * @param successCallback A callback that will be called after the mesh was simplified.
  70093. */
  70094. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70095. private runDecimation;
  70096. private initWithMesh;
  70097. private init;
  70098. private reconstructMesh;
  70099. private initDecimatedMesh;
  70100. private isFlipped;
  70101. private updateTriangles;
  70102. private identifyBorder;
  70103. private updateMesh;
  70104. private vertexError;
  70105. private calculateError;
  70106. }
  70107. }
  70108. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70109. import { Scene } from "babylonjs/scene";
  70110. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70111. import { ISceneComponent } from "babylonjs/sceneComponent";
  70112. module "babylonjs/scene" {
  70113. interface Scene {
  70114. /** @hidden (Backing field) */
  70115. _simplificationQueue: SimplificationQueue;
  70116. /**
  70117. * Gets or sets the simplification queue attached to the scene
  70118. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70119. */
  70120. simplificationQueue: SimplificationQueue;
  70121. }
  70122. }
  70123. module "babylonjs/Meshes/mesh" {
  70124. interface Mesh {
  70125. /**
  70126. * Simplify the mesh according to the given array of settings.
  70127. * Function will return immediately and will simplify async
  70128. * @param settings a collection of simplification settings
  70129. * @param parallelProcessing should all levels calculate parallel or one after the other
  70130. * @param simplificationType the type of simplification to run
  70131. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70132. * @returns the current mesh
  70133. */
  70134. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70135. }
  70136. }
  70137. /**
  70138. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70139. * created in a scene
  70140. */
  70141. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70142. /**
  70143. * The component name helpfull to identify the component in the list of scene components.
  70144. */
  70145. readonly name: string;
  70146. /**
  70147. * The scene the component belongs to.
  70148. */
  70149. scene: Scene;
  70150. /**
  70151. * Creates a new instance of the component for the given scene
  70152. * @param scene Defines the scene to register the component in
  70153. */
  70154. constructor(scene: Scene);
  70155. /**
  70156. * Registers the component in a given scene
  70157. */
  70158. register(): void;
  70159. /**
  70160. * Rebuilds the elements related to this component in case of
  70161. * context lost for instance.
  70162. */
  70163. rebuild(): void;
  70164. /**
  70165. * Disposes the component and the associated ressources
  70166. */
  70167. dispose(): void;
  70168. private _beforeCameraUpdate;
  70169. }
  70170. }
  70171. declare module "babylonjs/Meshes/Builders/index" {
  70172. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70173. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70174. export * from "babylonjs/Meshes/Builders/discBuilder";
  70175. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70176. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70177. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70178. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70179. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70180. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70181. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70182. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70183. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70184. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70185. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70186. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70187. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70188. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70189. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70190. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70191. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70192. }
  70193. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70194. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70195. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70196. import { Matrix } from "babylonjs/Maths/math.vector";
  70197. module "babylonjs/Meshes/mesh" {
  70198. interface Mesh {
  70199. /**
  70200. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70201. */
  70202. thinInstanceEnablePicking: boolean;
  70203. /**
  70204. * Creates a new thin instance
  70205. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70206. * @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
  70207. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70208. */
  70209. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70210. /**
  70211. * Adds the transformation (matrix) of the current mesh as a thin instance
  70212. * @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
  70213. * @returns the thin instance index number
  70214. */
  70215. thinInstanceAddSelf(refresh: boolean): number;
  70216. /**
  70217. * Registers a custom attribute to be used with thin instances
  70218. * @param kind name of the attribute
  70219. * @param stride size in floats of the attribute
  70220. */
  70221. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70222. /**
  70223. * Sets the matrix of a thin instance
  70224. * @param index index of the thin instance
  70225. * @param matrix matrix to set
  70226. * @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
  70227. */
  70228. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70229. /**
  70230. * Sets the value of a custom attribute for a thin instance
  70231. * @param kind name of the attribute
  70232. * @param index index of the thin instance
  70233. * @param value value to set
  70234. * @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
  70235. */
  70236. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70237. /**
  70238. * 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.
  70239. */
  70240. thinInstanceCount: number;
  70241. /**
  70242. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70243. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70244. * @param buffer buffer to set
  70245. * @param stride size in floats of each value of the buffer
  70246. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70247. */
  70248. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70249. /**
  70250. * Gets the list of world matrices
  70251. * @return an array containing all the world matrices from the thin instances
  70252. */
  70253. thinInstanceGetWorldMatrices(): Matrix[];
  70254. /**
  70255. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70256. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70257. */
  70258. thinInstanceBufferUpdated(kind: string): void;
  70259. /**
  70260. * Applies a partial update to a buffer directly on the GPU
  70261. * 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
  70262. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70263. * @param data the data to set in the GPU buffer
  70264. * @param offset the offset in the GPU buffer where to update the data
  70265. */
  70266. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70267. /**
  70268. * Refreshes the bounding info, taking into account all the thin instances defined
  70269. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70270. */
  70271. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70272. /** @hidden */
  70273. _thinInstanceInitializeUserStorage(): void;
  70274. /** @hidden */
  70275. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70276. /** @hidden */
  70277. _userThinInstanceBuffersStorage: {
  70278. data: {
  70279. [key: string]: Float32Array;
  70280. };
  70281. sizes: {
  70282. [key: string]: number;
  70283. };
  70284. vertexBuffers: {
  70285. [key: string]: Nullable<VertexBuffer>;
  70286. };
  70287. strides: {
  70288. [key: string]: number;
  70289. };
  70290. };
  70291. }
  70292. }
  70293. }
  70294. declare module "babylonjs/Meshes/index" {
  70295. export * from "babylonjs/Meshes/abstractMesh";
  70296. export * from "babylonjs/Meshes/buffer";
  70297. export * from "babylonjs/Meshes/Compression/index";
  70298. export * from "babylonjs/Meshes/csg";
  70299. export * from "babylonjs/Meshes/geometry";
  70300. export * from "babylonjs/Meshes/groundMesh";
  70301. export * from "babylonjs/Meshes/trailMesh";
  70302. export * from "babylonjs/Meshes/instancedMesh";
  70303. export * from "babylonjs/Meshes/linesMesh";
  70304. export * from "babylonjs/Meshes/mesh";
  70305. export * from "babylonjs/Meshes/mesh.vertexData";
  70306. export * from "babylonjs/Meshes/meshBuilder";
  70307. export * from "babylonjs/Meshes/meshSimplification";
  70308. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70309. export * from "babylonjs/Meshes/polygonMesh";
  70310. export * from "babylonjs/Meshes/subMesh";
  70311. export * from "babylonjs/Meshes/meshLODLevel";
  70312. export * from "babylonjs/Meshes/transformNode";
  70313. export * from "babylonjs/Meshes/Builders/index";
  70314. export * from "babylonjs/Meshes/dataBuffer";
  70315. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70316. import "babylonjs/Meshes/thinInstanceMesh";
  70317. export * from "babylonjs/Meshes/thinInstanceMesh";
  70318. }
  70319. declare module "babylonjs/Morph/index" {
  70320. export * from "babylonjs/Morph/morphTarget";
  70321. export * from "babylonjs/Morph/morphTargetManager";
  70322. }
  70323. declare module "babylonjs/Navigation/INavigationEngine" {
  70324. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70325. import { Vector3 } from "babylonjs/Maths/math";
  70326. import { Mesh } from "babylonjs/Meshes/mesh";
  70327. import { Scene } from "babylonjs/scene";
  70328. /**
  70329. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70330. */
  70331. export interface INavigationEnginePlugin {
  70332. /**
  70333. * plugin name
  70334. */
  70335. name: string;
  70336. /**
  70337. * Creates a navigation mesh
  70338. * @param meshes array of all the geometry used to compute the navigatio mesh
  70339. * @param parameters bunch of parameters used to filter geometry
  70340. */
  70341. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70342. /**
  70343. * Create a navigation mesh debug mesh
  70344. * @param scene is where the mesh will be added
  70345. * @returns debug display mesh
  70346. */
  70347. createDebugNavMesh(scene: Scene): Mesh;
  70348. /**
  70349. * Get a navigation mesh constrained position, closest to the parameter position
  70350. * @param position world position
  70351. * @returns the closest point to position constrained by the navigation mesh
  70352. */
  70353. getClosestPoint(position: Vector3): Vector3;
  70354. /**
  70355. * Get a navigation mesh constrained position, closest to the parameter position
  70356. * @param position world position
  70357. * @param result output the closest point to position constrained by the navigation mesh
  70358. */
  70359. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70360. /**
  70361. * Get a navigation mesh constrained position, within a particular radius
  70362. * @param position world position
  70363. * @param maxRadius the maximum distance to the constrained world position
  70364. * @returns the closest point to position constrained by the navigation mesh
  70365. */
  70366. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70367. /**
  70368. * Get a navigation mesh constrained position, within a particular radius
  70369. * @param position world position
  70370. * @param maxRadius the maximum distance to the constrained world position
  70371. * @param result output the closest point to position constrained by the navigation mesh
  70372. */
  70373. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70374. /**
  70375. * Compute the final position from a segment made of destination-position
  70376. * @param position world position
  70377. * @param destination world position
  70378. * @returns the resulting point along the navmesh
  70379. */
  70380. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70381. /**
  70382. * Compute the final position from a segment made of destination-position
  70383. * @param position world position
  70384. * @param destination world position
  70385. * @param result output the resulting point along the navmesh
  70386. */
  70387. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70388. /**
  70389. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70390. * @param start world position
  70391. * @param end world position
  70392. * @returns array containing world position composing the path
  70393. */
  70394. computePath(start: Vector3, end: Vector3): Vector3[];
  70395. /**
  70396. * If this plugin is supported
  70397. * @returns true if plugin is supported
  70398. */
  70399. isSupported(): boolean;
  70400. /**
  70401. * Create a new Crowd so you can add agents
  70402. * @param maxAgents the maximum agent count in the crowd
  70403. * @param maxAgentRadius the maximum radius an agent can have
  70404. * @param scene to attach the crowd to
  70405. * @returns the crowd you can add agents to
  70406. */
  70407. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70408. /**
  70409. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70410. * The queries will try to find a solution within those bounds
  70411. * default is (1,1,1)
  70412. * @param extent x,y,z value that define the extent around the queries point of reference
  70413. */
  70414. setDefaultQueryExtent(extent: Vector3): void;
  70415. /**
  70416. * Get the Bounding box extent specified by setDefaultQueryExtent
  70417. * @returns the box extent values
  70418. */
  70419. getDefaultQueryExtent(): Vector3;
  70420. /**
  70421. * build the navmesh from a previously saved state using getNavmeshData
  70422. * @param data the Uint8Array returned by getNavmeshData
  70423. */
  70424. buildFromNavmeshData(data: Uint8Array): void;
  70425. /**
  70426. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70427. * @returns data the Uint8Array that can be saved and reused
  70428. */
  70429. getNavmeshData(): Uint8Array;
  70430. /**
  70431. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70432. * @param result output the box extent values
  70433. */
  70434. getDefaultQueryExtentToRef(result: Vector3): void;
  70435. /**
  70436. * Release all resources
  70437. */
  70438. dispose(): void;
  70439. }
  70440. /**
  70441. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70442. */
  70443. export interface ICrowd {
  70444. /**
  70445. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70446. * You can attach anything to that node. The node position is updated in the scene update tick.
  70447. * @param pos world position that will be constrained by the navigation mesh
  70448. * @param parameters agent parameters
  70449. * @param transform hooked to the agent that will be update by the scene
  70450. * @returns agent index
  70451. */
  70452. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70453. /**
  70454. * Returns the agent position in world space
  70455. * @param index agent index returned by addAgent
  70456. * @returns world space position
  70457. */
  70458. getAgentPosition(index: number): Vector3;
  70459. /**
  70460. * Gets the agent position result in world space
  70461. * @param index agent index returned by addAgent
  70462. * @param result output world space position
  70463. */
  70464. getAgentPositionToRef(index: number, result: Vector3): void;
  70465. /**
  70466. * Gets the agent velocity in world space
  70467. * @param index agent index returned by addAgent
  70468. * @returns world space velocity
  70469. */
  70470. getAgentVelocity(index: number): Vector3;
  70471. /**
  70472. * Gets the agent velocity result in world space
  70473. * @param index agent index returned by addAgent
  70474. * @param result output world space velocity
  70475. */
  70476. getAgentVelocityToRef(index: number, result: Vector3): void;
  70477. /**
  70478. * remove a particular agent previously created
  70479. * @param index agent index returned by addAgent
  70480. */
  70481. removeAgent(index: number): void;
  70482. /**
  70483. * get the list of all agents attached to this crowd
  70484. * @returns list of agent indices
  70485. */
  70486. getAgents(): number[];
  70487. /**
  70488. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70489. * @param deltaTime in seconds
  70490. */
  70491. update(deltaTime: number): void;
  70492. /**
  70493. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70494. * @param index agent index returned by addAgent
  70495. * @param destination targeted world position
  70496. */
  70497. agentGoto(index: number, destination: Vector3): void;
  70498. /**
  70499. * Teleport the agent to a new position
  70500. * @param index agent index returned by addAgent
  70501. * @param destination targeted world position
  70502. */
  70503. agentTeleport(index: number, destination: Vector3): void;
  70504. /**
  70505. * Update agent parameters
  70506. * @param index agent index returned by addAgent
  70507. * @param parameters agent parameters
  70508. */
  70509. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70510. /**
  70511. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70512. * The queries will try to find a solution within those bounds
  70513. * default is (1,1,1)
  70514. * @param extent x,y,z value that define the extent around the queries point of reference
  70515. */
  70516. setDefaultQueryExtent(extent: Vector3): void;
  70517. /**
  70518. * Get the Bounding box extent specified by setDefaultQueryExtent
  70519. * @returns the box extent values
  70520. */
  70521. getDefaultQueryExtent(): Vector3;
  70522. /**
  70523. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70524. * @param result output the box extent values
  70525. */
  70526. getDefaultQueryExtentToRef(result: Vector3): void;
  70527. /**
  70528. * Release all resources
  70529. */
  70530. dispose(): void;
  70531. }
  70532. /**
  70533. * Configures an agent
  70534. */
  70535. export interface IAgentParameters {
  70536. /**
  70537. * Agent radius. [Limit: >= 0]
  70538. */
  70539. radius: number;
  70540. /**
  70541. * Agent height. [Limit: > 0]
  70542. */
  70543. height: number;
  70544. /**
  70545. * Maximum allowed acceleration. [Limit: >= 0]
  70546. */
  70547. maxAcceleration: number;
  70548. /**
  70549. * Maximum allowed speed. [Limit: >= 0]
  70550. */
  70551. maxSpeed: number;
  70552. /**
  70553. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70554. */
  70555. collisionQueryRange: number;
  70556. /**
  70557. * The path visibility optimization range. [Limit: > 0]
  70558. */
  70559. pathOptimizationRange: number;
  70560. /**
  70561. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70562. */
  70563. separationWeight: number;
  70564. }
  70565. /**
  70566. * Configures the navigation mesh creation
  70567. */
  70568. export interface INavMeshParameters {
  70569. /**
  70570. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70571. */
  70572. cs: number;
  70573. /**
  70574. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70575. */
  70576. ch: number;
  70577. /**
  70578. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70579. */
  70580. walkableSlopeAngle: number;
  70581. /**
  70582. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70583. * be considered walkable. [Limit: >= 3] [Units: vx]
  70584. */
  70585. walkableHeight: number;
  70586. /**
  70587. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70588. */
  70589. walkableClimb: number;
  70590. /**
  70591. * The distance to erode/shrink the walkable area of the heightfield away from
  70592. * obstructions. [Limit: >=0] [Units: vx]
  70593. */
  70594. walkableRadius: number;
  70595. /**
  70596. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70597. */
  70598. maxEdgeLen: number;
  70599. /**
  70600. * The maximum distance a simplfied contour's border edges should deviate
  70601. * the original raw contour. [Limit: >=0] [Units: vx]
  70602. */
  70603. maxSimplificationError: number;
  70604. /**
  70605. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70606. */
  70607. minRegionArea: number;
  70608. /**
  70609. * Any regions with a span count smaller than this value will, if possible,
  70610. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70611. */
  70612. mergeRegionArea: number;
  70613. /**
  70614. * The maximum number of vertices allowed for polygons generated during the
  70615. * contour to polygon conversion process. [Limit: >= 3]
  70616. */
  70617. maxVertsPerPoly: number;
  70618. /**
  70619. * Sets the sampling distance to use when generating the detail mesh.
  70620. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70621. */
  70622. detailSampleDist: number;
  70623. /**
  70624. * The maximum distance the detail mesh surface should deviate from heightfield
  70625. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70626. */
  70627. detailSampleMaxError: number;
  70628. }
  70629. }
  70630. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70631. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70632. import { Mesh } from "babylonjs/Meshes/mesh";
  70633. import { Scene } from "babylonjs/scene";
  70634. import { Vector3 } from "babylonjs/Maths/math";
  70635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70636. /**
  70637. * RecastJS navigation plugin
  70638. */
  70639. export class RecastJSPlugin implements INavigationEnginePlugin {
  70640. /**
  70641. * Reference to the Recast library
  70642. */
  70643. bjsRECAST: any;
  70644. /**
  70645. * plugin name
  70646. */
  70647. name: string;
  70648. /**
  70649. * the first navmesh created. We might extend this to support multiple navmeshes
  70650. */
  70651. navMesh: any;
  70652. /**
  70653. * Initializes the recastJS plugin
  70654. * @param recastInjection can be used to inject your own recast reference
  70655. */
  70656. constructor(recastInjection?: any);
  70657. /**
  70658. * Creates a navigation mesh
  70659. * @param meshes array of all the geometry used to compute the navigatio mesh
  70660. * @param parameters bunch of parameters used to filter geometry
  70661. */
  70662. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70663. /**
  70664. * Create a navigation mesh debug mesh
  70665. * @param scene is where the mesh will be added
  70666. * @returns debug display mesh
  70667. */
  70668. createDebugNavMesh(scene: Scene): Mesh;
  70669. /**
  70670. * Get a navigation mesh constrained position, closest to the parameter position
  70671. * @param position world position
  70672. * @returns the closest point to position constrained by the navigation mesh
  70673. */
  70674. getClosestPoint(position: Vector3): Vector3;
  70675. /**
  70676. * Get a navigation mesh constrained position, closest to the parameter position
  70677. * @param position world position
  70678. * @param result output the closest point to position constrained by the navigation mesh
  70679. */
  70680. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70681. /**
  70682. * Get a navigation mesh constrained position, within a particular radius
  70683. * @param position world position
  70684. * @param maxRadius the maximum distance to the constrained world position
  70685. * @returns the closest point to position constrained by the navigation mesh
  70686. */
  70687. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70688. /**
  70689. * Get a navigation mesh constrained position, within a particular radius
  70690. * @param position world position
  70691. * @param maxRadius the maximum distance to the constrained world position
  70692. * @param result output the closest point to position constrained by the navigation mesh
  70693. */
  70694. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70695. /**
  70696. * Compute the final position from a segment made of destination-position
  70697. * @param position world position
  70698. * @param destination world position
  70699. * @returns the resulting point along the navmesh
  70700. */
  70701. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70702. /**
  70703. * Compute the final position from a segment made of destination-position
  70704. * @param position world position
  70705. * @param destination world position
  70706. * @param result output the resulting point along the navmesh
  70707. */
  70708. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70709. /**
  70710. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70711. * @param start world position
  70712. * @param end world position
  70713. * @returns array containing world position composing the path
  70714. */
  70715. computePath(start: Vector3, end: Vector3): Vector3[];
  70716. /**
  70717. * Create a new Crowd so you can add agents
  70718. * @param maxAgents the maximum agent count in the crowd
  70719. * @param maxAgentRadius the maximum radius an agent can have
  70720. * @param scene to attach the crowd to
  70721. * @returns the crowd you can add agents to
  70722. */
  70723. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70724. /**
  70725. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70726. * The queries will try to find a solution within those bounds
  70727. * default is (1,1,1)
  70728. * @param extent x,y,z value that define the extent around the queries point of reference
  70729. */
  70730. setDefaultQueryExtent(extent: Vector3): void;
  70731. /**
  70732. * Get the Bounding box extent specified by setDefaultQueryExtent
  70733. * @returns the box extent values
  70734. */
  70735. getDefaultQueryExtent(): Vector3;
  70736. /**
  70737. * build the navmesh from a previously saved state using getNavmeshData
  70738. * @param data the Uint8Array returned by getNavmeshData
  70739. */
  70740. buildFromNavmeshData(data: Uint8Array): void;
  70741. /**
  70742. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70743. * @returns data the Uint8Array that can be saved and reused
  70744. */
  70745. getNavmeshData(): Uint8Array;
  70746. /**
  70747. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70748. * @param result output the box extent values
  70749. */
  70750. getDefaultQueryExtentToRef(result: Vector3): void;
  70751. /**
  70752. * Disposes
  70753. */
  70754. dispose(): void;
  70755. /**
  70756. * If this plugin is supported
  70757. * @returns true if plugin is supported
  70758. */
  70759. isSupported(): boolean;
  70760. }
  70761. /**
  70762. * Recast detour crowd implementation
  70763. */
  70764. export class RecastJSCrowd implements ICrowd {
  70765. /**
  70766. * Recast/detour plugin
  70767. */
  70768. bjsRECASTPlugin: RecastJSPlugin;
  70769. /**
  70770. * Link to the detour crowd
  70771. */
  70772. recastCrowd: any;
  70773. /**
  70774. * One transform per agent
  70775. */
  70776. transforms: TransformNode[];
  70777. /**
  70778. * All agents created
  70779. */
  70780. agents: number[];
  70781. /**
  70782. * Link to the scene is kept to unregister the crowd from the scene
  70783. */
  70784. private _scene;
  70785. /**
  70786. * Observer for crowd updates
  70787. */
  70788. private _onBeforeAnimationsObserver;
  70789. /**
  70790. * Constructor
  70791. * @param plugin recastJS plugin
  70792. * @param maxAgents the maximum agent count in the crowd
  70793. * @param maxAgentRadius the maximum radius an agent can have
  70794. * @param scene to attach the crowd to
  70795. * @returns the crowd you can add agents to
  70796. */
  70797. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70798. /**
  70799. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70800. * You can attach anything to that node. The node position is updated in the scene update tick.
  70801. * @param pos world position that will be constrained by the navigation mesh
  70802. * @param parameters agent parameters
  70803. * @param transform hooked to the agent that will be update by the scene
  70804. * @returns agent index
  70805. */
  70806. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70807. /**
  70808. * Returns the agent position in world space
  70809. * @param index agent index returned by addAgent
  70810. * @returns world space position
  70811. */
  70812. getAgentPosition(index: number): Vector3;
  70813. /**
  70814. * Returns the agent position result in world space
  70815. * @param index agent index returned by addAgent
  70816. * @param result output world space position
  70817. */
  70818. getAgentPositionToRef(index: number, result: Vector3): void;
  70819. /**
  70820. * Returns the agent velocity in world space
  70821. * @param index agent index returned by addAgent
  70822. * @returns world space velocity
  70823. */
  70824. getAgentVelocity(index: number): Vector3;
  70825. /**
  70826. * Returns the agent velocity result in world space
  70827. * @param index agent index returned by addAgent
  70828. * @param result output world space velocity
  70829. */
  70830. getAgentVelocityToRef(index: number, result: Vector3): void;
  70831. /**
  70832. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70833. * @param index agent index returned by addAgent
  70834. * @param destination targeted world position
  70835. */
  70836. agentGoto(index: number, destination: Vector3): void;
  70837. /**
  70838. * Teleport the agent to a new position
  70839. * @param index agent index returned by addAgent
  70840. * @param destination targeted world position
  70841. */
  70842. agentTeleport(index: number, destination: Vector3): void;
  70843. /**
  70844. * Update agent parameters
  70845. * @param index agent index returned by addAgent
  70846. * @param parameters agent parameters
  70847. */
  70848. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70849. /**
  70850. * remove a particular agent previously created
  70851. * @param index agent index returned by addAgent
  70852. */
  70853. removeAgent(index: number): void;
  70854. /**
  70855. * get the list of all agents attached to this crowd
  70856. * @returns list of agent indices
  70857. */
  70858. getAgents(): number[];
  70859. /**
  70860. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70861. * @param deltaTime in seconds
  70862. */
  70863. update(deltaTime: number): void;
  70864. /**
  70865. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70866. * The queries will try to find a solution within those bounds
  70867. * default is (1,1,1)
  70868. * @param extent x,y,z value that define the extent around the queries point of reference
  70869. */
  70870. setDefaultQueryExtent(extent: Vector3): void;
  70871. /**
  70872. * Get the Bounding box extent specified by setDefaultQueryExtent
  70873. * @returns the box extent values
  70874. */
  70875. getDefaultQueryExtent(): Vector3;
  70876. /**
  70877. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70878. * @param result output the box extent values
  70879. */
  70880. getDefaultQueryExtentToRef(result: Vector3): void;
  70881. /**
  70882. * Release all resources
  70883. */
  70884. dispose(): void;
  70885. }
  70886. }
  70887. declare module "babylonjs/Navigation/Plugins/index" {
  70888. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70889. }
  70890. declare module "babylonjs/Navigation/index" {
  70891. export * from "babylonjs/Navigation/INavigationEngine";
  70892. export * from "babylonjs/Navigation/Plugins/index";
  70893. }
  70894. declare module "babylonjs/Offline/database" {
  70895. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70896. /**
  70897. * Class used to enable access to IndexedDB
  70898. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70899. */
  70900. export class Database implements IOfflineProvider {
  70901. private _callbackManifestChecked;
  70902. private _currentSceneUrl;
  70903. private _db;
  70904. private _enableSceneOffline;
  70905. private _enableTexturesOffline;
  70906. private _manifestVersionFound;
  70907. private _mustUpdateRessources;
  70908. private _hasReachedQuota;
  70909. private _isSupported;
  70910. private _idbFactory;
  70911. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70912. private static IsUASupportingBlobStorage;
  70913. /**
  70914. * Gets a boolean indicating if Database storate is enabled (off by default)
  70915. */
  70916. static IDBStorageEnabled: boolean;
  70917. /**
  70918. * Gets a boolean indicating if scene must be saved in the database
  70919. */
  70920. get enableSceneOffline(): boolean;
  70921. /**
  70922. * Gets a boolean indicating if textures must be saved in the database
  70923. */
  70924. get enableTexturesOffline(): boolean;
  70925. /**
  70926. * Creates a new Database
  70927. * @param urlToScene defines the url to load the scene
  70928. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70929. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70930. */
  70931. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70932. private static _ParseURL;
  70933. private static _ReturnFullUrlLocation;
  70934. private _checkManifestFile;
  70935. /**
  70936. * Open the database and make it available
  70937. * @param successCallback defines the callback to call on success
  70938. * @param errorCallback defines the callback to call on error
  70939. */
  70940. open(successCallback: () => void, errorCallback: () => void): void;
  70941. /**
  70942. * Loads an image from the database
  70943. * @param url defines the url to load from
  70944. * @param image defines the target DOM image
  70945. */
  70946. loadImage(url: string, image: HTMLImageElement): void;
  70947. private _loadImageFromDBAsync;
  70948. private _saveImageIntoDBAsync;
  70949. private _checkVersionFromDB;
  70950. private _loadVersionFromDBAsync;
  70951. private _saveVersionIntoDBAsync;
  70952. /**
  70953. * Loads a file from database
  70954. * @param url defines the URL to load from
  70955. * @param sceneLoaded defines a callback to call on success
  70956. * @param progressCallBack defines a callback to call when progress changed
  70957. * @param errorCallback defines a callback to call on error
  70958. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70959. */
  70960. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70961. private _loadFileAsync;
  70962. private _saveFileAsync;
  70963. /**
  70964. * Validates if xhr data is correct
  70965. * @param xhr defines the request to validate
  70966. * @param dataType defines the expected data type
  70967. * @returns true if data is correct
  70968. */
  70969. private static _ValidateXHRData;
  70970. }
  70971. }
  70972. declare module "babylonjs/Offline/index" {
  70973. export * from "babylonjs/Offline/database";
  70974. export * from "babylonjs/Offline/IOfflineProvider";
  70975. }
  70976. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70977. /** @hidden */
  70978. export var gpuUpdateParticlesPixelShader: {
  70979. name: string;
  70980. shader: string;
  70981. };
  70982. }
  70983. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70984. /** @hidden */
  70985. export var gpuUpdateParticlesVertexShader: {
  70986. name: string;
  70987. shader: string;
  70988. };
  70989. }
  70990. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70991. /** @hidden */
  70992. export var clipPlaneFragmentDeclaration2: {
  70993. name: string;
  70994. shader: string;
  70995. };
  70996. }
  70997. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70998. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70999. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71000. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71001. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71002. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71003. /** @hidden */
  71004. export var gpuRenderParticlesPixelShader: {
  71005. name: string;
  71006. shader: string;
  71007. };
  71008. }
  71009. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71010. /** @hidden */
  71011. export var clipPlaneVertexDeclaration2: {
  71012. name: string;
  71013. shader: string;
  71014. };
  71015. }
  71016. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71017. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71018. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71019. /** @hidden */
  71020. export var gpuRenderParticlesVertexShader: {
  71021. name: string;
  71022. shader: string;
  71023. };
  71024. }
  71025. declare module "babylonjs/Particles/gpuParticleSystem" {
  71026. import { Nullable } from "babylonjs/types";
  71027. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71028. import { Observable } from "babylonjs/Misc/observable";
  71029. import { Matrix } from "babylonjs/Maths/math.vector";
  71030. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71031. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71032. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71033. import { IDisposable } from "babylonjs/scene";
  71034. import { Effect } from "babylonjs/Materials/effect";
  71035. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71036. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71037. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71038. import { Scene } from "babylonjs/scene";
  71039. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71040. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71041. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71042. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71043. /**
  71044. * This represents a GPU particle system in Babylon
  71045. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71046. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71047. */
  71048. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71049. /**
  71050. * The layer mask we are rendering the particles through.
  71051. */
  71052. layerMask: number;
  71053. private _capacity;
  71054. private _activeCount;
  71055. private _currentActiveCount;
  71056. private _accumulatedCount;
  71057. private _renderEffect;
  71058. private _updateEffect;
  71059. private _buffer0;
  71060. private _buffer1;
  71061. private _spriteBuffer;
  71062. private _updateVAO;
  71063. private _renderVAO;
  71064. private _targetIndex;
  71065. private _sourceBuffer;
  71066. private _targetBuffer;
  71067. private _currentRenderId;
  71068. private _started;
  71069. private _stopped;
  71070. private _timeDelta;
  71071. private _randomTexture;
  71072. private _randomTexture2;
  71073. private _attributesStrideSize;
  71074. private _updateEffectOptions;
  71075. private _randomTextureSize;
  71076. private _actualFrame;
  71077. private _customEffect;
  71078. private readonly _rawTextureWidth;
  71079. /**
  71080. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71081. */
  71082. static get IsSupported(): boolean;
  71083. /**
  71084. * An event triggered when the system is disposed.
  71085. */
  71086. onDisposeObservable: Observable<IParticleSystem>;
  71087. /**
  71088. * Gets the maximum number of particles active at the same time.
  71089. * @returns The max number of active particles.
  71090. */
  71091. getCapacity(): number;
  71092. /**
  71093. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71094. * to override the particles.
  71095. */
  71096. forceDepthWrite: boolean;
  71097. /**
  71098. * Gets or set the number of active particles
  71099. */
  71100. get activeParticleCount(): number;
  71101. set activeParticleCount(value: number);
  71102. private _preWarmDone;
  71103. /**
  71104. * Specifies if the particles are updated in emitter local space or world space.
  71105. */
  71106. isLocal: boolean;
  71107. /** Gets or sets a matrix to use to compute projection */
  71108. defaultProjectionMatrix: Matrix;
  71109. /**
  71110. * Is this system ready to be used/rendered
  71111. * @return true if the system is ready
  71112. */
  71113. isReady(): boolean;
  71114. /**
  71115. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71116. * @returns True if it has been started, otherwise false.
  71117. */
  71118. isStarted(): boolean;
  71119. /**
  71120. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71121. * @returns True if it has been stopped, otherwise false.
  71122. */
  71123. isStopped(): boolean;
  71124. /**
  71125. * Gets a boolean indicating that the system is stopping
  71126. * @returns true if the system is currently stopping
  71127. */
  71128. isStopping(): boolean;
  71129. /**
  71130. * Gets the number of particles active at the same time.
  71131. * @returns The number of active particles.
  71132. */
  71133. getActiveCount(): number;
  71134. /**
  71135. * Starts the particle system and begins to emit
  71136. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71137. */
  71138. start(delay?: number): void;
  71139. /**
  71140. * Stops the particle system.
  71141. */
  71142. stop(): void;
  71143. /**
  71144. * Remove all active particles
  71145. */
  71146. reset(): void;
  71147. /**
  71148. * Returns the string "GPUParticleSystem"
  71149. * @returns a string containing the class name
  71150. */
  71151. getClassName(): string;
  71152. /**
  71153. * Gets the custom effect used to render the particles
  71154. * @param blendMode Blend mode for which the effect should be retrieved
  71155. * @returns The effect
  71156. */
  71157. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71158. /**
  71159. * Sets the custom effect used to render the particles
  71160. * @param effect The effect to set
  71161. * @param blendMode Blend mode for which the effect should be set
  71162. */
  71163. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71164. /** @hidden */
  71165. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71166. /**
  71167. * Observable that will be called just before the particles are drawn
  71168. */
  71169. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71170. /**
  71171. * Gets the name of the particle vertex shader
  71172. */
  71173. get vertexShaderName(): string;
  71174. private _colorGradientsTexture;
  71175. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71176. /**
  71177. * Adds a new color gradient
  71178. * @param gradient defines the gradient to use (between 0 and 1)
  71179. * @param color1 defines the color to affect to the specified gradient
  71180. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71181. * @returns the current particle system
  71182. */
  71183. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71184. private _refreshColorGradient;
  71185. /** Force the system to rebuild all gradients that need to be resync */
  71186. forceRefreshGradients(): void;
  71187. /**
  71188. * Remove a specific color gradient
  71189. * @param gradient defines the gradient to remove
  71190. * @returns the current particle system
  71191. */
  71192. removeColorGradient(gradient: number): GPUParticleSystem;
  71193. private _angularSpeedGradientsTexture;
  71194. private _sizeGradientsTexture;
  71195. private _velocityGradientsTexture;
  71196. private _limitVelocityGradientsTexture;
  71197. private _dragGradientsTexture;
  71198. private _addFactorGradient;
  71199. /**
  71200. * Adds a new size gradient
  71201. * @param gradient defines the gradient to use (between 0 and 1)
  71202. * @param factor defines the size factor to affect to the specified gradient
  71203. * @returns the current particle system
  71204. */
  71205. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71206. /**
  71207. * Remove a specific size gradient
  71208. * @param gradient defines the gradient to remove
  71209. * @returns the current particle system
  71210. */
  71211. removeSizeGradient(gradient: number): GPUParticleSystem;
  71212. private _refreshFactorGradient;
  71213. /**
  71214. * Adds a new angular speed gradient
  71215. * @param gradient defines the gradient to use (between 0 and 1)
  71216. * @param factor defines the angular speed to affect to the specified gradient
  71217. * @returns the current particle system
  71218. */
  71219. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71220. /**
  71221. * Remove a specific angular speed gradient
  71222. * @param gradient defines the gradient to remove
  71223. * @returns the current particle system
  71224. */
  71225. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71226. /**
  71227. * Adds a new velocity gradient
  71228. * @param gradient defines the gradient to use (between 0 and 1)
  71229. * @param factor defines the velocity to affect to the specified gradient
  71230. * @returns the current particle system
  71231. */
  71232. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71233. /**
  71234. * Remove a specific velocity gradient
  71235. * @param gradient defines the gradient to remove
  71236. * @returns the current particle system
  71237. */
  71238. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71239. /**
  71240. * Adds a new limit velocity gradient
  71241. * @param gradient defines the gradient to use (between 0 and 1)
  71242. * @param factor defines the limit velocity value to affect to the specified gradient
  71243. * @returns the current particle system
  71244. */
  71245. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71246. /**
  71247. * Remove a specific limit velocity gradient
  71248. * @param gradient defines the gradient to remove
  71249. * @returns the current particle system
  71250. */
  71251. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71252. /**
  71253. * Adds a new drag gradient
  71254. * @param gradient defines the gradient to use (between 0 and 1)
  71255. * @param factor defines the drag value to affect to the specified gradient
  71256. * @returns the current particle system
  71257. */
  71258. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71259. /**
  71260. * Remove a specific drag gradient
  71261. * @param gradient defines the gradient to remove
  71262. * @returns the current particle system
  71263. */
  71264. removeDragGradient(gradient: number): GPUParticleSystem;
  71265. /**
  71266. * Not supported by GPUParticleSystem
  71267. * @param gradient defines the gradient to use (between 0 and 1)
  71268. * @param factor defines the emit rate value to affect to the specified gradient
  71269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71270. * @returns the current particle system
  71271. */
  71272. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71273. /**
  71274. * Not supported by GPUParticleSystem
  71275. * @param gradient defines the gradient to remove
  71276. * @returns the current particle system
  71277. */
  71278. removeEmitRateGradient(gradient: number): IParticleSystem;
  71279. /**
  71280. * Not supported by GPUParticleSystem
  71281. * @param gradient defines the gradient to use (between 0 and 1)
  71282. * @param factor defines the start size value to affect to the specified gradient
  71283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71284. * @returns the current particle system
  71285. */
  71286. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71287. /**
  71288. * Not supported by GPUParticleSystem
  71289. * @param gradient defines the gradient to remove
  71290. * @returns the current particle system
  71291. */
  71292. removeStartSizeGradient(gradient: number): IParticleSystem;
  71293. /**
  71294. * Not supported by GPUParticleSystem
  71295. * @param gradient defines the gradient to use (between 0 and 1)
  71296. * @param min defines the color remap minimal range
  71297. * @param max defines the color remap maximal range
  71298. * @returns the current particle system
  71299. */
  71300. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71301. /**
  71302. * Not supported by GPUParticleSystem
  71303. * @param gradient defines the gradient to remove
  71304. * @returns the current particle system
  71305. */
  71306. removeColorRemapGradient(): IParticleSystem;
  71307. /**
  71308. * Not supported by GPUParticleSystem
  71309. * @param gradient defines the gradient to use (between 0 and 1)
  71310. * @param min defines the alpha remap minimal range
  71311. * @param max defines the alpha remap maximal range
  71312. * @returns the current particle system
  71313. */
  71314. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71315. /**
  71316. * Not supported by GPUParticleSystem
  71317. * @param gradient defines the gradient to remove
  71318. * @returns the current particle system
  71319. */
  71320. removeAlphaRemapGradient(): IParticleSystem;
  71321. /**
  71322. * Not supported by GPUParticleSystem
  71323. * @param gradient defines the gradient to use (between 0 and 1)
  71324. * @param color defines the color to affect to the specified gradient
  71325. * @returns the current particle system
  71326. */
  71327. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71328. /**
  71329. * Not supported by GPUParticleSystem
  71330. * @param gradient defines the gradient to remove
  71331. * @returns the current particle system
  71332. */
  71333. removeRampGradient(): IParticleSystem;
  71334. /**
  71335. * Not supported by GPUParticleSystem
  71336. * @returns the list of ramp gradients
  71337. */
  71338. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71339. /**
  71340. * Not supported by GPUParticleSystem
  71341. * Gets or sets a boolean indicating that ramp gradients must be used
  71342. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71343. */
  71344. get useRampGradients(): boolean;
  71345. set useRampGradients(value: boolean);
  71346. /**
  71347. * Not supported by GPUParticleSystem
  71348. * @param gradient defines the gradient to use (between 0 and 1)
  71349. * @param factor defines the life time factor to affect to the specified gradient
  71350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71351. * @returns the current particle system
  71352. */
  71353. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71354. /**
  71355. * Not supported by GPUParticleSystem
  71356. * @param gradient defines the gradient to remove
  71357. * @returns the current particle system
  71358. */
  71359. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71360. /**
  71361. * Instantiates a GPU particle system.
  71362. * 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.
  71363. * @param name The name of the particle system
  71364. * @param options The options used to create the system
  71365. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71366. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71367. * @param customEffect a custom effect used to change the way particles are rendered by default
  71368. */
  71369. constructor(name: string, options: Partial<{
  71370. capacity: number;
  71371. randomTextureSize: number;
  71372. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71373. protected _reset(): void;
  71374. private _createUpdateVAO;
  71375. private _createRenderVAO;
  71376. private _initialize;
  71377. /** @hidden */
  71378. _recreateUpdateEffect(): void;
  71379. private _getEffect;
  71380. /**
  71381. * Fill the defines array according to the current settings of the particle system
  71382. * @param defines Array to be updated
  71383. * @param blendMode blend mode to take into account when updating the array
  71384. */
  71385. fillDefines(defines: Array<string>, blendMode?: number): void;
  71386. /**
  71387. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71388. * @param uniforms Uniforms array to fill
  71389. * @param attributes Attributes array to fill
  71390. * @param samplers Samplers array to fill
  71391. */
  71392. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71393. /** @hidden */
  71394. _recreateRenderEffect(): Effect;
  71395. /**
  71396. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71397. * @param preWarm defines if we are in the pre-warmimg phase
  71398. */
  71399. animate(preWarm?: boolean): void;
  71400. private _createFactorGradientTexture;
  71401. private _createSizeGradientTexture;
  71402. private _createAngularSpeedGradientTexture;
  71403. private _createVelocityGradientTexture;
  71404. private _createLimitVelocityGradientTexture;
  71405. private _createDragGradientTexture;
  71406. private _createColorGradientTexture;
  71407. /**
  71408. * Renders the particle system in its current state
  71409. * @param preWarm defines if the system should only update the particles but not render them
  71410. * @returns the current number of particles
  71411. */
  71412. render(preWarm?: boolean): number;
  71413. /**
  71414. * Rebuilds the particle system
  71415. */
  71416. rebuild(): void;
  71417. private _releaseBuffers;
  71418. private _releaseVAOs;
  71419. /**
  71420. * Disposes the particle system and free the associated resources
  71421. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71422. */
  71423. dispose(disposeTexture?: boolean): void;
  71424. /**
  71425. * Clones the particle system.
  71426. * @param name The name of the cloned object
  71427. * @param newEmitter The new emitter to use
  71428. * @returns the cloned particle system
  71429. */
  71430. clone(name: string, newEmitter: any): GPUParticleSystem;
  71431. /**
  71432. * Serializes the particle system to a JSON object
  71433. * @param serializeTexture defines if the texture must be serialized as well
  71434. * @returns the JSON object
  71435. */
  71436. serialize(serializeTexture?: boolean): any;
  71437. /**
  71438. * Parses a JSON object to create a GPU particle system.
  71439. * @param parsedParticleSystem The JSON object to parse
  71440. * @param sceneOrEngine The scene or the engine to create the particle system in
  71441. * @param rootUrl The root url to use to load external dependencies like texture
  71442. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71443. * @returns the parsed GPU particle system
  71444. */
  71445. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71446. }
  71447. }
  71448. declare module "babylonjs/Particles/particleSystemSet" {
  71449. import { Nullable } from "babylonjs/types";
  71450. import { Color3 } from "babylonjs/Maths/math.color";
  71451. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71453. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71454. import { Scene, IDisposable } from "babylonjs/scene";
  71455. /**
  71456. * Represents a set of particle systems working together to create a specific effect
  71457. */
  71458. export class ParticleSystemSet implements IDisposable {
  71459. /**
  71460. * Gets or sets base Assets URL
  71461. */
  71462. static BaseAssetsUrl: string;
  71463. private _emitterCreationOptions;
  71464. private _emitterNode;
  71465. /**
  71466. * Gets the particle system list
  71467. */
  71468. systems: IParticleSystem[];
  71469. /**
  71470. * Gets the emitter node used with this set
  71471. */
  71472. get emitterNode(): Nullable<TransformNode>;
  71473. /**
  71474. * Creates a new emitter mesh as a sphere
  71475. * @param options defines the options used to create the sphere
  71476. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71477. * @param scene defines the hosting scene
  71478. */
  71479. setEmitterAsSphere(options: {
  71480. diameter: number;
  71481. segments: number;
  71482. color: Color3;
  71483. }, renderingGroupId: number, scene: Scene): void;
  71484. /**
  71485. * Starts all particle systems of the set
  71486. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71487. */
  71488. start(emitter?: AbstractMesh): void;
  71489. /**
  71490. * Release all associated resources
  71491. */
  71492. dispose(): void;
  71493. /**
  71494. * Serialize the set into a JSON compatible object
  71495. * @param serializeTexture defines if the texture must be serialized as well
  71496. * @returns a JSON compatible representation of the set
  71497. */
  71498. serialize(serializeTexture?: boolean): any;
  71499. /**
  71500. * Parse a new ParticleSystemSet from a serialized source
  71501. * @param data defines a JSON compatible representation of the set
  71502. * @param scene defines the hosting scene
  71503. * @param gpu defines if we want GPU particles or CPU particles
  71504. * @returns a new ParticleSystemSet
  71505. */
  71506. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71507. }
  71508. }
  71509. declare module "babylonjs/Particles/particleHelper" {
  71510. import { Nullable } from "babylonjs/types";
  71511. import { Scene } from "babylonjs/scene";
  71512. import { Vector3 } from "babylonjs/Maths/math.vector";
  71513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71514. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71515. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71516. /**
  71517. * This class is made for on one-liner static method to help creating particle system set.
  71518. */
  71519. export class ParticleHelper {
  71520. /**
  71521. * Gets or sets base Assets URL
  71522. */
  71523. static BaseAssetsUrl: string;
  71524. /** Define the Url to load snippets */
  71525. static SnippetUrl: string;
  71526. /**
  71527. * Create a default particle system that you can tweak
  71528. * @param emitter defines the emitter to use
  71529. * @param capacity defines the system capacity (default is 500 particles)
  71530. * @param scene defines the hosting scene
  71531. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71532. * @returns the new Particle system
  71533. */
  71534. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71535. /**
  71536. * This is the main static method (one-liner) of this helper to create different particle systems
  71537. * @param type This string represents the type to the particle system to create
  71538. * @param scene The scene where the particle system should live
  71539. * @param gpu If the system will use gpu
  71540. * @returns the ParticleSystemSet created
  71541. */
  71542. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71543. /**
  71544. * Static function used to export a particle system to a ParticleSystemSet variable.
  71545. * Please note that the emitter shape is not exported
  71546. * @param systems defines the particle systems to export
  71547. * @returns the created particle system set
  71548. */
  71549. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71550. /**
  71551. * Creates a particle system from a snippet saved in a remote file
  71552. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71553. * @param url defines the url to load from
  71554. * @param scene defines the hosting scene
  71555. * @param gpu If the system will use gpu
  71556. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71557. * @returns a promise that will resolve to the new particle system
  71558. */
  71559. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71560. /**
  71561. * Creates a particle system from a snippet saved by the particle system editor
  71562. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71563. * @param scene defines the hosting scene
  71564. * @param gpu If the system will use gpu
  71565. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71566. * @returns a promise that will resolve to the new particle system
  71567. */
  71568. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71569. }
  71570. }
  71571. declare module "babylonjs/Particles/particleSystemComponent" {
  71572. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71573. import { Effect } from "babylonjs/Materials/effect";
  71574. import "babylonjs/Shaders/particles.vertex";
  71575. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71576. module "babylonjs/Engines/engine" {
  71577. interface Engine {
  71578. /**
  71579. * Create an effect to use with particle systems.
  71580. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71581. * the particle system for which you want to create a custom effect in the last parameter
  71582. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71583. * @param uniformsNames defines a list of attribute names
  71584. * @param samplers defines an array of string used to represent textures
  71585. * @param defines defines the string containing the defines to use to compile the shaders
  71586. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71587. * @param onCompiled defines a function to call when the effect creation is successful
  71588. * @param onError defines a function to call when the effect creation has failed
  71589. * @param particleSystem the particle system you want to create the effect for
  71590. * @returns the new Effect
  71591. */
  71592. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71593. }
  71594. }
  71595. module "babylonjs/Meshes/mesh" {
  71596. interface Mesh {
  71597. /**
  71598. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71599. * @returns an array of IParticleSystem
  71600. */
  71601. getEmittedParticleSystems(): IParticleSystem[];
  71602. /**
  71603. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71604. * @returns an array of IParticleSystem
  71605. */
  71606. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71607. }
  71608. }
  71609. }
  71610. declare module "babylonjs/Particles/pointsCloudSystem" {
  71611. import { Color4 } from "babylonjs/Maths/math";
  71612. import { Mesh } from "babylonjs/Meshes/mesh";
  71613. import { Scene, IDisposable } from "babylonjs/scene";
  71614. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71615. /** Defines the 4 color options */
  71616. export enum PointColor {
  71617. /** color value */
  71618. Color = 2,
  71619. /** uv value */
  71620. UV = 1,
  71621. /** random value */
  71622. Random = 0,
  71623. /** stated value */
  71624. Stated = 3
  71625. }
  71626. /**
  71627. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71628. * 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.
  71629. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71630. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71631. *
  71632. * Full documentation here : TO BE ENTERED
  71633. */
  71634. export class PointsCloudSystem implements IDisposable {
  71635. /**
  71636. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71637. * Example : var p = SPS.particles[i];
  71638. */
  71639. particles: CloudPoint[];
  71640. /**
  71641. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71642. */
  71643. nbParticles: number;
  71644. /**
  71645. * This a counter for your own usage. It's not set by any SPS functions.
  71646. */
  71647. counter: number;
  71648. /**
  71649. * The PCS name. This name is also given to the underlying mesh.
  71650. */
  71651. name: string;
  71652. /**
  71653. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71654. */
  71655. mesh: Mesh;
  71656. /**
  71657. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71658. * Please read :
  71659. */
  71660. vars: any;
  71661. /**
  71662. * @hidden
  71663. */
  71664. _size: number;
  71665. private _scene;
  71666. private _promises;
  71667. private _positions;
  71668. private _indices;
  71669. private _normals;
  71670. private _colors;
  71671. private _uvs;
  71672. private _indices32;
  71673. private _positions32;
  71674. private _colors32;
  71675. private _uvs32;
  71676. private _updatable;
  71677. private _isVisibilityBoxLocked;
  71678. private _alwaysVisible;
  71679. private _groups;
  71680. private _groupCounter;
  71681. private _computeParticleColor;
  71682. private _computeParticleTexture;
  71683. private _computeParticleRotation;
  71684. private _computeBoundingBox;
  71685. private _isReady;
  71686. /**
  71687. * Creates a PCS (Points Cloud System) object
  71688. * @param name (String) is the PCS name, this will be the underlying mesh name
  71689. * @param pointSize (number) is the size for each point
  71690. * @param scene (Scene) is the scene in which the PCS is added
  71691. * @param options defines the options of the PCS e.g.
  71692. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71693. */
  71694. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71695. updatable?: boolean;
  71696. });
  71697. /**
  71698. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71699. * If no points were added to the PCS, the returned mesh is just a single point.
  71700. * @returns a promise for the created mesh
  71701. */
  71702. buildMeshAsync(): Promise<Mesh>;
  71703. /**
  71704. * @hidden
  71705. */
  71706. private _buildMesh;
  71707. private _addParticle;
  71708. private _randomUnitVector;
  71709. private _getColorIndicesForCoord;
  71710. private _setPointsColorOrUV;
  71711. private _colorFromTexture;
  71712. private _calculateDensity;
  71713. /**
  71714. * Adds points to the PCS in random positions within a unit sphere
  71715. * @param nb (positive integer) the number of particles to be created from this model
  71716. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71717. * @returns the number of groups in the system
  71718. */
  71719. addPoints(nb: number, pointFunction?: any): number;
  71720. /**
  71721. * Adds points to the PCS from the surface of the model shape
  71722. * @param mesh is any Mesh object that will be used as a surface model for the points
  71723. * @param nb (positive integer) the number of particles to be created from this model
  71724. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71725. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71726. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71727. * @returns the number of groups in the system
  71728. */
  71729. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71730. /**
  71731. * Adds points to the PCS inside the model shape
  71732. * @param mesh is any Mesh object that will be used as a surface model for the points
  71733. * @param nb (positive integer) the number of particles to be created from this model
  71734. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71735. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71736. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71737. * @returns the number of groups in the system
  71738. */
  71739. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71740. /**
  71741. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71742. * This method calls `updateParticle()` for each particle of the SPS.
  71743. * For an animated SPS, it is usually called within the render loop.
  71744. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71745. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71746. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71747. * @returns the PCS.
  71748. */
  71749. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71750. /**
  71751. * Disposes the PCS.
  71752. */
  71753. dispose(): void;
  71754. /**
  71755. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71756. * doc :
  71757. * @returns the PCS.
  71758. */
  71759. refreshVisibleSize(): PointsCloudSystem;
  71760. /**
  71761. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71762. * @param size the size (float) of the visibility box
  71763. * note : this doesn't lock the PCS mesh bounding box.
  71764. * doc :
  71765. */
  71766. setVisibilityBox(size: number): void;
  71767. /**
  71768. * Gets whether the PCS is always visible or not
  71769. * doc :
  71770. */
  71771. get isAlwaysVisible(): boolean;
  71772. /**
  71773. * Sets the PCS as always visible or not
  71774. * doc :
  71775. */
  71776. set isAlwaysVisible(val: boolean);
  71777. /**
  71778. * Tells to `setParticles()` to compute the particle rotations or not
  71779. * Default value : false. The PCS is faster when it's set to false
  71780. * Note : particle rotations are only applied to parent particles
  71781. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71782. */
  71783. set computeParticleRotation(val: boolean);
  71784. /**
  71785. * Tells to `setParticles()` to compute the particle colors or not.
  71786. * Default value : true. The PCS is faster when it's set to false.
  71787. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71788. */
  71789. set computeParticleColor(val: boolean);
  71790. set computeParticleTexture(val: boolean);
  71791. /**
  71792. * Gets if `setParticles()` computes the particle colors or not.
  71793. * Default value : false. The PCS is faster when it's set to false.
  71794. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71795. */
  71796. get computeParticleColor(): boolean;
  71797. /**
  71798. * Gets if `setParticles()` computes the particle textures or not.
  71799. * Default value : false. The PCS is faster when it's set to false.
  71800. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71801. */
  71802. get computeParticleTexture(): boolean;
  71803. /**
  71804. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71805. */
  71806. set computeBoundingBox(val: boolean);
  71807. /**
  71808. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71809. */
  71810. get computeBoundingBox(): boolean;
  71811. /**
  71812. * This function does nothing. It may be overwritten to set all the particle first values.
  71813. * The PCS doesn't call this function, you may have to call it by your own.
  71814. * doc :
  71815. */
  71816. initParticles(): void;
  71817. /**
  71818. * This function does nothing. It may be overwritten to recycle a particle
  71819. * The PCS doesn't call this function, you can to call it
  71820. * doc :
  71821. * @param particle The particle to recycle
  71822. * @returns the recycled particle
  71823. */
  71824. recycleParticle(particle: CloudPoint): CloudPoint;
  71825. /**
  71826. * Updates a particle : this function should be overwritten by the user.
  71827. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71828. * doc :
  71829. * @example : just set a particle position or velocity and recycle conditions
  71830. * @param particle The particle to update
  71831. * @returns the updated particle
  71832. */
  71833. updateParticle(particle: CloudPoint): CloudPoint;
  71834. /**
  71835. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71836. * This does nothing and may be overwritten by the user.
  71837. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71838. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71839. * @param update the boolean update value actually passed to setParticles()
  71840. */
  71841. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71842. /**
  71843. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71844. * This will be passed three parameters.
  71845. * This does nothing and may be overwritten by the user.
  71846. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71847. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71848. * @param update the boolean update value actually passed to setParticles()
  71849. */
  71850. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71851. }
  71852. }
  71853. declare module "babylonjs/Particles/cloudPoint" {
  71854. import { Nullable } from "babylonjs/types";
  71855. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71856. import { Mesh } from "babylonjs/Meshes/mesh";
  71857. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71858. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71859. /**
  71860. * Represents one particle of a points cloud system.
  71861. */
  71862. export class CloudPoint {
  71863. /**
  71864. * particle global index
  71865. */
  71866. idx: number;
  71867. /**
  71868. * The color of the particle
  71869. */
  71870. color: Nullable<Color4>;
  71871. /**
  71872. * The world space position of the particle.
  71873. */
  71874. position: Vector3;
  71875. /**
  71876. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71877. */
  71878. rotation: Vector3;
  71879. /**
  71880. * The world space rotation quaternion of the particle.
  71881. */
  71882. rotationQuaternion: Nullable<Quaternion>;
  71883. /**
  71884. * The uv of the particle.
  71885. */
  71886. uv: Nullable<Vector2>;
  71887. /**
  71888. * The current speed of the particle.
  71889. */
  71890. velocity: Vector3;
  71891. /**
  71892. * The pivot point in the particle local space.
  71893. */
  71894. pivot: Vector3;
  71895. /**
  71896. * Must the particle be translated from its pivot point in its local space ?
  71897. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71898. * Default : false
  71899. */
  71900. translateFromPivot: boolean;
  71901. /**
  71902. * Index of this particle in the global "positions" array (Internal use)
  71903. * @hidden
  71904. */
  71905. _pos: number;
  71906. /**
  71907. * @hidden Index of this particle in the global "indices" array (Internal use)
  71908. */
  71909. _ind: number;
  71910. /**
  71911. * Group this particle belongs to
  71912. */
  71913. _group: PointsGroup;
  71914. /**
  71915. * Group id of this particle
  71916. */
  71917. groupId: number;
  71918. /**
  71919. * Index of the particle in its group id (Internal use)
  71920. */
  71921. idxInGroup: number;
  71922. /**
  71923. * @hidden Particle BoundingInfo object (Internal use)
  71924. */
  71925. _boundingInfo: BoundingInfo;
  71926. /**
  71927. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71928. */
  71929. _pcs: PointsCloudSystem;
  71930. /**
  71931. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71932. */
  71933. _stillInvisible: boolean;
  71934. /**
  71935. * @hidden Last computed particle rotation matrix
  71936. */
  71937. _rotationMatrix: number[];
  71938. /**
  71939. * Parent particle Id, if any.
  71940. * Default null.
  71941. */
  71942. parentId: Nullable<number>;
  71943. /**
  71944. * @hidden Internal global position in the PCS.
  71945. */
  71946. _globalPosition: Vector3;
  71947. /**
  71948. * Creates a Point Cloud object.
  71949. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71950. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71951. * @param group (PointsGroup) is the group the particle belongs to
  71952. * @param groupId (integer) is the group identifier in the PCS.
  71953. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71954. * @param pcs defines the PCS it is associated to
  71955. */
  71956. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71957. /**
  71958. * get point size
  71959. */
  71960. get size(): Vector3;
  71961. /**
  71962. * Set point size
  71963. */
  71964. set size(scale: Vector3);
  71965. /**
  71966. * Legacy support, changed quaternion to rotationQuaternion
  71967. */
  71968. get quaternion(): Nullable<Quaternion>;
  71969. /**
  71970. * Legacy support, changed quaternion to rotationQuaternion
  71971. */
  71972. set quaternion(q: Nullable<Quaternion>);
  71973. /**
  71974. * Returns a boolean. True if the particle intersects a mesh, else false
  71975. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71976. * @param target is the object (point or mesh) what the intersection is computed against
  71977. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71978. * @returns true if it intersects
  71979. */
  71980. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71981. /**
  71982. * get the rotation matrix of the particle
  71983. * @hidden
  71984. */
  71985. getRotationMatrix(m: Matrix): void;
  71986. }
  71987. /**
  71988. * Represents a group of points in a points cloud system
  71989. * * PCS internal tool, don't use it manually.
  71990. */
  71991. export class PointsGroup {
  71992. /**
  71993. * The group id
  71994. * @hidden
  71995. */
  71996. groupID: number;
  71997. /**
  71998. * image data for group (internal use)
  71999. * @hidden
  72000. */
  72001. _groupImageData: Nullable<ArrayBufferView>;
  72002. /**
  72003. * Image Width (internal use)
  72004. * @hidden
  72005. */
  72006. _groupImgWidth: number;
  72007. /**
  72008. * Image Height (internal use)
  72009. * @hidden
  72010. */
  72011. _groupImgHeight: number;
  72012. /**
  72013. * Custom position function (internal use)
  72014. * @hidden
  72015. */
  72016. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72017. /**
  72018. * density per facet for surface points
  72019. * @hidden
  72020. */
  72021. _groupDensity: number[];
  72022. /**
  72023. * Only when points are colored by texture carries pointer to texture list array
  72024. * @hidden
  72025. */
  72026. _textureNb: number;
  72027. /**
  72028. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72029. * PCS internal tool, don't use it manually.
  72030. * @hidden
  72031. */
  72032. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72033. }
  72034. }
  72035. declare module "babylonjs/Particles/index" {
  72036. export * from "babylonjs/Particles/baseParticleSystem";
  72037. export * from "babylonjs/Particles/EmitterTypes/index";
  72038. export * from "babylonjs/Particles/gpuParticleSystem";
  72039. export * from "babylonjs/Particles/IParticleSystem";
  72040. export * from "babylonjs/Particles/particle";
  72041. export * from "babylonjs/Particles/particleHelper";
  72042. export * from "babylonjs/Particles/particleSystem";
  72043. import "babylonjs/Particles/particleSystemComponent";
  72044. export * from "babylonjs/Particles/particleSystemComponent";
  72045. export * from "babylonjs/Particles/particleSystemSet";
  72046. export * from "babylonjs/Particles/solidParticle";
  72047. export * from "babylonjs/Particles/solidParticleSystem";
  72048. export * from "babylonjs/Particles/cloudPoint";
  72049. export * from "babylonjs/Particles/pointsCloudSystem";
  72050. export * from "babylonjs/Particles/subEmitter";
  72051. }
  72052. declare module "babylonjs/Physics/physicsEngineComponent" {
  72053. import { Nullable } from "babylonjs/types";
  72054. import { Observable, Observer } from "babylonjs/Misc/observable";
  72055. import { Vector3 } from "babylonjs/Maths/math.vector";
  72056. import { Mesh } from "babylonjs/Meshes/mesh";
  72057. import { ISceneComponent } from "babylonjs/sceneComponent";
  72058. import { Scene } from "babylonjs/scene";
  72059. import { Node } from "babylonjs/node";
  72060. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72061. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72062. module "babylonjs/scene" {
  72063. interface Scene {
  72064. /** @hidden (Backing field) */
  72065. _physicsEngine: Nullable<IPhysicsEngine>;
  72066. /** @hidden */
  72067. _physicsTimeAccumulator: number;
  72068. /**
  72069. * Gets the current physics engine
  72070. * @returns a IPhysicsEngine or null if none attached
  72071. */
  72072. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72073. /**
  72074. * Enables physics to the current scene
  72075. * @param gravity defines the scene's gravity for the physics engine
  72076. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72077. * @return a boolean indicating if the physics engine was initialized
  72078. */
  72079. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72080. /**
  72081. * Disables and disposes the physics engine associated with the scene
  72082. */
  72083. disablePhysicsEngine(): void;
  72084. /**
  72085. * Gets a boolean indicating if there is an active physics engine
  72086. * @returns a boolean indicating if there is an active physics engine
  72087. */
  72088. isPhysicsEnabled(): boolean;
  72089. /**
  72090. * Deletes a physics compound impostor
  72091. * @param compound defines the compound to delete
  72092. */
  72093. deleteCompoundImpostor(compound: any): void;
  72094. /**
  72095. * An event triggered when physic simulation is about to be run
  72096. */
  72097. onBeforePhysicsObservable: Observable<Scene>;
  72098. /**
  72099. * An event triggered when physic simulation has been done
  72100. */
  72101. onAfterPhysicsObservable: Observable<Scene>;
  72102. }
  72103. }
  72104. module "babylonjs/Meshes/abstractMesh" {
  72105. interface AbstractMesh {
  72106. /** @hidden */
  72107. _physicsImpostor: Nullable<PhysicsImpostor>;
  72108. /**
  72109. * Gets or sets impostor used for physic simulation
  72110. * @see https://doc.babylonjs.com/features/physics_engine
  72111. */
  72112. physicsImpostor: Nullable<PhysicsImpostor>;
  72113. /**
  72114. * Gets the current physics impostor
  72115. * @see https://doc.babylonjs.com/features/physics_engine
  72116. * @returns a physics impostor or null
  72117. */
  72118. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72119. /** Apply a physic impulse to the mesh
  72120. * @param force defines the force to apply
  72121. * @param contactPoint defines where to apply the force
  72122. * @returns the current mesh
  72123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72124. */
  72125. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72126. /**
  72127. * Creates a physic joint between two meshes
  72128. * @param otherMesh defines the other mesh to use
  72129. * @param pivot1 defines the pivot to use on this mesh
  72130. * @param pivot2 defines the pivot to use on the other mesh
  72131. * @param options defines additional options (can be plugin dependent)
  72132. * @returns the current mesh
  72133. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72134. */
  72135. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72136. /** @hidden */
  72137. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72138. }
  72139. }
  72140. /**
  72141. * Defines the physics engine scene component responsible to manage a physics engine
  72142. */
  72143. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72144. /**
  72145. * The component name helpful to identify the component in the list of scene components.
  72146. */
  72147. readonly name: string;
  72148. /**
  72149. * The scene the component belongs to.
  72150. */
  72151. scene: Scene;
  72152. /**
  72153. * Creates a new instance of the component for the given scene
  72154. * @param scene Defines the scene to register the component in
  72155. */
  72156. constructor(scene: Scene);
  72157. /**
  72158. * Registers the component in a given scene
  72159. */
  72160. register(): void;
  72161. /**
  72162. * Rebuilds the elements related to this component in case of
  72163. * context lost for instance.
  72164. */
  72165. rebuild(): void;
  72166. /**
  72167. * Disposes the component and the associated ressources
  72168. */
  72169. dispose(): void;
  72170. }
  72171. }
  72172. declare module "babylonjs/Physics/physicsHelper" {
  72173. import { Nullable } from "babylonjs/types";
  72174. import { Vector3 } from "babylonjs/Maths/math.vector";
  72175. import { Mesh } from "babylonjs/Meshes/mesh";
  72176. import { Scene } from "babylonjs/scene";
  72177. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72178. /**
  72179. * A helper for physics simulations
  72180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72181. */
  72182. export class PhysicsHelper {
  72183. private _scene;
  72184. private _physicsEngine;
  72185. /**
  72186. * Initializes the Physics helper
  72187. * @param scene Babylon.js scene
  72188. */
  72189. constructor(scene: Scene);
  72190. /**
  72191. * Applies a radial explosion impulse
  72192. * @param origin the origin of the explosion
  72193. * @param radiusOrEventOptions the radius or the options of radial explosion
  72194. * @param strength the explosion strength
  72195. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72196. * @returns A physics radial explosion event, or null
  72197. */
  72198. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72199. /**
  72200. * Applies a radial explosion force
  72201. * @param origin the origin of the explosion
  72202. * @param radiusOrEventOptions the radius or the options of radial explosion
  72203. * @param strength the explosion strength
  72204. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72205. * @returns A physics radial explosion event, or null
  72206. */
  72207. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72208. /**
  72209. * Creates a gravitational field
  72210. * @param origin the origin of the explosion
  72211. * @param radiusOrEventOptions the radius or the options of radial explosion
  72212. * @param strength the explosion strength
  72213. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72214. * @returns A physics gravitational field event, or null
  72215. */
  72216. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72217. /**
  72218. * Creates a physics updraft event
  72219. * @param origin the origin of the updraft
  72220. * @param radiusOrEventOptions the radius or the options of the updraft
  72221. * @param strength the strength of the updraft
  72222. * @param height the height of the updraft
  72223. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72224. * @returns A physics updraft event, or null
  72225. */
  72226. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72227. /**
  72228. * Creates a physics vortex event
  72229. * @param origin the of the vortex
  72230. * @param radiusOrEventOptions the radius or the options of the vortex
  72231. * @param strength the strength of the vortex
  72232. * @param height the height of the vortex
  72233. * @returns a Physics vortex event, or null
  72234. * A physics vortex event or null
  72235. */
  72236. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72237. }
  72238. /**
  72239. * Represents a physics radial explosion event
  72240. */
  72241. class PhysicsRadialExplosionEvent {
  72242. private _scene;
  72243. private _options;
  72244. private _sphere;
  72245. private _dataFetched;
  72246. /**
  72247. * Initializes a radial explosioin event
  72248. * @param _scene BabylonJS scene
  72249. * @param _options The options for the vortex event
  72250. */
  72251. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72252. /**
  72253. * Returns the data related to the radial explosion event (sphere).
  72254. * @returns The radial explosion event data
  72255. */
  72256. getData(): PhysicsRadialExplosionEventData;
  72257. /**
  72258. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72259. * @param impostor A physics imposter
  72260. * @param origin the origin of the explosion
  72261. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72262. */
  72263. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72264. /**
  72265. * Triggers affecterd impostors callbacks
  72266. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72267. */
  72268. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72269. /**
  72270. * Disposes the sphere.
  72271. * @param force Specifies if the sphere should be disposed by force
  72272. */
  72273. dispose(force?: boolean): void;
  72274. /*** Helpers ***/
  72275. private _prepareSphere;
  72276. private _intersectsWithSphere;
  72277. }
  72278. /**
  72279. * Represents a gravitational field event
  72280. */
  72281. class PhysicsGravitationalFieldEvent {
  72282. private _physicsHelper;
  72283. private _scene;
  72284. private _origin;
  72285. private _options;
  72286. private _tickCallback;
  72287. private _sphere;
  72288. private _dataFetched;
  72289. /**
  72290. * Initializes the physics gravitational field event
  72291. * @param _physicsHelper A physics helper
  72292. * @param _scene BabylonJS scene
  72293. * @param _origin The origin position of the gravitational field event
  72294. * @param _options The options for the vortex event
  72295. */
  72296. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72297. /**
  72298. * Returns the data related to the gravitational field event (sphere).
  72299. * @returns A gravitational field event
  72300. */
  72301. getData(): PhysicsGravitationalFieldEventData;
  72302. /**
  72303. * Enables the gravitational field.
  72304. */
  72305. enable(): void;
  72306. /**
  72307. * Disables the gravitational field.
  72308. */
  72309. disable(): void;
  72310. /**
  72311. * Disposes the sphere.
  72312. * @param force The force to dispose from the gravitational field event
  72313. */
  72314. dispose(force?: boolean): void;
  72315. private _tick;
  72316. }
  72317. /**
  72318. * Represents a physics updraft event
  72319. */
  72320. class PhysicsUpdraftEvent {
  72321. private _scene;
  72322. private _origin;
  72323. private _options;
  72324. private _physicsEngine;
  72325. private _originTop;
  72326. private _originDirection;
  72327. private _tickCallback;
  72328. private _cylinder;
  72329. private _cylinderPosition;
  72330. private _dataFetched;
  72331. /**
  72332. * Initializes the physics updraft event
  72333. * @param _scene BabylonJS scene
  72334. * @param _origin The origin position of the updraft
  72335. * @param _options The options for the updraft event
  72336. */
  72337. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72338. /**
  72339. * Returns the data related to the updraft event (cylinder).
  72340. * @returns A physics updraft event
  72341. */
  72342. getData(): PhysicsUpdraftEventData;
  72343. /**
  72344. * Enables the updraft.
  72345. */
  72346. enable(): void;
  72347. /**
  72348. * Disables the updraft.
  72349. */
  72350. disable(): void;
  72351. /**
  72352. * Disposes the cylinder.
  72353. * @param force Specifies if the updraft should be disposed by force
  72354. */
  72355. dispose(force?: boolean): void;
  72356. private getImpostorHitData;
  72357. private _tick;
  72358. /*** Helpers ***/
  72359. private _prepareCylinder;
  72360. private _intersectsWithCylinder;
  72361. }
  72362. /**
  72363. * Represents a physics vortex event
  72364. */
  72365. class PhysicsVortexEvent {
  72366. private _scene;
  72367. private _origin;
  72368. private _options;
  72369. private _physicsEngine;
  72370. private _originTop;
  72371. private _tickCallback;
  72372. private _cylinder;
  72373. private _cylinderPosition;
  72374. private _dataFetched;
  72375. /**
  72376. * Initializes the physics vortex event
  72377. * @param _scene The BabylonJS scene
  72378. * @param _origin The origin position of the vortex
  72379. * @param _options The options for the vortex event
  72380. */
  72381. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72382. /**
  72383. * Returns the data related to the vortex event (cylinder).
  72384. * @returns The physics vortex event data
  72385. */
  72386. getData(): PhysicsVortexEventData;
  72387. /**
  72388. * Enables the vortex.
  72389. */
  72390. enable(): void;
  72391. /**
  72392. * Disables the cortex.
  72393. */
  72394. disable(): void;
  72395. /**
  72396. * Disposes the sphere.
  72397. * @param force
  72398. */
  72399. dispose(force?: boolean): void;
  72400. private getImpostorHitData;
  72401. private _tick;
  72402. /*** Helpers ***/
  72403. private _prepareCylinder;
  72404. private _intersectsWithCylinder;
  72405. }
  72406. /**
  72407. * Options fot the radial explosion event
  72408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72409. */
  72410. export class PhysicsRadialExplosionEventOptions {
  72411. /**
  72412. * The radius of the sphere for the radial explosion.
  72413. */
  72414. radius: number;
  72415. /**
  72416. * The strenth of the explosion.
  72417. */
  72418. strength: number;
  72419. /**
  72420. * The strenght of the force in correspondence to the distance of the affected object
  72421. */
  72422. falloff: PhysicsRadialImpulseFalloff;
  72423. /**
  72424. * Sphere options for the radial explosion.
  72425. */
  72426. sphere: {
  72427. segments: number;
  72428. diameter: number;
  72429. };
  72430. /**
  72431. * Sphere options for the radial explosion.
  72432. */
  72433. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72434. }
  72435. /**
  72436. * Options fot the updraft event
  72437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72438. */
  72439. export class PhysicsUpdraftEventOptions {
  72440. /**
  72441. * The radius of the cylinder for the vortex
  72442. */
  72443. radius: number;
  72444. /**
  72445. * The strenth of the updraft.
  72446. */
  72447. strength: number;
  72448. /**
  72449. * The height of the cylinder for the updraft.
  72450. */
  72451. height: number;
  72452. /**
  72453. * The mode for the the updraft.
  72454. */
  72455. updraftMode: PhysicsUpdraftMode;
  72456. }
  72457. /**
  72458. * Options fot the vortex event
  72459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72460. */
  72461. export class PhysicsVortexEventOptions {
  72462. /**
  72463. * The radius of the cylinder for the vortex
  72464. */
  72465. radius: number;
  72466. /**
  72467. * The strenth of the vortex.
  72468. */
  72469. strength: number;
  72470. /**
  72471. * The height of the cylinder for the vortex.
  72472. */
  72473. height: number;
  72474. /**
  72475. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72476. */
  72477. centripetalForceThreshold: number;
  72478. /**
  72479. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72480. */
  72481. centripetalForceMultiplier: number;
  72482. /**
  72483. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72484. */
  72485. centrifugalForceMultiplier: number;
  72486. /**
  72487. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72488. */
  72489. updraftForceMultiplier: number;
  72490. }
  72491. /**
  72492. * The strenght of the force in correspondence to the distance of the affected object
  72493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72494. */
  72495. export enum PhysicsRadialImpulseFalloff {
  72496. /** Defines that impulse is constant in strength across it's whole radius */
  72497. Constant = 0,
  72498. /** Defines that impulse gets weaker if it's further from the origin */
  72499. Linear = 1
  72500. }
  72501. /**
  72502. * The strength of the force in correspondence to the distance of the affected object
  72503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72504. */
  72505. export enum PhysicsUpdraftMode {
  72506. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72507. Center = 0,
  72508. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72509. Perpendicular = 1
  72510. }
  72511. /**
  72512. * Interface for a physics hit data
  72513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72514. */
  72515. export interface PhysicsHitData {
  72516. /**
  72517. * The force applied at the contact point
  72518. */
  72519. force: Vector3;
  72520. /**
  72521. * The contact point
  72522. */
  72523. contactPoint: Vector3;
  72524. /**
  72525. * The distance from the origin to the contact point
  72526. */
  72527. distanceFromOrigin: number;
  72528. }
  72529. /**
  72530. * Interface for radial explosion event data
  72531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72532. */
  72533. export interface PhysicsRadialExplosionEventData {
  72534. /**
  72535. * A sphere used for the radial explosion event
  72536. */
  72537. sphere: Mesh;
  72538. }
  72539. /**
  72540. * Interface for gravitational field event data
  72541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72542. */
  72543. export interface PhysicsGravitationalFieldEventData {
  72544. /**
  72545. * A sphere mesh used for the gravitational field event
  72546. */
  72547. sphere: Mesh;
  72548. }
  72549. /**
  72550. * Interface for updraft event data
  72551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72552. */
  72553. export interface PhysicsUpdraftEventData {
  72554. /**
  72555. * A cylinder used for the updraft event
  72556. */
  72557. cylinder: Mesh;
  72558. }
  72559. /**
  72560. * Interface for vortex event data
  72561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72562. */
  72563. export interface PhysicsVortexEventData {
  72564. /**
  72565. * A cylinder used for the vortex event
  72566. */
  72567. cylinder: Mesh;
  72568. }
  72569. /**
  72570. * Interface for an affected physics impostor
  72571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72572. */
  72573. export interface PhysicsAffectedImpostorWithData {
  72574. /**
  72575. * The impostor affected by the effect
  72576. */
  72577. impostor: PhysicsImpostor;
  72578. /**
  72579. * The data about the hit/horce from the explosion
  72580. */
  72581. hitData: PhysicsHitData;
  72582. }
  72583. }
  72584. declare module "babylonjs/Physics/Plugins/index" {
  72585. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72586. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72587. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72588. }
  72589. declare module "babylonjs/Physics/index" {
  72590. export * from "babylonjs/Physics/IPhysicsEngine";
  72591. export * from "babylonjs/Physics/physicsEngine";
  72592. export * from "babylonjs/Physics/physicsEngineComponent";
  72593. export * from "babylonjs/Physics/physicsHelper";
  72594. export * from "babylonjs/Physics/physicsImpostor";
  72595. export * from "babylonjs/Physics/physicsJoint";
  72596. export * from "babylonjs/Physics/Plugins/index";
  72597. }
  72598. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72599. /** @hidden */
  72600. export var blackAndWhitePixelShader: {
  72601. name: string;
  72602. shader: string;
  72603. };
  72604. }
  72605. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72606. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72607. import { Camera } from "babylonjs/Cameras/camera";
  72608. import { Engine } from "babylonjs/Engines/engine";
  72609. import "babylonjs/Shaders/blackAndWhite.fragment";
  72610. import { Nullable } from "babylonjs/types";
  72611. import { Scene } from "babylonjs/scene";
  72612. /**
  72613. * Post process used to render in black and white
  72614. */
  72615. export class BlackAndWhitePostProcess extends PostProcess {
  72616. /**
  72617. * Linear about to convert he result to black and white (default: 1)
  72618. */
  72619. degree: number;
  72620. /**
  72621. * Gets a string identifying the name of the class
  72622. * @returns "BlackAndWhitePostProcess" string
  72623. */
  72624. getClassName(): string;
  72625. /**
  72626. * Creates a black and white post process
  72627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72628. * @param name The name of the effect.
  72629. * @param options The required width/height ratio to downsize to before computing the render pass.
  72630. * @param camera The camera to apply the render pass to.
  72631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72632. * @param engine The engine which the post process will be applied. (default: current engine)
  72633. * @param reusable If the post process can be reused on the same frame. (default: false)
  72634. */
  72635. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72636. /** @hidden */
  72637. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72638. }
  72639. }
  72640. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72641. import { Nullable } from "babylonjs/types";
  72642. import { Camera } from "babylonjs/Cameras/camera";
  72643. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72644. import { Engine } from "babylonjs/Engines/engine";
  72645. /**
  72646. * This represents a set of one or more post processes in Babylon.
  72647. * A post process can be used to apply a shader to a texture after it is rendered.
  72648. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72649. */
  72650. export class PostProcessRenderEffect {
  72651. private _postProcesses;
  72652. private _getPostProcesses;
  72653. private _singleInstance;
  72654. private _cameras;
  72655. private _indicesForCamera;
  72656. /**
  72657. * Name of the effect
  72658. * @hidden
  72659. */
  72660. _name: string;
  72661. /**
  72662. * Instantiates a post process render effect.
  72663. * A post process can be used to apply a shader to a texture after it is rendered.
  72664. * @param engine The engine the effect is tied to
  72665. * @param name The name of the effect
  72666. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72667. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72668. */
  72669. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72670. /**
  72671. * Checks if all the post processes in the effect are supported.
  72672. */
  72673. get isSupported(): boolean;
  72674. /**
  72675. * Updates the current state of the effect
  72676. * @hidden
  72677. */
  72678. _update(): void;
  72679. /**
  72680. * Attaches the effect on cameras
  72681. * @param cameras The camera to attach to.
  72682. * @hidden
  72683. */
  72684. _attachCameras(cameras: Camera): void;
  72685. /**
  72686. * Attaches the effect on cameras
  72687. * @param cameras The camera to attach to.
  72688. * @hidden
  72689. */
  72690. _attachCameras(cameras: Camera[]): void;
  72691. /**
  72692. * Detaches the effect on cameras
  72693. * @param cameras The camera to detatch from.
  72694. * @hidden
  72695. */
  72696. _detachCameras(cameras: Camera): void;
  72697. /**
  72698. * Detatches the effect on cameras
  72699. * @param cameras The camera to detatch from.
  72700. * @hidden
  72701. */
  72702. _detachCameras(cameras: Camera[]): void;
  72703. /**
  72704. * Enables the effect on given cameras
  72705. * @param cameras The camera to enable.
  72706. * @hidden
  72707. */
  72708. _enable(cameras: Camera): void;
  72709. /**
  72710. * Enables the effect on given cameras
  72711. * @param cameras The camera to enable.
  72712. * @hidden
  72713. */
  72714. _enable(cameras: Nullable<Camera[]>): void;
  72715. /**
  72716. * Disables the effect on the given cameras
  72717. * @param cameras The camera to disable.
  72718. * @hidden
  72719. */
  72720. _disable(cameras: Camera): void;
  72721. /**
  72722. * Disables the effect on the given cameras
  72723. * @param cameras The camera to disable.
  72724. * @hidden
  72725. */
  72726. _disable(cameras: Nullable<Camera[]>): void;
  72727. /**
  72728. * Gets a list of the post processes contained in the effect.
  72729. * @param camera The camera to get the post processes on.
  72730. * @returns The list of the post processes in the effect.
  72731. */
  72732. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72733. }
  72734. }
  72735. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72737. /** @hidden */
  72738. export var extractHighlightsPixelShader: {
  72739. name: string;
  72740. shader: string;
  72741. };
  72742. }
  72743. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72744. import { Nullable } from "babylonjs/types";
  72745. import { Camera } from "babylonjs/Cameras/camera";
  72746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72747. import { Engine } from "babylonjs/Engines/engine";
  72748. import "babylonjs/Shaders/extractHighlights.fragment";
  72749. /**
  72750. * 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.
  72751. */
  72752. export class ExtractHighlightsPostProcess extends PostProcess {
  72753. /**
  72754. * The luminance threshold, pixels below this value will be set to black.
  72755. */
  72756. threshold: number;
  72757. /** @hidden */
  72758. _exposure: number;
  72759. /**
  72760. * Post process which has the input texture to be used when performing highlight extraction
  72761. * @hidden
  72762. */
  72763. _inputPostProcess: Nullable<PostProcess>;
  72764. /**
  72765. * Gets a string identifying the name of the class
  72766. * @returns "ExtractHighlightsPostProcess" string
  72767. */
  72768. getClassName(): string;
  72769. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72770. }
  72771. }
  72772. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72773. /** @hidden */
  72774. export var bloomMergePixelShader: {
  72775. name: string;
  72776. shader: string;
  72777. };
  72778. }
  72779. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72780. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72781. import { Nullable } from "babylonjs/types";
  72782. import { Engine } from "babylonjs/Engines/engine";
  72783. import { Camera } from "babylonjs/Cameras/camera";
  72784. import "babylonjs/Shaders/bloomMerge.fragment";
  72785. /**
  72786. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72787. */
  72788. export class BloomMergePostProcess extends PostProcess {
  72789. /** Weight of the bloom to be added to the original input. */
  72790. weight: number;
  72791. /**
  72792. * Gets a string identifying the name of the class
  72793. * @returns "BloomMergePostProcess" string
  72794. */
  72795. getClassName(): string;
  72796. /**
  72797. * Creates a new instance of @see BloomMergePostProcess
  72798. * @param name The name of the effect.
  72799. * @param originalFromInput Post process which's input will be used for the merge.
  72800. * @param blurred Blurred highlights post process which's output will be used.
  72801. * @param weight Weight of the bloom to be added to the original input.
  72802. * @param options The required width/height ratio to downsize to before computing the render pass.
  72803. * @param camera The camera to apply the render pass to.
  72804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72805. * @param engine The engine which the post process will be applied. (default: current engine)
  72806. * @param reusable If the post process can be reused on the same frame. (default: false)
  72807. * @param textureType Type of textures used when performing the post process. (default: 0)
  72808. * @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)
  72809. */
  72810. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72811. /** Weight of the bloom to be added to the original input. */
  72812. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72813. }
  72814. }
  72815. declare module "babylonjs/PostProcesses/bloomEffect" {
  72816. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72817. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72818. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72819. import { Camera } from "babylonjs/Cameras/camera";
  72820. import { Scene } from "babylonjs/scene";
  72821. /**
  72822. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72823. */
  72824. export class BloomEffect extends PostProcessRenderEffect {
  72825. private bloomScale;
  72826. /**
  72827. * @hidden Internal
  72828. */
  72829. _effects: Array<PostProcess>;
  72830. /**
  72831. * @hidden Internal
  72832. */
  72833. _downscale: ExtractHighlightsPostProcess;
  72834. private _blurX;
  72835. private _blurY;
  72836. private _merge;
  72837. /**
  72838. * The luminance threshold to find bright areas of the image to bloom.
  72839. */
  72840. get threshold(): number;
  72841. set threshold(value: number);
  72842. /**
  72843. * The strength of the bloom.
  72844. */
  72845. get weight(): number;
  72846. set weight(value: number);
  72847. /**
  72848. * Specifies the size of the bloom blur kernel, relative to the final output size
  72849. */
  72850. get kernel(): number;
  72851. set kernel(value: number);
  72852. /**
  72853. * Creates a new instance of @see BloomEffect
  72854. * @param scene The scene the effect belongs to.
  72855. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72856. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72857. * @param bloomWeight The the strength of bloom.
  72858. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72859. * @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)
  72860. */
  72861. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72862. /**
  72863. * Disposes each of the internal effects for a given camera.
  72864. * @param camera The camera to dispose the effect on.
  72865. */
  72866. disposeEffects(camera: Camera): void;
  72867. /**
  72868. * @hidden Internal
  72869. */
  72870. _updateEffects(): void;
  72871. /**
  72872. * Internal
  72873. * @returns if all the contained post processes are ready.
  72874. * @hidden
  72875. */
  72876. _isReady(): boolean;
  72877. }
  72878. }
  72879. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72880. /** @hidden */
  72881. export var chromaticAberrationPixelShader: {
  72882. name: string;
  72883. shader: string;
  72884. };
  72885. }
  72886. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72887. import { Vector2 } from "babylonjs/Maths/math.vector";
  72888. import { Nullable } from "babylonjs/types";
  72889. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72890. import { Camera } from "babylonjs/Cameras/camera";
  72891. import { Engine } from "babylonjs/Engines/engine";
  72892. import "babylonjs/Shaders/chromaticAberration.fragment";
  72893. import { Scene } from "babylonjs/scene";
  72894. /**
  72895. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72896. */
  72897. export class ChromaticAberrationPostProcess extends PostProcess {
  72898. /**
  72899. * The amount of seperation of rgb channels (default: 30)
  72900. */
  72901. aberrationAmount: number;
  72902. /**
  72903. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72904. */
  72905. radialIntensity: number;
  72906. /**
  72907. * 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))
  72908. */
  72909. direction: Vector2;
  72910. /**
  72911. * 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))
  72912. */
  72913. centerPosition: Vector2;
  72914. /** The width of the screen to apply the effect on */
  72915. screenWidth: number;
  72916. /** The height of the screen to apply the effect on */
  72917. screenHeight: number;
  72918. /**
  72919. * Gets a string identifying the name of the class
  72920. * @returns "ChromaticAberrationPostProcess" string
  72921. */
  72922. getClassName(): string;
  72923. /**
  72924. * Creates a new instance ChromaticAberrationPostProcess
  72925. * @param name The name of the effect.
  72926. * @param screenWidth The width of the screen to apply the effect on.
  72927. * @param screenHeight The height of the screen to apply the effect on.
  72928. * @param options The required width/height ratio to downsize to before computing the render pass.
  72929. * @param camera The camera to apply the render pass to.
  72930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72931. * @param engine The engine which the post process will be applied. (default: current engine)
  72932. * @param reusable If the post process can be reused on the same frame. (default: false)
  72933. * @param textureType Type of textures used when performing the post process. (default: 0)
  72934. * @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)
  72935. */
  72936. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72937. /** @hidden */
  72938. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  72939. }
  72940. }
  72941. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72942. /** @hidden */
  72943. export var circleOfConfusionPixelShader: {
  72944. name: string;
  72945. shader: string;
  72946. };
  72947. }
  72948. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72949. import { Nullable } from "babylonjs/types";
  72950. import { Engine } from "babylonjs/Engines/engine";
  72951. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72952. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72953. import { Camera } from "babylonjs/Cameras/camera";
  72954. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72955. /**
  72956. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72957. */
  72958. export class CircleOfConfusionPostProcess extends PostProcess {
  72959. /**
  72960. * 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.
  72961. */
  72962. lensSize: number;
  72963. /**
  72964. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72965. */
  72966. fStop: number;
  72967. /**
  72968. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72969. */
  72970. focusDistance: number;
  72971. /**
  72972. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72973. */
  72974. focalLength: number;
  72975. /**
  72976. * Gets a string identifying the name of the class
  72977. * @returns "CircleOfConfusionPostProcess" string
  72978. */
  72979. getClassName(): string;
  72980. private _depthTexture;
  72981. /**
  72982. * Creates a new instance CircleOfConfusionPostProcess
  72983. * @param name The name of the effect.
  72984. * @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.
  72985. * @param options The required width/height ratio to downsize to before computing the render pass.
  72986. * @param camera The camera to apply the render pass to.
  72987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72988. * @param engine The engine which the post process will be applied. (default: current engine)
  72989. * @param reusable If the post process can be reused on the same frame. (default: false)
  72990. * @param textureType Type of textures used when performing the post process. (default: 0)
  72991. * @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)
  72992. */
  72993. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72994. /**
  72995. * 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.
  72996. */
  72997. set depthTexture(value: RenderTargetTexture);
  72998. }
  72999. }
  73000. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73001. /** @hidden */
  73002. export var colorCorrectionPixelShader: {
  73003. name: string;
  73004. shader: string;
  73005. };
  73006. }
  73007. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73008. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73009. import { Engine } from "babylonjs/Engines/engine";
  73010. import { Camera } from "babylonjs/Cameras/camera";
  73011. import "babylonjs/Shaders/colorCorrection.fragment";
  73012. import { Nullable } from "babylonjs/types";
  73013. import { Scene } from "babylonjs/scene";
  73014. /**
  73015. *
  73016. * This post-process allows the modification of rendered colors by using
  73017. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73018. *
  73019. * The object needs to be provided an url to a texture containing the color
  73020. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73021. * Use an image editing software to tweak the LUT to match your needs.
  73022. *
  73023. * For an example of a color LUT, see here:
  73024. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73025. * For explanations on color grading, see here:
  73026. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73027. *
  73028. */
  73029. export class ColorCorrectionPostProcess extends PostProcess {
  73030. private _colorTableTexture;
  73031. /**
  73032. * Gets the color table url used to create the LUT texture
  73033. */
  73034. colorTableUrl: string;
  73035. /**
  73036. * Gets a string identifying the name of the class
  73037. * @returns "ColorCorrectionPostProcess" string
  73038. */
  73039. getClassName(): string;
  73040. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73041. /** @hidden */
  73042. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73043. }
  73044. }
  73045. declare module "babylonjs/Shaders/convolution.fragment" {
  73046. /** @hidden */
  73047. export var convolutionPixelShader: {
  73048. name: string;
  73049. shader: string;
  73050. };
  73051. }
  73052. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73053. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73054. import { Nullable } from "babylonjs/types";
  73055. import { Camera } from "babylonjs/Cameras/camera";
  73056. import { Engine } from "babylonjs/Engines/engine";
  73057. import "babylonjs/Shaders/convolution.fragment";
  73058. import { Scene } from "babylonjs/scene";
  73059. /**
  73060. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73061. * input texture to perform effects such as edge detection or sharpening
  73062. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73063. */
  73064. export class ConvolutionPostProcess extends PostProcess {
  73065. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73066. kernel: number[];
  73067. /**
  73068. * Gets a string identifying the name of the class
  73069. * @returns "ConvolutionPostProcess" string
  73070. */
  73071. getClassName(): string;
  73072. /**
  73073. * Creates a new instance ConvolutionPostProcess
  73074. * @param name The name of the effect.
  73075. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73076. * @param options The required width/height ratio to downsize to before computing the render pass.
  73077. * @param camera The camera to apply the render pass to.
  73078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73079. * @param engine The engine which the post process will be applied. (default: current engine)
  73080. * @param reusable If the post process can be reused on the same frame. (default: false)
  73081. * @param textureType Type of textures used when performing the post process. (default: 0)
  73082. */
  73083. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73084. /** @hidden */
  73085. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73086. /**
  73087. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73088. */
  73089. static EdgeDetect0Kernel: number[];
  73090. /**
  73091. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73092. */
  73093. static EdgeDetect1Kernel: number[];
  73094. /**
  73095. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73096. */
  73097. static EdgeDetect2Kernel: number[];
  73098. /**
  73099. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73100. */
  73101. static SharpenKernel: number[];
  73102. /**
  73103. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73104. */
  73105. static EmbossKernel: number[];
  73106. /**
  73107. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73108. */
  73109. static GaussianKernel: number[];
  73110. }
  73111. }
  73112. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73113. import { Nullable } from "babylonjs/types";
  73114. import { Vector2 } from "babylonjs/Maths/math.vector";
  73115. import { Camera } from "babylonjs/Cameras/camera";
  73116. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73117. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73118. import { Engine } from "babylonjs/Engines/engine";
  73119. import { Scene } from "babylonjs/scene";
  73120. /**
  73121. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73122. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73123. * based on samples that have a large difference in distance than the center pixel.
  73124. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73125. */
  73126. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73127. /**
  73128. * The direction the blur should be applied
  73129. */
  73130. direction: Vector2;
  73131. /**
  73132. * Gets a string identifying the name of the class
  73133. * @returns "DepthOfFieldBlurPostProcess" string
  73134. */
  73135. getClassName(): string;
  73136. /**
  73137. * Creates a new instance CircleOfConfusionPostProcess
  73138. * @param name The name of the effect.
  73139. * @param scene The scene the effect belongs to.
  73140. * @param direction The direction the blur should be applied.
  73141. * @param kernel The size of the kernel used to blur.
  73142. * @param options The required width/height ratio to downsize to before computing the render pass.
  73143. * @param camera The camera to apply the render pass to.
  73144. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73145. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73147. * @param engine The engine which the post process will be applied. (default: current engine)
  73148. * @param reusable If the post process can be reused on the same frame. (default: false)
  73149. * @param textureType Type of textures used when performing the post process. (default: 0)
  73150. * @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)
  73151. */
  73152. 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);
  73153. }
  73154. }
  73155. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73156. /** @hidden */
  73157. export var depthOfFieldMergePixelShader: {
  73158. name: string;
  73159. shader: string;
  73160. };
  73161. }
  73162. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73163. import { Nullable } from "babylonjs/types";
  73164. import { Camera } from "babylonjs/Cameras/camera";
  73165. import { Effect } from "babylonjs/Materials/effect";
  73166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73167. import { Engine } from "babylonjs/Engines/engine";
  73168. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73169. /**
  73170. * Options to be set when merging outputs from the default pipeline.
  73171. */
  73172. export class DepthOfFieldMergePostProcessOptions {
  73173. /**
  73174. * The original image to merge on top of
  73175. */
  73176. originalFromInput: PostProcess;
  73177. /**
  73178. * Parameters to perform the merge of the depth of field effect
  73179. */
  73180. depthOfField?: {
  73181. circleOfConfusion: PostProcess;
  73182. blurSteps: Array<PostProcess>;
  73183. };
  73184. /**
  73185. * Parameters to perform the merge of bloom effect
  73186. */
  73187. bloom?: {
  73188. blurred: PostProcess;
  73189. weight: number;
  73190. };
  73191. }
  73192. /**
  73193. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73194. */
  73195. export class DepthOfFieldMergePostProcess extends PostProcess {
  73196. private blurSteps;
  73197. /**
  73198. * Gets a string identifying the name of the class
  73199. * @returns "DepthOfFieldMergePostProcess" string
  73200. */
  73201. getClassName(): string;
  73202. /**
  73203. * Creates a new instance of DepthOfFieldMergePostProcess
  73204. * @param name The name of the effect.
  73205. * @param originalFromInput Post process which's input will be used for the merge.
  73206. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73207. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73208. * @param options The required width/height ratio to downsize to before computing the render pass.
  73209. * @param camera The camera to apply the render pass to.
  73210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73211. * @param engine The engine which the post process will be applied. (default: current engine)
  73212. * @param reusable If the post process can be reused on the same frame. (default: false)
  73213. * @param textureType Type of textures used when performing the post process. (default: 0)
  73214. * @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)
  73215. */
  73216. 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);
  73217. /**
  73218. * Updates the effect with the current post process compile time values and recompiles the shader.
  73219. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73220. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73221. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73222. * @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
  73223. * @param onCompiled Called when the shader has been compiled.
  73224. * @param onError Called if there is an error when compiling a shader.
  73225. */
  73226. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73227. }
  73228. }
  73229. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73230. import { Nullable } from "babylonjs/types";
  73231. import { Camera } from "babylonjs/Cameras/camera";
  73232. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73233. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73234. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73235. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73236. import { Scene } from "babylonjs/scene";
  73237. /**
  73238. * Specifies the level of max blur that should be applied when using the depth of field effect
  73239. */
  73240. export enum DepthOfFieldEffectBlurLevel {
  73241. /**
  73242. * Subtle blur
  73243. */
  73244. Low = 0,
  73245. /**
  73246. * Medium blur
  73247. */
  73248. Medium = 1,
  73249. /**
  73250. * Large blur
  73251. */
  73252. High = 2
  73253. }
  73254. /**
  73255. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73256. */
  73257. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73258. private _circleOfConfusion;
  73259. /**
  73260. * @hidden Internal, blurs from high to low
  73261. */
  73262. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73263. private _depthOfFieldBlurY;
  73264. private _dofMerge;
  73265. /**
  73266. * @hidden Internal post processes in depth of field effect
  73267. */
  73268. _effects: Array<PostProcess>;
  73269. /**
  73270. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73271. */
  73272. set focalLength(value: number);
  73273. get focalLength(): number;
  73274. /**
  73275. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73276. */
  73277. set fStop(value: number);
  73278. get fStop(): number;
  73279. /**
  73280. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73281. */
  73282. set focusDistance(value: number);
  73283. get focusDistance(): number;
  73284. /**
  73285. * 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.
  73286. */
  73287. set lensSize(value: number);
  73288. get lensSize(): number;
  73289. /**
  73290. * Creates a new instance DepthOfFieldEffect
  73291. * @param scene The scene the effect belongs to.
  73292. * @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.
  73293. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73294. * @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)
  73295. */
  73296. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73297. /**
  73298. * Get the current class name of the current effet
  73299. * @returns "DepthOfFieldEffect"
  73300. */
  73301. getClassName(): string;
  73302. /**
  73303. * 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.
  73304. */
  73305. set depthTexture(value: RenderTargetTexture);
  73306. /**
  73307. * Disposes each of the internal effects for a given camera.
  73308. * @param camera The camera to dispose the effect on.
  73309. */
  73310. disposeEffects(camera: Camera): void;
  73311. /**
  73312. * @hidden Internal
  73313. */
  73314. _updateEffects(): void;
  73315. /**
  73316. * Internal
  73317. * @returns if all the contained post processes are ready.
  73318. * @hidden
  73319. */
  73320. _isReady(): boolean;
  73321. }
  73322. }
  73323. declare module "babylonjs/Shaders/displayPass.fragment" {
  73324. /** @hidden */
  73325. export var displayPassPixelShader: {
  73326. name: string;
  73327. shader: string;
  73328. };
  73329. }
  73330. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73331. import { Nullable } from "babylonjs/types";
  73332. import { Camera } from "babylonjs/Cameras/camera";
  73333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73334. import { Engine } from "babylonjs/Engines/engine";
  73335. import "babylonjs/Shaders/displayPass.fragment";
  73336. import { Scene } from "babylonjs/scene";
  73337. /**
  73338. * DisplayPassPostProcess which produces an output the same as it's input
  73339. */
  73340. export class DisplayPassPostProcess extends PostProcess {
  73341. /**
  73342. * Gets a string identifying the name of the class
  73343. * @returns "DisplayPassPostProcess" string
  73344. */
  73345. getClassName(): string;
  73346. /**
  73347. * Creates the DisplayPassPostProcess
  73348. * @param name The name of the effect.
  73349. * @param options The required width/height ratio to downsize to before computing the render pass.
  73350. * @param camera The camera to apply the render pass to.
  73351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73352. * @param engine The engine which the post process will be applied. (default: current engine)
  73353. * @param reusable If the post process can be reused on the same frame. (default: false)
  73354. */
  73355. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73356. /** @hidden */
  73357. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73358. }
  73359. }
  73360. declare module "babylonjs/Shaders/filter.fragment" {
  73361. /** @hidden */
  73362. export var filterPixelShader: {
  73363. name: string;
  73364. shader: string;
  73365. };
  73366. }
  73367. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73368. import { Nullable } from "babylonjs/types";
  73369. import { Matrix } from "babylonjs/Maths/math.vector";
  73370. import { Camera } from "babylonjs/Cameras/camera";
  73371. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73372. import { Engine } from "babylonjs/Engines/engine";
  73373. import "babylonjs/Shaders/filter.fragment";
  73374. import { Scene } from "babylonjs/scene";
  73375. /**
  73376. * Applies a kernel filter to the image
  73377. */
  73378. export class FilterPostProcess extends PostProcess {
  73379. /** The matrix to be applied to the image */
  73380. kernelMatrix: Matrix;
  73381. /**
  73382. * Gets a string identifying the name of the class
  73383. * @returns "FilterPostProcess" string
  73384. */
  73385. getClassName(): string;
  73386. /**
  73387. *
  73388. * @param name The name of the effect.
  73389. * @param kernelMatrix The matrix to be applied to the image
  73390. * @param options The required width/height ratio to downsize to before computing the render pass.
  73391. * @param camera The camera to apply the render pass to.
  73392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73393. * @param engine The engine which the post process will be applied. (default: current engine)
  73394. * @param reusable If the post process can be reused on the same frame. (default: false)
  73395. */
  73396. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73397. /** @hidden */
  73398. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73399. }
  73400. }
  73401. declare module "babylonjs/Shaders/fxaa.fragment" {
  73402. /** @hidden */
  73403. export var fxaaPixelShader: {
  73404. name: string;
  73405. shader: string;
  73406. };
  73407. }
  73408. declare module "babylonjs/Shaders/fxaa.vertex" {
  73409. /** @hidden */
  73410. export var fxaaVertexShader: {
  73411. name: string;
  73412. shader: string;
  73413. };
  73414. }
  73415. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73416. import { Nullable } from "babylonjs/types";
  73417. import { Camera } from "babylonjs/Cameras/camera";
  73418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73419. import { Engine } from "babylonjs/Engines/engine";
  73420. import "babylonjs/Shaders/fxaa.fragment";
  73421. import "babylonjs/Shaders/fxaa.vertex";
  73422. import { Scene } from "babylonjs/scene";
  73423. /**
  73424. * Fxaa post process
  73425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73426. */
  73427. export class FxaaPostProcess extends PostProcess {
  73428. /**
  73429. * Gets a string identifying the name of the class
  73430. * @returns "FxaaPostProcess" string
  73431. */
  73432. getClassName(): string;
  73433. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73434. private _getDefines;
  73435. /** @hidden */
  73436. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73437. }
  73438. }
  73439. declare module "babylonjs/Shaders/grain.fragment" {
  73440. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73441. /** @hidden */
  73442. export var grainPixelShader: {
  73443. name: string;
  73444. shader: string;
  73445. };
  73446. }
  73447. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73448. import { Nullable } from "babylonjs/types";
  73449. import { Camera } from "babylonjs/Cameras/camera";
  73450. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73451. import { Engine } from "babylonjs/Engines/engine";
  73452. import "babylonjs/Shaders/grain.fragment";
  73453. import { Scene } from "babylonjs/scene";
  73454. /**
  73455. * The GrainPostProcess adds noise to the image at mid luminance levels
  73456. */
  73457. export class GrainPostProcess extends PostProcess {
  73458. /**
  73459. * The intensity of the grain added (default: 30)
  73460. */
  73461. intensity: number;
  73462. /**
  73463. * If the grain should be randomized on every frame
  73464. */
  73465. animated: boolean;
  73466. /**
  73467. * Gets a string identifying the name of the class
  73468. * @returns "GrainPostProcess" string
  73469. */
  73470. getClassName(): string;
  73471. /**
  73472. * Creates a new instance of @see GrainPostProcess
  73473. * @param name The name of the effect.
  73474. * @param options The required width/height ratio to downsize to before computing the render pass.
  73475. * @param camera The camera to apply the render pass to.
  73476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73477. * @param engine The engine which the post process will be applied. (default: current engine)
  73478. * @param reusable If the post process can be reused on the same frame. (default: false)
  73479. * @param textureType Type of textures used when performing the post process. (default: 0)
  73480. * @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)
  73481. */
  73482. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73483. /** @hidden */
  73484. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73485. }
  73486. }
  73487. declare module "babylonjs/Shaders/highlights.fragment" {
  73488. /** @hidden */
  73489. export var highlightsPixelShader: {
  73490. name: string;
  73491. shader: string;
  73492. };
  73493. }
  73494. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73495. import { Nullable } from "babylonjs/types";
  73496. import { Camera } from "babylonjs/Cameras/camera";
  73497. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73498. import { Engine } from "babylonjs/Engines/engine";
  73499. import "babylonjs/Shaders/highlights.fragment";
  73500. /**
  73501. * Extracts highlights from the image
  73502. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73503. */
  73504. export class HighlightsPostProcess extends PostProcess {
  73505. /**
  73506. * Gets a string identifying the name of the class
  73507. * @returns "HighlightsPostProcess" string
  73508. */
  73509. getClassName(): string;
  73510. /**
  73511. * Extracts highlights from the image
  73512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73513. * @param name The name of the effect.
  73514. * @param options The required width/height ratio to downsize to before computing the render pass.
  73515. * @param camera The camera to apply the render pass to.
  73516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73517. * @param engine The engine which the post process will be applied. (default: current engine)
  73518. * @param reusable If the post process can be reused on the same frame. (default: false)
  73519. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73520. */
  73521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73522. }
  73523. }
  73524. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73525. /** @hidden */
  73526. export var mrtFragmentDeclaration: {
  73527. name: string;
  73528. shader: string;
  73529. };
  73530. }
  73531. declare module "babylonjs/Shaders/geometry.fragment" {
  73532. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73533. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73534. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73535. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73536. /** @hidden */
  73537. export var geometryPixelShader: {
  73538. name: string;
  73539. shader: string;
  73540. };
  73541. }
  73542. declare module "babylonjs/Shaders/geometry.vertex" {
  73543. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73545. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73546. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73548. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73549. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73550. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73551. /** @hidden */
  73552. export var geometryVertexShader: {
  73553. name: string;
  73554. shader: string;
  73555. };
  73556. }
  73557. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73558. import { Matrix } from "babylonjs/Maths/math.vector";
  73559. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73560. import { Mesh } from "babylonjs/Meshes/mesh";
  73561. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73562. import { Effect } from "babylonjs/Materials/effect";
  73563. import { Scene } from "babylonjs/scene";
  73564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73565. import "babylonjs/Shaders/geometry.fragment";
  73566. import "babylonjs/Shaders/geometry.vertex";
  73567. /** @hidden */
  73568. interface ISavedTransformationMatrix {
  73569. world: Matrix;
  73570. viewProjection: Matrix;
  73571. }
  73572. /**
  73573. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73574. */
  73575. export class GeometryBufferRenderer {
  73576. /**
  73577. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73578. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73579. */
  73580. static readonly POSITION_TEXTURE_TYPE: number;
  73581. /**
  73582. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73583. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73584. */
  73585. static readonly VELOCITY_TEXTURE_TYPE: number;
  73586. /**
  73587. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73588. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73589. */
  73590. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73591. /**
  73592. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73593. * in order to compute objects velocities when enableVelocity is set to "true"
  73594. * @hidden
  73595. */
  73596. _previousTransformationMatrices: {
  73597. [index: number]: ISavedTransformationMatrix;
  73598. };
  73599. /**
  73600. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73601. * in order to compute objects velocities when enableVelocity is set to "true"
  73602. * @hidden
  73603. */
  73604. _previousBonesTransformationMatrices: {
  73605. [index: number]: Float32Array;
  73606. };
  73607. /**
  73608. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73609. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73610. */
  73611. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73612. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73613. renderTransparentMeshes: boolean;
  73614. private _scene;
  73615. private _resizeObserver;
  73616. private _multiRenderTarget;
  73617. private _ratio;
  73618. private _enablePosition;
  73619. private _enableVelocity;
  73620. private _enableReflectivity;
  73621. private _positionIndex;
  73622. private _velocityIndex;
  73623. private _reflectivityIndex;
  73624. protected _effect: Effect;
  73625. protected _cachedDefines: string;
  73626. /**
  73627. * Set the render list (meshes to be rendered) used in the G buffer.
  73628. */
  73629. set renderList(meshes: Mesh[]);
  73630. /**
  73631. * Gets wether or not G buffer are supported by the running hardware.
  73632. * This requires draw buffer supports
  73633. */
  73634. get isSupported(): boolean;
  73635. /**
  73636. * Returns the index of the given texture type in the G-Buffer textures array
  73637. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73638. * @returns the index of the given texture type in the G-Buffer textures array
  73639. */
  73640. getTextureIndex(textureType: number): number;
  73641. /**
  73642. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73643. */
  73644. get enablePosition(): boolean;
  73645. /**
  73646. * Sets whether or not objects positions are enabled for the G buffer.
  73647. */
  73648. set enablePosition(enable: boolean);
  73649. /**
  73650. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73651. */
  73652. get enableVelocity(): boolean;
  73653. /**
  73654. * Sets wether or not objects velocities are enabled for the G buffer.
  73655. */
  73656. set enableVelocity(enable: boolean);
  73657. /**
  73658. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73659. */
  73660. get enableReflectivity(): boolean;
  73661. /**
  73662. * Sets wether or not objects roughness are enabled for the G buffer.
  73663. */
  73664. set enableReflectivity(enable: boolean);
  73665. /**
  73666. * Gets the scene associated with the buffer.
  73667. */
  73668. get scene(): Scene;
  73669. /**
  73670. * Gets the ratio used by the buffer during its creation.
  73671. * How big is the buffer related to the main canvas.
  73672. */
  73673. get ratio(): number;
  73674. /** @hidden */
  73675. static _SceneComponentInitialization: (scene: Scene) => void;
  73676. /**
  73677. * Creates a new G Buffer for the scene
  73678. * @param scene The scene the buffer belongs to
  73679. * @param ratio How big is the buffer related to the main canvas.
  73680. */
  73681. constructor(scene: Scene, ratio?: number);
  73682. /**
  73683. * Checks wether everything is ready to render a submesh to the G buffer.
  73684. * @param subMesh the submesh to check readiness for
  73685. * @param useInstances is the mesh drawn using instance or not
  73686. * @returns true if ready otherwise false
  73687. */
  73688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73689. /**
  73690. * Gets the current underlying G Buffer.
  73691. * @returns the buffer
  73692. */
  73693. getGBuffer(): MultiRenderTarget;
  73694. /**
  73695. * Gets the number of samples used to render the buffer (anti aliasing).
  73696. */
  73697. get samples(): number;
  73698. /**
  73699. * Sets the number of samples used to render the buffer (anti aliasing).
  73700. */
  73701. set samples(value: number);
  73702. /**
  73703. * Disposes the renderer and frees up associated resources.
  73704. */
  73705. dispose(): void;
  73706. protected _createRenderTargets(): void;
  73707. private _copyBonesTransformationMatrices;
  73708. }
  73709. }
  73710. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73711. import { Nullable } from "babylonjs/types";
  73712. import { Scene } from "babylonjs/scene";
  73713. import { ISceneComponent } from "babylonjs/sceneComponent";
  73714. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73715. module "babylonjs/scene" {
  73716. interface Scene {
  73717. /** @hidden (Backing field) */
  73718. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73719. /**
  73720. * Gets or Sets the current geometry buffer associated to the scene.
  73721. */
  73722. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73723. /**
  73724. * Enables a GeometryBufferRender and associates it with the scene
  73725. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73726. * @returns the GeometryBufferRenderer
  73727. */
  73728. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73729. /**
  73730. * Disables the GeometryBufferRender associated with the scene
  73731. */
  73732. disableGeometryBufferRenderer(): void;
  73733. }
  73734. }
  73735. /**
  73736. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73737. * in several rendering techniques.
  73738. */
  73739. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73740. /**
  73741. * The component name helpful to identify the component in the list of scene components.
  73742. */
  73743. readonly name: string;
  73744. /**
  73745. * The scene the component belongs to.
  73746. */
  73747. scene: Scene;
  73748. /**
  73749. * Creates a new instance of the component for the given scene
  73750. * @param scene Defines the scene to register the component in
  73751. */
  73752. constructor(scene: Scene);
  73753. /**
  73754. * Registers the component in a given scene
  73755. */
  73756. register(): void;
  73757. /**
  73758. * Rebuilds the elements related to this component in case of
  73759. * context lost for instance.
  73760. */
  73761. rebuild(): void;
  73762. /**
  73763. * Disposes the component and the associated ressources
  73764. */
  73765. dispose(): void;
  73766. private _gatherRenderTargets;
  73767. }
  73768. }
  73769. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73770. /** @hidden */
  73771. export var motionBlurPixelShader: {
  73772. name: string;
  73773. shader: string;
  73774. };
  73775. }
  73776. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73777. import { Nullable } from "babylonjs/types";
  73778. import { Camera } from "babylonjs/Cameras/camera";
  73779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73781. import "babylonjs/Animations/animatable";
  73782. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73783. import "babylonjs/Shaders/motionBlur.fragment";
  73784. import { Engine } from "babylonjs/Engines/engine";
  73785. import { Scene } from "babylonjs/scene";
  73786. /**
  73787. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73788. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73789. * As an example, all you have to do is to create the post-process:
  73790. * var mb = new BABYLON.MotionBlurPostProcess(
  73791. * 'mb', // The name of the effect.
  73792. * scene, // The scene containing the objects to blur according to their velocity.
  73793. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73794. * camera // The camera to apply the render pass to.
  73795. * );
  73796. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73797. */
  73798. export class MotionBlurPostProcess extends PostProcess {
  73799. /**
  73800. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73801. */
  73802. motionStrength: number;
  73803. /**
  73804. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73805. */
  73806. get motionBlurSamples(): number;
  73807. /**
  73808. * Sets the number of iterations to be used for motion blur quality
  73809. */
  73810. set motionBlurSamples(samples: number);
  73811. private _motionBlurSamples;
  73812. private _geometryBufferRenderer;
  73813. /**
  73814. * Gets a string identifying the name of the class
  73815. * @returns "MotionBlurPostProcess" string
  73816. */
  73817. getClassName(): string;
  73818. /**
  73819. * Creates a new instance MotionBlurPostProcess
  73820. * @param name The name of the effect.
  73821. * @param scene The scene containing the objects to blur according to their velocity.
  73822. * @param options The required width/height ratio to downsize to before computing the render pass.
  73823. * @param camera The camera to apply the render pass to.
  73824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73825. * @param engine The engine which the post process will be applied. (default: current engine)
  73826. * @param reusable If the post process can be reused on the same frame. (default: false)
  73827. * @param textureType Type of textures used when performing the post process. (default: 0)
  73828. * @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)
  73829. */
  73830. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73831. /**
  73832. * Excludes the given skinned mesh from computing bones velocities.
  73833. * 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.
  73834. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73835. */
  73836. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73837. /**
  73838. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73839. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73840. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73841. */
  73842. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73843. /**
  73844. * Disposes the post process.
  73845. * @param camera The camera to dispose the post process on.
  73846. */
  73847. dispose(camera?: Camera): void;
  73848. /** @hidden */
  73849. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73850. }
  73851. }
  73852. declare module "babylonjs/Shaders/refraction.fragment" {
  73853. /** @hidden */
  73854. export var refractionPixelShader: {
  73855. name: string;
  73856. shader: string;
  73857. };
  73858. }
  73859. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73860. import { Color3 } from "babylonjs/Maths/math.color";
  73861. import { Camera } from "babylonjs/Cameras/camera";
  73862. import { Texture } from "babylonjs/Materials/Textures/texture";
  73863. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73864. import { Engine } from "babylonjs/Engines/engine";
  73865. import "babylonjs/Shaders/refraction.fragment";
  73866. import { Scene } from "babylonjs/scene";
  73867. /**
  73868. * Post process which applies a refractin texture
  73869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73870. */
  73871. export class RefractionPostProcess extends PostProcess {
  73872. private _refTexture;
  73873. private _ownRefractionTexture;
  73874. /** the base color of the refraction (used to taint the rendering) */
  73875. color: Color3;
  73876. /** simulated refraction depth */
  73877. depth: number;
  73878. /** the coefficient of the base color (0 to remove base color tainting) */
  73879. colorLevel: number;
  73880. /** Gets the url used to load the refraction texture */
  73881. refractionTextureUrl: string;
  73882. /**
  73883. * Gets or sets the refraction texture
  73884. * Please note that you are responsible for disposing the texture if you set it manually
  73885. */
  73886. get refractionTexture(): Texture;
  73887. set refractionTexture(value: Texture);
  73888. /**
  73889. * Gets a string identifying the name of the class
  73890. * @returns "RefractionPostProcess" string
  73891. */
  73892. getClassName(): string;
  73893. /**
  73894. * Initializes the RefractionPostProcess
  73895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73896. * @param name The name of the effect.
  73897. * @param refractionTextureUrl Url of the refraction texture to use
  73898. * @param color the base color of the refraction (used to taint the rendering)
  73899. * @param depth simulated refraction depth
  73900. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73901. * @param camera The camera to apply the render pass to.
  73902. * @param options The required width/height ratio to downsize to before computing the render pass.
  73903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73904. * @param engine The engine which the post process will be applied. (default: current engine)
  73905. * @param reusable If the post process can be reused on the same frame. (default: false)
  73906. */
  73907. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73908. /**
  73909. * Disposes of the post process
  73910. * @param camera Camera to dispose post process on
  73911. */
  73912. dispose(camera: Camera): void;
  73913. /** @hidden */
  73914. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  73915. }
  73916. }
  73917. declare module "babylonjs/Shaders/sharpen.fragment" {
  73918. /** @hidden */
  73919. export var sharpenPixelShader: {
  73920. name: string;
  73921. shader: string;
  73922. };
  73923. }
  73924. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73925. import { Nullable } from "babylonjs/types";
  73926. import { Camera } from "babylonjs/Cameras/camera";
  73927. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73928. import "babylonjs/Shaders/sharpen.fragment";
  73929. import { Engine } from "babylonjs/Engines/engine";
  73930. import { Scene } from "babylonjs/scene";
  73931. /**
  73932. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73933. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73934. */
  73935. export class SharpenPostProcess extends PostProcess {
  73936. /**
  73937. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73938. */
  73939. colorAmount: number;
  73940. /**
  73941. * How much sharpness should be applied (default: 0.3)
  73942. */
  73943. edgeAmount: number;
  73944. /**
  73945. * Gets a string identifying the name of the class
  73946. * @returns "SharpenPostProcess" string
  73947. */
  73948. getClassName(): string;
  73949. /**
  73950. * Creates a new instance ConvolutionPostProcess
  73951. * @param name The name of the effect.
  73952. * @param options The required width/height ratio to downsize to before computing the render pass.
  73953. * @param camera The camera to apply the render pass to.
  73954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73955. * @param engine The engine which the post process will be applied. (default: current engine)
  73956. * @param reusable If the post process can be reused on the same frame. (default: false)
  73957. * @param textureType Type of textures used when performing the post process. (default: 0)
  73958. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  73959. */
  73960. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73961. /** @hidden */
  73962. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  73963. }
  73964. }
  73965. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73966. import { Nullable } from "babylonjs/types";
  73967. import { Camera } from "babylonjs/Cameras/camera";
  73968. import { Engine } from "babylonjs/Engines/engine";
  73969. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73970. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73971. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73972. /**
  73973. * PostProcessRenderPipeline
  73974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73975. */
  73976. export class PostProcessRenderPipeline {
  73977. private engine;
  73978. private _renderEffects;
  73979. private _renderEffectsForIsolatedPass;
  73980. /**
  73981. * List of inspectable custom properties (used by the Inspector)
  73982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73983. */
  73984. inspectableCustomProperties: IInspectable[];
  73985. /**
  73986. * @hidden
  73987. */
  73988. protected _cameras: Camera[];
  73989. /** @hidden */
  73990. _name: string;
  73991. /**
  73992. * Gets pipeline name
  73993. */
  73994. get name(): string;
  73995. /** Gets the list of attached cameras */
  73996. get cameras(): Camera[];
  73997. /**
  73998. * Initializes a PostProcessRenderPipeline
  73999. * @param engine engine to add the pipeline to
  74000. * @param name name of the pipeline
  74001. */
  74002. constructor(engine: Engine, name: string);
  74003. /**
  74004. * Gets the class name
  74005. * @returns "PostProcessRenderPipeline"
  74006. */
  74007. getClassName(): string;
  74008. /**
  74009. * If all the render effects in the pipeline are supported
  74010. */
  74011. get isSupported(): boolean;
  74012. /**
  74013. * Adds an effect to the pipeline
  74014. * @param renderEffect the effect to add
  74015. */
  74016. addEffect(renderEffect: PostProcessRenderEffect): void;
  74017. /** @hidden */
  74018. _rebuild(): void;
  74019. /** @hidden */
  74020. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74021. /** @hidden */
  74022. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74023. /** @hidden */
  74024. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74025. /** @hidden */
  74026. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74027. /** @hidden */
  74028. _attachCameras(cameras: Camera, unique: boolean): void;
  74029. /** @hidden */
  74030. _attachCameras(cameras: Camera[], unique: boolean): void;
  74031. /** @hidden */
  74032. _detachCameras(cameras: Camera): void;
  74033. /** @hidden */
  74034. _detachCameras(cameras: Nullable<Camera[]>): void;
  74035. /** @hidden */
  74036. _update(): void;
  74037. /** @hidden */
  74038. _reset(): void;
  74039. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74040. /**
  74041. * Sets the required values to the prepass renderer.
  74042. * @param prePassRenderer defines the prepass renderer to setup.
  74043. * @returns true if the pre pass is needed.
  74044. */
  74045. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74046. /**
  74047. * Disposes of the pipeline
  74048. */
  74049. dispose(): void;
  74050. }
  74051. }
  74052. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74053. import { Camera } from "babylonjs/Cameras/camera";
  74054. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74055. /**
  74056. * PostProcessRenderPipelineManager class
  74057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74058. */
  74059. export class PostProcessRenderPipelineManager {
  74060. private _renderPipelines;
  74061. /**
  74062. * Initializes a PostProcessRenderPipelineManager
  74063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74064. */
  74065. constructor();
  74066. /**
  74067. * Gets the list of supported render pipelines
  74068. */
  74069. get supportedPipelines(): PostProcessRenderPipeline[];
  74070. /**
  74071. * Adds a pipeline to the manager
  74072. * @param renderPipeline The pipeline to add
  74073. */
  74074. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74075. /**
  74076. * Attaches a camera to the pipeline
  74077. * @param renderPipelineName The name of the pipeline to attach to
  74078. * @param cameras the camera to attach
  74079. * @param unique if the camera can be attached multiple times to the pipeline
  74080. */
  74081. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74082. /**
  74083. * Detaches a camera from the pipeline
  74084. * @param renderPipelineName The name of the pipeline to detach from
  74085. * @param cameras the camera to detach
  74086. */
  74087. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74088. /**
  74089. * Enables an effect by name on a pipeline
  74090. * @param renderPipelineName the name of the pipeline to enable the effect in
  74091. * @param renderEffectName the name of the effect to enable
  74092. * @param cameras the cameras that the effect should be enabled on
  74093. */
  74094. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74095. /**
  74096. * Disables an effect by name on a pipeline
  74097. * @param renderPipelineName the name of the pipeline to disable the effect in
  74098. * @param renderEffectName the name of the effect to disable
  74099. * @param cameras the cameras that the effect should be disabled on
  74100. */
  74101. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74102. /**
  74103. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74104. */
  74105. update(): void;
  74106. /** @hidden */
  74107. _rebuild(): void;
  74108. /**
  74109. * Disposes of the manager and pipelines
  74110. */
  74111. dispose(): void;
  74112. }
  74113. }
  74114. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74115. import { ISceneComponent } from "babylonjs/sceneComponent";
  74116. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74117. import { Scene } from "babylonjs/scene";
  74118. module "babylonjs/scene" {
  74119. interface Scene {
  74120. /** @hidden (Backing field) */
  74121. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74122. /**
  74123. * Gets the postprocess render pipeline manager
  74124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74125. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74126. */
  74127. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74128. }
  74129. }
  74130. /**
  74131. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74132. */
  74133. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74134. /**
  74135. * The component name helpfull to identify the component in the list of scene components.
  74136. */
  74137. readonly name: string;
  74138. /**
  74139. * The scene the component belongs to.
  74140. */
  74141. scene: Scene;
  74142. /**
  74143. * Creates a new instance of the component for the given scene
  74144. * @param scene Defines the scene to register the component in
  74145. */
  74146. constructor(scene: Scene);
  74147. /**
  74148. * Registers the component in a given scene
  74149. */
  74150. register(): void;
  74151. /**
  74152. * Rebuilds the elements related to this component in case of
  74153. * context lost for instance.
  74154. */
  74155. rebuild(): void;
  74156. /**
  74157. * Disposes the component and the associated ressources
  74158. */
  74159. dispose(): void;
  74160. private _gatherRenderTargets;
  74161. }
  74162. }
  74163. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74164. import { Nullable } from "babylonjs/types";
  74165. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74166. import { Camera } from "babylonjs/Cameras/camera";
  74167. import { IDisposable } from "babylonjs/scene";
  74168. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74169. import { Scene } from "babylonjs/scene";
  74170. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74171. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74172. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74173. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74174. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74175. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74176. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74177. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74178. import { Animation } from "babylonjs/Animations/animation";
  74179. /**
  74180. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74181. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74182. */
  74183. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74184. private _scene;
  74185. private _camerasToBeAttached;
  74186. /**
  74187. * ID of the sharpen post process,
  74188. */
  74189. private readonly SharpenPostProcessId;
  74190. /**
  74191. * @ignore
  74192. * ID of the image processing post process;
  74193. */
  74194. readonly ImageProcessingPostProcessId: string;
  74195. /**
  74196. * @ignore
  74197. * ID of the Fast Approximate Anti-Aliasing post process;
  74198. */
  74199. readonly FxaaPostProcessId: string;
  74200. /**
  74201. * ID of the chromatic aberration post process,
  74202. */
  74203. private readonly ChromaticAberrationPostProcessId;
  74204. /**
  74205. * ID of the grain post process
  74206. */
  74207. private readonly GrainPostProcessId;
  74208. /**
  74209. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74210. */
  74211. sharpen: SharpenPostProcess;
  74212. private _sharpenEffect;
  74213. private bloom;
  74214. /**
  74215. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74216. */
  74217. depthOfField: DepthOfFieldEffect;
  74218. /**
  74219. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74220. */
  74221. fxaa: FxaaPostProcess;
  74222. /**
  74223. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74224. */
  74225. imageProcessing: ImageProcessingPostProcess;
  74226. /**
  74227. * Chromatic aberration post process which will shift rgb colors in the image
  74228. */
  74229. chromaticAberration: ChromaticAberrationPostProcess;
  74230. private _chromaticAberrationEffect;
  74231. /**
  74232. * Grain post process which add noise to the image
  74233. */
  74234. grain: GrainPostProcess;
  74235. private _grainEffect;
  74236. /**
  74237. * Glow post process which adds a glow to emissive areas of the image
  74238. */
  74239. private _glowLayer;
  74240. /**
  74241. * Animations which can be used to tweak settings over a period of time
  74242. */
  74243. animations: Animation[];
  74244. private _imageProcessingConfigurationObserver;
  74245. private _sharpenEnabled;
  74246. private _bloomEnabled;
  74247. private _depthOfFieldEnabled;
  74248. private _depthOfFieldBlurLevel;
  74249. private _fxaaEnabled;
  74250. private _imageProcessingEnabled;
  74251. private _defaultPipelineTextureType;
  74252. private _bloomScale;
  74253. private _chromaticAberrationEnabled;
  74254. private _grainEnabled;
  74255. private _buildAllowed;
  74256. /**
  74257. * Gets active scene
  74258. */
  74259. get scene(): Scene;
  74260. /**
  74261. * Enable or disable the sharpen process from the pipeline
  74262. */
  74263. set sharpenEnabled(enabled: boolean);
  74264. get sharpenEnabled(): boolean;
  74265. private _resizeObserver;
  74266. private _hardwareScaleLevel;
  74267. private _bloomKernel;
  74268. /**
  74269. * Specifies the size of the bloom blur kernel, relative to the final output size
  74270. */
  74271. get bloomKernel(): number;
  74272. set bloomKernel(value: number);
  74273. /**
  74274. * Specifies the weight of the bloom in the final rendering
  74275. */
  74276. private _bloomWeight;
  74277. /**
  74278. * Specifies the luma threshold for the area that will be blurred by the bloom
  74279. */
  74280. private _bloomThreshold;
  74281. private _hdr;
  74282. /**
  74283. * The strength of the bloom.
  74284. */
  74285. set bloomWeight(value: number);
  74286. get bloomWeight(): number;
  74287. /**
  74288. * The strength of the bloom.
  74289. */
  74290. set bloomThreshold(value: number);
  74291. get bloomThreshold(): number;
  74292. /**
  74293. * The scale of the bloom, lower value will provide better performance.
  74294. */
  74295. set bloomScale(value: number);
  74296. get bloomScale(): number;
  74297. /**
  74298. * Enable or disable the bloom from the pipeline
  74299. */
  74300. set bloomEnabled(enabled: boolean);
  74301. get bloomEnabled(): boolean;
  74302. private _rebuildBloom;
  74303. /**
  74304. * If the depth of field is enabled.
  74305. */
  74306. get depthOfFieldEnabled(): boolean;
  74307. set depthOfFieldEnabled(enabled: boolean);
  74308. /**
  74309. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74310. */
  74311. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74312. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74313. /**
  74314. * If the anti aliasing is enabled.
  74315. */
  74316. set fxaaEnabled(enabled: boolean);
  74317. get fxaaEnabled(): boolean;
  74318. private _samples;
  74319. /**
  74320. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74321. */
  74322. set samples(sampleCount: number);
  74323. get samples(): number;
  74324. /**
  74325. * If image processing is enabled.
  74326. */
  74327. set imageProcessingEnabled(enabled: boolean);
  74328. get imageProcessingEnabled(): boolean;
  74329. /**
  74330. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74331. */
  74332. set glowLayerEnabled(enabled: boolean);
  74333. get glowLayerEnabled(): boolean;
  74334. /**
  74335. * Gets the glow layer (or null if not defined)
  74336. */
  74337. get glowLayer(): Nullable<GlowLayer>;
  74338. /**
  74339. * Enable or disable the chromaticAberration process from the pipeline
  74340. */
  74341. set chromaticAberrationEnabled(enabled: boolean);
  74342. get chromaticAberrationEnabled(): boolean;
  74343. /**
  74344. * Enable or disable the grain process from the pipeline
  74345. */
  74346. set grainEnabled(enabled: boolean);
  74347. get grainEnabled(): boolean;
  74348. /**
  74349. * @constructor
  74350. * @param name - The rendering pipeline name (default: "")
  74351. * @param hdr - If high dynamic range textures should be used (default: true)
  74352. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74353. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74354. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74355. */
  74356. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74357. /**
  74358. * Get the class name
  74359. * @returns "DefaultRenderingPipeline"
  74360. */
  74361. getClassName(): string;
  74362. /**
  74363. * Force the compilation of the entire pipeline.
  74364. */
  74365. prepare(): void;
  74366. private _hasCleared;
  74367. private _prevPostProcess;
  74368. private _prevPrevPostProcess;
  74369. private _setAutoClearAndTextureSharing;
  74370. private _depthOfFieldSceneObserver;
  74371. private _buildPipeline;
  74372. private _disposePostProcesses;
  74373. /**
  74374. * Adds a camera to the pipeline
  74375. * @param camera the camera to be added
  74376. */
  74377. addCamera(camera: Camera): void;
  74378. /**
  74379. * Removes a camera from the pipeline
  74380. * @param camera the camera to remove
  74381. */
  74382. removeCamera(camera: Camera): void;
  74383. /**
  74384. * Dispose of the pipeline and stop all post processes
  74385. */
  74386. dispose(): void;
  74387. /**
  74388. * Serialize the rendering pipeline (Used when exporting)
  74389. * @returns the serialized object
  74390. */
  74391. serialize(): any;
  74392. /**
  74393. * Parse the serialized pipeline
  74394. * @param source Source pipeline.
  74395. * @param scene The scene to load the pipeline to.
  74396. * @param rootUrl The URL of the serialized pipeline.
  74397. * @returns An instantiated pipeline from the serialized object.
  74398. */
  74399. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74400. }
  74401. }
  74402. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74403. /** @hidden */
  74404. export var lensHighlightsPixelShader: {
  74405. name: string;
  74406. shader: string;
  74407. };
  74408. }
  74409. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74410. /** @hidden */
  74411. export var depthOfFieldPixelShader: {
  74412. name: string;
  74413. shader: string;
  74414. };
  74415. }
  74416. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74417. import { Camera } from "babylonjs/Cameras/camera";
  74418. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74419. import { Scene } from "babylonjs/scene";
  74420. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74421. import "babylonjs/Shaders/chromaticAberration.fragment";
  74422. import "babylonjs/Shaders/lensHighlights.fragment";
  74423. import "babylonjs/Shaders/depthOfField.fragment";
  74424. /**
  74425. * BABYLON.JS Chromatic Aberration GLSL Shader
  74426. * Author: Olivier Guyot
  74427. * Separates very slightly R, G and B colors on the edges of the screen
  74428. * Inspired by Francois Tarlier & Martins Upitis
  74429. */
  74430. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74431. /**
  74432. * @ignore
  74433. * The chromatic aberration PostProcess id in the pipeline
  74434. */
  74435. LensChromaticAberrationEffect: string;
  74436. /**
  74437. * @ignore
  74438. * The highlights enhancing PostProcess id in the pipeline
  74439. */
  74440. HighlightsEnhancingEffect: string;
  74441. /**
  74442. * @ignore
  74443. * The depth-of-field PostProcess id in the pipeline
  74444. */
  74445. LensDepthOfFieldEffect: string;
  74446. private _scene;
  74447. private _depthTexture;
  74448. private _grainTexture;
  74449. private _chromaticAberrationPostProcess;
  74450. private _highlightsPostProcess;
  74451. private _depthOfFieldPostProcess;
  74452. private _edgeBlur;
  74453. private _grainAmount;
  74454. private _chromaticAberration;
  74455. private _distortion;
  74456. private _highlightsGain;
  74457. private _highlightsThreshold;
  74458. private _dofDistance;
  74459. private _dofAperture;
  74460. private _dofDarken;
  74461. private _dofPentagon;
  74462. private _blurNoise;
  74463. /**
  74464. * @constructor
  74465. *
  74466. * Effect parameters are as follow:
  74467. * {
  74468. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74469. * edge_blur: number; // from 0 to x (1 for realism)
  74470. * distortion: number; // from 0 to x (1 for realism)
  74471. * grain_amount: number; // from 0 to 1
  74472. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74473. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74474. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74475. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74476. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74477. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74478. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74479. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74480. * }
  74481. * Note: if an effect parameter is unset, effect is disabled
  74482. *
  74483. * @param name The rendering pipeline name
  74484. * @param parameters - An object containing all parameters (see above)
  74485. * @param scene The scene linked to this pipeline
  74486. * @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)
  74487. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74488. */
  74489. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74490. /**
  74491. * Get the class name
  74492. * @returns "LensRenderingPipeline"
  74493. */
  74494. getClassName(): string;
  74495. /**
  74496. * Gets associated scene
  74497. */
  74498. get scene(): Scene;
  74499. /**
  74500. * Gets or sets the edge blur
  74501. */
  74502. get edgeBlur(): number;
  74503. set edgeBlur(value: number);
  74504. /**
  74505. * Gets or sets the grain amount
  74506. */
  74507. get grainAmount(): number;
  74508. set grainAmount(value: number);
  74509. /**
  74510. * Gets or sets the chromatic aberration amount
  74511. */
  74512. get chromaticAberration(): number;
  74513. set chromaticAberration(value: number);
  74514. /**
  74515. * Gets or sets the depth of field aperture
  74516. */
  74517. get dofAperture(): number;
  74518. set dofAperture(value: number);
  74519. /**
  74520. * Gets or sets the edge distortion
  74521. */
  74522. get edgeDistortion(): number;
  74523. set edgeDistortion(value: number);
  74524. /**
  74525. * Gets or sets the depth of field distortion
  74526. */
  74527. get dofDistortion(): number;
  74528. set dofDistortion(value: number);
  74529. /**
  74530. * Gets or sets the darken out of focus amount
  74531. */
  74532. get darkenOutOfFocus(): number;
  74533. set darkenOutOfFocus(value: number);
  74534. /**
  74535. * Gets or sets a boolean indicating if blur noise is enabled
  74536. */
  74537. get blurNoise(): boolean;
  74538. set blurNoise(value: boolean);
  74539. /**
  74540. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74541. */
  74542. get pentagonBokeh(): boolean;
  74543. set pentagonBokeh(value: boolean);
  74544. /**
  74545. * Gets or sets the highlight grain amount
  74546. */
  74547. get highlightsGain(): number;
  74548. set highlightsGain(value: number);
  74549. /**
  74550. * Gets or sets the highlight threshold
  74551. */
  74552. get highlightsThreshold(): number;
  74553. set highlightsThreshold(value: number);
  74554. /**
  74555. * Sets the amount of blur at the edges
  74556. * @param amount blur amount
  74557. */
  74558. setEdgeBlur(amount: number): void;
  74559. /**
  74560. * Sets edge blur to 0
  74561. */
  74562. disableEdgeBlur(): void;
  74563. /**
  74564. * Sets the amout of grain
  74565. * @param amount Amount of grain
  74566. */
  74567. setGrainAmount(amount: number): void;
  74568. /**
  74569. * Set grain amount to 0
  74570. */
  74571. disableGrain(): void;
  74572. /**
  74573. * Sets the chromatic aberration amount
  74574. * @param amount amount of chromatic aberration
  74575. */
  74576. setChromaticAberration(amount: number): void;
  74577. /**
  74578. * Sets chromatic aberration amount to 0
  74579. */
  74580. disableChromaticAberration(): void;
  74581. /**
  74582. * Sets the EdgeDistortion amount
  74583. * @param amount amount of EdgeDistortion
  74584. */
  74585. setEdgeDistortion(amount: number): void;
  74586. /**
  74587. * Sets edge distortion to 0
  74588. */
  74589. disableEdgeDistortion(): void;
  74590. /**
  74591. * Sets the FocusDistance amount
  74592. * @param amount amount of FocusDistance
  74593. */
  74594. setFocusDistance(amount: number): void;
  74595. /**
  74596. * Disables depth of field
  74597. */
  74598. disableDepthOfField(): void;
  74599. /**
  74600. * Sets the Aperture amount
  74601. * @param amount amount of Aperture
  74602. */
  74603. setAperture(amount: number): void;
  74604. /**
  74605. * Sets the DarkenOutOfFocus amount
  74606. * @param amount amount of DarkenOutOfFocus
  74607. */
  74608. setDarkenOutOfFocus(amount: number): void;
  74609. private _pentagonBokehIsEnabled;
  74610. /**
  74611. * Creates a pentagon bokeh effect
  74612. */
  74613. enablePentagonBokeh(): void;
  74614. /**
  74615. * Disables the pentagon bokeh effect
  74616. */
  74617. disablePentagonBokeh(): void;
  74618. /**
  74619. * Enables noise blur
  74620. */
  74621. enableNoiseBlur(): void;
  74622. /**
  74623. * Disables noise blur
  74624. */
  74625. disableNoiseBlur(): void;
  74626. /**
  74627. * Sets the HighlightsGain amount
  74628. * @param amount amount of HighlightsGain
  74629. */
  74630. setHighlightsGain(amount: number): void;
  74631. /**
  74632. * Sets the HighlightsThreshold amount
  74633. * @param amount amount of HighlightsThreshold
  74634. */
  74635. setHighlightsThreshold(amount: number): void;
  74636. /**
  74637. * Disables highlights
  74638. */
  74639. disableHighlights(): void;
  74640. /**
  74641. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74642. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74643. */
  74644. dispose(disableDepthRender?: boolean): void;
  74645. private _createChromaticAberrationPostProcess;
  74646. private _createHighlightsPostProcess;
  74647. private _createDepthOfFieldPostProcess;
  74648. private _createGrainTexture;
  74649. }
  74650. }
  74651. declare module "babylonjs/Shaders/ssao2.fragment" {
  74652. /** @hidden */
  74653. export var ssao2PixelShader: {
  74654. name: string;
  74655. shader: string;
  74656. };
  74657. }
  74658. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74659. /** @hidden */
  74660. export var ssaoCombinePixelShader: {
  74661. name: string;
  74662. shader: string;
  74663. };
  74664. }
  74665. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74666. import { Camera } from "babylonjs/Cameras/camera";
  74667. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74668. import { Scene } from "babylonjs/scene";
  74669. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74670. import "babylonjs/Shaders/ssao2.fragment";
  74671. import "babylonjs/Shaders/ssaoCombine.fragment";
  74672. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74673. /**
  74674. * Render pipeline to produce ssao effect
  74675. */
  74676. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74677. /**
  74678. * @ignore
  74679. * The PassPostProcess id in the pipeline that contains the original scene color
  74680. */
  74681. SSAOOriginalSceneColorEffect: string;
  74682. /**
  74683. * @ignore
  74684. * The SSAO PostProcess id in the pipeline
  74685. */
  74686. SSAORenderEffect: string;
  74687. /**
  74688. * @ignore
  74689. * The horizontal blur PostProcess id in the pipeline
  74690. */
  74691. SSAOBlurHRenderEffect: string;
  74692. /**
  74693. * @ignore
  74694. * The vertical blur PostProcess id in the pipeline
  74695. */
  74696. SSAOBlurVRenderEffect: string;
  74697. /**
  74698. * @ignore
  74699. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74700. */
  74701. SSAOCombineRenderEffect: string;
  74702. /**
  74703. * The output strength of the SSAO post-process. Default value is 1.0.
  74704. */
  74705. totalStrength: number;
  74706. /**
  74707. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74708. */
  74709. maxZ: number;
  74710. /**
  74711. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74712. */
  74713. minZAspect: number;
  74714. private _samples;
  74715. /**
  74716. * Number of samples used for the SSAO calculations. Default value is 8
  74717. */
  74718. set samples(n: number);
  74719. get samples(): number;
  74720. private _textureSamples;
  74721. /**
  74722. * Number of samples to use for antialiasing
  74723. */
  74724. set textureSamples(n: number);
  74725. get textureSamples(): number;
  74726. /**
  74727. * Force rendering the geometry through geometry buffer
  74728. */
  74729. private _forceGeometryBuffer;
  74730. /**
  74731. * Ratio object used for SSAO ratio and blur ratio
  74732. */
  74733. private _ratio;
  74734. /**
  74735. * Dynamically generated sphere sampler.
  74736. */
  74737. private _sampleSphere;
  74738. /**
  74739. * Blur filter offsets
  74740. */
  74741. private _samplerOffsets;
  74742. private _expensiveBlur;
  74743. /**
  74744. * If bilateral blur should be used
  74745. */
  74746. set expensiveBlur(b: boolean);
  74747. get expensiveBlur(): boolean;
  74748. /**
  74749. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74750. */
  74751. radius: number;
  74752. /**
  74753. * The base color of the SSAO post-process
  74754. * The final result is "base + ssao" between [0, 1]
  74755. */
  74756. base: number;
  74757. /**
  74758. * Support test.
  74759. */
  74760. static get IsSupported(): boolean;
  74761. private _scene;
  74762. private _randomTexture;
  74763. private _originalColorPostProcess;
  74764. private _ssaoPostProcess;
  74765. private _blurHPostProcess;
  74766. private _blurVPostProcess;
  74767. private _ssaoCombinePostProcess;
  74768. private _prePassRenderer;
  74769. /**
  74770. * Gets active scene
  74771. */
  74772. get scene(): Scene;
  74773. /**
  74774. * @constructor
  74775. * @param name The rendering pipeline name
  74776. * @param scene The scene linked to this pipeline
  74777. * @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 }
  74778. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74779. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74780. */
  74781. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74782. /**
  74783. * Get the class name
  74784. * @returns "SSAO2RenderingPipeline"
  74785. */
  74786. getClassName(): string;
  74787. /**
  74788. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74789. */
  74790. dispose(disableGeometryBufferRenderer?: boolean): void;
  74791. private _createBlurPostProcess;
  74792. /** @hidden */
  74793. _rebuild(): void;
  74794. private _bits;
  74795. private _radicalInverse_VdC;
  74796. private _hammersley;
  74797. private _hemisphereSample_uniform;
  74798. private _generateHemisphere;
  74799. private _getDefinesForSSAO;
  74800. private _createSSAOPostProcess;
  74801. private _createSSAOCombinePostProcess;
  74802. private _createRandomTexture;
  74803. /**
  74804. * Serialize the rendering pipeline (Used when exporting)
  74805. * @returns the serialized object
  74806. */
  74807. serialize(): any;
  74808. /**
  74809. * Parse the serialized pipeline
  74810. * @param source Source pipeline.
  74811. * @param scene The scene to load the pipeline to.
  74812. * @param rootUrl The URL of the serialized pipeline.
  74813. * @returns An instantiated pipeline from the serialized object.
  74814. */
  74815. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74816. /**
  74817. * Sets the required values to the prepass renderer.
  74818. * @param prePassRenderer defines the prepass renderer to setup
  74819. * @returns true if the pre pass is needed.
  74820. */
  74821. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74822. }
  74823. }
  74824. declare module "babylonjs/Shaders/ssao.fragment" {
  74825. /** @hidden */
  74826. export var ssaoPixelShader: {
  74827. name: string;
  74828. shader: string;
  74829. };
  74830. }
  74831. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74832. import { Camera } from "babylonjs/Cameras/camera";
  74833. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74834. import { Scene } from "babylonjs/scene";
  74835. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74836. import "babylonjs/Shaders/ssao.fragment";
  74837. import "babylonjs/Shaders/ssaoCombine.fragment";
  74838. /**
  74839. * Render pipeline to produce ssao effect
  74840. */
  74841. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74842. /**
  74843. * @ignore
  74844. * The PassPostProcess id in the pipeline that contains the original scene color
  74845. */
  74846. SSAOOriginalSceneColorEffect: string;
  74847. /**
  74848. * @ignore
  74849. * The SSAO PostProcess id in the pipeline
  74850. */
  74851. SSAORenderEffect: string;
  74852. /**
  74853. * @ignore
  74854. * The horizontal blur PostProcess id in the pipeline
  74855. */
  74856. SSAOBlurHRenderEffect: string;
  74857. /**
  74858. * @ignore
  74859. * The vertical blur PostProcess id in the pipeline
  74860. */
  74861. SSAOBlurVRenderEffect: string;
  74862. /**
  74863. * @ignore
  74864. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74865. */
  74866. SSAOCombineRenderEffect: string;
  74867. /**
  74868. * The output strength of the SSAO post-process. Default value is 1.0.
  74869. */
  74870. totalStrength: number;
  74871. /**
  74872. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74873. */
  74874. radius: number;
  74875. /**
  74876. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74877. * Must not be equal to fallOff and superior to fallOff.
  74878. * Default value is 0.0075
  74879. */
  74880. area: number;
  74881. /**
  74882. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74883. * Must not be equal to area and inferior to area.
  74884. * Default value is 0.000001
  74885. */
  74886. fallOff: number;
  74887. /**
  74888. * The base color of the SSAO post-process
  74889. * The final result is "base + ssao" between [0, 1]
  74890. */
  74891. base: number;
  74892. private _scene;
  74893. private _depthTexture;
  74894. private _randomTexture;
  74895. private _originalColorPostProcess;
  74896. private _ssaoPostProcess;
  74897. private _blurHPostProcess;
  74898. private _blurVPostProcess;
  74899. private _ssaoCombinePostProcess;
  74900. private _firstUpdate;
  74901. /**
  74902. * Gets active scene
  74903. */
  74904. get scene(): Scene;
  74905. /**
  74906. * @constructor
  74907. * @param name - The rendering pipeline name
  74908. * @param scene - The scene linked to this pipeline
  74909. * @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 }
  74910. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74911. */
  74912. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74913. /**
  74914. * Get the class name
  74915. * @returns "SSAORenderingPipeline"
  74916. */
  74917. getClassName(): string;
  74918. /**
  74919. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74920. */
  74921. dispose(disableDepthRender?: boolean): void;
  74922. private _createBlurPostProcess;
  74923. /** @hidden */
  74924. _rebuild(): void;
  74925. private _createSSAOPostProcess;
  74926. private _createSSAOCombinePostProcess;
  74927. private _createRandomTexture;
  74928. }
  74929. }
  74930. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74931. /** @hidden */
  74932. export var screenSpaceReflectionPixelShader: {
  74933. name: string;
  74934. shader: string;
  74935. };
  74936. }
  74937. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74938. import { Nullable } from "babylonjs/types";
  74939. import { Camera } from "babylonjs/Cameras/camera";
  74940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74941. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74942. import { Engine } from "babylonjs/Engines/engine";
  74943. import { Scene } from "babylonjs/scene";
  74944. /**
  74945. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74946. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74947. */
  74948. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74949. /**
  74950. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74951. */
  74952. threshold: number;
  74953. /**
  74954. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74955. */
  74956. strength: number;
  74957. /**
  74958. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74959. */
  74960. reflectionSpecularFalloffExponent: number;
  74961. /**
  74962. * 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]
  74963. */
  74964. step: number;
  74965. /**
  74966. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74967. */
  74968. roughnessFactor: number;
  74969. private _geometryBufferRenderer;
  74970. private _enableSmoothReflections;
  74971. private _reflectionSamples;
  74972. private _smoothSteps;
  74973. /**
  74974. * Gets a string identifying the name of the class
  74975. * @returns "ScreenSpaceReflectionPostProcess" string
  74976. */
  74977. getClassName(): string;
  74978. /**
  74979. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74980. * @param name The name of the effect.
  74981. * @param scene The scene containing the objects to calculate reflections.
  74982. * @param options The required width/height ratio to downsize to before computing the render pass.
  74983. * @param camera The camera to apply the render pass to.
  74984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74985. * @param engine The engine which the post process will be applied. (default: current engine)
  74986. * @param reusable If the post process can be reused on the same frame. (default: false)
  74987. * @param textureType Type of textures used when performing the post process. (default: 0)
  74988. * @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)
  74989. */
  74990. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74991. /**
  74992. * Gets wether or not smoothing reflections is enabled.
  74993. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74994. */
  74995. get enableSmoothReflections(): boolean;
  74996. /**
  74997. * Sets wether or not smoothing reflections is enabled.
  74998. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74999. */
  75000. set enableSmoothReflections(enabled: boolean);
  75001. /**
  75002. * Gets the number of samples taken while computing reflections. More samples count is high,
  75003. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75004. */
  75005. get reflectionSamples(): number;
  75006. /**
  75007. * Sets the number of samples taken while computing reflections. More samples count is high,
  75008. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75009. */
  75010. set reflectionSamples(samples: number);
  75011. /**
  75012. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75013. * more the post-process will require GPU power and can generate a drop in FPS.
  75014. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75015. */
  75016. get smoothSteps(): number;
  75017. set smoothSteps(steps: number);
  75018. private _updateEffectDefines;
  75019. /** @hidden */
  75020. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75021. }
  75022. }
  75023. declare module "babylonjs/Shaders/standard.fragment" {
  75024. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75025. /** @hidden */
  75026. export var standardPixelShader: {
  75027. name: string;
  75028. shader: string;
  75029. };
  75030. }
  75031. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75032. import { Nullable } from "babylonjs/types";
  75033. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75034. import { Camera } from "babylonjs/Cameras/camera";
  75035. import { Texture } from "babylonjs/Materials/Textures/texture";
  75036. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75037. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75038. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75039. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75040. import { IDisposable } from "babylonjs/scene";
  75041. import { SpotLight } from "babylonjs/Lights/spotLight";
  75042. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75043. import { Scene } from "babylonjs/scene";
  75044. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75045. import { Animation } from "babylonjs/Animations/animation";
  75046. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75047. import "babylonjs/Shaders/standard.fragment";
  75048. /**
  75049. * Standard rendering pipeline
  75050. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75051. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75052. */
  75053. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75054. /**
  75055. * Public members
  75056. */
  75057. /**
  75058. * Post-process which contains the original scene color before the pipeline applies all the effects
  75059. */
  75060. originalPostProcess: Nullable<PostProcess>;
  75061. /**
  75062. * Post-process used to down scale an image x4
  75063. */
  75064. downSampleX4PostProcess: Nullable<PostProcess>;
  75065. /**
  75066. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75067. */
  75068. brightPassPostProcess: Nullable<PostProcess>;
  75069. /**
  75070. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75071. */
  75072. blurHPostProcesses: PostProcess[];
  75073. /**
  75074. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75075. */
  75076. blurVPostProcesses: PostProcess[];
  75077. /**
  75078. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75079. */
  75080. textureAdderPostProcess: Nullable<PostProcess>;
  75081. /**
  75082. * Post-process used to create volumetric lighting effect
  75083. */
  75084. volumetricLightPostProcess: Nullable<PostProcess>;
  75085. /**
  75086. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75087. */
  75088. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75089. /**
  75090. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75091. */
  75092. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75093. /**
  75094. * Post-process used to merge the volumetric light effect and the real scene color
  75095. */
  75096. volumetricLightMergePostProces: Nullable<PostProcess>;
  75097. /**
  75098. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75099. */
  75100. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75101. /**
  75102. * Base post-process used to calculate the average luminance of the final image for HDR
  75103. */
  75104. luminancePostProcess: Nullable<PostProcess>;
  75105. /**
  75106. * Post-processes used to create down sample post-processes in order to get
  75107. * the average luminance of the final image for HDR
  75108. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75109. */
  75110. luminanceDownSamplePostProcesses: PostProcess[];
  75111. /**
  75112. * Post-process used to create a HDR effect (light adaptation)
  75113. */
  75114. hdrPostProcess: Nullable<PostProcess>;
  75115. /**
  75116. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75117. */
  75118. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75119. /**
  75120. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75121. */
  75122. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75123. /**
  75124. * Post-process used to merge the final HDR post-process and the real scene color
  75125. */
  75126. hdrFinalPostProcess: Nullable<PostProcess>;
  75127. /**
  75128. * Post-process used to create a lens flare effect
  75129. */
  75130. lensFlarePostProcess: Nullable<PostProcess>;
  75131. /**
  75132. * Post-process that merges the result of the lens flare post-process and the real scene color
  75133. */
  75134. lensFlareComposePostProcess: Nullable<PostProcess>;
  75135. /**
  75136. * Post-process used to create a motion blur effect
  75137. */
  75138. motionBlurPostProcess: Nullable<PostProcess>;
  75139. /**
  75140. * Post-process used to create a depth of field effect
  75141. */
  75142. depthOfFieldPostProcess: Nullable<PostProcess>;
  75143. /**
  75144. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75145. */
  75146. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75147. /**
  75148. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75149. */
  75150. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75151. /**
  75152. * Represents the brightness threshold in order to configure the illuminated surfaces
  75153. */
  75154. brightThreshold: number;
  75155. /**
  75156. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75157. */
  75158. blurWidth: number;
  75159. /**
  75160. * Sets if the blur for highlighted surfaces must be only horizontal
  75161. */
  75162. horizontalBlur: boolean;
  75163. /**
  75164. * Gets the overall exposure used by the pipeline
  75165. */
  75166. get exposure(): number;
  75167. /**
  75168. * Sets the overall exposure used by the pipeline
  75169. */
  75170. set exposure(value: number);
  75171. /**
  75172. * Texture used typically to simulate "dirty" on camera lens
  75173. */
  75174. lensTexture: Nullable<Texture>;
  75175. /**
  75176. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75177. */
  75178. volumetricLightCoefficient: number;
  75179. /**
  75180. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75181. */
  75182. volumetricLightPower: number;
  75183. /**
  75184. * Used the set the blur intensity to smooth the volumetric lights
  75185. */
  75186. volumetricLightBlurScale: number;
  75187. /**
  75188. * Light (spot or directional) used to generate the volumetric lights rays
  75189. * The source light must have a shadow generate so the pipeline can get its
  75190. * depth map
  75191. */
  75192. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75193. /**
  75194. * For eye adaptation, represents the minimum luminance the eye can see
  75195. */
  75196. hdrMinimumLuminance: number;
  75197. /**
  75198. * For eye adaptation, represents the decrease luminance speed
  75199. */
  75200. hdrDecreaseRate: number;
  75201. /**
  75202. * For eye adaptation, represents the increase luminance speed
  75203. */
  75204. hdrIncreaseRate: number;
  75205. /**
  75206. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75207. */
  75208. get hdrAutoExposure(): boolean;
  75209. /**
  75210. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75211. */
  75212. set hdrAutoExposure(value: boolean);
  75213. /**
  75214. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75215. */
  75216. lensColorTexture: Nullable<Texture>;
  75217. /**
  75218. * The overall strengh for the lens flare effect
  75219. */
  75220. lensFlareStrength: number;
  75221. /**
  75222. * Dispersion coefficient for lens flare ghosts
  75223. */
  75224. lensFlareGhostDispersal: number;
  75225. /**
  75226. * Main lens flare halo width
  75227. */
  75228. lensFlareHaloWidth: number;
  75229. /**
  75230. * Based on the lens distortion effect, defines how much the lens flare result
  75231. * is distorted
  75232. */
  75233. lensFlareDistortionStrength: number;
  75234. /**
  75235. * Configures the blur intensity used for for lens flare (halo)
  75236. */
  75237. lensFlareBlurWidth: number;
  75238. /**
  75239. * Lens star texture must be used to simulate rays on the flares and is available
  75240. * in the documentation
  75241. */
  75242. lensStarTexture: Nullable<Texture>;
  75243. /**
  75244. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75245. * flare effect by taking account of the dirt texture
  75246. */
  75247. lensFlareDirtTexture: Nullable<Texture>;
  75248. /**
  75249. * Represents the focal length for the depth of field effect
  75250. */
  75251. depthOfFieldDistance: number;
  75252. /**
  75253. * Represents the blur intensity for the blurred part of the depth of field effect
  75254. */
  75255. depthOfFieldBlurWidth: number;
  75256. /**
  75257. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75258. */
  75259. get motionStrength(): number;
  75260. /**
  75261. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75262. */
  75263. set motionStrength(strength: number);
  75264. /**
  75265. * Gets wether or not the motion blur post-process is object based or screen based.
  75266. */
  75267. get objectBasedMotionBlur(): boolean;
  75268. /**
  75269. * Sets wether or not the motion blur post-process should be object based or screen based
  75270. */
  75271. set objectBasedMotionBlur(value: boolean);
  75272. /**
  75273. * List of animations for the pipeline (IAnimatable implementation)
  75274. */
  75275. animations: Animation[];
  75276. /**
  75277. * Private members
  75278. */
  75279. private _scene;
  75280. private _currentDepthOfFieldSource;
  75281. private _basePostProcess;
  75282. private _fixedExposure;
  75283. private _currentExposure;
  75284. private _hdrAutoExposure;
  75285. private _hdrCurrentLuminance;
  75286. private _motionStrength;
  75287. private _isObjectBasedMotionBlur;
  75288. private _floatTextureType;
  75289. private _camerasToBeAttached;
  75290. private _ratio;
  75291. private _bloomEnabled;
  75292. private _depthOfFieldEnabled;
  75293. private _vlsEnabled;
  75294. private _lensFlareEnabled;
  75295. private _hdrEnabled;
  75296. private _motionBlurEnabled;
  75297. private _fxaaEnabled;
  75298. private _screenSpaceReflectionsEnabled;
  75299. private _motionBlurSamples;
  75300. private _volumetricLightStepsCount;
  75301. private _samples;
  75302. /**
  75303. * @ignore
  75304. * Specifies if the bloom pipeline is enabled
  75305. */
  75306. get BloomEnabled(): boolean;
  75307. set BloomEnabled(enabled: boolean);
  75308. /**
  75309. * @ignore
  75310. * Specifies if the depth of field pipeline is enabed
  75311. */
  75312. get DepthOfFieldEnabled(): boolean;
  75313. set DepthOfFieldEnabled(enabled: boolean);
  75314. /**
  75315. * @ignore
  75316. * Specifies if the lens flare pipeline is enabed
  75317. */
  75318. get LensFlareEnabled(): boolean;
  75319. set LensFlareEnabled(enabled: boolean);
  75320. /**
  75321. * @ignore
  75322. * Specifies if the HDR pipeline is enabled
  75323. */
  75324. get HDREnabled(): boolean;
  75325. set HDREnabled(enabled: boolean);
  75326. /**
  75327. * @ignore
  75328. * Specifies if the volumetric lights scattering effect is enabled
  75329. */
  75330. get VLSEnabled(): boolean;
  75331. set VLSEnabled(enabled: boolean);
  75332. /**
  75333. * @ignore
  75334. * Specifies if the motion blur effect is enabled
  75335. */
  75336. get MotionBlurEnabled(): boolean;
  75337. set MotionBlurEnabled(enabled: boolean);
  75338. /**
  75339. * Specifies if anti-aliasing is enabled
  75340. */
  75341. get fxaaEnabled(): boolean;
  75342. set fxaaEnabled(enabled: boolean);
  75343. /**
  75344. * Specifies if screen space reflections are enabled.
  75345. */
  75346. get screenSpaceReflectionsEnabled(): boolean;
  75347. set screenSpaceReflectionsEnabled(enabled: boolean);
  75348. /**
  75349. * Specifies the number of steps used to calculate the volumetric lights
  75350. * Typically in interval [50, 200]
  75351. */
  75352. get volumetricLightStepsCount(): number;
  75353. set volumetricLightStepsCount(count: number);
  75354. /**
  75355. * Specifies the number of samples used for the motion blur effect
  75356. * Typically in interval [16, 64]
  75357. */
  75358. get motionBlurSamples(): number;
  75359. set motionBlurSamples(samples: number);
  75360. /**
  75361. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75362. */
  75363. get samples(): number;
  75364. set samples(sampleCount: number);
  75365. /**
  75366. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75367. * @constructor
  75368. * @param name The rendering pipeline name
  75369. * @param scene The scene linked to this pipeline
  75370. * @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)
  75371. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75372. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75373. */
  75374. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75375. private _buildPipeline;
  75376. private _createDownSampleX4PostProcess;
  75377. private _createBrightPassPostProcess;
  75378. private _createBlurPostProcesses;
  75379. private _createTextureAdderPostProcess;
  75380. private _createVolumetricLightPostProcess;
  75381. private _createLuminancePostProcesses;
  75382. private _createHdrPostProcess;
  75383. private _createLensFlarePostProcess;
  75384. private _createDepthOfFieldPostProcess;
  75385. private _createMotionBlurPostProcess;
  75386. private _getDepthTexture;
  75387. private _disposePostProcesses;
  75388. /**
  75389. * Dispose of the pipeline and stop all post processes
  75390. */
  75391. dispose(): void;
  75392. /**
  75393. * Serialize the rendering pipeline (Used when exporting)
  75394. * @returns the serialized object
  75395. */
  75396. serialize(): any;
  75397. /**
  75398. * Parse the serialized pipeline
  75399. * @param source Source pipeline.
  75400. * @param scene The scene to load the pipeline to.
  75401. * @param rootUrl The URL of the serialized pipeline.
  75402. * @returns An instantiated pipeline from the serialized object.
  75403. */
  75404. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75405. /**
  75406. * Luminance steps
  75407. */
  75408. static LuminanceSteps: number;
  75409. }
  75410. }
  75411. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75412. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75413. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75414. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75415. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75416. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75417. }
  75418. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75419. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75420. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75421. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75422. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75423. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75424. }
  75425. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75426. /** @hidden */
  75427. export var stereoscopicInterlacePixelShader: {
  75428. name: string;
  75429. shader: string;
  75430. };
  75431. }
  75432. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75433. import { Camera } from "babylonjs/Cameras/camera";
  75434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75435. import { Engine } from "babylonjs/Engines/engine";
  75436. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75437. /**
  75438. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75439. */
  75440. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75441. private _stepSize;
  75442. private _passedProcess;
  75443. /**
  75444. * Gets a string identifying the name of the class
  75445. * @returns "StereoscopicInterlacePostProcessI" string
  75446. */
  75447. getClassName(): string;
  75448. /**
  75449. * Initializes a StereoscopicInterlacePostProcessI
  75450. * @param name The name of the effect.
  75451. * @param rigCameras The rig cameras to be appled to the post process
  75452. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75453. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75455. * @param engine The engine which the post process will be applied. (default: current engine)
  75456. * @param reusable If the post process can be reused on the same frame. (default: false)
  75457. */
  75458. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75459. }
  75460. /**
  75461. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75462. */
  75463. export class StereoscopicInterlacePostProcess extends PostProcess {
  75464. private _stepSize;
  75465. private _passedProcess;
  75466. /**
  75467. * Gets a string identifying the name of the class
  75468. * @returns "StereoscopicInterlacePostProcess" string
  75469. */
  75470. getClassName(): string;
  75471. /**
  75472. * Initializes a StereoscopicInterlacePostProcess
  75473. * @param name The name of the effect.
  75474. * @param rigCameras The rig cameras to be appled to the post process
  75475. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75477. * @param engine The engine which the post process will be applied. (default: current engine)
  75478. * @param reusable If the post process can be reused on the same frame. (default: false)
  75479. */
  75480. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75481. }
  75482. }
  75483. declare module "babylonjs/Shaders/tonemap.fragment" {
  75484. /** @hidden */
  75485. export var tonemapPixelShader: {
  75486. name: string;
  75487. shader: string;
  75488. };
  75489. }
  75490. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75491. import { Camera } from "babylonjs/Cameras/camera";
  75492. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75493. import "babylonjs/Shaders/tonemap.fragment";
  75494. import { Engine } from "babylonjs/Engines/engine";
  75495. /** Defines operator used for tonemapping */
  75496. export enum TonemappingOperator {
  75497. /** Hable */
  75498. Hable = 0,
  75499. /** Reinhard */
  75500. Reinhard = 1,
  75501. /** HejiDawson */
  75502. HejiDawson = 2,
  75503. /** Photographic */
  75504. Photographic = 3
  75505. }
  75506. /**
  75507. * Defines a post process to apply tone mapping
  75508. */
  75509. export class TonemapPostProcess extends PostProcess {
  75510. private _operator;
  75511. /** Defines the required exposure adjustement */
  75512. exposureAdjustment: number;
  75513. /**
  75514. * Gets a string identifying the name of the class
  75515. * @returns "TonemapPostProcess" string
  75516. */
  75517. getClassName(): string;
  75518. /**
  75519. * Creates a new TonemapPostProcess
  75520. * @param name defines the name of the postprocess
  75521. * @param _operator defines the operator to use
  75522. * @param exposureAdjustment defines the required exposure adjustement
  75523. * @param camera defines the camera to use (can be null)
  75524. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75525. * @param engine defines the hosting engine (can be ignore if camera is set)
  75526. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75527. */
  75528. constructor(name: string, _operator: TonemappingOperator,
  75529. /** Defines the required exposure adjustement */
  75530. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75531. }
  75532. }
  75533. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75534. /** @hidden */
  75535. export var volumetricLightScatteringPixelShader: {
  75536. name: string;
  75537. shader: string;
  75538. };
  75539. }
  75540. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75541. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75544. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75545. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75546. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75547. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75548. /** @hidden */
  75549. export var volumetricLightScatteringPassVertexShader: {
  75550. name: string;
  75551. shader: string;
  75552. };
  75553. }
  75554. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75555. /** @hidden */
  75556. export var volumetricLightScatteringPassPixelShader: {
  75557. name: string;
  75558. shader: string;
  75559. };
  75560. }
  75561. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75562. import { Vector3 } from "babylonjs/Maths/math.vector";
  75563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75564. import { Mesh } from "babylonjs/Meshes/mesh";
  75565. import { Camera } from "babylonjs/Cameras/camera";
  75566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75567. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75568. import { Scene } from "babylonjs/scene";
  75569. import "babylonjs/Meshes/Builders/planeBuilder";
  75570. import "babylonjs/Shaders/depth.vertex";
  75571. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75572. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75573. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75574. import { Engine } from "babylonjs/Engines/engine";
  75575. /**
  75576. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75577. */
  75578. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75579. private _volumetricLightScatteringPass;
  75580. private _volumetricLightScatteringRTT;
  75581. private _viewPort;
  75582. private _screenCoordinates;
  75583. private _cachedDefines;
  75584. /**
  75585. * If not undefined, the mesh position is computed from the attached node position
  75586. */
  75587. attachedNode: {
  75588. position: Vector3;
  75589. };
  75590. /**
  75591. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75592. */
  75593. customMeshPosition: Vector3;
  75594. /**
  75595. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75596. */
  75597. useCustomMeshPosition: boolean;
  75598. /**
  75599. * If the post-process should inverse the light scattering direction
  75600. */
  75601. invert: boolean;
  75602. /**
  75603. * The internal mesh used by the post-process
  75604. */
  75605. mesh: Mesh;
  75606. /**
  75607. * @hidden
  75608. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75609. */
  75610. get useDiffuseColor(): boolean;
  75611. set useDiffuseColor(useDiffuseColor: boolean);
  75612. /**
  75613. * Array containing the excluded meshes not rendered in the internal pass
  75614. */
  75615. excludedMeshes: AbstractMesh[];
  75616. /**
  75617. * Controls the overall intensity of the post-process
  75618. */
  75619. exposure: number;
  75620. /**
  75621. * Dissipates each sample's contribution in range [0, 1]
  75622. */
  75623. decay: number;
  75624. /**
  75625. * Controls the overall intensity of each sample
  75626. */
  75627. weight: number;
  75628. /**
  75629. * Controls the density of each sample
  75630. */
  75631. density: number;
  75632. /**
  75633. * @constructor
  75634. * @param name The post-process name
  75635. * @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)
  75636. * @param camera The camera that the post-process will be attached to
  75637. * @param mesh The mesh used to create the light scattering
  75638. * @param samples The post-process quality, default 100
  75639. * @param samplingModeThe post-process filtering mode
  75640. * @param engine The babylon engine
  75641. * @param reusable If the post-process is reusable
  75642. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75643. */
  75644. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75645. /**
  75646. * Returns the string "VolumetricLightScatteringPostProcess"
  75647. * @returns "VolumetricLightScatteringPostProcess"
  75648. */
  75649. getClassName(): string;
  75650. private _isReady;
  75651. /**
  75652. * Sets the new light position for light scattering effect
  75653. * @param position The new custom light position
  75654. */
  75655. setCustomMeshPosition(position: Vector3): void;
  75656. /**
  75657. * Returns the light position for light scattering effect
  75658. * @return Vector3 The custom light position
  75659. */
  75660. getCustomMeshPosition(): Vector3;
  75661. /**
  75662. * Disposes the internal assets and detaches the post-process from the camera
  75663. */
  75664. dispose(camera: Camera): void;
  75665. /**
  75666. * Returns the render target texture used by the post-process
  75667. * @return the render target texture used by the post-process
  75668. */
  75669. getPass(): RenderTargetTexture;
  75670. private _meshExcluded;
  75671. private _createPass;
  75672. private _updateMeshScreenCoordinates;
  75673. /**
  75674. * Creates a default mesh for the Volumeric Light Scattering post-process
  75675. * @param name The mesh name
  75676. * @param scene The scene where to create the mesh
  75677. * @return the default mesh
  75678. */
  75679. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75680. }
  75681. }
  75682. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75683. /** @hidden */
  75684. export var screenSpaceCurvaturePixelShader: {
  75685. name: string;
  75686. shader: string;
  75687. };
  75688. }
  75689. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75690. import { Nullable } from "babylonjs/types";
  75691. import { Camera } from "babylonjs/Cameras/camera";
  75692. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75693. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75694. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75695. import { Engine } from "babylonjs/Engines/engine";
  75696. import { Scene } from "babylonjs/scene";
  75697. /**
  75698. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75699. */
  75700. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75701. /**
  75702. * Defines how much ridge the curvature effect displays.
  75703. */
  75704. ridge: number;
  75705. /**
  75706. * Defines how much valley the curvature effect displays.
  75707. */
  75708. valley: number;
  75709. private _geometryBufferRenderer;
  75710. /**
  75711. * Gets a string identifying the name of the class
  75712. * @returns "ScreenSpaceCurvaturePostProcess" string
  75713. */
  75714. getClassName(): string;
  75715. /**
  75716. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75717. * @param name The name of the effect.
  75718. * @param scene The scene containing the objects to blur according to their velocity.
  75719. * @param options The required width/height ratio to downsize to before computing the render pass.
  75720. * @param camera The camera to apply the render pass to.
  75721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75722. * @param engine The engine which the post process will be applied. (default: current engine)
  75723. * @param reusable If the post process can be reused on the same frame. (default: false)
  75724. * @param textureType Type of textures used when performing the post process. (default: 0)
  75725. * @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)
  75726. */
  75727. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75728. /**
  75729. * Support test.
  75730. */
  75731. static get IsSupported(): boolean;
  75732. /** @hidden */
  75733. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75734. }
  75735. }
  75736. declare module "babylonjs/PostProcesses/index" {
  75737. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75738. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75739. export * from "babylonjs/PostProcesses/bloomEffect";
  75740. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75741. export * from "babylonjs/PostProcesses/blurPostProcess";
  75742. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75743. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75744. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75745. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75746. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75747. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75748. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75749. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75750. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75751. export * from "babylonjs/PostProcesses/filterPostProcess";
  75752. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75753. export * from "babylonjs/PostProcesses/grainPostProcess";
  75754. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75755. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75756. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75757. export * from "babylonjs/PostProcesses/passPostProcess";
  75758. export * from "babylonjs/PostProcesses/postProcess";
  75759. export * from "babylonjs/PostProcesses/postProcessManager";
  75760. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75761. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75762. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75763. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75764. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75765. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75766. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75767. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75768. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75769. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75770. }
  75771. declare module "babylonjs/Probes/index" {
  75772. export * from "babylonjs/Probes/reflectionProbe";
  75773. }
  75774. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75775. import { Scene } from "babylonjs/scene";
  75776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75777. import { SmartArray } from "babylonjs/Misc/smartArray";
  75778. import { ISceneComponent } from "babylonjs/sceneComponent";
  75779. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75780. import "babylonjs/Meshes/Builders/boxBuilder";
  75781. import "babylonjs/Shaders/color.fragment";
  75782. import "babylonjs/Shaders/color.vertex";
  75783. import { Color3 } from "babylonjs/Maths/math.color";
  75784. import { Observable } from "babylonjs/Misc/observable";
  75785. module "babylonjs/scene" {
  75786. interface Scene {
  75787. /** @hidden (Backing field) */
  75788. _boundingBoxRenderer: BoundingBoxRenderer;
  75789. /** @hidden (Backing field) */
  75790. _forceShowBoundingBoxes: boolean;
  75791. /**
  75792. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75793. */
  75794. forceShowBoundingBoxes: boolean;
  75795. /**
  75796. * Gets the bounding box renderer associated with the scene
  75797. * @returns a BoundingBoxRenderer
  75798. */
  75799. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75800. }
  75801. }
  75802. module "babylonjs/Meshes/abstractMesh" {
  75803. interface AbstractMesh {
  75804. /** @hidden (Backing field) */
  75805. _showBoundingBox: boolean;
  75806. /**
  75807. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75808. */
  75809. showBoundingBox: boolean;
  75810. }
  75811. }
  75812. /**
  75813. * Component responsible of rendering the bounding box of the meshes in a scene.
  75814. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75815. */
  75816. export class BoundingBoxRenderer implements ISceneComponent {
  75817. /**
  75818. * The component name helpfull to identify the component in the list of scene components.
  75819. */
  75820. readonly name: string;
  75821. /**
  75822. * The scene the component belongs to.
  75823. */
  75824. scene: Scene;
  75825. /**
  75826. * Color of the bounding box lines placed in front of an object
  75827. */
  75828. frontColor: Color3;
  75829. /**
  75830. * Color of the bounding box lines placed behind an object
  75831. */
  75832. backColor: Color3;
  75833. /**
  75834. * Defines if the renderer should show the back lines or not
  75835. */
  75836. showBackLines: boolean;
  75837. /**
  75838. * Observable raised before rendering a bounding box
  75839. */
  75840. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75841. /**
  75842. * Observable raised after rendering a bounding box
  75843. */
  75844. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75845. /**
  75846. * @hidden
  75847. */
  75848. renderList: SmartArray<BoundingBox>;
  75849. private _colorShader;
  75850. private _vertexBuffers;
  75851. private _indexBuffer;
  75852. private _fillIndexBuffer;
  75853. private _fillIndexData;
  75854. /**
  75855. * Instantiates a new bounding box renderer in a scene.
  75856. * @param scene the scene the renderer renders in
  75857. */
  75858. constructor(scene: Scene);
  75859. /**
  75860. * Registers the component in a given scene
  75861. */
  75862. register(): void;
  75863. private _evaluateSubMesh;
  75864. private _activeMesh;
  75865. private _prepareRessources;
  75866. private _createIndexBuffer;
  75867. /**
  75868. * Rebuilds the elements related to this component in case of
  75869. * context lost for instance.
  75870. */
  75871. rebuild(): void;
  75872. /**
  75873. * @hidden
  75874. */
  75875. reset(): void;
  75876. /**
  75877. * Render the bounding boxes of a specific rendering group
  75878. * @param renderingGroupId defines the rendering group to render
  75879. */
  75880. render(renderingGroupId: number): void;
  75881. /**
  75882. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75883. * @param mesh Define the mesh to render the occlusion bounding box for
  75884. */
  75885. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75886. /**
  75887. * Dispose and release the resources attached to this renderer.
  75888. */
  75889. dispose(): void;
  75890. }
  75891. }
  75892. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75893. import { Nullable } from "babylonjs/types";
  75894. import { Scene } from "babylonjs/scene";
  75895. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75896. import { Camera } from "babylonjs/Cameras/camera";
  75897. import { ISceneComponent } from "babylonjs/sceneComponent";
  75898. module "babylonjs/scene" {
  75899. interface Scene {
  75900. /** @hidden (Backing field) */
  75901. _depthRenderer: {
  75902. [id: string]: DepthRenderer;
  75903. };
  75904. /**
  75905. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75906. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75907. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75908. * @returns the created depth renderer
  75909. */
  75910. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75911. /**
  75912. * Disables a depth renderer for a given camera
  75913. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75914. */
  75915. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75916. }
  75917. }
  75918. /**
  75919. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75920. * in several rendering techniques.
  75921. */
  75922. export class DepthRendererSceneComponent implements ISceneComponent {
  75923. /**
  75924. * The component name helpfull to identify the component in the list of scene components.
  75925. */
  75926. readonly name: string;
  75927. /**
  75928. * The scene the component belongs to.
  75929. */
  75930. scene: Scene;
  75931. /**
  75932. * Creates a new instance of the component for the given scene
  75933. * @param scene Defines the scene to register the component in
  75934. */
  75935. constructor(scene: Scene);
  75936. /**
  75937. * Registers the component in a given scene
  75938. */
  75939. register(): void;
  75940. /**
  75941. * Rebuilds the elements related to this component in case of
  75942. * context lost for instance.
  75943. */
  75944. rebuild(): void;
  75945. /**
  75946. * Disposes the component and the associated ressources
  75947. */
  75948. dispose(): void;
  75949. private _gatherRenderTargets;
  75950. private _gatherActiveCameraRenderTargets;
  75951. }
  75952. }
  75953. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75954. import { Nullable } from "babylonjs/types";
  75955. import { Scene } from "babylonjs/scene";
  75956. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75957. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75958. import { AbstractScene } from "babylonjs/abstractScene";
  75959. module "babylonjs/abstractScene" {
  75960. interface AbstractScene {
  75961. /** @hidden (Backing field) */
  75962. _prePassRenderer: Nullable<PrePassRenderer>;
  75963. /**
  75964. * Gets or Sets the current prepass renderer associated to the scene.
  75965. */
  75966. prePassRenderer: Nullable<PrePassRenderer>;
  75967. /**
  75968. * Enables the prepass and associates it with the scene
  75969. * @returns the PrePassRenderer
  75970. */
  75971. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75972. /**
  75973. * Disables the prepass associated with the scene
  75974. */
  75975. disablePrePassRenderer(): void;
  75976. }
  75977. }
  75978. /**
  75979. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75980. * in several rendering techniques.
  75981. */
  75982. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75983. /**
  75984. * The component name helpful to identify the component in the list of scene components.
  75985. */
  75986. readonly name: string;
  75987. /**
  75988. * The scene the component belongs to.
  75989. */
  75990. scene: Scene;
  75991. /**
  75992. * Creates a new instance of the component for the given scene
  75993. * @param scene Defines the scene to register the component in
  75994. */
  75995. constructor(scene: Scene);
  75996. /**
  75997. * Registers the component in a given scene
  75998. */
  75999. register(): void;
  76000. private _beforeCameraDraw;
  76001. private _afterCameraDraw;
  76002. private _beforeClearStage;
  76003. /**
  76004. * Serializes the component data to the specified json object
  76005. * @param serializationObject The object to serialize to
  76006. */
  76007. serialize(serializationObject: any): void;
  76008. /**
  76009. * Adds all the elements from the container to the scene
  76010. * @param container the container holding the elements
  76011. */
  76012. addFromContainer(container: AbstractScene): void;
  76013. /**
  76014. * Removes all the elements in the container from the scene
  76015. * @param container contains the elements to remove
  76016. * @param dispose if the removed element should be disposed (default: false)
  76017. */
  76018. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76019. /**
  76020. * Rebuilds the elements related to this component in case of
  76021. * context lost for instance.
  76022. */
  76023. rebuild(): void;
  76024. /**
  76025. * Disposes the component and the associated ressources
  76026. */
  76027. dispose(): void;
  76028. }
  76029. }
  76030. declare module "babylonjs/Shaders/outline.fragment" {
  76031. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76032. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76033. /** @hidden */
  76034. export var outlinePixelShader: {
  76035. name: string;
  76036. shader: string;
  76037. };
  76038. }
  76039. declare module "babylonjs/Shaders/outline.vertex" {
  76040. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76041. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76042. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76043. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76044. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76045. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76046. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76047. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76048. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76049. /** @hidden */
  76050. export var outlineVertexShader: {
  76051. name: string;
  76052. shader: string;
  76053. };
  76054. }
  76055. declare module "babylonjs/Rendering/outlineRenderer" {
  76056. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76057. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76058. import { Scene } from "babylonjs/scene";
  76059. import { ISceneComponent } from "babylonjs/sceneComponent";
  76060. import "babylonjs/Shaders/outline.fragment";
  76061. import "babylonjs/Shaders/outline.vertex";
  76062. module "babylonjs/scene" {
  76063. interface Scene {
  76064. /** @hidden */
  76065. _outlineRenderer: OutlineRenderer;
  76066. /**
  76067. * Gets the outline renderer associated with the scene
  76068. * @returns a OutlineRenderer
  76069. */
  76070. getOutlineRenderer(): OutlineRenderer;
  76071. }
  76072. }
  76073. module "babylonjs/Meshes/abstractMesh" {
  76074. interface AbstractMesh {
  76075. /** @hidden (Backing field) */
  76076. _renderOutline: boolean;
  76077. /**
  76078. * Gets or sets a boolean indicating if the outline must be rendered as well
  76079. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76080. */
  76081. renderOutline: boolean;
  76082. /** @hidden (Backing field) */
  76083. _renderOverlay: boolean;
  76084. /**
  76085. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76086. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76087. */
  76088. renderOverlay: boolean;
  76089. }
  76090. }
  76091. /**
  76092. * This class is responsible to draw bothe outline/overlay of meshes.
  76093. * It should not be used directly but through the available method on mesh.
  76094. */
  76095. export class OutlineRenderer implements ISceneComponent {
  76096. /**
  76097. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76098. */
  76099. private static _StencilReference;
  76100. /**
  76101. * The name of the component. Each component must have a unique name.
  76102. */
  76103. name: string;
  76104. /**
  76105. * The scene the component belongs to.
  76106. */
  76107. scene: Scene;
  76108. /**
  76109. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76110. */
  76111. zOffset: number;
  76112. private _engine;
  76113. private _effect;
  76114. private _cachedDefines;
  76115. private _savedDepthWrite;
  76116. /**
  76117. * Instantiates a new outline renderer. (There could be only one per scene).
  76118. * @param scene Defines the scene it belongs to
  76119. */
  76120. constructor(scene: Scene);
  76121. /**
  76122. * Register the component to one instance of a scene.
  76123. */
  76124. register(): void;
  76125. /**
  76126. * Rebuilds the elements related to this component in case of
  76127. * context lost for instance.
  76128. */
  76129. rebuild(): void;
  76130. /**
  76131. * Disposes the component and the associated ressources.
  76132. */
  76133. dispose(): void;
  76134. /**
  76135. * Renders the outline in the canvas.
  76136. * @param subMesh Defines the sumesh to render
  76137. * @param batch Defines the batch of meshes in case of instances
  76138. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76139. */
  76140. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76141. /**
  76142. * Returns whether or not the outline renderer is ready for a given submesh.
  76143. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76144. * @param subMesh Defines the submesh to check readyness for
  76145. * @param useInstances Defines wheter wee are trying to render instances or not
  76146. * @returns true if ready otherwise false
  76147. */
  76148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76149. private _beforeRenderingMesh;
  76150. private _afterRenderingMesh;
  76151. }
  76152. }
  76153. declare module "babylonjs/Rendering/index" {
  76154. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76155. export * from "babylonjs/Rendering/depthRenderer";
  76156. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76157. export * from "babylonjs/Rendering/edgesRenderer";
  76158. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76159. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76160. export * from "babylonjs/Rendering/prePassRenderer";
  76161. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76162. export * from "babylonjs/Rendering/outlineRenderer";
  76163. export * from "babylonjs/Rendering/renderingGroup";
  76164. export * from "babylonjs/Rendering/renderingManager";
  76165. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76166. }
  76167. declare module "babylonjs/Sprites/ISprites" {
  76168. /**
  76169. * Defines the basic options interface of a Sprite Frame Source Size.
  76170. */
  76171. export interface ISpriteJSONSpriteSourceSize {
  76172. /**
  76173. * number of the original width of the Frame
  76174. */
  76175. w: number;
  76176. /**
  76177. * number of the original height of the Frame
  76178. */
  76179. h: number;
  76180. }
  76181. /**
  76182. * Defines the basic options interface of a Sprite Frame Data.
  76183. */
  76184. export interface ISpriteJSONSpriteFrameData {
  76185. /**
  76186. * number of the x offset of the Frame
  76187. */
  76188. x: number;
  76189. /**
  76190. * number of the y offset of the Frame
  76191. */
  76192. y: number;
  76193. /**
  76194. * number of the width of the Frame
  76195. */
  76196. w: number;
  76197. /**
  76198. * number of the height of the Frame
  76199. */
  76200. h: number;
  76201. }
  76202. /**
  76203. * Defines the basic options interface of a JSON Sprite.
  76204. */
  76205. export interface ISpriteJSONSprite {
  76206. /**
  76207. * string name of the Frame
  76208. */
  76209. filename: string;
  76210. /**
  76211. * ISpriteJSONSpriteFrame basic object of the frame data
  76212. */
  76213. frame: ISpriteJSONSpriteFrameData;
  76214. /**
  76215. * boolean to flag is the frame was rotated.
  76216. */
  76217. rotated: boolean;
  76218. /**
  76219. * boolean to flag is the frame was trimmed.
  76220. */
  76221. trimmed: boolean;
  76222. /**
  76223. * ISpriteJSONSpriteFrame basic object of the source data
  76224. */
  76225. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76226. /**
  76227. * ISpriteJSONSpriteFrame basic object of the source data
  76228. */
  76229. sourceSize: ISpriteJSONSpriteSourceSize;
  76230. }
  76231. /**
  76232. * Defines the basic options interface of a JSON atlas.
  76233. */
  76234. export interface ISpriteJSONAtlas {
  76235. /**
  76236. * Array of objects that contain the frame data.
  76237. */
  76238. frames: Array<ISpriteJSONSprite>;
  76239. /**
  76240. * object basic object containing the sprite meta data.
  76241. */
  76242. meta?: object;
  76243. }
  76244. }
  76245. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76246. /** @hidden */
  76247. export var spriteMapPixelShader: {
  76248. name: string;
  76249. shader: string;
  76250. };
  76251. }
  76252. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76253. /** @hidden */
  76254. export var spriteMapVertexShader: {
  76255. name: string;
  76256. shader: string;
  76257. };
  76258. }
  76259. declare module "babylonjs/Sprites/spriteMap" {
  76260. import { IDisposable, Scene } from "babylonjs/scene";
  76261. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76262. import { Texture } from "babylonjs/Materials/Textures/texture";
  76263. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76264. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76265. import "babylonjs/Meshes/Builders/planeBuilder";
  76266. import "babylonjs/Shaders/spriteMap.fragment";
  76267. import "babylonjs/Shaders/spriteMap.vertex";
  76268. /**
  76269. * Defines the basic options interface of a SpriteMap
  76270. */
  76271. export interface ISpriteMapOptions {
  76272. /**
  76273. * Vector2 of the number of cells in the grid.
  76274. */
  76275. stageSize?: Vector2;
  76276. /**
  76277. * Vector2 of the size of the output plane in World Units.
  76278. */
  76279. outputSize?: Vector2;
  76280. /**
  76281. * Vector3 of the position of the output plane in World Units.
  76282. */
  76283. outputPosition?: Vector3;
  76284. /**
  76285. * Vector3 of the rotation of the output plane.
  76286. */
  76287. outputRotation?: Vector3;
  76288. /**
  76289. * number of layers that the system will reserve in resources.
  76290. */
  76291. layerCount?: number;
  76292. /**
  76293. * number of max animation frames a single cell will reserve in resources.
  76294. */
  76295. maxAnimationFrames?: number;
  76296. /**
  76297. * number cell index of the base tile when the system compiles.
  76298. */
  76299. baseTile?: number;
  76300. /**
  76301. * boolean flip the sprite after its been repositioned by the framing data.
  76302. */
  76303. flipU?: boolean;
  76304. /**
  76305. * Vector3 scalar of the global RGB values of the SpriteMap.
  76306. */
  76307. colorMultiply?: Vector3;
  76308. }
  76309. /**
  76310. * Defines the IDisposable interface in order to be cleanable from resources.
  76311. */
  76312. export interface ISpriteMap extends IDisposable {
  76313. /**
  76314. * String name of the SpriteMap.
  76315. */
  76316. name: string;
  76317. /**
  76318. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76319. */
  76320. atlasJSON: ISpriteJSONAtlas;
  76321. /**
  76322. * Texture of the SpriteMap.
  76323. */
  76324. spriteSheet: Texture;
  76325. /**
  76326. * The parameters to initialize the SpriteMap with.
  76327. */
  76328. options: ISpriteMapOptions;
  76329. }
  76330. /**
  76331. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76332. */
  76333. export class SpriteMap implements ISpriteMap {
  76334. /** The Name of the spriteMap */
  76335. name: string;
  76336. /** The JSON file with the frame and meta data */
  76337. atlasJSON: ISpriteJSONAtlas;
  76338. /** The systems Sprite Sheet Texture */
  76339. spriteSheet: Texture;
  76340. /** Arguments passed with the Constructor */
  76341. options: ISpriteMapOptions;
  76342. /** Public Sprite Storage array, parsed from atlasJSON */
  76343. sprites: Array<ISpriteJSONSprite>;
  76344. /** Returns the Number of Sprites in the System */
  76345. get spriteCount(): number;
  76346. /** Returns the Position of Output Plane*/
  76347. get position(): Vector3;
  76348. /** Returns the Position of Output Plane*/
  76349. set position(v: Vector3);
  76350. /** Returns the Rotation of Output Plane*/
  76351. get rotation(): Vector3;
  76352. /** Returns the Rotation of Output Plane*/
  76353. set rotation(v: Vector3);
  76354. /** Sets the AnimationMap*/
  76355. get animationMap(): RawTexture;
  76356. /** Sets the AnimationMap*/
  76357. set animationMap(v: RawTexture);
  76358. /** Scene that the SpriteMap was created in */
  76359. private _scene;
  76360. /** Texture Buffer of Float32 that holds tile frame data*/
  76361. private _frameMap;
  76362. /** Texture Buffers of Float32 that holds tileMap data*/
  76363. private _tileMaps;
  76364. /** Texture Buffer of Float32 that holds Animation Data*/
  76365. private _animationMap;
  76366. /** Custom ShaderMaterial Central to the System*/
  76367. private _material;
  76368. /** Custom ShaderMaterial Central to the System*/
  76369. private _output;
  76370. /** Systems Time Ticker*/
  76371. private _time;
  76372. /**
  76373. * Creates a new SpriteMap
  76374. * @param name defines the SpriteMaps Name
  76375. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76376. * @param spriteSheet is the Texture that the Sprites are on.
  76377. * @param options a basic deployment configuration
  76378. * @param scene The Scene that the map is deployed on
  76379. */
  76380. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76381. /**
  76382. * Returns tileID location
  76383. * @returns Vector2 the cell position ID
  76384. */
  76385. getTileID(): Vector2;
  76386. /**
  76387. * Gets the UV location of the mouse over the SpriteMap.
  76388. * @returns Vector2 the UV position of the mouse interaction
  76389. */
  76390. getMousePosition(): Vector2;
  76391. /**
  76392. * Creates the "frame" texture Buffer
  76393. * -------------------------------------
  76394. * Structure of frames
  76395. * "filename": "Falling-Water-2.png",
  76396. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76397. * "rotated": true,
  76398. * "trimmed": true,
  76399. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76400. * "sourceSize": {"w":32,"h":32}
  76401. * @returns RawTexture of the frameMap
  76402. */
  76403. private _createFrameBuffer;
  76404. /**
  76405. * Creates the tileMap texture Buffer
  76406. * @param buffer normally and array of numbers, or a false to generate from scratch
  76407. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76408. * @returns RawTexture of the tileMap
  76409. */
  76410. private _createTileBuffer;
  76411. /**
  76412. * Modifies the data of the tileMaps
  76413. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76414. * @param pos is the iVector2 Coordinates of the Tile
  76415. * @param tile The SpriteIndex of the new Tile
  76416. */
  76417. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76418. /**
  76419. * Creates the animationMap texture Buffer
  76420. * @param buffer normally and array of numbers, or a false to generate from scratch
  76421. * @returns RawTexture of the animationMap
  76422. */
  76423. private _createTileAnimationBuffer;
  76424. /**
  76425. * Modifies the data of the animationMap
  76426. * @param cellID is the Index of the Sprite
  76427. * @param _frame is the target Animation frame
  76428. * @param toCell is the Target Index of the next frame of the animation
  76429. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76430. * @param speed is a global scalar of the time variable on the map.
  76431. */
  76432. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76433. /**
  76434. * Exports the .tilemaps file
  76435. */
  76436. saveTileMaps(): void;
  76437. /**
  76438. * Imports the .tilemaps file
  76439. * @param url of the .tilemaps file
  76440. */
  76441. loadTileMaps(url: string): void;
  76442. /**
  76443. * Release associated resources
  76444. */
  76445. dispose(): void;
  76446. }
  76447. }
  76448. declare module "babylonjs/Sprites/spritePackedManager" {
  76449. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76450. import { Scene } from "babylonjs/scene";
  76451. /**
  76452. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76453. * @see https://doc.babylonjs.com/babylon101/sprites
  76454. */
  76455. export class SpritePackedManager extends SpriteManager {
  76456. /** defines the packed manager's name */
  76457. name: string;
  76458. /**
  76459. * Creates a new sprite manager from a packed sprite sheet
  76460. * @param name defines the manager's name
  76461. * @param imgUrl defines the sprite sheet url
  76462. * @param capacity defines the maximum allowed number of sprites
  76463. * @param scene defines the hosting scene
  76464. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76465. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76466. * @param samplingMode defines the smapling mode to use with spritesheet
  76467. * @param fromPacked set to true; do not alter
  76468. */
  76469. constructor(
  76470. /** defines the packed manager's name */
  76471. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76472. }
  76473. }
  76474. declare module "babylonjs/Sprites/index" {
  76475. export * from "babylonjs/Sprites/sprite";
  76476. export * from "babylonjs/Sprites/ISprites";
  76477. export * from "babylonjs/Sprites/spriteManager";
  76478. export * from "babylonjs/Sprites/spriteMap";
  76479. export * from "babylonjs/Sprites/spritePackedManager";
  76480. export * from "babylonjs/Sprites/spriteSceneComponent";
  76481. }
  76482. declare module "babylonjs/States/index" {
  76483. export * from "babylonjs/States/alphaCullingState";
  76484. export * from "babylonjs/States/depthCullingState";
  76485. export * from "babylonjs/States/stencilState";
  76486. }
  76487. declare module "babylonjs/Misc/assetsManager" {
  76488. import { Scene } from "babylonjs/scene";
  76489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76490. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76491. import { Skeleton } from "babylonjs/Bones/skeleton";
  76492. import { Observable } from "babylonjs/Misc/observable";
  76493. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76494. import { Texture } from "babylonjs/Materials/Textures/texture";
  76495. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76496. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76497. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76498. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76499. import { AssetContainer } from "babylonjs/assetContainer";
  76500. /**
  76501. * Defines the list of states available for a task inside a AssetsManager
  76502. */
  76503. export enum AssetTaskState {
  76504. /**
  76505. * Initialization
  76506. */
  76507. INIT = 0,
  76508. /**
  76509. * Running
  76510. */
  76511. RUNNING = 1,
  76512. /**
  76513. * Done
  76514. */
  76515. DONE = 2,
  76516. /**
  76517. * Error
  76518. */
  76519. ERROR = 3
  76520. }
  76521. /**
  76522. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76523. */
  76524. export abstract class AbstractAssetTask {
  76525. /**
  76526. * Task name
  76527. */ name: string;
  76528. /**
  76529. * Callback called when the task is successful
  76530. */
  76531. onSuccess: (task: any) => void;
  76532. /**
  76533. * Callback called when the task is not successful
  76534. */
  76535. onError: (task: any, message?: string, exception?: any) => void;
  76536. /**
  76537. * Creates a new AssetsManager
  76538. * @param name defines the name of the task
  76539. */
  76540. constructor(
  76541. /**
  76542. * Task name
  76543. */ name: string);
  76544. private _isCompleted;
  76545. private _taskState;
  76546. private _errorObject;
  76547. /**
  76548. * Get if the task is completed
  76549. */
  76550. get isCompleted(): boolean;
  76551. /**
  76552. * Gets the current state of the task
  76553. */
  76554. get taskState(): AssetTaskState;
  76555. /**
  76556. * Gets the current error object (if task is in error)
  76557. */
  76558. get errorObject(): {
  76559. message?: string;
  76560. exception?: any;
  76561. };
  76562. /**
  76563. * Internal only
  76564. * @hidden
  76565. */
  76566. _setErrorObject(message?: string, exception?: any): void;
  76567. /**
  76568. * Execute the current task
  76569. * @param scene defines the scene where you want your assets to be loaded
  76570. * @param onSuccess is a callback called when the task is successfully executed
  76571. * @param onError is a callback called if an error occurs
  76572. */
  76573. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76574. /**
  76575. * Execute the current task
  76576. * @param scene defines the scene where you want your assets to be loaded
  76577. * @param onSuccess is a callback called when the task is successfully executed
  76578. * @param onError is a callback called if an error occurs
  76579. */
  76580. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76581. /**
  76582. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76583. * This can be used with failed tasks that have the reason for failure fixed.
  76584. */
  76585. reset(): void;
  76586. private onErrorCallback;
  76587. private onDoneCallback;
  76588. }
  76589. /**
  76590. * Define the interface used by progress events raised during assets loading
  76591. */
  76592. export interface IAssetsProgressEvent {
  76593. /**
  76594. * Defines the number of remaining tasks to process
  76595. */
  76596. remainingCount: number;
  76597. /**
  76598. * Defines the total number of tasks
  76599. */
  76600. totalCount: number;
  76601. /**
  76602. * Defines the task that was just processed
  76603. */
  76604. task: AbstractAssetTask;
  76605. }
  76606. /**
  76607. * Class used to share progress information about assets loading
  76608. */
  76609. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76610. /**
  76611. * Defines the number of remaining tasks to process
  76612. */
  76613. remainingCount: number;
  76614. /**
  76615. * Defines the total number of tasks
  76616. */
  76617. totalCount: number;
  76618. /**
  76619. * Defines the task that was just processed
  76620. */
  76621. task: AbstractAssetTask;
  76622. /**
  76623. * Creates a AssetsProgressEvent
  76624. * @param remainingCount defines the number of remaining tasks to process
  76625. * @param totalCount defines the total number of tasks
  76626. * @param task defines the task that was just processed
  76627. */
  76628. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76629. }
  76630. /**
  76631. * Define a task used by AssetsManager to load assets into a container
  76632. */
  76633. export class ContainerAssetTask extends AbstractAssetTask {
  76634. /**
  76635. * Defines the name of the task
  76636. */
  76637. name: string;
  76638. /**
  76639. * Defines the list of mesh's names you want to load
  76640. */
  76641. meshesNames: any;
  76642. /**
  76643. * Defines the root url to use as a base to load your meshes and associated resources
  76644. */
  76645. rootUrl: string;
  76646. /**
  76647. * Defines the filename or File of the scene to load from
  76648. */
  76649. sceneFilename: string | File;
  76650. /**
  76651. * Get the loaded asset container
  76652. */
  76653. loadedContainer: AssetContainer;
  76654. /**
  76655. * Gets the list of loaded meshes
  76656. */
  76657. loadedMeshes: Array<AbstractMesh>;
  76658. /**
  76659. * Gets the list of loaded particle systems
  76660. */
  76661. loadedParticleSystems: Array<IParticleSystem>;
  76662. /**
  76663. * Gets the list of loaded skeletons
  76664. */
  76665. loadedSkeletons: Array<Skeleton>;
  76666. /**
  76667. * Gets the list of loaded animation groups
  76668. */
  76669. loadedAnimationGroups: Array<AnimationGroup>;
  76670. /**
  76671. * Callback called when the task is successful
  76672. */
  76673. onSuccess: (task: ContainerAssetTask) => void;
  76674. /**
  76675. * Callback called when the task is successful
  76676. */
  76677. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76678. /**
  76679. * Creates a new ContainerAssetTask
  76680. * @param name defines the name of the task
  76681. * @param meshesNames defines the list of mesh's names you want to load
  76682. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76683. * @param sceneFilename defines the filename or File of the scene to load from
  76684. */
  76685. constructor(
  76686. /**
  76687. * Defines the name of the task
  76688. */
  76689. name: string,
  76690. /**
  76691. * Defines the list of mesh's names you want to load
  76692. */
  76693. meshesNames: any,
  76694. /**
  76695. * Defines the root url to use as a base to load your meshes and associated resources
  76696. */
  76697. rootUrl: string,
  76698. /**
  76699. * Defines the filename or File of the scene to load from
  76700. */
  76701. sceneFilename: string | File);
  76702. /**
  76703. * Execute the current task
  76704. * @param scene defines the scene where you want your assets to be loaded
  76705. * @param onSuccess is a callback called when the task is successfully executed
  76706. * @param onError is a callback called if an error occurs
  76707. */
  76708. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76709. }
  76710. /**
  76711. * Define a task used by AssetsManager to load meshes
  76712. */
  76713. export class MeshAssetTask extends AbstractAssetTask {
  76714. /**
  76715. * Defines the name of the task
  76716. */
  76717. name: string;
  76718. /**
  76719. * Defines the list of mesh's names you want to load
  76720. */
  76721. meshesNames: any;
  76722. /**
  76723. * Defines the root url to use as a base to load your meshes and associated resources
  76724. */
  76725. rootUrl: string;
  76726. /**
  76727. * Defines the filename or File of the scene to load from
  76728. */
  76729. sceneFilename: string | File;
  76730. /**
  76731. * Gets the list of loaded meshes
  76732. */
  76733. loadedMeshes: Array<AbstractMesh>;
  76734. /**
  76735. * Gets the list of loaded particle systems
  76736. */
  76737. loadedParticleSystems: Array<IParticleSystem>;
  76738. /**
  76739. * Gets the list of loaded skeletons
  76740. */
  76741. loadedSkeletons: Array<Skeleton>;
  76742. /**
  76743. * Gets the list of loaded animation groups
  76744. */
  76745. loadedAnimationGroups: Array<AnimationGroup>;
  76746. /**
  76747. * Callback called when the task is successful
  76748. */
  76749. onSuccess: (task: MeshAssetTask) => void;
  76750. /**
  76751. * Callback called when the task is successful
  76752. */
  76753. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76754. /**
  76755. * Creates a new MeshAssetTask
  76756. * @param name defines the name of the task
  76757. * @param meshesNames defines the list of mesh's names you want to load
  76758. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76759. * @param sceneFilename defines the filename or File of the scene to load from
  76760. */
  76761. constructor(
  76762. /**
  76763. * Defines the name of the task
  76764. */
  76765. name: string,
  76766. /**
  76767. * Defines the list of mesh's names you want to load
  76768. */
  76769. meshesNames: any,
  76770. /**
  76771. * Defines the root url to use as a base to load your meshes and associated resources
  76772. */
  76773. rootUrl: string,
  76774. /**
  76775. * Defines the filename or File of the scene to load from
  76776. */
  76777. sceneFilename: string | File);
  76778. /**
  76779. * Execute the current task
  76780. * @param scene defines the scene where you want your assets to be loaded
  76781. * @param onSuccess is a callback called when the task is successfully executed
  76782. * @param onError is a callback called if an error occurs
  76783. */
  76784. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76785. }
  76786. /**
  76787. * Define a task used by AssetsManager to load text content
  76788. */
  76789. export class TextFileAssetTask extends AbstractAssetTask {
  76790. /**
  76791. * Defines the name of the task
  76792. */
  76793. name: string;
  76794. /**
  76795. * Defines the location of the file to load
  76796. */
  76797. url: string;
  76798. /**
  76799. * Gets the loaded text string
  76800. */
  76801. text: string;
  76802. /**
  76803. * Callback called when the task is successful
  76804. */
  76805. onSuccess: (task: TextFileAssetTask) => void;
  76806. /**
  76807. * Callback called when the task is successful
  76808. */
  76809. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76810. /**
  76811. * Creates a new TextFileAssetTask object
  76812. * @param name defines the name of the task
  76813. * @param url defines the location of the file to load
  76814. */
  76815. constructor(
  76816. /**
  76817. * Defines the name of the task
  76818. */
  76819. name: string,
  76820. /**
  76821. * Defines the location of the file to load
  76822. */
  76823. url: string);
  76824. /**
  76825. * Execute the current task
  76826. * @param scene defines the scene where you want your assets to be loaded
  76827. * @param onSuccess is a callback called when the task is successfully executed
  76828. * @param onError is a callback called if an error occurs
  76829. */
  76830. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76831. }
  76832. /**
  76833. * Define a task used by AssetsManager to load binary data
  76834. */
  76835. export class BinaryFileAssetTask extends AbstractAssetTask {
  76836. /**
  76837. * Defines the name of the task
  76838. */
  76839. name: string;
  76840. /**
  76841. * Defines the location of the file to load
  76842. */
  76843. url: string;
  76844. /**
  76845. * Gets the lodaded data (as an array buffer)
  76846. */
  76847. data: ArrayBuffer;
  76848. /**
  76849. * Callback called when the task is successful
  76850. */
  76851. onSuccess: (task: BinaryFileAssetTask) => void;
  76852. /**
  76853. * Callback called when the task is successful
  76854. */
  76855. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76856. /**
  76857. * Creates a new BinaryFileAssetTask object
  76858. * @param name defines the name of the new task
  76859. * @param url defines the location of the file to load
  76860. */
  76861. constructor(
  76862. /**
  76863. * Defines the name of the task
  76864. */
  76865. name: string,
  76866. /**
  76867. * Defines the location of the file to load
  76868. */
  76869. url: string);
  76870. /**
  76871. * Execute the current task
  76872. * @param scene defines the scene where you want your assets to be loaded
  76873. * @param onSuccess is a callback called when the task is successfully executed
  76874. * @param onError is a callback called if an error occurs
  76875. */
  76876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76877. }
  76878. /**
  76879. * Define a task used by AssetsManager to load images
  76880. */
  76881. export class ImageAssetTask extends AbstractAssetTask {
  76882. /**
  76883. * Defines the name of the task
  76884. */
  76885. name: string;
  76886. /**
  76887. * Defines the location of the image to load
  76888. */
  76889. url: string;
  76890. /**
  76891. * Gets the loaded images
  76892. */
  76893. image: HTMLImageElement;
  76894. /**
  76895. * Callback called when the task is successful
  76896. */
  76897. onSuccess: (task: ImageAssetTask) => void;
  76898. /**
  76899. * Callback called when the task is successful
  76900. */
  76901. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76902. /**
  76903. * Creates a new ImageAssetTask
  76904. * @param name defines the name of the task
  76905. * @param url defines the location of the image to load
  76906. */
  76907. constructor(
  76908. /**
  76909. * Defines the name of the task
  76910. */
  76911. name: string,
  76912. /**
  76913. * Defines the location of the image to load
  76914. */
  76915. url: string);
  76916. /**
  76917. * Execute the current task
  76918. * @param scene defines the scene where you want your assets to be loaded
  76919. * @param onSuccess is a callback called when the task is successfully executed
  76920. * @param onError is a callback called if an error occurs
  76921. */
  76922. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76923. }
  76924. /**
  76925. * Defines the interface used by texture loading tasks
  76926. */
  76927. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76928. /**
  76929. * Gets the loaded texture
  76930. */
  76931. texture: TEX;
  76932. }
  76933. /**
  76934. * Define a task used by AssetsManager to load 2D textures
  76935. */
  76936. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76937. /**
  76938. * Defines the name of the task
  76939. */
  76940. name: string;
  76941. /**
  76942. * Defines the location of the file to load
  76943. */
  76944. url: string;
  76945. /**
  76946. * Defines if mipmap should not be generated (default is false)
  76947. */
  76948. noMipmap?: boolean | undefined;
  76949. /**
  76950. * Defines if texture must be inverted on Y axis (default is true)
  76951. */
  76952. invertY: boolean;
  76953. /**
  76954. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76955. */
  76956. samplingMode: number;
  76957. /**
  76958. * Gets the loaded texture
  76959. */
  76960. texture: Texture;
  76961. /**
  76962. * Callback called when the task is successful
  76963. */
  76964. onSuccess: (task: TextureAssetTask) => void;
  76965. /**
  76966. * Callback called when the task is successful
  76967. */
  76968. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76969. /**
  76970. * Creates a new TextureAssetTask object
  76971. * @param name defines the name of the task
  76972. * @param url defines the location of the file to load
  76973. * @param noMipmap defines if mipmap should not be generated (default is false)
  76974. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76975. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76976. */
  76977. constructor(
  76978. /**
  76979. * Defines the name of the task
  76980. */
  76981. name: string,
  76982. /**
  76983. * Defines the location of the file to load
  76984. */
  76985. url: string,
  76986. /**
  76987. * Defines if mipmap should not be generated (default is false)
  76988. */
  76989. noMipmap?: boolean | undefined,
  76990. /**
  76991. * Defines if texture must be inverted on Y axis (default is true)
  76992. */
  76993. invertY?: boolean,
  76994. /**
  76995. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76996. */
  76997. samplingMode?: number);
  76998. /**
  76999. * Execute the current task
  77000. * @param scene defines the scene where you want your assets to be loaded
  77001. * @param onSuccess is a callback called when the task is successfully executed
  77002. * @param onError is a callback called if an error occurs
  77003. */
  77004. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77005. }
  77006. /**
  77007. * Define a task used by AssetsManager to load cube textures
  77008. */
  77009. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77010. /**
  77011. * Defines the name of the task
  77012. */
  77013. name: string;
  77014. /**
  77015. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77016. */
  77017. url: string;
  77018. /**
  77019. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77020. */
  77021. extensions?: string[] | undefined;
  77022. /**
  77023. * Defines if mipmaps should not be generated (default is false)
  77024. */
  77025. noMipmap?: boolean | undefined;
  77026. /**
  77027. * Defines the explicit list of files (undefined by default)
  77028. */
  77029. files?: string[] | undefined;
  77030. /**
  77031. * Gets the loaded texture
  77032. */
  77033. texture: CubeTexture;
  77034. /**
  77035. * Callback called when the task is successful
  77036. */
  77037. onSuccess: (task: CubeTextureAssetTask) => void;
  77038. /**
  77039. * Callback called when the task is successful
  77040. */
  77041. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77042. /**
  77043. * Creates a new CubeTextureAssetTask
  77044. * @param name defines the name of the task
  77045. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77046. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77047. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77048. * @param files defines the explicit list of files (undefined by default)
  77049. */
  77050. constructor(
  77051. /**
  77052. * Defines the name of the task
  77053. */
  77054. name: string,
  77055. /**
  77056. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77057. */
  77058. url: string,
  77059. /**
  77060. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77061. */
  77062. extensions?: string[] | undefined,
  77063. /**
  77064. * Defines if mipmaps should not be generated (default is false)
  77065. */
  77066. noMipmap?: boolean | undefined,
  77067. /**
  77068. * Defines the explicit list of files (undefined by default)
  77069. */
  77070. files?: string[] | undefined);
  77071. /**
  77072. * Execute the current task
  77073. * @param scene defines the scene where you want your assets to be loaded
  77074. * @param onSuccess is a callback called when the task is successfully executed
  77075. * @param onError is a callback called if an error occurs
  77076. */
  77077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77078. }
  77079. /**
  77080. * Define a task used by AssetsManager to load HDR cube textures
  77081. */
  77082. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77083. /**
  77084. * Defines the name of the task
  77085. */
  77086. name: string;
  77087. /**
  77088. * Defines the location of the file to load
  77089. */
  77090. url: string;
  77091. /**
  77092. * Defines the desired size (the more it increases the longer the generation will be)
  77093. */
  77094. size: number;
  77095. /**
  77096. * Defines if mipmaps should not be generated (default is false)
  77097. */
  77098. noMipmap: boolean;
  77099. /**
  77100. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77101. */
  77102. generateHarmonics: boolean;
  77103. /**
  77104. * 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)
  77105. */
  77106. gammaSpace: boolean;
  77107. /**
  77108. * Internal Use Only
  77109. */
  77110. reserved: boolean;
  77111. /**
  77112. * Gets the loaded texture
  77113. */
  77114. texture: HDRCubeTexture;
  77115. /**
  77116. * Callback called when the task is successful
  77117. */
  77118. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77119. /**
  77120. * Callback called when the task is successful
  77121. */
  77122. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77123. /**
  77124. * Creates a new HDRCubeTextureAssetTask object
  77125. * @param name defines the name of the task
  77126. * @param url defines the location of the file to load
  77127. * @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.
  77128. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77129. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77130. * @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)
  77131. * @param reserved Internal use only
  77132. */
  77133. constructor(
  77134. /**
  77135. * Defines the name of the task
  77136. */
  77137. name: string,
  77138. /**
  77139. * Defines the location of the file to load
  77140. */
  77141. url: string,
  77142. /**
  77143. * Defines the desired size (the more it increases the longer the generation will be)
  77144. */
  77145. size: number,
  77146. /**
  77147. * Defines if mipmaps should not be generated (default is false)
  77148. */
  77149. noMipmap?: boolean,
  77150. /**
  77151. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77152. */
  77153. generateHarmonics?: boolean,
  77154. /**
  77155. * 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)
  77156. */
  77157. gammaSpace?: boolean,
  77158. /**
  77159. * Internal Use Only
  77160. */
  77161. reserved?: boolean);
  77162. /**
  77163. * Execute the current task
  77164. * @param scene defines the scene where you want your assets to be loaded
  77165. * @param onSuccess is a callback called when the task is successfully executed
  77166. * @param onError is a callback called if an error occurs
  77167. */
  77168. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77169. }
  77170. /**
  77171. * Define a task used by AssetsManager to load Equirectangular cube textures
  77172. */
  77173. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77174. /**
  77175. * Defines the name of the task
  77176. */
  77177. name: string;
  77178. /**
  77179. * Defines the location of the file to load
  77180. */
  77181. url: string;
  77182. /**
  77183. * Defines the desired size (the more it increases the longer the generation will be)
  77184. */
  77185. size: number;
  77186. /**
  77187. * Defines if mipmaps should not be generated (default is false)
  77188. */
  77189. noMipmap: boolean;
  77190. /**
  77191. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77192. * but the standard material would require them in Gamma space) (default is true)
  77193. */
  77194. gammaSpace: boolean;
  77195. /**
  77196. * Gets the loaded texture
  77197. */
  77198. texture: EquiRectangularCubeTexture;
  77199. /**
  77200. * Callback called when the task is successful
  77201. */
  77202. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77203. /**
  77204. * Callback called when the task is successful
  77205. */
  77206. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77207. /**
  77208. * Creates a new EquiRectangularCubeTextureAssetTask object
  77209. * @param name defines the name of the task
  77210. * @param url defines the location of the file to load
  77211. * @param size defines the desired size (the more it increases the longer the generation will be)
  77212. * If the size is omitted this implies you are using a preprocessed cubemap.
  77213. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77214. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77215. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77216. * (default is true)
  77217. */
  77218. constructor(
  77219. /**
  77220. * Defines the name of the task
  77221. */
  77222. name: string,
  77223. /**
  77224. * Defines the location of the file to load
  77225. */
  77226. url: string,
  77227. /**
  77228. * Defines the desired size (the more it increases the longer the generation will be)
  77229. */
  77230. size: number,
  77231. /**
  77232. * Defines if mipmaps should not be generated (default is false)
  77233. */
  77234. noMipmap?: boolean,
  77235. /**
  77236. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77237. * but the standard material would require them in Gamma space) (default is true)
  77238. */
  77239. gammaSpace?: boolean);
  77240. /**
  77241. * Execute the current task
  77242. * @param scene defines the scene where you want your assets to be loaded
  77243. * @param onSuccess is a callback called when the task is successfully executed
  77244. * @param onError is a callback called if an error occurs
  77245. */
  77246. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77247. }
  77248. /**
  77249. * This class can be used to easily import assets into a scene
  77250. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77251. */
  77252. export class AssetsManager {
  77253. private _scene;
  77254. private _isLoading;
  77255. protected _tasks: AbstractAssetTask[];
  77256. protected _waitingTasksCount: number;
  77257. protected _totalTasksCount: number;
  77258. /**
  77259. * Callback called when all tasks are processed
  77260. */
  77261. onFinish: (tasks: AbstractAssetTask[]) => void;
  77262. /**
  77263. * Callback called when a task is successful
  77264. */
  77265. onTaskSuccess: (task: AbstractAssetTask) => void;
  77266. /**
  77267. * Callback called when a task had an error
  77268. */
  77269. onTaskError: (task: AbstractAssetTask) => void;
  77270. /**
  77271. * Callback called when a task is done (whatever the result is)
  77272. */
  77273. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77274. /**
  77275. * Observable called when all tasks are processed
  77276. */
  77277. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77278. /**
  77279. * Observable called when a task had an error
  77280. */
  77281. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77282. /**
  77283. * Observable called when all tasks were executed
  77284. */
  77285. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77286. /**
  77287. * Observable called when a task is done (whatever the result is)
  77288. */
  77289. onProgressObservable: Observable<IAssetsProgressEvent>;
  77290. /**
  77291. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77292. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77293. */
  77294. useDefaultLoadingScreen: boolean;
  77295. /**
  77296. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77297. * when all assets have been downloaded.
  77298. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77299. */
  77300. autoHideLoadingUI: boolean;
  77301. /**
  77302. * Creates a new AssetsManager
  77303. * @param scene defines the scene to work on
  77304. */
  77305. constructor(scene: Scene);
  77306. /**
  77307. * Add a ContainerAssetTask to the list of active tasks
  77308. * @param taskName defines the name of the new task
  77309. * @param meshesNames defines the name of meshes to load
  77310. * @param rootUrl defines the root url to use to locate files
  77311. * @param sceneFilename defines the filename of the scene file
  77312. * @returns a new ContainerAssetTask object
  77313. */
  77314. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77315. /**
  77316. * Add a MeshAssetTask to the list of active tasks
  77317. * @param taskName defines the name of the new task
  77318. * @param meshesNames defines the name of meshes to load
  77319. * @param rootUrl defines the root url to use to locate files
  77320. * @param sceneFilename defines the filename of the scene file
  77321. * @returns a new MeshAssetTask object
  77322. */
  77323. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77324. /**
  77325. * Add a TextFileAssetTask to the list of active tasks
  77326. * @param taskName defines the name of the new task
  77327. * @param url defines the url of the file to load
  77328. * @returns a new TextFileAssetTask object
  77329. */
  77330. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77331. /**
  77332. * Add a BinaryFileAssetTask to the list of active tasks
  77333. * @param taskName defines the name of the new task
  77334. * @param url defines the url of the file to load
  77335. * @returns a new BinaryFileAssetTask object
  77336. */
  77337. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77338. /**
  77339. * Add a ImageAssetTask to the list of active tasks
  77340. * @param taskName defines the name of the new task
  77341. * @param url defines the url of the file to load
  77342. * @returns a new ImageAssetTask object
  77343. */
  77344. addImageTask(taskName: string, url: string): ImageAssetTask;
  77345. /**
  77346. * Add a TextureAssetTask to the list of active tasks
  77347. * @param taskName defines the name of the new task
  77348. * @param url defines the url of the file to load
  77349. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77350. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77351. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77352. * @returns a new TextureAssetTask object
  77353. */
  77354. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77355. /**
  77356. * Add a CubeTextureAssetTask to the list of active tasks
  77357. * @param taskName defines the name of the new task
  77358. * @param url defines the url of the file to load
  77359. * @param extensions defines the extension to use to load the cube map (can be null)
  77360. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77361. * @param files defines the list of files to load (can be null)
  77362. * @returns a new CubeTextureAssetTask object
  77363. */
  77364. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77365. /**
  77366. *
  77367. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77368. * @param taskName defines the name of the new task
  77369. * @param url defines the url of the file to load
  77370. * @param size defines the size you want for the cubemap (can be null)
  77371. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77372. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77373. * @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)
  77374. * @param reserved Internal use only
  77375. * @returns a new HDRCubeTextureAssetTask object
  77376. */
  77377. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77378. /**
  77379. *
  77380. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77381. * @param taskName defines the name of the new task
  77382. * @param url defines the url of the file to load
  77383. * @param size defines the size you want for the cubemap (can be null)
  77384. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77385. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77386. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77387. * @returns a new EquiRectangularCubeTextureAssetTask object
  77388. */
  77389. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77390. /**
  77391. * Remove a task from the assets manager.
  77392. * @param task the task to remove
  77393. */
  77394. removeTask(task: AbstractAssetTask): void;
  77395. private _decreaseWaitingTasksCount;
  77396. private _runTask;
  77397. /**
  77398. * Reset the AssetsManager and remove all tasks
  77399. * @return the current instance of the AssetsManager
  77400. */
  77401. reset(): AssetsManager;
  77402. /**
  77403. * Start the loading process
  77404. * @return the current instance of the AssetsManager
  77405. */
  77406. load(): AssetsManager;
  77407. /**
  77408. * Start the loading process as an async operation
  77409. * @return a promise returning the list of failed tasks
  77410. */
  77411. loadAsync(): Promise<void>;
  77412. }
  77413. }
  77414. declare module "babylonjs/Misc/deferred" {
  77415. /**
  77416. * Wrapper class for promise with external resolve and reject.
  77417. */
  77418. export class Deferred<T> {
  77419. /**
  77420. * The promise associated with this deferred object.
  77421. */
  77422. readonly promise: Promise<T>;
  77423. private _resolve;
  77424. private _reject;
  77425. /**
  77426. * The resolve method of the promise associated with this deferred object.
  77427. */
  77428. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77429. /**
  77430. * The reject method of the promise associated with this deferred object.
  77431. */
  77432. get reject(): (reason?: any) => void;
  77433. /**
  77434. * Constructor for this deferred object.
  77435. */
  77436. constructor();
  77437. }
  77438. }
  77439. declare module "babylonjs/Misc/meshExploder" {
  77440. import { Mesh } from "babylonjs/Meshes/mesh";
  77441. /**
  77442. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77443. */
  77444. export class MeshExploder {
  77445. private _centerMesh;
  77446. private _meshes;
  77447. private _meshesOrigins;
  77448. private _toCenterVectors;
  77449. private _scaledDirection;
  77450. private _newPosition;
  77451. private _centerPosition;
  77452. /**
  77453. * Explodes meshes from a center mesh.
  77454. * @param meshes The meshes to explode.
  77455. * @param centerMesh The mesh to be center of explosion.
  77456. */
  77457. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77458. private _setCenterMesh;
  77459. /**
  77460. * Get class name
  77461. * @returns "MeshExploder"
  77462. */
  77463. getClassName(): string;
  77464. /**
  77465. * "Exploded meshes"
  77466. * @returns Array of meshes with the centerMesh at index 0.
  77467. */
  77468. getMeshes(): Array<Mesh>;
  77469. /**
  77470. * Explodes meshes giving a specific direction
  77471. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77472. */
  77473. explode(direction?: number): void;
  77474. }
  77475. }
  77476. declare module "babylonjs/Misc/filesInput" {
  77477. import { Engine } from "babylonjs/Engines/engine";
  77478. import { Scene } from "babylonjs/scene";
  77479. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77480. import { Nullable } from "babylonjs/types";
  77481. /**
  77482. * Class used to help managing file picking and drag'n'drop
  77483. */
  77484. export class FilesInput {
  77485. /**
  77486. * List of files ready to be loaded
  77487. */
  77488. static get FilesToLoad(): {
  77489. [key: string]: File;
  77490. };
  77491. /**
  77492. * Callback called when a file is processed
  77493. */
  77494. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77495. private _engine;
  77496. private _currentScene;
  77497. private _sceneLoadedCallback;
  77498. private _progressCallback;
  77499. private _additionalRenderLoopLogicCallback;
  77500. private _textureLoadingCallback;
  77501. private _startingProcessingFilesCallback;
  77502. private _onReloadCallback;
  77503. private _errorCallback;
  77504. private _elementToMonitor;
  77505. private _sceneFileToLoad;
  77506. private _filesToLoad;
  77507. /**
  77508. * Creates a new FilesInput
  77509. * @param engine defines the rendering engine
  77510. * @param scene defines the hosting scene
  77511. * @param sceneLoadedCallback callback called when scene is loaded
  77512. * @param progressCallback callback called to track progress
  77513. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77514. * @param textureLoadingCallback callback called when a texture is loading
  77515. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77516. * @param onReloadCallback callback called when a reload is requested
  77517. * @param errorCallback callback call if an error occurs
  77518. */
  77519. 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>);
  77520. private _dragEnterHandler;
  77521. private _dragOverHandler;
  77522. private _dropHandler;
  77523. /**
  77524. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77525. * @param elementToMonitor defines the DOM element to track
  77526. */
  77527. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77528. /** Gets the current list of files to load */
  77529. get filesToLoad(): File[];
  77530. /**
  77531. * Release all associated resources
  77532. */
  77533. dispose(): void;
  77534. private renderFunction;
  77535. private drag;
  77536. private drop;
  77537. private _traverseFolder;
  77538. private _processFiles;
  77539. /**
  77540. * Load files from a drop event
  77541. * @param event defines the drop event to use as source
  77542. */
  77543. loadFiles(event: any): void;
  77544. private _processReload;
  77545. /**
  77546. * Reload the current scene from the loaded files
  77547. */
  77548. reload(): void;
  77549. }
  77550. }
  77551. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77552. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77553. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77554. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77555. }
  77556. declare module "babylonjs/Misc/sceneOptimizer" {
  77557. import { Scene, IDisposable } from "babylonjs/scene";
  77558. import { Observable } from "babylonjs/Misc/observable";
  77559. /**
  77560. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77561. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77562. */
  77563. export class SceneOptimization {
  77564. /**
  77565. * Defines the priority of this optimization (0 by default which means first in the list)
  77566. */
  77567. priority: number;
  77568. /**
  77569. * Gets a string describing the action executed by the current optimization
  77570. * @returns description string
  77571. */
  77572. getDescription(): string;
  77573. /**
  77574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77575. * @param scene defines the current scene where to apply this optimization
  77576. * @param optimizer defines the current optimizer
  77577. * @returns true if everything that can be done was applied
  77578. */
  77579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77580. /**
  77581. * Creates the SceneOptimization object
  77582. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77583. * @param desc defines the description associated with the optimization
  77584. */
  77585. constructor(
  77586. /**
  77587. * Defines the priority of this optimization (0 by default which means first in the list)
  77588. */
  77589. priority?: number);
  77590. }
  77591. /**
  77592. * Defines an optimization used to reduce the size of render target textures
  77593. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77594. */
  77595. export class TextureOptimization extends SceneOptimization {
  77596. /**
  77597. * Defines the priority of this optimization (0 by default which means first in the list)
  77598. */
  77599. priority: number;
  77600. /**
  77601. * 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
  77602. */
  77603. maximumSize: number;
  77604. /**
  77605. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77606. */
  77607. step: number;
  77608. /**
  77609. * Gets a string describing the action executed by the current optimization
  77610. * @returns description string
  77611. */
  77612. getDescription(): string;
  77613. /**
  77614. * Creates the TextureOptimization object
  77615. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77616. * @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
  77617. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77618. */
  77619. constructor(
  77620. /**
  77621. * Defines the priority of this optimization (0 by default which means first in the list)
  77622. */
  77623. priority?: number,
  77624. /**
  77625. * 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
  77626. */
  77627. maximumSize?: number,
  77628. /**
  77629. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77630. */
  77631. step?: number);
  77632. /**
  77633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77634. * @param scene defines the current scene where to apply this optimization
  77635. * @param optimizer defines the current optimizer
  77636. * @returns true if everything that can be done was applied
  77637. */
  77638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77639. }
  77640. /**
  77641. * Defines an optimization used to increase or decrease the rendering resolution
  77642. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77643. */
  77644. export class HardwareScalingOptimization extends SceneOptimization {
  77645. /**
  77646. * Defines the priority of this optimization (0 by default which means first in the list)
  77647. */
  77648. priority: number;
  77649. /**
  77650. * Defines the maximum scale to use (2 by default)
  77651. */
  77652. maximumScale: number;
  77653. /**
  77654. * Defines the step to use between two passes (0.5 by default)
  77655. */
  77656. step: number;
  77657. private _currentScale;
  77658. private _directionOffset;
  77659. /**
  77660. * Gets a string describing the action executed by the current optimization
  77661. * @return description string
  77662. */
  77663. getDescription(): string;
  77664. /**
  77665. * Creates the HardwareScalingOptimization object
  77666. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77667. * @param maximumScale defines the maximum scale to use (2 by default)
  77668. * @param step defines the step to use between two passes (0.5 by default)
  77669. */
  77670. constructor(
  77671. /**
  77672. * Defines the priority of this optimization (0 by default which means first in the list)
  77673. */
  77674. priority?: number,
  77675. /**
  77676. * Defines the maximum scale to use (2 by default)
  77677. */
  77678. maximumScale?: number,
  77679. /**
  77680. * Defines the step to use between two passes (0.5 by default)
  77681. */
  77682. step?: number);
  77683. /**
  77684. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77685. * @param scene defines the current scene where to apply this optimization
  77686. * @param optimizer defines the current optimizer
  77687. * @returns true if everything that can be done was applied
  77688. */
  77689. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77690. }
  77691. /**
  77692. * Defines an optimization used to remove shadows
  77693. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77694. */
  77695. export class ShadowsOptimization extends SceneOptimization {
  77696. /**
  77697. * Gets a string describing the action executed by the current optimization
  77698. * @return description string
  77699. */
  77700. getDescription(): string;
  77701. /**
  77702. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77703. * @param scene defines the current scene where to apply this optimization
  77704. * @param optimizer defines the current optimizer
  77705. * @returns true if everything that can be done was applied
  77706. */
  77707. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77708. }
  77709. /**
  77710. * Defines an optimization used to turn post-processes off
  77711. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77712. */
  77713. export class PostProcessesOptimization extends SceneOptimization {
  77714. /**
  77715. * Gets a string describing the action executed by the current optimization
  77716. * @return description string
  77717. */
  77718. getDescription(): string;
  77719. /**
  77720. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77721. * @param scene defines the current scene where to apply this optimization
  77722. * @param optimizer defines the current optimizer
  77723. * @returns true if everything that can be done was applied
  77724. */
  77725. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77726. }
  77727. /**
  77728. * Defines an optimization used to turn lens flares off
  77729. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77730. */
  77731. export class LensFlaresOptimization extends SceneOptimization {
  77732. /**
  77733. * Gets a string describing the action executed by the current optimization
  77734. * @return description string
  77735. */
  77736. getDescription(): string;
  77737. /**
  77738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77739. * @param scene defines the current scene where to apply this optimization
  77740. * @param optimizer defines the current optimizer
  77741. * @returns true if everything that can be done was applied
  77742. */
  77743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77744. }
  77745. /**
  77746. * Defines an optimization based on user defined callback.
  77747. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77748. */
  77749. export class CustomOptimization extends SceneOptimization {
  77750. /**
  77751. * Callback called to apply the custom optimization.
  77752. */
  77753. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77754. /**
  77755. * Callback called to get custom description
  77756. */
  77757. onGetDescription: () => string;
  77758. /**
  77759. * Gets a string describing the action executed by the current optimization
  77760. * @returns description string
  77761. */
  77762. getDescription(): string;
  77763. /**
  77764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77765. * @param scene defines the current scene where to apply this optimization
  77766. * @param optimizer defines the current optimizer
  77767. * @returns true if everything that can be done was applied
  77768. */
  77769. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77770. }
  77771. /**
  77772. * Defines an optimization used to turn particles off
  77773. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77774. */
  77775. export class ParticlesOptimization extends SceneOptimization {
  77776. /**
  77777. * Gets a string describing the action executed by the current optimization
  77778. * @return description string
  77779. */
  77780. getDescription(): string;
  77781. /**
  77782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77783. * @param scene defines the current scene where to apply this optimization
  77784. * @param optimizer defines the current optimizer
  77785. * @returns true if everything that can be done was applied
  77786. */
  77787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77788. }
  77789. /**
  77790. * Defines an optimization used to turn render targets off
  77791. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77792. */
  77793. export class RenderTargetsOptimization extends SceneOptimization {
  77794. /**
  77795. * Gets a string describing the action executed by the current optimization
  77796. * @return description string
  77797. */
  77798. getDescription(): string;
  77799. /**
  77800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77801. * @param scene defines the current scene where to apply this optimization
  77802. * @param optimizer defines the current optimizer
  77803. * @returns true if everything that can be done was applied
  77804. */
  77805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77806. }
  77807. /**
  77808. * Defines an optimization used to merge meshes with compatible materials
  77809. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77810. */
  77811. export class MergeMeshesOptimization extends SceneOptimization {
  77812. private static _UpdateSelectionTree;
  77813. /**
  77814. * Gets or sets a boolean which defines if optimization octree has to be updated
  77815. */
  77816. static get UpdateSelectionTree(): boolean;
  77817. /**
  77818. * Gets or sets a boolean which defines if optimization octree has to be updated
  77819. */
  77820. static set UpdateSelectionTree(value: boolean);
  77821. /**
  77822. * Gets a string describing the action executed by the current optimization
  77823. * @return description string
  77824. */
  77825. getDescription(): string;
  77826. private _canBeMerged;
  77827. /**
  77828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77829. * @param scene defines the current scene where to apply this optimization
  77830. * @param optimizer defines the current optimizer
  77831. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77832. * @returns true if everything that can be done was applied
  77833. */
  77834. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77835. }
  77836. /**
  77837. * Defines a list of options used by SceneOptimizer
  77838. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77839. */
  77840. export class SceneOptimizerOptions {
  77841. /**
  77842. * Defines the target frame rate to reach (60 by default)
  77843. */
  77844. targetFrameRate: number;
  77845. /**
  77846. * Defines the interval between two checkes (2000ms by default)
  77847. */
  77848. trackerDuration: number;
  77849. /**
  77850. * Gets the list of optimizations to apply
  77851. */
  77852. optimizations: SceneOptimization[];
  77853. /**
  77854. * Creates a new list of options used by SceneOptimizer
  77855. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77856. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77857. */
  77858. constructor(
  77859. /**
  77860. * Defines the target frame rate to reach (60 by default)
  77861. */
  77862. targetFrameRate?: number,
  77863. /**
  77864. * Defines the interval between two checkes (2000ms by default)
  77865. */
  77866. trackerDuration?: number);
  77867. /**
  77868. * Add a new optimization
  77869. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77870. * @returns the current SceneOptimizerOptions
  77871. */
  77872. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77873. /**
  77874. * Add a new custom optimization
  77875. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77876. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77877. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77878. * @returns the current SceneOptimizerOptions
  77879. */
  77880. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77881. /**
  77882. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77883. * @param targetFrameRate defines the target frame rate (60 by default)
  77884. * @returns a SceneOptimizerOptions object
  77885. */
  77886. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77887. /**
  77888. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77889. * @param targetFrameRate defines the target frame rate (60 by default)
  77890. * @returns a SceneOptimizerOptions object
  77891. */
  77892. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77893. /**
  77894. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77895. * @param targetFrameRate defines the target frame rate (60 by default)
  77896. * @returns a SceneOptimizerOptions object
  77897. */
  77898. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77899. }
  77900. /**
  77901. * Class used to run optimizations in order to reach a target frame rate
  77902. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77903. */
  77904. export class SceneOptimizer implements IDisposable {
  77905. private _isRunning;
  77906. private _options;
  77907. private _scene;
  77908. private _currentPriorityLevel;
  77909. private _targetFrameRate;
  77910. private _trackerDuration;
  77911. private _currentFrameRate;
  77912. private _sceneDisposeObserver;
  77913. private _improvementMode;
  77914. /**
  77915. * Defines an observable called when the optimizer reaches the target frame rate
  77916. */
  77917. onSuccessObservable: Observable<SceneOptimizer>;
  77918. /**
  77919. * Defines an observable called when the optimizer enables an optimization
  77920. */
  77921. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77922. /**
  77923. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77924. */
  77925. onFailureObservable: Observable<SceneOptimizer>;
  77926. /**
  77927. * Gets a boolean indicating if the optimizer is in improvement mode
  77928. */
  77929. get isInImprovementMode(): boolean;
  77930. /**
  77931. * Gets the current priority level (0 at start)
  77932. */
  77933. get currentPriorityLevel(): number;
  77934. /**
  77935. * Gets the current frame rate checked by the SceneOptimizer
  77936. */
  77937. get currentFrameRate(): number;
  77938. /**
  77939. * Gets or sets the current target frame rate (60 by default)
  77940. */
  77941. get targetFrameRate(): number;
  77942. /**
  77943. * Gets or sets the current target frame rate (60 by default)
  77944. */
  77945. set targetFrameRate(value: number);
  77946. /**
  77947. * Gets or sets the current interval between two checks (every 2000ms by default)
  77948. */
  77949. get trackerDuration(): number;
  77950. /**
  77951. * Gets or sets the current interval between two checks (every 2000ms by default)
  77952. */
  77953. set trackerDuration(value: number);
  77954. /**
  77955. * Gets the list of active optimizations
  77956. */
  77957. get optimizations(): SceneOptimization[];
  77958. /**
  77959. * Creates a new SceneOptimizer
  77960. * @param scene defines the scene to work on
  77961. * @param options defines the options to use with the SceneOptimizer
  77962. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77963. * @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)
  77964. */
  77965. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77966. /**
  77967. * Stops the current optimizer
  77968. */
  77969. stop(): void;
  77970. /**
  77971. * Reset the optimizer to initial step (current priority level = 0)
  77972. */
  77973. reset(): void;
  77974. /**
  77975. * Start the optimizer. By default it will try to reach a specific framerate
  77976. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77977. */
  77978. start(): void;
  77979. private _checkCurrentState;
  77980. /**
  77981. * Release all resources
  77982. */
  77983. dispose(): void;
  77984. /**
  77985. * Helper function to create a SceneOptimizer with one single line of code
  77986. * @param scene defines the scene to work on
  77987. * @param options defines the options to use with the SceneOptimizer
  77988. * @param onSuccess defines a callback to call on success
  77989. * @param onFailure defines a callback to call on failure
  77990. * @returns the new SceneOptimizer object
  77991. */
  77992. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77993. }
  77994. }
  77995. declare module "babylonjs/Misc/sceneSerializer" {
  77996. import { Scene } from "babylonjs/scene";
  77997. /**
  77998. * Class used to serialize a scene into a string
  77999. */
  78000. export class SceneSerializer {
  78001. /**
  78002. * Clear cache used by a previous serialization
  78003. */
  78004. static ClearCache(): void;
  78005. /**
  78006. * Serialize a scene into a JSON compatible object
  78007. * @param scene defines the scene to serialize
  78008. * @returns a JSON compatible object
  78009. */
  78010. static Serialize(scene: Scene): any;
  78011. /**
  78012. * Serialize a mesh into a JSON compatible object
  78013. * @param toSerialize defines the mesh to serialize
  78014. * @param withParents defines if parents must be serialized as well
  78015. * @param withChildren defines if children must be serialized as well
  78016. * @returns a JSON compatible object
  78017. */
  78018. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78019. }
  78020. }
  78021. declare module "babylonjs/Misc/textureTools" {
  78022. import { Texture } from "babylonjs/Materials/Textures/texture";
  78023. /**
  78024. * Class used to host texture specific utilities
  78025. */
  78026. export class TextureTools {
  78027. /**
  78028. * Uses the GPU to create a copy texture rescaled at a given size
  78029. * @param texture Texture to copy from
  78030. * @param width defines the desired width
  78031. * @param height defines the desired height
  78032. * @param useBilinearMode defines if bilinear mode has to be used
  78033. * @return the generated texture
  78034. */
  78035. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78036. }
  78037. }
  78038. declare module "babylonjs/Misc/videoRecorder" {
  78039. import { Nullable } from "babylonjs/types";
  78040. import { Engine } from "babylonjs/Engines/engine";
  78041. /**
  78042. * This represents the different options available for the video capture.
  78043. */
  78044. export interface VideoRecorderOptions {
  78045. /** Defines the mime type of the video. */
  78046. mimeType: string;
  78047. /** Defines the FPS the video should be recorded at. */
  78048. fps: number;
  78049. /** Defines the chunk size for the recording data. */
  78050. recordChunckSize: number;
  78051. /** The audio tracks to attach to the recording. */
  78052. audioTracks?: MediaStreamTrack[];
  78053. }
  78054. /**
  78055. * This can help with recording videos from BabylonJS.
  78056. * This is based on the available WebRTC functionalities of the browser.
  78057. *
  78058. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78059. */
  78060. export class VideoRecorder {
  78061. private static readonly _defaultOptions;
  78062. /**
  78063. * Returns whether or not the VideoRecorder is available in your browser.
  78064. * @param engine Defines the Babylon Engine.
  78065. * @returns true if supported otherwise false.
  78066. */
  78067. static IsSupported(engine: Engine): boolean;
  78068. private readonly _options;
  78069. private _canvas;
  78070. private _mediaRecorder;
  78071. private _recordedChunks;
  78072. private _fileName;
  78073. private _resolve;
  78074. private _reject;
  78075. /**
  78076. * True when a recording is already in progress.
  78077. */
  78078. get isRecording(): boolean;
  78079. /**
  78080. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78081. * @param engine Defines the BabylonJS Engine you wish to record.
  78082. * @param options Defines options that can be used to customize the capture.
  78083. */
  78084. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78085. /**
  78086. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78087. */
  78088. stopRecording(): void;
  78089. /**
  78090. * Starts recording the canvas for a max duration specified in parameters.
  78091. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78092. * If null no automatic download will start and you can rely on the promise to get the data back.
  78093. * @param maxDuration Defines the maximum recording time in seconds.
  78094. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78095. * @return A promise callback at the end of the recording with the video data in Blob.
  78096. */
  78097. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78098. /**
  78099. * Releases internal resources used during the recording.
  78100. */
  78101. dispose(): void;
  78102. private _handleDataAvailable;
  78103. private _handleError;
  78104. private _handleStop;
  78105. }
  78106. }
  78107. declare module "babylonjs/Misc/screenshotTools" {
  78108. import { Camera } from "babylonjs/Cameras/camera";
  78109. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78110. import { Engine } from "babylonjs/Engines/engine";
  78111. /**
  78112. * Class containing a set of static utilities functions for screenshots
  78113. */
  78114. export class ScreenshotTools {
  78115. /**
  78116. * Captures a screenshot of the current rendering
  78117. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78118. * @param engine defines the rendering engine
  78119. * @param camera defines the source camera
  78120. * @param size This parameter can be set to a single number or to an object with the
  78121. * following (optional) properties: precision, width, height. If a single number is passed,
  78122. * it will be used for both width and height. If an object is passed, the screenshot size
  78123. * will be derived from the parameters. The precision property is a multiplier allowing
  78124. * rendering at a higher or lower resolution
  78125. * @param successCallback defines the callback receives a single parameter which contains the
  78126. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78127. * src parameter of an <img> to display it
  78128. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78129. * Check your browser for supported MIME types
  78130. */
  78131. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78132. /**
  78133. * Captures a screenshot of the current rendering
  78134. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78135. * @param engine defines the rendering engine
  78136. * @param camera defines the source camera
  78137. * @param size This parameter can be set to a single number or to an object with the
  78138. * following (optional) properties: precision, width, height. If a single number is passed,
  78139. * it will be used for both width and height. If an object is passed, the screenshot size
  78140. * will be derived from the parameters. The precision property is a multiplier allowing
  78141. * rendering at a higher or lower resolution
  78142. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78143. * Check your browser for supported MIME types
  78144. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78145. * to the src parameter of an <img> to display it
  78146. */
  78147. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78148. /**
  78149. * Generates an image screenshot from the specified camera.
  78150. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78151. * @param engine The engine to use for rendering
  78152. * @param camera The camera to use for rendering
  78153. * @param size This parameter can be set to a single number or to an object with the
  78154. * following (optional) properties: precision, width, height. If a single number is passed,
  78155. * it will be used for both width and height. If an object is passed, the screenshot size
  78156. * will be derived from the parameters. The precision property is a multiplier allowing
  78157. * rendering at a higher or lower resolution
  78158. * @param successCallback The callback receives a single parameter which contains the
  78159. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78160. * src parameter of an <img> to display it
  78161. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78162. * Check your browser for supported MIME types
  78163. * @param samples Texture samples (default: 1)
  78164. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78165. * @param fileName A name for for the downloaded file.
  78166. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78167. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78168. */
  78169. 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;
  78170. /**
  78171. * Generates an image screenshot from the specified camera.
  78172. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78173. * @param engine The engine to use for rendering
  78174. * @param camera The camera to use for rendering
  78175. * @param size This parameter can be set to a single number or to an object with the
  78176. * following (optional) properties: precision, width, height. If a single number is passed,
  78177. * it will be used for both width and height. If an object is passed, the screenshot size
  78178. * will be derived from the parameters. The precision property is a multiplier allowing
  78179. * rendering at a higher or lower resolution
  78180. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78181. * Check your browser for supported MIME types
  78182. * @param samples Texture samples (default: 1)
  78183. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78184. * @param fileName A name for for the downloaded file.
  78185. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78186. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78187. * to the src parameter of an <img> to display it
  78188. */
  78189. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78190. /**
  78191. * Gets height and width for screenshot size
  78192. * @private
  78193. */
  78194. private static _getScreenshotSize;
  78195. }
  78196. }
  78197. declare module "babylonjs/Misc/dataReader" {
  78198. /**
  78199. * Interface for a data buffer
  78200. */
  78201. export interface IDataBuffer {
  78202. /**
  78203. * Reads bytes from the data buffer.
  78204. * @param byteOffset The byte offset to read
  78205. * @param byteLength The byte length to read
  78206. * @returns A promise that resolves when the bytes are read
  78207. */
  78208. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78209. /**
  78210. * The byte length of the buffer.
  78211. */
  78212. readonly byteLength: number;
  78213. }
  78214. /**
  78215. * Utility class for reading from a data buffer
  78216. */
  78217. export class DataReader {
  78218. /**
  78219. * The data buffer associated with this data reader.
  78220. */
  78221. readonly buffer: IDataBuffer;
  78222. /**
  78223. * The current byte offset from the beginning of the data buffer.
  78224. */
  78225. byteOffset: number;
  78226. private _dataView;
  78227. private _dataByteOffset;
  78228. /**
  78229. * Constructor
  78230. * @param buffer The buffer to read
  78231. */
  78232. constructor(buffer: IDataBuffer);
  78233. /**
  78234. * Loads the given byte length.
  78235. * @param byteLength The byte length to load
  78236. * @returns A promise that resolves when the load is complete
  78237. */
  78238. loadAsync(byteLength: number): Promise<void>;
  78239. /**
  78240. * Read a unsigned 32-bit integer from the currently loaded data range.
  78241. * @returns The 32-bit integer read
  78242. */
  78243. readUint32(): number;
  78244. /**
  78245. * Read a byte array from the currently loaded data range.
  78246. * @param byteLength The byte length to read
  78247. * @returns The byte array read
  78248. */
  78249. readUint8Array(byteLength: number): Uint8Array;
  78250. /**
  78251. * Read a string from the currently loaded data range.
  78252. * @param byteLength The byte length to read
  78253. * @returns The string read
  78254. */
  78255. readString(byteLength: number): string;
  78256. /**
  78257. * Skips the given byte length the currently loaded data range.
  78258. * @param byteLength The byte length to skip
  78259. */
  78260. skipBytes(byteLength: number): void;
  78261. }
  78262. }
  78263. declare module "babylonjs/Misc/dataStorage" {
  78264. /**
  78265. * Class for storing data to local storage if available or in-memory storage otherwise
  78266. */
  78267. export class DataStorage {
  78268. private static _Storage;
  78269. private static _GetStorage;
  78270. /**
  78271. * Reads a string from the data storage
  78272. * @param key The key to read
  78273. * @param defaultValue The value if the key doesn't exist
  78274. * @returns The string value
  78275. */
  78276. static ReadString(key: string, defaultValue: string): string;
  78277. /**
  78278. * Writes a string to the data storage
  78279. * @param key The key to write
  78280. * @param value The value to write
  78281. */
  78282. static WriteString(key: string, value: string): void;
  78283. /**
  78284. * Reads a boolean from the data storage
  78285. * @param key The key to read
  78286. * @param defaultValue The value if the key doesn't exist
  78287. * @returns The boolean value
  78288. */
  78289. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78290. /**
  78291. * Writes a boolean to the data storage
  78292. * @param key The key to write
  78293. * @param value The value to write
  78294. */
  78295. static WriteBoolean(key: string, value: boolean): void;
  78296. /**
  78297. * Reads a number from the data storage
  78298. * @param key The key to read
  78299. * @param defaultValue The value if the key doesn't exist
  78300. * @returns The number value
  78301. */
  78302. static ReadNumber(key: string, defaultValue: number): number;
  78303. /**
  78304. * Writes a number to the data storage
  78305. * @param key The key to write
  78306. * @param value The value to write
  78307. */
  78308. static WriteNumber(key: string, value: number): void;
  78309. }
  78310. }
  78311. declare module "babylonjs/Misc/sceneRecorder" {
  78312. import { Scene } from "babylonjs/scene";
  78313. /**
  78314. * Class used to record delta files between 2 scene states
  78315. */
  78316. export class SceneRecorder {
  78317. private _trackedScene;
  78318. private _savedJSON;
  78319. /**
  78320. * Track a given scene. This means the current scene state will be considered the original state
  78321. * @param scene defines the scene to track
  78322. */
  78323. track(scene: Scene): void;
  78324. /**
  78325. * Get the delta between current state and original state
  78326. * @returns a string containing the delta
  78327. */
  78328. getDelta(): any;
  78329. private _compareArray;
  78330. private _compareObjects;
  78331. private _compareCollections;
  78332. private static GetShadowGeneratorById;
  78333. /**
  78334. * Apply a given delta to a given scene
  78335. * @param deltaJSON defines the JSON containing the delta
  78336. * @param scene defines the scene to apply the delta to
  78337. */
  78338. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78339. private static _ApplyPropertiesToEntity;
  78340. private static _ApplyDeltaForEntity;
  78341. }
  78342. }
  78343. declare module "babylonjs/Misc/index" {
  78344. export * from "babylonjs/Misc/andOrNotEvaluator";
  78345. export * from "babylonjs/Misc/assetsManager";
  78346. export * from "babylonjs/Misc/basis";
  78347. export * from "babylonjs/Misc/dds";
  78348. export * from "babylonjs/Misc/decorators";
  78349. export * from "babylonjs/Misc/deferred";
  78350. export * from "babylonjs/Misc/environmentTextureTools";
  78351. export * from "babylonjs/Misc/meshExploder";
  78352. export * from "babylonjs/Misc/filesInput";
  78353. export * from "babylonjs/Misc/HighDynamicRange/index";
  78354. export * from "babylonjs/Misc/khronosTextureContainer";
  78355. export * from "babylonjs/Misc/observable";
  78356. export * from "babylonjs/Misc/performanceMonitor";
  78357. export * from "babylonjs/Misc/promise";
  78358. export * from "babylonjs/Misc/sceneOptimizer";
  78359. export * from "babylonjs/Misc/sceneSerializer";
  78360. export * from "babylonjs/Misc/smartArray";
  78361. export * from "babylonjs/Misc/stringDictionary";
  78362. export * from "babylonjs/Misc/tags";
  78363. export * from "babylonjs/Misc/textureTools";
  78364. export * from "babylonjs/Misc/tga";
  78365. export * from "babylonjs/Misc/tools";
  78366. export * from "babylonjs/Misc/videoRecorder";
  78367. export * from "babylonjs/Misc/virtualJoystick";
  78368. export * from "babylonjs/Misc/workerPool";
  78369. export * from "babylonjs/Misc/logger";
  78370. export * from "babylonjs/Misc/typeStore";
  78371. export * from "babylonjs/Misc/filesInputStore";
  78372. export * from "babylonjs/Misc/deepCopier";
  78373. export * from "babylonjs/Misc/pivotTools";
  78374. export * from "babylonjs/Misc/precisionDate";
  78375. export * from "babylonjs/Misc/screenshotTools";
  78376. export * from "babylonjs/Misc/typeStore";
  78377. export * from "babylonjs/Misc/webRequest";
  78378. export * from "babylonjs/Misc/iInspectable";
  78379. export * from "babylonjs/Misc/brdfTextureTools";
  78380. export * from "babylonjs/Misc/rgbdTextureTools";
  78381. export * from "babylonjs/Misc/gradients";
  78382. export * from "babylonjs/Misc/perfCounter";
  78383. export * from "babylonjs/Misc/fileRequest";
  78384. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78385. export * from "babylonjs/Misc/retryStrategy";
  78386. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78387. export * from "babylonjs/Misc/canvasGenerator";
  78388. export * from "babylonjs/Misc/fileTools";
  78389. export * from "babylonjs/Misc/stringTools";
  78390. export * from "babylonjs/Misc/dataReader";
  78391. export * from "babylonjs/Misc/minMaxReducer";
  78392. export * from "babylonjs/Misc/depthReducer";
  78393. export * from "babylonjs/Misc/dataStorage";
  78394. export * from "babylonjs/Misc/sceneRecorder";
  78395. export * from "babylonjs/Misc/khronosTextureContainer2";
  78396. }
  78397. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78398. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78399. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78400. import { Observable } from "babylonjs/Misc/observable";
  78401. import { Matrix } from "babylonjs/Maths/math.vector";
  78402. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78403. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78404. /**
  78405. * An interface for all Hit test features
  78406. */
  78407. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78408. /**
  78409. * Triggered when new babylon (transformed) hit test results are available
  78410. */
  78411. onHitTestResultObservable: Observable<T[]>;
  78412. }
  78413. /**
  78414. * Options used for hit testing
  78415. */
  78416. export interface IWebXRLegacyHitTestOptions {
  78417. /**
  78418. * Only test when user interacted with the scene. Default - hit test every frame
  78419. */
  78420. testOnPointerDownOnly?: boolean;
  78421. /**
  78422. * The node to use to transform the local results to world coordinates
  78423. */
  78424. worldParentNode?: TransformNode;
  78425. }
  78426. /**
  78427. * Interface defining the babylon result of raycasting/hit-test
  78428. */
  78429. export interface IWebXRLegacyHitResult {
  78430. /**
  78431. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78432. */
  78433. transformationMatrix: Matrix;
  78434. /**
  78435. * The native hit test result
  78436. */
  78437. xrHitResult: XRHitResult | XRHitTestResult;
  78438. }
  78439. /**
  78440. * The currently-working hit-test module.
  78441. * Hit test (or Ray-casting) is used to interact with the real world.
  78442. * For further information read here - https://github.com/immersive-web/hit-test
  78443. */
  78444. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78445. /**
  78446. * options to use when constructing this feature
  78447. */
  78448. readonly options: IWebXRLegacyHitTestOptions;
  78449. private _direction;
  78450. private _mat;
  78451. private _onSelectEnabled;
  78452. private _origin;
  78453. /**
  78454. * The module's name
  78455. */
  78456. static readonly Name: string;
  78457. /**
  78458. * The (Babylon) version of this module.
  78459. * This is an integer representing the implementation version.
  78460. * This number does not correspond to the WebXR specs version
  78461. */
  78462. static readonly Version: number;
  78463. /**
  78464. * Populated with the last native XR Hit Results
  78465. */
  78466. lastNativeXRHitResults: XRHitResult[];
  78467. /**
  78468. * Triggered when new babylon (transformed) hit test results are available
  78469. */
  78470. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78471. /**
  78472. * Creates a new instance of the (legacy version) hit test feature
  78473. * @param _xrSessionManager an instance of WebXRSessionManager
  78474. * @param options options to use when constructing this feature
  78475. */
  78476. constructor(_xrSessionManager: WebXRSessionManager,
  78477. /**
  78478. * options to use when constructing this feature
  78479. */
  78480. options?: IWebXRLegacyHitTestOptions);
  78481. /**
  78482. * execute a hit test with an XR Ray
  78483. *
  78484. * @param xrSession a native xrSession that will execute this hit test
  78485. * @param xrRay the ray (position and direction) to use for ray-casting
  78486. * @param referenceSpace native XR reference space to use for the hit-test
  78487. * @param filter filter function that will filter the results
  78488. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78489. */
  78490. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78491. /**
  78492. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78493. * @param event the (select) event to use to select with
  78494. * @param referenceSpace the reference space to use for this hit test
  78495. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78496. */
  78497. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78498. /**
  78499. * attach this feature
  78500. * Will usually be called by the features manager
  78501. *
  78502. * @returns true if successful.
  78503. */
  78504. attach(): boolean;
  78505. /**
  78506. * detach this feature.
  78507. * Will usually be called by the features manager
  78508. *
  78509. * @returns true if successful.
  78510. */
  78511. detach(): boolean;
  78512. /**
  78513. * Dispose this feature and all of the resources attached
  78514. */
  78515. dispose(): void;
  78516. protected _onXRFrame(frame: XRFrame): void;
  78517. private _onHitTestResults;
  78518. private _onSelect;
  78519. }
  78520. }
  78521. declare module "babylonjs/XR/features/WebXRHitTest" {
  78522. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78523. import { Observable } from "babylonjs/Misc/observable";
  78524. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78525. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78526. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78527. /**
  78528. * Options used for hit testing (version 2)
  78529. */
  78530. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78531. /**
  78532. * Do not create a permanent hit test. Will usually be used when only
  78533. * transient inputs are needed.
  78534. */
  78535. disablePermanentHitTest?: boolean;
  78536. /**
  78537. * Enable transient (for example touch-based) hit test inspections
  78538. */
  78539. enableTransientHitTest?: boolean;
  78540. /**
  78541. * Offset ray for the permanent hit test
  78542. */
  78543. offsetRay?: Vector3;
  78544. /**
  78545. * Offset ray for the transient hit test
  78546. */
  78547. transientOffsetRay?: Vector3;
  78548. /**
  78549. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78550. */
  78551. useReferenceSpace?: boolean;
  78552. /**
  78553. * Override the default entity type(s) of the hit-test result
  78554. */
  78555. entityTypes?: XRHitTestTrackableType[];
  78556. }
  78557. /**
  78558. * Interface defining the babylon result of hit-test
  78559. */
  78560. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78561. /**
  78562. * The input source that generated this hit test (if transient)
  78563. */
  78564. inputSource?: XRInputSource;
  78565. /**
  78566. * Is this a transient hit test
  78567. */
  78568. isTransient?: boolean;
  78569. /**
  78570. * Position of the hit test result
  78571. */
  78572. position: Vector3;
  78573. /**
  78574. * Rotation of the hit test result
  78575. */
  78576. rotationQuaternion: Quaternion;
  78577. /**
  78578. * The native hit test result
  78579. */
  78580. xrHitResult: XRHitTestResult;
  78581. }
  78582. /**
  78583. * The currently-working hit-test module.
  78584. * Hit test (or Ray-casting) is used to interact with the real world.
  78585. * For further information read here - https://github.com/immersive-web/hit-test
  78586. *
  78587. * Tested on chrome (mobile) 80.
  78588. */
  78589. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78590. /**
  78591. * options to use when constructing this feature
  78592. */
  78593. readonly options: IWebXRHitTestOptions;
  78594. private _tmpMat;
  78595. private _tmpPos;
  78596. private _tmpQuat;
  78597. private _transientXrHitTestSource;
  78598. private _xrHitTestSource;
  78599. private initHitTestSource;
  78600. /**
  78601. * The module's name
  78602. */
  78603. static readonly Name: string;
  78604. /**
  78605. * The (Babylon) version of this module.
  78606. * This is an integer representing the implementation version.
  78607. * This number does not correspond to the WebXR specs version
  78608. */
  78609. static readonly Version: number;
  78610. /**
  78611. * When set to true, each hit test will have its own position/rotation objects
  78612. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78613. * the developers will clone them or copy them as they see fit.
  78614. */
  78615. autoCloneTransformation: boolean;
  78616. /**
  78617. * Triggered when new babylon (transformed) hit test results are available
  78618. */
  78619. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78620. /**
  78621. * Use this to temporarily pause hit test checks.
  78622. */
  78623. paused: boolean;
  78624. /**
  78625. * Creates a new instance of the hit test feature
  78626. * @param _xrSessionManager an instance of WebXRSessionManager
  78627. * @param options options to use when constructing this feature
  78628. */
  78629. constructor(_xrSessionManager: WebXRSessionManager,
  78630. /**
  78631. * options to use when constructing this feature
  78632. */
  78633. options?: IWebXRHitTestOptions);
  78634. /**
  78635. * attach this feature
  78636. * Will usually be called by the features manager
  78637. *
  78638. * @returns true if successful.
  78639. */
  78640. attach(): boolean;
  78641. /**
  78642. * detach this feature.
  78643. * Will usually be called by the features manager
  78644. *
  78645. * @returns true if successful.
  78646. */
  78647. detach(): boolean;
  78648. /**
  78649. * Dispose this feature and all of the resources attached
  78650. */
  78651. dispose(): void;
  78652. protected _onXRFrame(frame: XRFrame): void;
  78653. private _processWebXRHitTestResult;
  78654. }
  78655. }
  78656. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78657. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78658. import { Observable } from "babylonjs/Misc/observable";
  78659. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78661. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78662. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78663. /**
  78664. * Configuration options of the anchor system
  78665. */
  78666. export interface IWebXRAnchorSystemOptions {
  78667. /**
  78668. * a node that will be used to convert local to world coordinates
  78669. */
  78670. worldParentNode?: TransformNode;
  78671. /**
  78672. * If set to true a reference of the created anchors will be kept until the next session starts
  78673. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78674. */
  78675. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78676. }
  78677. /**
  78678. * A babylon container for an XR Anchor
  78679. */
  78680. export interface IWebXRAnchor {
  78681. /**
  78682. * A babylon-assigned ID for this anchor
  78683. */
  78684. id: number;
  78685. /**
  78686. * Transformation matrix to apply to an object attached to this anchor
  78687. */
  78688. transformationMatrix: Matrix;
  78689. /**
  78690. * The native anchor object
  78691. */
  78692. xrAnchor: XRAnchor;
  78693. /**
  78694. * if defined, this object will be constantly updated by the anchor's position and rotation
  78695. */
  78696. attachedNode?: TransformNode;
  78697. }
  78698. /**
  78699. * An implementation of the anchor system for WebXR.
  78700. * For further information see https://github.com/immersive-web/anchors/
  78701. */
  78702. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78703. private _options;
  78704. private _lastFrameDetected;
  78705. private _trackedAnchors;
  78706. private _referenceSpaceForFrameAnchors;
  78707. private _futureAnchors;
  78708. /**
  78709. * The module's name
  78710. */
  78711. static readonly Name: string;
  78712. /**
  78713. * The (Babylon) version of this module.
  78714. * This is an integer representing the implementation version.
  78715. * This number does not correspond to the WebXR specs version
  78716. */
  78717. static readonly Version: number;
  78718. /**
  78719. * Observers registered here will be executed when a new anchor was added to the session
  78720. */
  78721. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78722. /**
  78723. * Observers registered here will be executed when an anchor was removed from the session
  78724. */
  78725. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78726. /**
  78727. * Observers registered here will be executed when an existing anchor updates
  78728. * This can execute N times every frame
  78729. */
  78730. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78731. /**
  78732. * Set the reference space to use for anchor creation, when not using a hit test.
  78733. * Will default to the session's reference space if not defined
  78734. */
  78735. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78736. /**
  78737. * constructs a new anchor system
  78738. * @param _xrSessionManager an instance of WebXRSessionManager
  78739. * @param _options configuration object for this feature
  78740. */
  78741. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78742. private _tmpVector;
  78743. private _tmpQuaternion;
  78744. private _populateTmpTransformation;
  78745. /**
  78746. * Create a new anchor point using a hit test result at a specific point in the scene
  78747. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78748. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78749. *
  78750. * @param hitTestResult The hit test result to use for this anchor creation
  78751. * @param position an optional position offset for this anchor
  78752. * @param rotationQuaternion an optional rotation offset for this anchor
  78753. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78754. */
  78755. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78756. /**
  78757. * Add a new anchor at a specific position and rotation
  78758. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78759. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78760. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78761. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78762. *
  78763. * @param position the position in which to add an anchor
  78764. * @param rotationQuaternion an optional rotation for the anchor transformation
  78765. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78766. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78767. */
  78768. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78769. /**
  78770. * detach this feature.
  78771. * Will usually be called by the features manager
  78772. *
  78773. * @returns true if successful.
  78774. */
  78775. detach(): boolean;
  78776. /**
  78777. * Dispose this feature and all of the resources attached
  78778. */
  78779. dispose(): void;
  78780. protected _onXRFrame(frame: XRFrame): void;
  78781. /**
  78782. * avoiding using Array.find for global support.
  78783. * @param xrAnchor the plane to find in the array
  78784. */
  78785. private _findIndexInAnchorArray;
  78786. private _updateAnchorWithXRFrame;
  78787. private _createAnchorAtTransformation;
  78788. }
  78789. }
  78790. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78792. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78793. import { Observable } from "babylonjs/Misc/observable";
  78794. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78795. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78796. /**
  78797. * Options used in the plane detector module
  78798. */
  78799. export interface IWebXRPlaneDetectorOptions {
  78800. /**
  78801. * The node to use to transform the local results to world coordinates
  78802. */
  78803. worldParentNode?: TransformNode;
  78804. /**
  78805. * If set to true a reference of the created planes will be kept until the next session starts
  78806. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78807. */
  78808. doNotRemovePlanesOnSessionEnded?: boolean;
  78809. }
  78810. /**
  78811. * A babylon interface for a WebXR plane.
  78812. * A Plane is actually a polygon, built from N points in space
  78813. *
  78814. * Supported in chrome 79, not supported in canary 81 ATM
  78815. */
  78816. export interface IWebXRPlane {
  78817. /**
  78818. * a babylon-assigned ID for this polygon
  78819. */
  78820. id: number;
  78821. /**
  78822. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78823. */
  78824. polygonDefinition: Array<Vector3>;
  78825. /**
  78826. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78827. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78828. */
  78829. transformationMatrix: Matrix;
  78830. /**
  78831. * the native xr-plane object
  78832. */
  78833. xrPlane: XRPlane;
  78834. }
  78835. /**
  78836. * The plane detector is used to detect planes in the real world when in AR
  78837. * For more information see https://github.com/immersive-web/real-world-geometry/
  78838. */
  78839. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78840. private _options;
  78841. private _detectedPlanes;
  78842. private _enabled;
  78843. private _lastFrameDetected;
  78844. /**
  78845. * The module's name
  78846. */
  78847. static readonly Name: string;
  78848. /**
  78849. * The (Babylon) version of this module.
  78850. * This is an integer representing the implementation version.
  78851. * This number does not correspond to the WebXR specs version
  78852. */
  78853. static readonly Version: number;
  78854. /**
  78855. * Observers registered here will be executed when a new plane was added to the session
  78856. */
  78857. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78858. /**
  78859. * Observers registered here will be executed when a plane is no longer detected in the session
  78860. */
  78861. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78862. /**
  78863. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78864. * This can execute N times every frame
  78865. */
  78866. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78867. /**
  78868. * construct a new Plane Detector
  78869. * @param _xrSessionManager an instance of xr Session manager
  78870. * @param _options configuration to use when constructing this feature
  78871. */
  78872. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78873. /**
  78874. * detach this feature.
  78875. * Will usually be called by the features manager
  78876. *
  78877. * @returns true if successful.
  78878. */
  78879. detach(): boolean;
  78880. /**
  78881. * Dispose this feature and all of the resources attached
  78882. */
  78883. dispose(): void;
  78884. protected _onXRFrame(frame: XRFrame): void;
  78885. private _init;
  78886. private _updatePlaneWithXRPlane;
  78887. /**
  78888. * avoiding using Array.find for global support.
  78889. * @param xrPlane the plane to find in the array
  78890. */
  78891. private findIndexInPlaneArray;
  78892. }
  78893. }
  78894. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78895. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78897. import { Observable } from "babylonjs/Misc/observable";
  78898. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78899. /**
  78900. * Options interface for the background remover plugin
  78901. */
  78902. export interface IWebXRBackgroundRemoverOptions {
  78903. /**
  78904. * Further background meshes to disable when entering AR
  78905. */
  78906. backgroundMeshes?: AbstractMesh[];
  78907. /**
  78908. * flags to configure the removal of the environment helper.
  78909. * If not set, the entire background will be removed. If set, flags should be set as well.
  78910. */
  78911. environmentHelperRemovalFlags?: {
  78912. /**
  78913. * Should the skybox be removed (default false)
  78914. */
  78915. skyBox?: boolean;
  78916. /**
  78917. * Should the ground be removed (default false)
  78918. */
  78919. ground?: boolean;
  78920. };
  78921. /**
  78922. * don't disable the environment helper
  78923. */
  78924. ignoreEnvironmentHelper?: boolean;
  78925. }
  78926. /**
  78927. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78928. */
  78929. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78930. /**
  78931. * read-only options to be used in this module
  78932. */
  78933. readonly options: IWebXRBackgroundRemoverOptions;
  78934. /**
  78935. * The module's name
  78936. */
  78937. static readonly Name: string;
  78938. /**
  78939. * The (Babylon) version of this module.
  78940. * This is an integer representing the implementation version.
  78941. * This number does not correspond to the WebXR specs version
  78942. */
  78943. static readonly Version: number;
  78944. /**
  78945. * registered observers will be triggered when the background state changes
  78946. */
  78947. onBackgroundStateChangedObservable: Observable<boolean>;
  78948. /**
  78949. * constructs a new background remover module
  78950. * @param _xrSessionManager the session manager for this module
  78951. * @param options read-only options to be used in this module
  78952. */
  78953. constructor(_xrSessionManager: WebXRSessionManager,
  78954. /**
  78955. * read-only options to be used in this module
  78956. */
  78957. options?: IWebXRBackgroundRemoverOptions);
  78958. /**
  78959. * attach this feature
  78960. * Will usually be called by the features manager
  78961. *
  78962. * @returns true if successful.
  78963. */
  78964. attach(): boolean;
  78965. /**
  78966. * detach this feature.
  78967. * Will usually be called by the features manager
  78968. *
  78969. * @returns true if successful.
  78970. */
  78971. detach(): boolean;
  78972. /**
  78973. * Dispose this feature and all of the resources attached
  78974. */
  78975. dispose(): void;
  78976. protected _onXRFrame(_xrFrame: XRFrame): void;
  78977. private _setBackgroundState;
  78978. }
  78979. }
  78980. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78981. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78982. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78983. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78984. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78985. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78986. import { Nullable } from "babylonjs/types";
  78987. /**
  78988. * Options for the controller physics feature
  78989. */
  78990. export class IWebXRControllerPhysicsOptions {
  78991. /**
  78992. * Should the headset get its own impostor
  78993. */
  78994. enableHeadsetImpostor?: boolean;
  78995. /**
  78996. * Optional parameters for the headset impostor
  78997. */
  78998. headsetImpostorParams?: {
  78999. /**
  79000. * The type of impostor to create. Default is sphere
  79001. */
  79002. impostorType: number;
  79003. /**
  79004. * the size of the impostor. Defaults to 10cm
  79005. */
  79006. impostorSize?: number | {
  79007. width: number;
  79008. height: number;
  79009. depth: number;
  79010. };
  79011. /**
  79012. * Friction definitions
  79013. */
  79014. friction?: number;
  79015. /**
  79016. * Restitution
  79017. */
  79018. restitution?: number;
  79019. };
  79020. /**
  79021. * The physics properties of the future impostors
  79022. */
  79023. physicsProperties?: {
  79024. /**
  79025. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79026. * Note that this requires a physics engine that supports mesh impostors!
  79027. */
  79028. useControllerMesh?: boolean;
  79029. /**
  79030. * The type of impostor to create. Default is sphere
  79031. */
  79032. impostorType?: number;
  79033. /**
  79034. * the size of the impostor. Defaults to 10cm
  79035. */
  79036. impostorSize?: number | {
  79037. width: number;
  79038. height: number;
  79039. depth: number;
  79040. };
  79041. /**
  79042. * Friction definitions
  79043. */
  79044. friction?: number;
  79045. /**
  79046. * Restitution
  79047. */
  79048. restitution?: number;
  79049. };
  79050. /**
  79051. * the xr input to use with this pointer selection
  79052. */
  79053. xrInput: WebXRInput;
  79054. }
  79055. /**
  79056. * Add physics impostor to your webxr controllers,
  79057. * including naive calculation of their linear and angular velocity
  79058. */
  79059. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79060. private readonly _options;
  79061. private _attachController;
  79062. private _controllers;
  79063. private _debugMode;
  79064. private _delta;
  79065. private _headsetImpostor?;
  79066. private _headsetMesh?;
  79067. private _lastTimestamp;
  79068. private _tmpQuaternion;
  79069. private _tmpVector;
  79070. /**
  79071. * The module's name
  79072. */
  79073. static readonly Name: string;
  79074. /**
  79075. * The (Babylon) version of this module.
  79076. * This is an integer representing the implementation version.
  79077. * This number does not correspond to the webxr specs version
  79078. */
  79079. static readonly Version: number;
  79080. /**
  79081. * Construct a new Controller Physics Feature
  79082. * @param _xrSessionManager the corresponding xr session manager
  79083. * @param _options options to create this feature with
  79084. */
  79085. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79086. /**
  79087. * @hidden
  79088. * enable debugging - will show console outputs and the impostor mesh
  79089. */
  79090. _enablePhysicsDebug(): void;
  79091. /**
  79092. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79093. * @param xrController the controller to add
  79094. */
  79095. addController(xrController: WebXRInputSource): void;
  79096. /**
  79097. * attach this feature
  79098. * Will usually be called by the features manager
  79099. *
  79100. * @returns true if successful.
  79101. */
  79102. attach(): boolean;
  79103. /**
  79104. * detach this feature.
  79105. * Will usually be called by the features manager
  79106. *
  79107. * @returns true if successful.
  79108. */
  79109. detach(): boolean;
  79110. /**
  79111. * Get the headset impostor, if enabled
  79112. * @returns the impostor
  79113. */
  79114. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79115. /**
  79116. * Get the physics impostor of a specific controller.
  79117. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79118. * @param controller the controller or the controller id of which to get the impostor
  79119. * @returns the impostor or null
  79120. */
  79121. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79122. /**
  79123. * Update the physics properties provided in the constructor
  79124. * @param newProperties the new properties object
  79125. */
  79126. setPhysicsProperties(newProperties: {
  79127. impostorType?: number;
  79128. impostorSize?: number | {
  79129. width: number;
  79130. height: number;
  79131. depth: number;
  79132. };
  79133. friction?: number;
  79134. restitution?: number;
  79135. }): void;
  79136. protected _onXRFrame(_xrFrame: any): void;
  79137. private _detachController;
  79138. }
  79139. }
  79140. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79141. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79142. import { Observable } from "babylonjs/Misc/observable";
  79143. import { Vector3 } from "babylonjs/Maths/math.vector";
  79144. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79145. /**
  79146. * A babylon interface for a "WebXR" feature point.
  79147. * Represents the position and confidence value of a given feature point.
  79148. */
  79149. export interface IWebXRFeaturePoint {
  79150. /**
  79151. * Represents the position of the feature point in world space.
  79152. */
  79153. position: Vector3;
  79154. /**
  79155. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79156. */
  79157. confidenceValue: number;
  79158. }
  79159. /**
  79160. * The feature point system is used to detect feature points from real world geometry.
  79161. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79162. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79163. */
  79164. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79165. private _enabled;
  79166. private _featurePointCloud;
  79167. /**
  79168. * The module's name
  79169. */
  79170. static readonly Name: string;
  79171. /**
  79172. * The (Babylon) version of this module.
  79173. * This is an integer representing the implementation version.
  79174. * This number does not correspond to the WebXR specs version
  79175. */
  79176. static readonly Version: number;
  79177. /**
  79178. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79179. * Will notify the observers about which feature points have been added.
  79180. */
  79181. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79182. /**
  79183. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79184. * Will notify the observers about which feature points have been updated.
  79185. */
  79186. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79187. /**
  79188. * The current feature point cloud maintained across frames.
  79189. */
  79190. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79191. /**
  79192. * construct the feature point system
  79193. * @param _xrSessionManager an instance of xr Session manager
  79194. */
  79195. constructor(_xrSessionManager: WebXRSessionManager);
  79196. /**
  79197. * Detach this feature.
  79198. * Will usually be called by the features manager
  79199. *
  79200. * @returns true if successful.
  79201. */
  79202. detach(): boolean;
  79203. /**
  79204. * Dispose this feature and all of the resources attached
  79205. */
  79206. dispose(): void;
  79207. /**
  79208. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79209. */
  79210. protected _onXRFrame(frame: XRFrame): void;
  79211. /**
  79212. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79213. */
  79214. private _init;
  79215. }
  79216. }
  79217. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79218. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79219. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79221. import { Mesh } from "babylonjs/Meshes/mesh";
  79222. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79223. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79224. import { Nullable } from "babylonjs/types";
  79225. import { IDisposable } from "babylonjs/scene";
  79226. import { Observable } from "babylonjs/Misc/observable";
  79227. /**
  79228. * Configuration interface for the hand tracking feature
  79229. */
  79230. export interface IWebXRHandTrackingOptions {
  79231. /**
  79232. * The xrInput that will be used as source for new hands
  79233. */
  79234. xrInput: WebXRInput;
  79235. /**
  79236. * Configuration object for the joint meshes
  79237. */
  79238. jointMeshes?: {
  79239. /**
  79240. * Should the meshes created be invisible (defaults to false)
  79241. */
  79242. invisible?: boolean;
  79243. /**
  79244. * A source mesh to be used to create instances. Defaults to a sphere.
  79245. * This mesh will be the source for all other (25) meshes.
  79246. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79247. */
  79248. sourceMesh?: Mesh;
  79249. /**
  79250. * Should the source mesh stay visible. Defaults to false
  79251. */
  79252. keepOriginalVisible?: boolean;
  79253. /**
  79254. * Scale factor for all instances (defaults to 2)
  79255. */
  79256. scaleFactor?: number;
  79257. /**
  79258. * Should each instance have its own physics impostor
  79259. */
  79260. enablePhysics?: boolean;
  79261. /**
  79262. * If enabled, override default physics properties
  79263. */
  79264. physicsProps?: {
  79265. friction?: number;
  79266. restitution?: number;
  79267. impostorType?: number;
  79268. };
  79269. /**
  79270. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79271. */
  79272. handMesh?: AbstractMesh;
  79273. };
  79274. }
  79275. /**
  79276. * Parts of the hands divided to writs and finger names
  79277. */
  79278. export const enum HandPart {
  79279. /**
  79280. * HandPart - Wrist
  79281. */
  79282. WRIST = "wrist",
  79283. /**
  79284. * HandPart - The THumb
  79285. */
  79286. THUMB = "thumb",
  79287. /**
  79288. * HandPart - Index finger
  79289. */
  79290. INDEX = "index",
  79291. /**
  79292. * HandPart - Middle finger
  79293. */
  79294. MIDDLE = "middle",
  79295. /**
  79296. * HandPart - Ring finger
  79297. */
  79298. RING = "ring",
  79299. /**
  79300. * HandPart - Little finger
  79301. */
  79302. LITTLE = "little"
  79303. }
  79304. /**
  79305. * Representing a single hand (with its corresponding native XRHand object)
  79306. */
  79307. export class WebXRHand implements IDisposable {
  79308. /** the controller to which the hand correlates */
  79309. readonly xrController: WebXRInputSource;
  79310. /** the meshes to be used to track the hand joints */
  79311. readonly trackedMeshes: AbstractMesh[];
  79312. /**
  79313. * Hand-parts definition (key is HandPart)
  79314. */
  79315. handPartsDefinition: {
  79316. [key: string]: number[];
  79317. };
  79318. /**
  79319. * Populate the HandPartsDefinition object.
  79320. * This is called as a side effect since certain browsers don't have XRHand defined.
  79321. */
  79322. private generateHandPartsDefinition;
  79323. /**
  79324. * Construct a new hand object
  79325. * @param xrController the controller to which the hand correlates
  79326. * @param trackedMeshes the meshes to be used to track the hand joints
  79327. */
  79328. constructor(
  79329. /** the controller to which the hand correlates */
  79330. xrController: WebXRInputSource,
  79331. /** the meshes to be used to track the hand joints */
  79332. trackedMeshes: AbstractMesh[]);
  79333. /**
  79334. * Update this hand from the latest xr frame
  79335. * @param xrFrame xrFrame to update from
  79336. * @param referenceSpace The current viewer reference space
  79337. * @param scaleFactor optional scale factor for the meshes
  79338. */
  79339. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79340. /**
  79341. * Get meshes of part of the hand
  79342. * @param part the part of hand to get
  79343. * @returns An array of meshes that correlate to the hand part requested
  79344. */
  79345. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79346. /**
  79347. * Dispose this Hand object
  79348. */
  79349. dispose(): void;
  79350. }
  79351. /**
  79352. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79353. */
  79354. export class WebXRHandTracking extends WebXRAbstractFeature {
  79355. /**
  79356. * options to use when constructing this feature
  79357. */
  79358. readonly options: IWebXRHandTrackingOptions;
  79359. private static _idCounter;
  79360. /**
  79361. * The module's name
  79362. */
  79363. static readonly Name: string;
  79364. /**
  79365. * The (Babylon) version of this module.
  79366. * This is an integer representing the implementation version.
  79367. * This number does not correspond to the WebXR specs version
  79368. */
  79369. static readonly Version: number;
  79370. /**
  79371. * This observable will notify registered observers when a new hand object was added and initialized
  79372. */
  79373. onHandAddedObservable: Observable<WebXRHand>;
  79374. /**
  79375. * This observable will notify its observers right before the hand object is disposed
  79376. */
  79377. onHandRemovedObservable: Observable<WebXRHand>;
  79378. private _hands;
  79379. /**
  79380. * Creates a new instance of the hit test feature
  79381. * @param _xrSessionManager an instance of WebXRSessionManager
  79382. * @param options options to use when constructing this feature
  79383. */
  79384. constructor(_xrSessionManager: WebXRSessionManager,
  79385. /**
  79386. * options to use when constructing this feature
  79387. */
  79388. options: IWebXRHandTrackingOptions);
  79389. /**
  79390. * Check if the needed objects are defined.
  79391. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79392. */
  79393. isCompatible(): boolean;
  79394. /**
  79395. * attach this feature
  79396. * Will usually be called by the features manager
  79397. *
  79398. * @returns true if successful.
  79399. */
  79400. attach(): boolean;
  79401. /**
  79402. * detach this feature.
  79403. * Will usually be called by the features manager
  79404. *
  79405. * @returns true if successful.
  79406. */
  79407. detach(): boolean;
  79408. /**
  79409. * Dispose this feature and all of the resources attached
  79410. */
  79411. dispose(): void;
  79412. /**
  79413. * Get the hand object according to the controller id
  79414. * @param controllerId the controller id to which we want to get the hand
  79415. * @returns null if not found or the WebXRHand object if found
  79416. */
  79417. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79418. /**
  79419. * Get a hand object according to the requested handedness
  79420. * @param handedness the handedness to request
  79421. * @returns null if not found or the WebXRHand object if found
  79422. */
  79423. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79424. protected _onXRFrame(_xrFrame: XRFrame): void;
  79425. private _attachHand;
  79426. private _detachHand;
  79427. }
  79428. }
  79429. declare module "babylonjs/XR/features/index" {
  79430. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79431. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79432. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79433. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79434. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79435. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79436. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79437. export * from "babylonjs/XR/features/WebXRHitTest";
  79438. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79439. export * from "babylonjs/XR/features/WebXRHandTracking";
  79440. }
  79441. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79442. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79444. import { Scene } from "babylonjs/scene";
  79445. /**
  79446. * The motion controller class for all microsoft mixed reality controllers
  79447. */
  79448. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79449. protected readonly _mapping: {
  79450. defaultButton: {
  79451. valueNodeName: string;
  79452. unpressedNodeName: string;
  79453. pressedNodeName: string;
  79454. };
  79455. defaultAxis: {
  79456. valueNodeName: string;
  79457. minNodeName: string;
  79458. maxNodeName: string;
  79459. };
  79460. buttons: {
  79461. "xr-standard-trigger": {
  79462. rootNodeName: string;
  79463. componentProperty: string;
  79464. states: string[];
  79465. };
  79466. "xr-standard-squeeze": {
  79467. rootNodeName: string;
  79468. componentProperty: string;
  79469. states: string[];
  79470. };
  79471. "xr-standard-touchpad": {
  79472. rootNodeName: string;
  79473. labelAnchorNodeName: string;
  79474. touchPointNodeName: string;
  79475. };
  79476. "xr-standard-thumbstick": {
  79477. rootNodeName: string;
  79478. componentProperty: string;
  79479. states: string[];
  79480. };
  79481. };
  79482. axes: {
  79483. "xr-standard-touchpad": {
  79484. "x-axis": {
  79485. rootNodeName: string;
  79486. };
  79487. "y-axis": {
  79488. rootNodeName: string;
  79489. };
  79490. };
  79491. "xr-standard-thumbstick": {
  79492. "x-axis": {
  79493. rootNodeName: string;
  79494. };
  79495. "y-axis": {
  79496. rootNodeName: string;
  79497. };
  79498. };
  79499. };
  79500. };
  79501. /**
  79502. * The base url used to load the left and right controller models
  79503. */
  79504. static MODEL_BASE_URL: string;
  79505. /**
  79506. * The name of the left controller model file
  79507. */
  79508. static MODEL_LEFT_FILENAME: string;
  79509. /**
  79510. * The name of the right controller model file
  79511. */
  79512. static MODEL_RIGHT_FILENAME: string;
  79513. profileId: string;
  79514. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79515. protected _getFilenameAndPath(): {
  79516. filename: string;
  79517. path: string;
  79518. };
  79519. protected _getModelLoadingConstraints(): boolean;
  79520. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79521. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79522. protected _updateModel(): void;
  79523. }
  79524. }
  79525. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79526. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79528. import { Scene } from "babylonjs/scene";
  79529. /**
  79530. * The motion controller class for oculus touch (quest, rift).
  79531. * This class supports legacy mapping as well the standard xr mapping
  79532. */
  79533. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79534. private _forceLegacyControllers;
  79535. private _modelRootNode;
  79536. /**
  79537. * The base url used to load the left and right controller models
  79538. */
  79539. static MODEL_BASE_URL: string;
  79540. /**
  79541. * The name of the left controller model file
  79542. */
  79543. static MODEL_LEFT_FILENAME: string;
  79544. /**
  79545. * The name of the right controller model file
  79546. */
  79547. static MODEL_RIGHT_FILENAME: string;
  79548. /**
  79549. * Base Url for the Quest controller model.
  79550. */
  79551. static QUEST_MODEL_BASE_URL: string;
  79552. profileId: string;
  79553. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79554. protected _getFilenameAndPath(): {
  79555. filename: string;
  79556. path: string;
  79557. };
  79558. protected _getModelLoadingConstraints(): boolean;
  79559. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79560. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79561. protected _updateModel(): void;
  79562. /**
  79563. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79564. * between the touch and touch 2.
  79565. */
  79566. private _isQuest;
  79567. }
  79568. }
  79569. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79570. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79571. import { Scene } from "babylonjs/scene";
  79572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79573. /**
  79574. * The motion controller class for the standard HTC-Vive controllers
  79575. */
  79576. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79577. private _modelRootNode;
  79578. /**
  79579. * The base url used to load the left and right controller models
  79580. */
  79581. static MODEL_BASE_URL: string;
  79582. /**
  79583. * File name for the controller model.
  79584. */
  79585. static MODEL_FILENAME: string;
  79586. profileId: string;
  79587. /**
  79588. * Create a new Vive motion controller object
  79589. * @param scene the scene to use to create this controller
  79590. * @param gamepadObject the corresponding gamepad object
  79591. * @param handedness the handedness of the controller
  79592. */
  79593. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79594. protected _getFilenameAndPath(): {
  79595. filename: string;
  79596. path: string;
  79597. };
  79598. protected _getModelLoadingConstraints(): boolean;
  79599. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79600. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79601. protected _updateModel(): void;
  79602. }
  79603. }
  79604. declare module "babylonjs/XR/motionController/index" {
  79605. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79606. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79607. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79608. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79609. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79610. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79611. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79612. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79613. }
  79614. declare module "babylonjs/XR/index" {
  79615. export * from "babylonjs/XR/webXRCamera";
  79616. export * from "babylonjs/XR/webXREnterExitUI";
  79617. export * from "babylonjs/XR/webXRExperienceHelper";
  79618. export * from "babylonjs/XR/webXRInput";
  79619. export * from "babylonjs/XR/webXRInputSource";
  79620. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79621. export * from "babylonjs/XR/webXRTypes";
  79622. export * from "babylonjs/XR/webXRSessionManager";
  79623. export * from "babylonjs/XR/webXRDefaultExperience";
  79624. export * from "babylonjs/XR/webXRFeaturesManager";
  79625. export * from "babylonjs/XR/features/index";
  79626. export * from "babylonjs/XR/motionController/index";
  79627. }
  79628. declare module "babylonjs/index" {
  79629. export * from "babylonjs/abstractScene";
  79630. export * from "babylonjs/Actions/index";
  79631. export * from "babylonjs/Animations/index";
  79632. export * from "babylonjs/assetContainer";
  79633. export * from "babylonjs/Audio/index";
  79634. export * from "babylonjs/Behaviors/index";
  79635. export * from "babylonjs/Bones/index";
  79636. export * from "babylonjs/Cameras/index";
  79637. export * from "babylonjs/Collisions/index";
  79638. export * from "babylonjs/Culling/index";
  79639. export * from "babylonjs/Debug/index";
  79640. export * from "babylonjs/DeviceInput/index";
  79641. export * from "babylonjs/Engines/index";
  79642. export * from "babylonjs/Events/index";
  79643. export * from "babylonjs/Gamepads/index";
  79644. export * from "babylonjs/Gizmos/index";
  79645. export * from "babylonjs/Helpers/index";
  79646. export * from "babylonjs/Instrumentation/index";
  79647. export * from "babylonjs/Layers/index";
  79648. export * from "babylonjs/LensFlares/index";
  79649. export * from "babylonjs/Lights/index";
  79650. export * from "babylonjs/Loading/index";
  79651. export * from "babylonjs/Materials/index";
  79652. export * from "babylonjs/Maths/index";
  79653. export * from "babylonjs/Meshes/index";
  79654. export * from "babylonjs/Morph/index";
  79655. export * from "babylonjs/Navigation/index";
  79656. export * from "babylonjs/node";
  79657. export * from "babylonjs/Offline/index";
  79658. export * from "babylonjs/Particles/index";
  79659. export * from "babylonjs/Physics/index";
  79660. export * from "babylonjs/PostProcesses/index";
  79661. export * from "babylonjs/Probes/index";
  79662. export * from "babylonjs/Rendering/index";
  79663. export * from "babylonjs/scene";
  79664. export * from "babylonjs/sceneComponent";
  79665. export * from "babylonjs/Sprites/index";
  79666. export * from "babylonjs/States/index";
  79667. export * from "babylonjs/Misc/index";
  79668. export * from "babylonjs/XR/index";
  79669. export * from "babylonjs/types";
  79670. }
  79671. declare module "babylonjs/Animations/pathCursor" {
  79672. import { Vector3 } from "babylonjs/Maths/math.vector";
  79673. import { Path2 } from "babylonjs/Maths/math.path";
  79674. /**
  79675. * A cursor which tracks a point on a path
  79676. */
  79677. export class PathCursor {
  79678. private path;
  79679. /**
  79680. * Stores path cursor callbacks for when an onchange event is triggered
  79681. */
  79682. private _onchange;
  79683. /**
  79684. * The value of the path cursor
  79685. */
  79686. value: number;
  79687. /**
  79688. * The animation array of the path cursor
  79689. */
  79690. animations: Animation[];
  79691. /**
  79692. * Initializes the path cursor
  79693. * @param path The path to track
  79694. */
  79695. constructor(path: Path2);
  79696. /**
  79697. * Gets the cursor point on the path
  79698. * @returns A point on the path cursor at the cursor location
  79699. */
  79700. getPoint(): Vector3;
  79701. /**
  79702. * Moves the cursor ahead by the step amount
  79703. * @param step The amount to move the cursor forward
  79704. * @returns This path cursor
  79705. */
  79706. moveAhead(step?: number): PathCursor;
  79707. /**
  79708. * Moves the cursor behind by the step amount
  79709. * @param step The amount to move the cursor back
  79710. * @returns This path cursor
  79711. */
  79712. moveBack(step?: number): PathCursor;
  79713. /**
  79714. * Moves the cursor by the step amount
  79715. * If the step amount is greater than one, an exception is thrown
  79716. * @param step The amount to move the cursor
  79717. * @returns This path cursor
  79718. */
  79719. move(step: number): PathCursor;
  79720. /**
  79721. * Ensures that the value is limited between zero and one
  79722. * @returns This path cursor
  79723. */
  79724. private ensureLimits;
  79725. /**
  79726. * Runs onchange callbacks on change (used by the animation engine)
  79727. * @returns This path cursor
  79728. */
  79729. private raiseOnChange;
  79730. /**
  79731. * Executes a function on change
  79732. * @param f A path cursor onchange callback
  79733. * @returns This path cursor
  79734. */
  79735. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79736. }
  79737. }
  79738. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79739. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79740. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79741. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79742. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79743. }
  79744. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79745. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79746. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79747. }
  79748. declare module "babylonjs/Engines/Processors/index" {
  79749. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79750. export * from "babylonjs/Engines/Processors/Expressions/index";
  79751. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79752. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79753. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79754. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79755. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79756. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79757. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79758. }
  79759. declare module "babylonjs/Legacy/legacy" {
  79760. import * as Babylon from "babylonjs/index";
  79761. export * from "babylonjs/index";
  79762. }
  79763. declare module "babylonjs/Shaders/blur.fragment" {
  79764. /** @hidden */
  79765. export var blurPixelShader: {
  79766. name: string;
  79767. shader: string;
  79768. };
  79769. }
  79770. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79771. /** @hidden */
  79772. export var pointCloudVertexDeclaration: {
  79773. name: string;
  79774. shader: string;
  79775. };
  79776. }
  79777. declare module "babylonjs" {
  79778. export * from "babylonjs/Legacy/legacy";
  79779. }
  79780. declare module BABYLON {
  79781. /** Alias type for value that can be null */
  79782. export type Nullable<T> = T | null;
  79783. /**
  79784. * Alias type for number that are floats
  79785. * @ignorenaming
  79786. */
  79787. export type float = number;
  79788. /**
  79789. * Alias type for number that are doubles.
  79790. * @ignorenaming
  79791. */
  79792. export type double = number;
  79793. /**
  79794. * Alias type for number that are integer
  79795. * @ignorenaming
  79796. */
  79797. export type int = number;
  79798. /** Alias type for number array or Float32Array */
  79799. export type FloatArray = number[] | Float32Array;
  79800. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79801. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79802. /**
  79803. * Alias for types that can be used by a Buffer or VertexBuffer.
  79804. */
  79805. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79806. /**
  79807. * Alias type for primitive types
  79808. * @ignorenaming
  79809. */
  79810. type Primitive = undefined | null | boolean | string | number | Function;
  79811. /**
  79812. * Type modifier to make all the properties of an object Readonly
  79813. */
  79814. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79815. /**
  79816. * Type modifier to make all the properties of an object Readonly recursively
  79817. */
  79818. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79819. /**
  79820. * Type modifier to make object properties readonly.
  79821. */
  79822. export type DeepImmutableObject<T> = {
  79823. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79824. };
  79825. /** @hidden */
  79826. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79827. }
  79828. }
  79829. declare module BABYLON {
  79830. /**
  79831. * A class serves as a medium between the observable and its observers
  79832. */
  79833. export class EventState {
  79834. /**
  79835. * Create a new EventState
  79836. * @param mask defines the mask associated with this state
  79837. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79838. * @param target defines the original target of the state
  79839. * @param currentTarget defines the current target of the state
  79840. */
  79841. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79842. /**
  79843. * Initialize the current event state
  79844. * @param mask defines the mask associated with this state
  79845. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79846. * @param target defines the original target of the state
  79847. * @param currentTarget defines the current target of the state
  79848. * @returns the current event state
  79849. */
  79850. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79851. /**
  79852. * An Observer can set this property to true to prevent subsequent observers of being notified
  79853. */
  79854. skipNextObservers: boolean;
  79855. /**
  79856. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79857. */
  79858. mask: number;
  79859. /**
  79860. * The object that originally notified the event
  79861. */
  79862. target?: any;
  79863. /**
  79864. * The current object in the bubbling phase
  79865. */
  79866. currentTarget?: any;
  79867. /**
  79868. * This will be populated with the return value of the last function that was executed.
  79869. * If it is the first function in the callback chain it will be the event data.
  79870. */
  79871. lastReturnValue?: any;
  79872. }
  79873. /**
  79874. * Represent an Observer registered to a given Observable object.
  79875. */
  79876. export class Observer<T> {
  79877. /**
  79878. * Defines the callback to call when the observer is notified
  79879. */
  79880. callback: (eventData: T, eventState: EventState) => void;
  79881. /**
  79882. * Defines the mask of the observer (used to filter notifications)
  79883. */
  79884. mask: number;
  79885. /**
  79886. * Defines the current scope used to restore the JS context
  79887. */
  79888. scope: any;
  79889. /** @hidden */
  79890. _willBeUnregistered: boolean;
  79891. /**
  79892. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79893. */
  79894. unregisterOnNextCall: boolean;
  79895. /**
  79896. * Creates a new observer
  79897. * @param callback defines the callback to call when the observer is notified
  79898. * @param mask defines the mask of the observer (used to filter notifications)
  79899. * @param scope defines the current scope used to restore the JS context
  79900. */
  79901. constructor(
  79902. /**
  79903. * Defines the callback to call when the observer is notified
  79904. */
  79905. callback: (eventData: T, eventState: EventState) => void,
  79906. /**
  79907. * Defines the mask of the observer (used to filter notifications)
  79908. */
  79909. mask: number,
  79910. /**
  79911. * Defines the current scope used to restore the JS context
  79912. */
  79913. scope?: any);
  79914. }
  79915. /**
  79916. * Represent a list of observers registered to multiple Observables object.
  79917. */
  79918. export class MultiObserver<T> {
  79919. private _observers;
  79920. private _observables;
  79921. /**
  79922. * Release associated resources
  79923. */
  79924. dispose(): void;
  79925. /**
  79926. * Raise a callback when one of the observable will notify
  79927. * @param observables defines a list of observables to watch
  79928. * @param callback defines the callback to call on notification
  79929. * @param mask defines the mask used to filter notifications
  79930. * @param scope defines the current scope used to restore the JS context
  79931. * @returns the new MultiObserver
  79932. */
  79933. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79934. }
  79935. /**
  79936. * The Observable class is a simple implementation of the Observable pattern.
  79937. *
  79938. * 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.
  79939. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79940. * 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).
  79941. * 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.
  79942. */
  79943. export class Observable<T> {
  79944. private _observers;
  79945. private _eventState;
  79946. private _onObserverAdded;
  79947. /**
  79948. * Gets the list of observers
  79949. */
  79950. get observers(): Array<Observer<T>>;
  79951. /**
  79952. * Creates a new observable
  79953. * @param onObserverAdded defines a callback to call when a new observer is added
  79954. */
  79955. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79956. /**
  79957. * Create a new Observer with the specified callback
  79958. * @param callback the callback that will be executed for that Observer
  79959. * @param mask the mask used to filter observers
  79960. * @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.
  79961. * @param scope optional scope for the callback to be called from
  79962. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79963. * @returns the new observer created for the callback
  79964. */
  79965. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79966. /**
  79967. * Create a new Observer with the specified callback and unregisters after the next notification
  79968. * @param callback the callback that will be executed for that Observer
  79969. * @returns the new observer created for the callback
  79970. */
  79971. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79972. /**
  79973. * Remove an Observer from the Observable object
  79974. * @param observer the instance of the Observer to remove
  79975. * @returns false if it doesn't belong to this Observable
  79976. */
  79977. remove(observer: Nullable<Observer<T>>): boolean;
  79978. /**
  79979. * Remove a callback from the Observable object
  79980. * @param callback the callback to remove
  79981. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79982. * @returns false if it doesn't belong to this Observable
  79983. */
  79984. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79985. private _deferUnregister;
  79986. private _remove;
  79987. /**
  79988. * Moves the observable to the top of the observer list making it get called first when notified
  79989. * @param observer the observer to move
  79990. */
  79991. makeObserverTopPriority(observer: Observer<T>): void;
  79992. /**
  79993. * Moves the observable to the bottom of the observer list making it get called last when notified
  79994. * @param observer the observer to move
  79995. */
  79996. makeObserverBottomPriority(observer: Observer<T>): void;
  79997. /**
  79998. * Notify all Observers by calling their respective callback with the given data
  79999. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80000. * @param eventData defines the data to send to all observers
  80001. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80002. * @param target defines the original target of the state
  80003. * @param currentTarget defines the current target of the state
  80004. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80005. */
  80006. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80007. /**
  80008. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80009. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80010. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80011. * and it is crucial that all callbacks will be executed.
  80012. * The order of the callbacks is kept, callbacks are not executed parallel.
  80013. *
  80014. * @param eventData The data to be sent to each callback
  80015. * @param mask is used to filter observers defaults to -1
  80016. * @param target defines the callback target (see EventState)
  80017. * @param currentTarget defines he current object in the bubbling phase
  80018. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80019. */
  80020. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80021. /**
  80022. * Notify a specific observer
  80023. * @param observer defines the observer to notify
  80024. * @param eventData defines the data to be sent to each callback
  80025. * @param mask is used to filter observers defaults to -1
  80026. */
  80027. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80028. /**
  80029. * Gets a boolean indicating if the observable has at least one observer
  80030. * @returns true is the Observable has at least one Observer registered
  80031. */
  80032. hasObservers(): boolean;
  80033. /**
  80034. * Clear the list of observers
  80035. */
  80036. clear(): void;
  80037. /**
  80038. * Clone the current observable
  80039. * @returns a new observable
  80040. */
  80041. clone(): Observable<T>;
  80042. /**
  80043. * Does this observable handles observer registered with a given mask
  80044. * @param mask defines the mask to be tested
  80045. * @return whether or not one observer registered with the given mask is handeled
  80046. **/
  80047. hasSpecificMask(mask?: number): boolean;
  80048. }
  80049. }
  80050. declare module BABYLON {
  80051. /**
  80052. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80053. * Babylon.js
  80054. */
  80055. export class DomManagement {
  80056. /**
  80057. * Checks if the window object exists
  80058. * @returns true if the window object exists
  80059. */
  80060. static IsWindowObjectExist(): boolean;
  80061. /**
  80062. * Checks if the navigator object exists
  80063. * @returns true if the navigator object exists
  80064. */
  80065. static IsNavigatorAvailable(): boolean;
  80066. /**
  80067. * Check if the document object exists
  80068. * @returns true if the document object exists
  80069. */
  80070. static IsDocumentAvailable(): boolean;
  80071. /**
  80072. * Extracts text content from a DOM element hierarchy
  80073. * @param element defines the root element
  80074. * @returns a string
  80075. */
  80076. static GetDOMTextContent(element: HTMLElement): string;
  80077. }
  80078. }
  80079. declare module BABYLON {
  80080. /**
  80081. * Logger used througouht the application to allow configuration of
  80082. * the log level required for the messages.
  80083. */
  80084. export class Logger {
  80085. /**
  80086. * No log
  80087. */
  80088. static readonly NoneLogLevel: number;
  80089. /**
  80090. * Only message logs
  80091. */
  80092. static readonly MessageLogLevel: number;
  80093. /**
  80094. * Only warning logs
  80095. */
  80096. static readonly WarningLogLevel: number;
  80097. /**
  80098. * Only error logs
  80099. */
  80100. static readonly ErrorLogLevel: number;
  80101. /**
  80102. * All logs
  80103. */
  80104. static readonly AllLogLevel: number;
  80105. private static _LogCache;
  80106. /**
  80107. * Gets a value indicating the number of loading errors
  80108. * @ignorenaming
  80109. */
  80110. static errorsCount: number;
  80111. /**
  80112. * Callback called when a new log is added
  80113. */
  80114. static OnNewCacheEntry: (entry: string) => void;
  80115. private static _AddLogEntry;
  80116. private static _FormatMessage;
  80117. private static _LogDisabled;
  80118. private static _LogEnabled;
  80119. private static _WarnDisabled;
  80120. private static _WarnEnabled;
  80121. private static _ErrorDisabled;
  80122. private static _ErrorEnabled;
  80123. /**
  80124. * Log a message to the console
  80125. */
  80126. static Log: (message: string) => void;
  80127. /**
  80128. * Write a warning message to the console
  80129. */
  80130. static Warn: (message: string) => void;
  80131. /**
  80132. * Write an error message to the console
  80133. */
  80134. static Error: (message: string) => void;
  80135. /**
  80136. * Gets current log cache (list of logs)
  80137. */
  80138. static get LogCache(): string;
  80139. /**
  80140. * Clears the log cache
  80141. */
  80142. static ClearLogCache(): void;
  80143. /**
  80144. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80145. */
  80146. static set LogLevels(level: number);
  80147. }
  80148. }
  80149. declare module BABYLON {
  80150. /** @hidden */
  80151. export class _TypeStore {
  80152. /** @hidden */
  80153. static RegisteredTypes: {
  80154. [key: string]: Object;
  80155. };
  80156. /** @hidden */
  80157. static GetClass(fqdn: string): any;
  80158. }
  80159. }
  80160. declare module BABYLON {
  80161. /**
  80162. * Helper to manipulate strings
  80163. */
  80164. export class StringTools {
  80165. /**
  80166. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80167. * @param str Source string
  80168. * @param suffix Suffix to search for in the source string
  80169. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80170. */
  80171. static EndsWith(str: string, suffix: string): boolean;
  80172. /**
  80173. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80174. * @param str Source string
  80175. * @param suffix Suffix to search for in the source string
  80176. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80177. */
  80178. static StartsWith(str: string, suffix: string): boolean;
  80179. /**
  80180. * Decodes a buffer into a string
  80181. * @param buffer The buffer to decode
  80182. * @returns The decoded string
  80183. */
  80184. static Decode(buffer: Uint8Array | Uint16Array): string;
  80185. /**
  80186. * Encode a buffer to a base64 string
  80187. * @param buffer defines the buffer to encode
  80188. * @returns the encoded string
  80189. */
  80190. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80191. /**
  80192. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80193. * @param num the number to convert and pad
  80194. * @param length the expected length of the string
  80195. * @returns the padded string
  80196. */
  80197. static PadNumber(num: number, length: number): string;
  80198. }
  80199. }
  80200. declare module BABYLON {
  80201. /**
  80202. * Class containing a set of static utilities functions for deep copy.
  80203. */
  80204. export class DeepCopier {
  80205. /**
  80206. * Tries to copy an object by duplicating every property
  80207. * @param source defines the source object
  80208. * @param destination defines the target object
  80209. * @param doNotCopyList defines a list of properties to avoid
  80210. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80211. */
  80212. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80213. }
  80214. }
  80215. declare module BABYLON {
  80216. /**
  80217. * Class containing a set of static utilities functions for precision date
  80218. */
  80219. export class PrecisionDate {
  80220. /**
  80221. * Gets either window.performance.now() if supported or Date.now() else
  80222. */
  80223. static get Now(): number;
  80224. }
  80225. }
  80226. declare module BABYLON {
  80227. /** @hidden */
  80228. export class _DevTools {
  80229. static WarnImport(name: string): string;
  80230. }
  80231. }
  80232. declare module BABYLON {
  80233. /**
  80234. * Interface used to define the mechanism to get data from the network
  80235. */
  80236. export interface IWebRequest {
  80237. /**
  80238. * Returns client's response url
  80239. */
  80240. responseURL: string;
  80241. /**
  80242. * Returns client's status
  80243. */
  80244. status: number;
  80245. /**
  80246. * Returns client's status as a text
  80247. */
  80248. statusText: string;
  80249. }
  80250. }
  80251. declare module BABYLON {
  80252. /**
  80253. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80254. */
  80255. export class WebRequest implements IWebRequest {
  80256. private _xhr;
  80257. /**
  80258. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80259. * i.e. when loading files, where the server/service expects an Authorization header
  80260. */
  80261. static CustomRequestHeaders: {
  80262. [key: string]: string;
  80263. };
  80264. /**
  80265. * Add callback functions in this array to update all the requests before they get sent to the network
  80266. */
  80267. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80268. private _injectCustomRequestHeaders;
  80269. /**
  80270. * Gets or sets a function to be called when loading progress changes
  80271. */
  80272. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80273. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80274. /**
  80275. * Returns client's state
  80276. */
  80277. get readyState(): number;
  80278. /**
  80279. * Returns client's status
  80280. */
  80281. get status(): number;
  80282. /**
  80283. * Returns client's status as a text
  80284. */
  80285. get statusText(): string;
  80286. /**
  80287. * Returns client's response
  80288. */
  80289. get response(): any;
  80290. /**
  80291. * Returns client's response url
  80292. */
  80293. get responseURL(): string;
  80294. /**
  80295. * Returns client's response as text
  80296. */
  80297. get responseText(): string;
  80298. /**
  80299. * Gets or sets the expected response type
  80300. */
  80301. get responseType(): XMLHttpRequestResponseType;
  80302. set responseType(value: XMLHttpRequestResponseType);
  80303. /** @hidden */
  80304. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80305. /** @hidden */
  80306. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80307. /**
  80308. * Cancels any network activity
  80309. */
  80310. abort(): void;
  80311. /**
  80312. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80313. * @param body defines an optional request body
  80314. */
  80315. send(body?: Document | BodyInit | null): void;
  80316. /**
  80317. * Sets the request method, request URL
  80318. * @param method defines the method to use (GET, POST, etc..)
  80319. * @param url defines the url to connect with
  80320. */
  80321. open(method: string, url: string): void;
  80322. /**
  80323. * Sets the value of a request header.
  80324. * @param name The name of the header whose value is to be set
  80325. * @param value The value to set as the body of the header
  80326. */
  80327. setRequestHeader(name: string, value: string): void;
  80328. /**
  80329. * Get the string containing the text of a particular header's value.
  80330. * @param name The name of the header
  80331. * @returns The string containing the text of the given header name
  80332. */
  80333. getResponseHeader(name: string): Nullable<string>;
  80334. }
  80335. }
  80336. declare module BABYLON {
  80337. /**
  80338. * File request interface
  80339. */
  80340. export interface IFileRequest {
  80341. /**
  80342. * Raised when the request is complete (success or error).
  80343. */
  80344. onCompleteObservable: Observable<IFileRequest>;
  80345. /**
  80346. * Aborts the request for a file.
  80347. */
  80348. abort: () => void;
  80349. }
  80350. }
  80351. declare module BABYLON {
  80352. /**
  80353. * Define options used to create a render target texture
  80354. */
  80355. export class RenderTargetCreationOptions {
  80356. /**
  80357. * Specifies is mipmaps must be generated
  80358. */
  80359. generateMipMaps?: boolean;
  80360. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80361. generateDepthBuffer?: boolean;
  80362. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80363. generateStencilBuffer?: boolean;
  80364. /** Defines texture type (int by default) */
  80365. type?: number;
  80366. /** Defines sampling mode (trilinear by default) */
  80367. samplingMode?: number;
  80368. /** Defines format (RGBA by default) */
  80369. format?: number;
  80370. }
  80371. }
  80372. declare module BABYLON {
  80373. /** Defines the cross module used constants to avoid circular dependncies */
  80374. export class Constants {
  80375. /** Defines that alpha blending is disabled */
  80376. static readonly ALPHA_DISABLE: number;
  80377. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80378. static readonly ALPHA_ADD: number;
  80379. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80380. static readonly ALPHA_COMBINE: number;
  80381. /** Defines that alpha blending is DEST - SRC * DEST */
  80382. static readonly ALPHA_SUBTRACT: number;
  80383. /** Defines that alpha blending is SRC * DEST */
  80384. static readonly ALPHA_MULTIPLY: number;
  80385. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80386. static readonly ALPHA_MAXIMIZED: number;
  80387. /** Defines that alpha blending is SRC + DEST */
  80388. static readonly ALPHA_ONEONE: number;
  80389. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80390. static readonly ALPHA_PREMULTIPLIED: number;
  80391. /**
  80392. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80393. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80394. */
  80395. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80396. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80397. static readonly ALPHA_INTERPOLATE: number;
  80398. /**
  80399. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80400. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80401. */
  80402. static readonly ALPHA_SCREENMODE: number;
  80403. /**
  80404. * Defines that alpha blending is SRC + DST
  80405. * Alpha will be set to SRC ALPHA + DST ALPHA
  80406. */
  80407. static readonly ALPHA_ONEONE_ONEONE: number;
  80408. /**
  80409. * Defines that alpha blending is SRC * DST ALPHA + DST
  80410. * Alpha will be set to 0
  80411. */
  80412. static readonly ALPHA_ALPHATOCOLOR: number;
  80413. /**
  80414. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80415. */
  80416. static readonly ALPHA_REVERSEONEMINUS: number;
  80417. /**
  80418. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80419. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80420. */
  80421. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80422. /**
  80423. * Defines that alpha blending is SRC + DST
  80424. * Alpha will be set to SRC ALPHA
  80425. */
  80426. static readonly ALPHA_ONEONE_ONEZERO: number;
  80427. /**
  80428. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80429. * Alpha will be set to DST ALPHA
  80430. */
  80431. static readonly ALPHA_EXCLUSION: number;
  80432. /** Defines that alpha blending equation a SUM */
  80433. static readonly ALPHA_EQUATION_ADD: number;
  80434. /** Defines that alpha blending equation a SUBSTRACTION */
  80435. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80436. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80437. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80438. /** Defines that alpha blending equation a MAX operation */
  80439. static readonly ALPHA_EQUATION_MAX: number;
  80440. /** Defines that alpha blending equation a MIN operation */
  80441. static readonly ALPHA_EQUATION_MIN: number;
  80442. /**
  80443. * Defines that alpha blending equation a DARKEN operation:
  80444. * It takes the min of the src and sums the alpha channels.
  80445. */
  80446. static readonly ALPHA_EQUATION_DARKEN: number;
  80447. /** Defines that the ressource is not delayed*/
  80448. static readonly DELAYLOADSTATE_NONE: number;
  80449. /** Defines that the ressource was successfully delay loaded */
  80450. static readonly DELAYLOADSTATE_LOADED: number;
  80451. /** Defines that the ressource is currently delay loading */
  80452. static readonly DELAYLOADSTATE_LOADING: number;
  80453. /** Defines that the ressource is delayed and has not started loading */
  80454. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80455. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80456. static readonly NEVER: number;
  80457. /** 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 */
  80458. static readonly ALWAYS: number;
  80459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80460. static readonly LESS: number;
  80461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80462. static readonly EQUAL: number;
  80463. /** 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 */
  80464. static readonly LEQUAL: number;
  80465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80466. static readonly GREATER: number;
  80467. /** 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 */
  80468. static readonly GEQUAL: number;
  80469. /** 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 */
  80470. static readonly NOTEQUAL: number;
  80471. /** Passed to stencilOperation to specify that stencil value must be kept */
  80472. static readonly KEEP: number;
  80473. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80474. static readonly REPLACE: number;
  80475. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80476. static readonly INCR: number;
  80477. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80478. static readonly DECR: number;
  80479. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80480. static readonly INVERT: number;
  80481. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80482. static readonly INCR_WRAP: number;
  80483. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80484. static readonly DECR_WRAP: number;
  80485. /** Texture is not repeating outside of 0..1 UVs */
  80486. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80487. /** Texture is repeating outside of 0..1 UVs */
  80488. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80489. /** Texture is repeating and mirrored */
  80490. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80491. /** ALPHA */
  80492. static readonly TEXTUREFORMAT_ALPHA: number;
  80493. /** LUMINANCE */
  80494. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80495. /** LUMINANCE_ALPHA */
  80496. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80497. /** RGB */
  80498. static readonly TEXTUREFORMAT_RGB: number;
  80499. /** RGBA */
  80500. static readonly TEXTUREFORMAT_RGBA: number;
  80501. /** RED */
  80502. static readonly TEXTUREFORMAT_RED: number;
  80503. /** RED (2nd reference) */
  80504. static readonly TEXTUREFORMAT_R: number;
  80505. /** RG */
  80506. static readonly TEXTUREFORMAT_RG: number;
  80507. /** RED_INTEGER */
  80508. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80509. /** RED_INTEGER (2nd reference) */
  80510. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80511. /** RG_INTEGER */
  80512. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80513. /** RGB_INTEGER */
  80514. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80515. /** RGBA_INTEGER */
  80516. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80517. /** UNSIGNED_BYTE */
  80518. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80519. /** UNSIGNED_BYTE (2nd reference) */
  80520. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80521. /** FLOAT */
  80522. static readonly TEXTURETYPE_FLOAT: number;
  80523. /** HALF_FLOAT */
  80524. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80525. /** BYTE */
  80526. static readonly TEXTURETYPE_BYTE: number;
  80527. /** SHORT */
  80528. static readonly TEXTURETYPE_SHORT: number;
  80529. /** UNSIGNED_SHORT */
  80530. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80531. /** INT */
  80532. static readonly TEXTURETYPE_INT: number;
  80533. /** UNSIGNED_INT */
  80534. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80535. /** UNSIGNED_SHORT_4_4_4_4 */
  80536. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80537. /** UNSIGNED_SHORT_5_5_5_1 */
  80538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80539. /** UNSIGNED_SHORT_5_6_5 */
  80540. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80541. /** UNSIGNED_INT_2_10_10_10_REV */
  80542. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80543. /** UNSIGNED_INT_24_8 */
  80544. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80545. /** UNSIGNED_INT_10F_11F_11F_REV */
  80546. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80547. /** UNSIGNED_INT_5_9_9_9_REV */
  80548. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80549. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80550. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80551. /** nearest is mag = nearest and min = nearest and no mip */
  80552. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80553. /** mag = nearest and min = nearest and mip = none */
  80554. static readonly TEXTURE_NEAREST_NEAREST: number;
  80555. /** Bilinear is mag = linear and min = linear and no mip */
  80556. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80557. /** mag = linear and min = linear and mip = none */
  80558. static readonly TEXTURE_LINEAR_LINEAR: number;
  80559. /** Trilinear is mag = linear and min = linear and mip = linear */
  80560. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80561. /** Trilinear is mag = linear and min = linear and mip = linear */
  80562. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80563. /** mag = nearest and min = nearest and mip = nearest */
  80564. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80565. /** mag = nearest and min = linear and mip = nearest */
  80566. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80567. /** mag = nearest and min = linear and mip = linear */
  80568. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80569. /** mag = nearest and min = linear and mip = none */
  80570. static readonly TEXTURE_NEAREST_LINEAR: number;
  80571. /** nearest is mag = nearest and min = nearest and mip = linear */
  80572. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80573. /** mag = linear and min = nearest and mip = nearest */
  80574. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80575. /** mag = linear and min = nearest and mip = linear */
  80576. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80577. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80578. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80579. /** mag = linear and min = nearest and mip = none */
  80580. static readonly TEXTURE_LINEAR_NEAREST: number;
  80581. /** Explicit coordinates mode */
  80582. static readonly TEXTURE_EXPLICIT_MODE: number;
  80583. /** Spherical coordinates mode */
  80584. static readonly TEXTURE_SPHERICAL_MODE: number;
  80585. /** Planar coordinates mode */
  80586. static readonly TEXTURE_PLANAR_MODE: number;
  80587. /** Cubic coordinates mode */
  80588. static readonly TEXTURE_CUBIC_MODE: number;
  80589. /** Projection coordinates mode */
  80590. static readonly TEXTURE_PROJECTION_MODE: number;
  80591. /** Skybox coordinates mode */
  80592. static readonly TEXTURE_SKYBOX_MODE: number;
  80593. /** Inverse Cubic coordinates mode */
  80594. static readonly TEXTURE_INVCUBIC_MODE: number;
  80595. /** Equirectangular coordinates mode */
  80596. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80597. /** Equirectangular Fixed coordinates mode */
  80598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80599. /** Equirectangular Fixed Mirrored coordinates mode */
  80600. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80601. /** Offline (baking) quality for texture filtering */
  80602. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80603. /** High quality for texture filtering */
  80604. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80605. /** Medium quality for texture filtering */
  80606. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80607. /** Low quality for texture filtering */
  80608. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80609. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80610. static readonly SCALEMODE_FLOOR: number;
  80611. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80612. static readonly SCALEMODE_NEAREST: number;
  80613. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80614. static readonly SCALEMODE_CEILING: number;
  80615. /**
  80616. * The dirty texture flag value
  80617. */
  80618. static readonly MATERIAL_TextureDirtyFlag: number;
  80619. /**
  80620. * The dirty light flag value
  80621. */
  80622. static readonly MATERIAL_LightDirtyFlag: number;
  80623. /**
  80624. * The dirty fresnel flag value
  80625. */
  80626. static readonly MATERIAL_FresnelDirtyFlag: number;
  80627. /**
  80628. * The dirty attribute flag value
  80629. */
  80630. static readonly MATERIAL_AttributesDirtyFlag: number;
  80631. /**
  80632. * The dirty misc flag value
  80633. */
  80634. static readonly MATERIAL_MiscDirtyFlag: number;
  80635. /**
  80636. * The all dirty flag value
  80637. */
  80638. static readonly MATERIAL_AllDirtyFlag: number;
  80639. /**
  80640. * Returns the triangle fill mode
  80641. */
  80642. static readonly MATERIAL_TriangleFillMode: number;
  80643. /**
  80644. * Returns the wireframe mode
  80645. */
  80646. static readonly MATERIAL_WireFrameFillMode: number;
  80647. /**
  80648. * Returns the point fill mode
  80649. */
  80650. static readonly MATERIAL_PointFillMode: number;
  80651. /**
  80652. * Returns the point list draw mode
  80653. */
  80654. static readonly MATERIAL_PointListDrawMode: number;
  80655. /**
  80656. * Returns the line list draw mode
  80657. */
  80658. static readonly MATERIAL_LineListDrawMode: number;
  80659. /**
  80660. * Returns the line loop draw mode
  80661. */
  80662. static readonly MATERIAL_LineLoopDrawMode: number;
  80663. /**
  80664. * Returns the line strip draw mode
  80665. */
  80666. static readonly MATERIAL_LineStripDrawMode: number;
  80667. /**
  80668. * Returns the triangle strip draw mode
  80669. */
  80670. static readonly MATERIAL_TriangleStripDrawMode: number;
  80671. /**
  80672. * Returns the triangle fan draw mode
  80673. */
  80674. static readonly MATERIAL_TriangleFanDrawMode: number;
  80675. /**
  80676. * Stores the clock-wise side orientation
  80677. */
  80678. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80679. /**
  80680. * Stores the counter clock-wise side orientation
  80681. */
  80682. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80683. /**
  80684. * Nothing
  80685. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80686. */
  80687. static readonly ACTION_NothingTrigger: number;
  80688. /**
  80689. * On pick
  80690. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80691. */
  80692. static readonly ACTION_OnPickTrigger: number;
  80693. /**
  80694. * On left pick
  80695. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80696. */
  80697. static readonly ACTION_OnLeftPickTrigger: number;
  80698. /**
  80699. * On right pick
  80700. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80701. */
  80702. static readonly ACTION_OnRightPickTrigger: number;
  80703. /**
  80704. * On center pick
  80705. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80706. */
  80707. static readonly ACTION_OnCenterPickTrigger: number;
  80708. /**
  80709. * On pick down
  80710. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80711. */
  80712. static readonly ACTION_OnPickDownTrigger: number;
  80713. /**
  80714. * On double pick
  80715. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80716. */
  80717. static readonly ACTION_OnDoublePickTrigger: number;
  80718. /**
  80719. * On pick up
  80720. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80721. */
  80722. static readonly ACTION_OnPickUpTrigger: number;
  80723. /**
  80724. * On pick out.
  80725. * This trigger will only be raised if you also declared a OnPickDown
  80726. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80727. */
  80728. static readonly ACTION_OnPickOutTrigger: number;
  80729. /**
  80730. * On long press
  80731. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80732. */
  80733. static readonly ACTION_OnLongPressTrigger: number;
  80734. /**
  80735. * On pointer over
  80736. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80737. */
  80738. static readonly ACTION_OnPointerOverTrigger: number;
  80739. /**
  80740. * On pointer out
  80741. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80742. */
  80743. static readonly ACTION_OnPointerOutTrigger: number;
  80744. /**
  80745. * On every frame
  80746. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80747. */
  80748. static readonly ACTION_OnEveryFrameTrigger: number;
  80749. /**
  80750. * On intersection enter
  80751. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80752. */
  80753. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80754. /**
  80755. * On intersection exit
  80756. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80757. */
  80758. static readonly ACTION_OnIntersectionExitTrigger: number;
  80759. /**
  80760. * On key down
  80761. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80762. */
  80763. static readonly ACTION_OnKeyDownTrigger: number;
  80764. /**
  80765. * On key up
  80766. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80767. */
  80768. static readonly ACTION_OnKeyUpTrigger: number;
  80769. /**
  80770. * Billboard mode will only apply to Y axis
  80771. */
  80772. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80773. /**
  80774. * Billboard mode will apply to all axes
  80775. */
  80776. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80777. /**
  80778. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80779. */
  80780. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80781. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80782. * Test order :
  80783. * Is the bounding sphere outside the frustum ?
  80784. * If not, are the bounding box vertices outside the frustum ?
  80785. * It not, then the cullable object is in the frustum.
  80786. */
  80787. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80788. /** Culling strategy : Bounding Sphere Only.
  80789. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80790. * It's also less accurate than the standard because some not visible objects can still be selected.
  80791. * Test : is the bounding sphere outside the frustum ?
  80792. * If not, then the cullable object is in the frustum.
  80793. */
  80794. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80795. /** Culling strategy : Optimistic Inclusion.
  80796. * This in an inclusion test first, then the standard exclusion test.
  80797. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80798. * 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.
  80799. * Anyway, it's as accurate as the standard strategy.
  80800. * Test :
  80801. * Is the cullable object bounding sphere center in the frustum ?
  80802. * If not, apply the default culling strategy.
  80803. */
  80804. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80805. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80806. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80807. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80808. * 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.
  80809. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80810. * Test :
  80811. * Is the cullable object bounding sphere center in the frustum ?
  80812. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80813. */
  80814. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80815. /**
  80816. * No logging while loading
  80817. */
  80818. static readonly SCENELOADER_NO_LOGGING: number;
  80819. /**
  80820. * Minimal logging while loading
  80821. */
  80822. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80823. /**
  80824. * Summary logging while loading
  80825. */
  80826. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80827. /**
  80828. * Detailled logging while loading
  80829. */
  80830. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80831. /**
  80832. * Prepass texture index for color
  80833. */
  80834. static readonly PREPASS_COLOR_INDEX: number;
  80835. /**
  80836. * Prepass texture index for irradiance
  80837. */
  80838. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80839. /**
  80840. * Prepass texture index for depth + normal
  80841. */
  80842. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80843. /**
  80844. * Prepass texture index for albedo
  80845. */
  80846. static readonly PREPASS_ALBEDO_INDEX: number;
  80847. }
  80848. }
  80849. declare module BABYLON {
  80850. /**
  80851. * This represents the required contract to create a new type of texture loader.
  80852. */
  80853. export interface IInternalTextureLoader {
  80854. /**
  80855. * Defines wether the loader supports cascade loading the different faces.
  80856. */
  80857. supportCascades: boolean;
  80858. /**
  80859. * This returns if the loader support the current file information.
  80860. * @param extension defines the file extension of the file being loaded
  80861. * @param mimeType defines the optional mime type of the file being loaded
  80862. * @returns true if the loader can load the specified file
  80863. */
  80864. canLoad(extension: string, mimeType?: string): boolean;
  80865. /**
  80866. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80867. * @param data contains the texture data
  80868. * @param texture defines the BabylonJS internal texture
  80869. * @param createPolynomials will be true if polynomials have been requested
  80870. * @param onLoad defines the callback to trigger once the texture is ready
  80871. * @param onError defines the callback to trigger in case of error
  80872. */
  80873. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80874. /**
  80875. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80876. * @param data contains the texture data
  80877. * @param texture defines the BabylonJS internal texture
  80878. * @param callback defines the method to call once ready to upload
  80879. */
  80880. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80881. }
  80882. }
  80883. declare module BABYLON {
  80884. /**
  80885. * Class used to store and describe the pipeline context associated with an effect
  80886. */
  80887. export interface IPipelineContext {
  80888. /**
  80889. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80890. */
  80891. isAsync: boolean;
  80892. /**
  80893. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80894. */
  80895. isReady: boolean;
  80896. /** @hidden */
  80897. _getVertexShaderCode(): string | null;
  80898. /** @hidden */
  80899. _getFragmentShaderCode(): string | null;
  80900. /** @hidden */
  80901. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80902. }
  80903. }
  80904. declare module BABYLON {
  80905. /**
  80906. * Class used to store gfx data (like WebGLBuffer)
  80907. */
  80908. export class DataBuffer {
  80909. /**
  80910. * Gets or sets the number of objects referencing this buffer
  80911. */
  80912. references: number;
  80913. /** Gets or sets the size of the underlying buffer */
  80914. capacity: number;
  80915. /**
  80916. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80917. */
  80918. is32Bits: boolean;
  80919. /**
  80920. * Gets the underlying buffer
  80921. */
  80922. get underlyingResource(): any;
  80923. }
  80924. }
  80925. declare module BABYLON {
  80926. /** @hidden */
  80927. export interface IShaderProcessor {
  80928. attributeProcessor?: (attribute: string) => string;
  80929. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80930. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80931. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80932. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80933. lineProcessor?: (line: string, isFragment: boolean) => string;
  80934. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80935. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80936. }
  80937. }
  80938. declare module BABYLON {
  80939. /** @hidden */
  80940. export interface ProcessingOptions {
  80941. defines: string[];
  80942. indexParameters: any;
  80943. isFragment: boolean;
  80944. shouldUseHighPrecisionShader: boolean;
  80945. supportsUniformBuffers: boolean;
  80946. shadersRepository: string;
  80947. includesShadersStore: {
  80948. [key: string]: string;
  80949. };
  80950. processor?: IShaderProcessor;
  80951. version: string;
  80952. platformName: string;
  80953. lookForClosingBracketForUniformBuffer?: boolean;
  80954. }
  80955. }
  80956. declare module BABYLON {
  80957. /** @hidden */
  80958. export class ShaderCodeNode {
  80959. line: string;
  80960. children: ShaderCodeNode[];
  80961. additionalDefineKey?: string;
  80962. additionalDefineValue?: string;
  80963. isValid(preprocessors: {
  80964. [key: string]: string;
  80965. }): boolean;
  80966. process(preprocessors: {
  80967. [key: string]: string;
  80968. }, options: ProcessingOptions): string;
  80969. }
  80970. }
  80971. declare module BABYLON {
  80972. /** @hidden */
  80973. export class ShaderCodeCursor {
  80974. private _lines;
  80975. lineIndex: number;
  80976. get currentLine(): string;
  80977. get canRead(): boolean;
  80978. set lines(value: string[]);
  80979. }
  80980. }
  80981. declare module BABYLON {
  80982. /** @hidden */
  80983. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80984. process(preprocessors: {
  80985. [key: string]: string;
  80986. }, options: ProcessingOptions): string;
  80987. }
  80988. }
  80989. declare module BABYLON {
  80990. /** @hidden */
  80991. export class ShaderDefineExpression {
  80992. isTrue(preprocessors: {
  80993. [key: string]: string;
  80994. }): boolean;
  80995. private static _OperatorPriority;
  80996. private static _Stack;
  80997. static postfixToInfix(postfix: string[]): string;
  80998. static infixToPostfix(infix: string): string[];
  80999. }
  81000. }
  81001. declare module BABYLON {
  81002. /** @hidden */
  81003. export class ShaderCodeTestNode extends ShaderCodeNode {
  81004. testExpression: ShaderDefineExpression;
  81005. isValid(preprocessors: {
  81006. [key: string]: string;
  81007. }): boolean;
  81008. }
  81009. }
  81010. declare module BABYLON {
  81011. /** @hidden */
  81012. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81013. define: string;
  81014. not: boolean;
  81015. constructor(define: string, not?: boolean);
  81016. isTrue(preprocessors: {
  81017. [key: string]: string;
  81018. }): boolean;
  81019. }
  81020. }
  81021. declare module BABYLON {
  81022. /** @hidden */
  81023. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81024. leftOperand: ShaderDefineExpression;
  81025. rightOperand: ShaderDefineExpression;
  81026. isTrue(preprocessors: {
  81027. [key: string]: string;
  81028. }): boolean;
  81029. }
  81030. }
  81031. declare module BABYLON {
  81032. /** @hidden */
  81033. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81034. leftOperand: ShaderDefineExpression;
  81035. rightOperand: ShaderDefineExpression;
  81036. isTrue(preprocessors: {
  81037. [key: string]: string;
  81038. }): boolean;
  81039. }
  81040. }
  81041. declare module BABYLON {
  81042. /** @hidden */
  81043. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81044. define: string;
  81045. operand: string;
  81046. testValue: string;
  81047. constructor(define: string, operand: string, testValue: string);
  81048. isTrue(preprocessors: {
  81049. [key: string]: string;
  81050. }): boolean;
  81051. }
  81052. }
  81053. declare module BABYLON {
  81054. /**
  81055. * Class used to enable access to offline support
  81056. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81057. */
  81058. export interface IOfflineProvider {
  81059. /**
  81060. * Gets a boolean indicating if scene must be saved in the database
  81061. */
  81062. enableSceneOffline: boolean;
  81063. /**
  81064. * Gets a boolean indicating if textures must be saved in the database
  81065. */
  81066. enableTexturesOffline: boolean;
  81067. /**
  81068. * Open the offline support and make it available
  81069. * @param successCallback defines the callback to call on success
  81070. * @param errorCallback defines the callback to call on error
  81071. */
  81072. open(successCallback: () => void, errorCallback: () => void): void;
  81073. /**
  81074. * Loads an image from the offline support
  81075. * @param url defines the url to load from
  81076. * @param image defines the target DOM image
  81077. */
  81078. loadImage(url: string, image: HTMLImageElement): void;
  81079. /**
  81080. * Loads a file from offline support
  81081. * @param url defines the URL to load from
  81082. * @param sceneLoaded defines a callback to call on success
  81083. * @param progressCallBack defines a callback to call when progress changed
  81084. * @param errorCallback defines a callback to call on error
  81085. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81086. */
  81087. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /**
  81092. * Class used to help managing file picking and drag'n'drop
  81093. * File Storage
  81094. */
  81095. export class FilesInputStore {
  81096. /**
  81097. * List of files ready to be loaded
  81098. */
  81099. static FilesToLoad: {
  81100. [key: string]: File;
  81101. };
  81102. }
  81103. }
  81104. declare module BABYLON {
  81105. /**
  81106. * Class used to define a retry strategy when error happens while loading assets
  81107. */
  81108. export class RetryStrategy {
  81109. /**
  81110. * Function used to defines an exponential back off strategy
  81111. * @param maxRetries defines the maximum number of retries (3 by default)
  81112. * @param baseInterval defines the interval between retries
  81113. * @returns the strategy function to use
  81114. */
  81115. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81116. }
  81117. }
  81118. declare module BABYLON {
  81119. /**
  81120. * @ignore
  81121. * Application error to support additional information when loading a file
  81122. */
  81123. export abstract class BaseError extends Error {
  81124. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81125. }
  81126. }
  81127. declare module BABYLON {
  81128. /** @ignore */
  81129. export class LoadFileError extends BaseError {
  81130. request?: WebRequest;
  81131. file?: File;
  81132. /**
  81133. * Creates a new LoadFileError
  81134. * @param message defines the message of the error
  81135. * @param request defines the optional web request
  81136. * @param file defines the optional file
  81137. */
  81138. constructor(message: string, object?: WebRequest | File);
  81139. }
  81140. /** @ignore */
  81141. export class RequestFileError extends BaseError {
  81142. request: WebRequest;
  81143. /**
  81144. * Creates a new LoadFileError
  81145. * @param message defines the message of the error
  81146. * @param request defines the optional web request
  81147. */
  81148. constructor(message: string, request: WebRequest);
  81149. }
  81150. /** @ignore */
  81151. export class ReadFileError extends BaseError {
  81152. file: File;
  81153. /**
  81154. * Creates a new ReadFileError
  81155. * @param message defines the message of the error
  81156. * @param file defines the optional file
  81157. */
  81158. constructor(message: string, file: File);
  81159. }
  81160. /**
  81161. * @hidden
  81162. */
  81163. export class FileTools {
  81164. /**
  81165. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81166. */
  81167. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81168. /**
  81169. * Gets or sets the base URL to use to load assets
  81170. */
  81171. static BaseUrl: string;
  81172. /**
  81173. * Default behaviour for cors in the application.
  81174. * It can be a string if the expected behavior is identical in the entire app.
  81175. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81176. */
  81177. static CorsBehavior: string | ((url: string | string[]) => string);
  81178. /**
  81179. * Gets or sets a function used to pre-process url before using them to load assets
  81180. */
  81181. static PreprocessUrl: (url: string) => string;
  81182. /**
  81183. * Removes unwanted characters from an url
  81184. * @param url defines the url to clean
  81185. * @returns the cleaned url
  81186. */
  81187. private static _CleanUrl;
  81188. /**
  81189. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81190. * @param url define the url we are trying
  81191. * @param element define the dom element where to configure the cors policy
  81192. */
  81193. static SetCorsBehavior(url: string | string[], element: {
  81194. crossOrigin: string | null;
  81195. }): void;
  81196. /**
  81197. * Loads an image as an HTMLImageElement.
  81198. * @param input url string, ArrayBuffer, or Blob to load
  81199. * @param onLoad callback called when the image successfully loads
  81200. * @param onError callback called when the image fails to load
  81201. * @param offlineProvider offline provider for caching
  81202. * @param mimeType optional mime type
  81203. * @returns the HTMLImageElement of the loaded image
  81204. */
  81205. 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>;
  81206. /**
  81207. * Reads a file from a File object
  81208. * @param file defines the file to load
  81209. * @param onSuccess defines the callback to call when data is loaded
  81210. * @param onProgress defines the callback to call during loading process
  81211. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81212. * @param onError defines the callback to call when an error occurs
  81213. * @returns a file request object
  81214. */
  81215. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81216. /**
  81217. * Loads a file from a url
  81218. * @param url url to load
  81219. * @param onSuccess callback called when the file successfully loads
  81220. * @param onProgress callback called while file is loading (if the server supports this mode)
  81221. * @param offlineProvider defines the offline provider for caching
  81222. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81223. * @param onError callback called when the file fails to load
  81224. * @returns a file request object
  81225. */
  81226. 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;
  81227. /**
  81228. * Loads a file
  81229. * @param url url to load
  81230. * @param onSuccess callback called when the file successfully loads
  81231. * @param onProgress callback called while file is loading (if the server supports this mode)
  81232. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81233. * @param onError callback called when the file fails to load
  81234. * @param onOpened callback called when the web request is opened
  81235. * @returns a file request object
  81236. */
  81237. 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;
  81238. /**
  81239. * Checks if the loaded document was accessed via `file:`-Protocol.
  81240. * @returns boolean
  81241. */
  81242. static IsFileURL(): boolean;
  81243. }
  81244. }
  81245. declare module BABYLON {
  81246. /** @hidden */
  81247. export class ShaderProcessor {
  81248. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81249. private static _ProcessPrecision;
  81250. private static _ExtractOperation;
  81251. private static _BuildSubExpression;
  81252. private static _BuildExpression;
  81253. private static _MoveCursorWithinIf;
  81254. private static _MoveCursor;
  81255. private static _EvaluatePreProcessors;
  81256. private static _PreparePreProcessors;
  81257. private static _ProcessShaderConversion;
  81258. private static _ProcessIncludes;
  81259. /**
  81260. * Loads a file from a url
  81261. * @param url url to load
  81262. * @param onSuccess callback called when the file successfully loads
  81263. * @param onProgress callback called while file is loading (if the server supports this mode)
  81264. * @param offlineProvider defines the offline provider for caching
  81265. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81266. * @param onError callback called when the file fails to load
  81267. * @returns a file request object
  81268. * @hidden
  81269. */
  81270. 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;
  81271. }
  81272. }
  81273. declare module BABYLON {
  81274. /**
  81275. * @hidden
  81276. */
  81277. export interface IColor4Like {
  81278. r: float;
  81279. g: float;
  81280. b: float;
  81281. a: float;
  81282. }
  81283. /**
  81284. * @hidden
  81285. */
  81286. export interface IColor3Like {
  81287. r: float;
  81288. g: float;
  81289. b: float;
  81290. }
  81291. /**
  81292. * @hidden
  81293. */
  81294. export interface IVector4Like {
  81295. x: float;
  81296. y: float;
  81297. z: float;
  81298. w: float;
  81299. }
  81300. /**
  81301. * @hidden
  81302. */
  81303. export interface IVector3Like {
  81304. x: float;
  81305. y: float;
  81306. z: float;
  81307. }
  81308. /**
  81309. * @hidden
  81310. */
  81311. export interface IVector2Like {
  81312. x: float;
  81313. y: float;
  81314. }
  81315. /**
  81316. * @hidden
  81317. */
  81318. export interface IMatrixLike {
  81319. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81320. updateFlag: int;
  81321. }
  81322. /**
  81323. * @hidden
  81324. */
  81325. export interface IViewportLike {
  81326. x: float;
  81327. y: float;
  81328. width: float;
  81329. height: float;
  81330. }
  81331. /**
  81332. * @hidden
  81333. */
  81334. export interface IPlaneLike {
  81335. normal: IVector3Like;
  81336. d: float;
  81337. normalize(): void;
  81338. }
  81339. }
  81340. declare module BABYLON {
  81341. /**
  81342. * Interface used to define common properties for effect fallbacks
  81343. */
  81344. export interface IEffectFallbacks {
  81345. /**
  81346. * Removes the defines that should be removed when falling back.
  81347. * @param currentDefines defines the current define statements for the shader.
  81348. * @param effect defines the current effect we try to compile
  81349. * @returns The resulting defines with defines of the current rank removed.
  81350. */
  81351. reduce(currentDefines: string, effect: Effect): string;
  81352. /**
  81353. * Removes the fallback from the bound mesh.
  81354. */
  81355. unBindMesh(): void;
  81356. /**
  81357. * Checks to see if more fallbacks are still availible.
  81358. */
  81359. hasMoreFallbacks: boolean;
  81360. }
  81361. }
  81362. declare module BABYLON {
  81363. /**
  81364. * Class used to evalaute queries containing `and` and `or` operators
  81365. */
  81366. export class AndOrNotEvaluator {
  81367. /**
  81368. * Evaluate a query
  81369. * @param query defines the query to evaluate
  81370. * @param evaluateCallback defines the callback used to filter result
  81371. * @returns true if the query matches
  81372. */
  81373. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81374. private static _HandleParenthesisContent;
  81375. private static _SimplifyNegation;
  81376. }
  81377. }
  81378. declare module BABYLON {
  81379. /**
  81380. * Class used to store custom tags
  81381. */
  81382. export class Tags {
  81383. /**
  81384. * Adds support for tags on the given object
  81385. * @param obj defines the object to use
  81386. */
  81387. static EnableFor(obj: any): void;
  81388. /**
  81389. * Removes tags support
  81390. * @param obj defines the object to use
  81391. */
  81392. static DisableFor(obj: any): void;
  81393. /**
  81394. * Gets a boolean indicating if the given object has tags
  81395. * @param obj defines the object to use
  81396. * @returns a boolean
  81397. */
  81398. static HasTags(obj: any): boolean;
  81399. /**
  81400. * Gets the tags available on a given object
  81401. * @param obj defines the object to use
  81402. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81403. * @returns the tags
  81404. */
  81405. static GetTags(obj: any, asString?: boolean): any;
  81406. /**
  81407. * Adds tags to an object
  81408. * @param obj defines the object to use
  81409. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81410. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81411. */
  81412. static AddTagsTo(obj: any, tagsString: string): void;
  81413. /**
  81414. * @hidden
  81415. */
  81416. static _AddTagTo(obj: any, tag: string): void;
  81417. /**
  81418. * Removes specific tags from a specific object
  81419. * @param obj defines the object to use
  81420. * @param tagsString defines the tags to remove
  81421. */
  81422. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81423. /**
  81424. * @hidden
  81425. */
  81426. static _RemoveTagFrom(obj: any, tag: string): void;
  81427. /**
  81428. * Defines if tags hosted on an object match a given query
  81429. * @param obj defines the object to use
  81430. * @param tagsQuery defines the tag query
  81431. * @returns a boolean
  81432. */
  81433. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81434. }
  81435. }
  81436. declare module BABYLON {
  81437. /**
  81438. * Scalar computation library
  81439. */
  81440. export class Scalar {
  81441. /**
  81442. * Two pi constants convenient for computation.
  81443. */
  81444. static TwoPi: number;
  81445. /**
  81446. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81447. * @param a number
  81448. * @param b number
  81449. * @param epsilon (default = 1.401298E-45)
  81450. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81451. */
  81452. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81453. /**
  81454. * Returns a string : the upper case translation of the number i to hexadecimal.
  81455. * @param i number
  81456. * @returns the upper case translation of the number i to hexadecimal.
  81457. */
  81458. static ToHex(i: number): string;
  81459. /**
  81460. * Returns -1 if value is negative and +1 is value is positive.
  81461. * @param value the value
  81462. * @returns the value itself if it's equal to zero.
  81463. */
  81464. static Sign(value: number): number;
  81465. /**
  81466. * Returns the value itself if it's between min and max.
  81467. * Returns min if the value is lower than min.
  81468. * Returns max if the value is greater than max.
  81469. * @param value the value to clmap
  81470. * @param min the min value to clamp to (default: 0)
  81471. * @param max the max value to clamp to (default: 1)
  81472. * @returns the clamped value
  81473. */
  81474. static Clamp(value: number, min?: number, max?: number): number;
  81475. /**
  81476. * the log2 of value.
  81477. * @param value the value to compute log2 of
  81478. * @returns the log2 of value.
  81479. */
  81480. static Log2(value: number): number;
  81481. /**
  81482. * Loops the value, so that it is never larger than length and never smaller than 0.
  81483. *
  81484. * This is similar to the modulo operator but it works with floating point numbers.
  81485. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81486. * With t = 5 and length = 2.5, the result would be 0.0.
  81487. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81488. * @param value the value
  81489. * @param length the length
  81490. * @returns the looped value
  81491. */
  81492. static Repeat(value: number, length: number): number;
  81493. /**
  81494. * Normalize the value between 0.0 and 1.0 using min and max values
  81495. * @param value value to normalize
  81496. * @param min max to normalize between
  81497. * @param max min to normalize between
  81498. * @returns the normalized value
  81499. */
  81500. static Normalize(value: number, min: number, max: number): number;
  81501. /**
  81502. * Denormalize the value from 0.0 and 1.0 using min and max values
  81503. * @param normalized value to denormalize
  81504. * @param min max to denormalize between
  81505. * @param max min to denormalize between
  81506. * @returns the denormalized value
  81507. */
  81508. static Denormalize(normalized: number, min: number, max: number): number;
  81509. /**
  81510. * Calculates the shortest difference between two given angles given in degrees.
  81511. * @param current current angle in degrees
  81512. * @param target target angle in degrees
  81513. * @returns the delta
  81514. */
  81515. static DeltaAngle(current: number, target: number): number;
  81516. /**
  81517. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81518. * @param tx value
  81519. * @param length length
  81520. * @returns The returned value will move back and forth between 0 and length
  81521. */
  81522. static PingPong(tx: number, length: number): number;
  81523. /**
  81524. * Interpolates between min and max with smoothing at the limits.
  81525. *
  81526. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81527. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81528. * @param from from
  81529. * @param to to
  81530. * @param tx value
  81531. * @returns the smooth stepped value
  81532. */
  81533. static SmoothStep(from: number, to: number, tx: number): number;
  81534. /**
  81535. * Moves a value current towards target.
  81536. *
  81537. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81538. * Negative values of maxDelta pushes the value away from target.
  81539. * @param current current value
  81540. * @param target target value
  81541. * @param maxDelta max distance to move
  81542. * @returns resulting value
  81543. */
  81544. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81545. /**
  81546. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81547. *
  81548. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81549. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81550. * @param current current value
  81551. * @param target target value
  81552. * @param maxDelta max distance to move
  81553. * @returns resulting angle
  81554. */
  81555. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81556. /**
  81557. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81558. * @param start start value
  81559. * @param end target value
  81560. * @param amount amount to lerp between
  81561. * @returns the lerped value
  81562. */
  81563. static Lerp(start: number, end: number, amount: number): number;
  81564. /**
  81565. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81566. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81567. * @param start start value
  81568. * @param end target value
  81569. * @param amount amount to lerp between
  81570. * @returns the lerped value
  81571. */
  81572. static LerpAngle(start: number, end: number, amount: number): number;
  81573. /**
  81574. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81575. * @param a start value
  81576. * @param b target value
  81577. * @param value value between a and b
  81578. * @returns the inverseLerp value
  81579. */
  81580. static InverseLerp(a: number, b: number, value: number): number;
  81581. /**
  81582. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81583. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81584. * @param value1 spline value
  81585. * @param tangent1 spline value
  81586. * @param value2 spline value
  81587. * @param tangent2 spline value
  81588. * @param amount input value
  81589. * @returns hermite result
  81590. */
  81591. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81592. /**
  81593. * Returns a random float number between and min and max values
  81594. * @param min min value of random
  81595. * @param max max value of random
  81596. * @returns random value
  81597. */
  81598. static RandomRange(min: number, max: number): number;
  81599. /**
  81600. * This function returns percentage of a number in a given range.
  81601. *
  81602. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81603. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81604. * @param number to convert to percentage
  81605. * @param min min range
  81606. * @param max max range
  81607. * @returns the percentage
  81608. */
  81609. static RangeToPercent(number: number, min: number, max: number): number;
  81610. /**
  81611. * This function returns number that corresponds to the percentage in a given range.
  81612. *
  81613. * PercentToRange(0.34,0,100) will return 34.
  81614. * @param percent to convert to number
  81615. * @param min min range
  81616. * @param max max range
  81617. * @returns the number
  81618. */
  81619. static PercentToRange(percent: number, min: number, max: number): number;
  81620. /**
  81621. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81622. * @param angle The angle to normalize in radian.
  81623. * @return The converted angle.
  81624. */
  81625. static NormalizeRadians(angle: number): number;
  81626. }
  81627. }
  81628. declare module BABYLON {
  81629. /**
  81630. * Constant used to convert a value to gamma space
  81631. * @ignorenaming
  81632. */
  81633. export const ToGammaSpace: number;
  81634. /**
  81635. * Constant used to convert a value to linear space
  81636. * @ignorenaming
  81637. */
  81638. export const ToLinearSpace = 2.2;
  81639. /**
  81640. * Constant used to define the minimal number value in Babylon.js
  81641. * @ignorenaming
  81642. */
  81643. let Epsilon: number;
  81644. }
  81645. declare module BABYLON {
  81646. /**
  81647. * Class used to represent a viewport on screen
  81648. */
  81649. export class Viewport {
  81650. /** viewport left coordinate */
  81651. x: number;
  81652. /** viewport top coordinate */
  81653. y: number;
  81654. /**viewport width */
  81655. width: number;
  81656. /** viewport height */
  81657. height: number;
  81658. /**
  81659. * Creates a Viewport object located at (x, y) and sized (width, height)
  81660. * @param x defines viewport left coordinate
  81661. * @param y defines viewport top coordinate
  81662. * @param width defines the viewport width
  81663. * @param height defines the viewport height
  81664. */
  81665. constructor(
  81666. /** viewport left coordinate */
  81667. x: number,
  81668. /** viewport top coordinate */
  81669. y: number,
  81670. /**viewport width */
  81671. width: number,
  81672. /** viewport height */
  81673. height: number);
  81674. /**
  81675. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81676. * @param renderWidth defines the rendering width
  81677. * @param renderHeight defines the rendering height
  81678. * @returns a new Viewport
  81679. */
  81680. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81681. /**
  81682. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81683. * @param renderWidth defines the rendering width
  81684. * @param renderHeight defines the rendering height
  81685. * @param ref defines the target viewport
  81686. * @returns the current viewport
  81687. */
  81688. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81689. /**
  81690. * Returns a new Viewport copied from the current one
  81691. * @returns a new Viewport
  81692. */
  81693. clone(): Viewport;
  81694. }
  81695. }
  81696. declare module BABYLON {
  81697. /**
  81698. * Class containing a set of static utilities functions for arrays.
  81699. */
  81700. export class ArrayTools {
  81701. /**
  81702. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81703. * @param size the number of element to construct and put in the array
  81704. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81705. * @returns a new array filled with new objects
  81706. */
  81707. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81708. }
  81709. }
  81710. declare module BABYLON {
  81711. /**
  81712. * Represents a plane by the equation ax + by + cz + d = 0
  81713. */
  81714. export class Plane {
  81715. private static _TmpMatrix;
  81716. /**
  81717. * Normal of the plane (a,b,c)
  81718. */
  81719. normal: Vector3;
  81720. /**
  81721. * d component of the plane
  81722. */
  81723. d: number;
  81724. /**
  81725. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81726. * @param a a component of the plane
  81727. * @param b b component of the plane
  81728. * @param c c component of the plane
  81729. * @param d d component of the plane
  81730. */
  81731. constructor(a: number, b: number, c: number, d: number);
  81732. /**
  81733. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81734. */
  81735. asArray(): number[];
  81736. /**
  81737. * @returns a new plane copied from the current Plane.
  81738. */
  81739. clone(): Plane;
  81740. /**
  81741. * @returns the string "Plane".
  81742. */
  81743. getClassName(): string;
  81744. /**
  81745. * @returns the Plane hash code.
  81746. */
  81747. getHashCode(): number;
  81748. /**
  81749. * Normalize the current Plane in place.
  81750. * @returns the updated Plane.
  81751. */
  81752. normalize(): Plane;
  81753. /**
  81754. * Applies a transformation the plane and returns the result
  81755. * @param transformation the transformation matrix to be applied to the plane
  81756. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81757. */
  81758. transform(transformation: DeepImmutable<Matrix>): Plane;
  81759. /**
  81760. * Compute the dot product between the point and the plane normal
  81761. * @param point point to calculate the dot product with
  81762. * @returns the dot product (float) of the point coordinates and the plane normal.
  81763. */
  81764. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81765. /**
  81766. * Updates the current Plane from the plane defined by the three given points.
  81767. * @param point1 one of the points used to contruct the plane
  81768. * @param point2 one of the points used to contruct the plane
  81769. * @param point3 one of the points used to contruct the plane
  81770. * @returns the updated Plane.
  81771. */
  81772. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81773. /**
  81774. * Checks if the plane is facing a given direction
  81775. * @param direction the direction to check if the plane is facing
  81776. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81777. * @returns True is the vector "direction" is the same side than the plane normal.
  81778. */
  81779. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81780. /**
  81781. * Calculates the distance to a point
  81782. * @param point point to calculate distance to
  81783. * @returns the signed distance (float) from the given point to the Plane.
  81784. */
  81785. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81786. /**
  81787. * Creates a plane from an array
  81788. * @param array the array to create a plane from
  81789. * @returns a new Plane from the given array.
  81790. */
  81791. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81792. /**
  81793. * Creates a plane from three points
  81794. * @param point1 point used to create the plane
  81795. * @param point2 point used to create the plane
  81796. * @param point3 point used to create the plane
  81797. * @returns a new Plane defined by the three given points.
  81798. */
  81799. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81800. /**
  81801. * Creates a plane from an origin point and a normal
  81802. * @param origin origin of the plane to be constructed
  81803. * @param normal normal of the plane to be constructed
  81804. * @returns a new Plane the normal vector to this plane at the given origin point.
  81805. * Note : the vector "normal" is updated because normalized.
  81806. */
  81807. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81808. /**
  81809. * Calculates the distance from a plane and a point
  81810. * @param origin origin of the plane to be constructed
  81811. * @param normal normal of the plane to be constructed
  81812. * @param point point to calculate distance to
  81813. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81814. */
  81815. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81816. }
  81817. }
  81818. declare module BABYLON {
  81819. /** @hidden */
  81820. export class PerformanceConfigurator {
  81821. /** @hidden */
  81822. static MatrixUse64Bits: boolean;
  81823. /** @hidden */
  81824. static MatrixTrackPrecisionChange: boolean;
  81825. /** @hidden */
  81826. static MatrixCurrentType: any;
  81827. /** @hidden */
  81828. static MatrixTrackedMatrices: Array<any> | null;
  81829. /** @hidden */
  81830. static SetMatrixPrecision(use64bits: boolean): void;
  81831. }
  81832. }
  81833. declare module BABYLON {
  81834. /**
  81835. * Class representing a vector containing 2 coordinates
  81836. */
  81837. export class Vector2 {
  81838. /** defines the first coordinate */
  81839. x: number;
  81840. /** defines the second coordinate */
  81841. y: number;
  81842. /**
  81843. * Creates a new Vector2 from the given x and y coordinates
  81844. * @param x defines the first coordinate
  81845. * @param y defines the second coordinate
  81846. */
  81847. constructor(
  81848. /** defines the first coordinate */
  81849. x?: number,
  81850. /** defines the second coordinate */
  81851. y?: number);
  81852. /**
  81853. * Gets a string with the Vector2 coordinates
  81854. * @returns a string with the Vector2 coordinates
  81855. */
  81856. toString(): string;
  81857. /**
  81858. * Gets class name
  81859. * @returns the string "Vector2"
  81860. */
  81861. getClassName(): string;
  81862. /**
  81863. * Gets current vector hash code
  81864. * @returns the Vector2 hash code as a number
  81865. */
  81866. getHashCode(): number;
  81867. /**
  81868. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81869. * @param array defines the source array
  81870. * @param index defines the offset in source array
  81871. * @returns the current Vector2
  81872. */
  81873. toArray(array: FloatArray, index?: number): Vector2;
  81874. /**
  81875. * Update the current vector from an array
  81876. * @param array defines the destination array
  81877. * @param index defines the offset in the destination array
  81878. * @returns the current Vector3
  81879. */
  81880. fromArray(array: FloatArray, index?: number): Vector2;
  81881. /**
  81882. * Copy the current vector to an array
  81883. * @returns a new array with 2 elements: the Vector2 coordinates.
  81884. */
  81885. asArray(): number[];
  81886. /**
  81887. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81888. * @param source defines the source Vector2
  81889. * @returns the current updated Vector2
  81890. */
  81891. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81892. /**
  81893. * Sets the Vector2 coordinates with the given floats
  81894. * @param x defines the first coordinate
  81895. * @param y defines the second coordinate
  81896. * @returns the current updated Vector2
  81897. */
  81898. copyFromFloats(x: number, y: number): Vector2;
  81899. /**
  81900. * Sets the Vector2 coordinates with the given floats
  81901. * @param x defines the first coordinate
  81902. * @param y defines the second coordinate
  81903. * @returns the current updated Vector2
  81904. */
  81905. set(x: number, y: number): Vector2;
  81906. /**
  81907. * Add another vector with the current one
  81908. * @param otherVector defines the other vector
  81909. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81910. */
  81911. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81912. /**
  81913. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81914. * @param otherVector defines the other vector
  81915. * @param result defines the target vector
  81916. * @returns the unmodified current Vector2
  81917. */
  81918. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81919. /**
  81920. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81921. * @param otherVector defines the other vector
  81922. * @returns the current updated Vector2
  81923. */
  81924. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81925. /**
  81926. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81927. * @param otherVector defines the other vector
  81928. * @returns a new Vector2
  81929. */
  81930. addVector3(otherVector: Vector3): Vector2;
  81931. /**
  81932. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81933. * @param otherVector defines the other vector
  81934. * @returns a new Vector2
  81935. */
  81936. subtract(otherVector: Vector2): Vector2;
  81937. /**
  81938. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81939. * @param otherVector defines the other vector
  81940. * @param result defines the target vector
  81941. * @returns the unmodified current Vector2
  81942. */
  81943. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81944. /**
  81945. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81946. * @param otherVector defines the other vector
  81947. * @returns the current updated Vector2
  81948. */
  81949. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81950. /**
  81951. * Multiplies in place the current Vector2 coordinates by the given ones
  81952. * @param otherVector defines the other vector
  81953. * @returns the current updated Vector2
  81954. */
  81955. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81956. /**
  81957. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81958. * @param otherVector defines the other vector
  81959. * @returns a new Vector2
  81960. */
  81961. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81962. /**
  81963. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81964. * @param otherVector defines the other vector
  81965. * @param result defines the target vector
  81966. * @returns the unmodified current Vector2
  81967. */
  81968. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81969. /**
  81970. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81971. * @param x defines the first coordinate
  81972. * @param y defines the second coordinate
  81973. * @returns a new Vector2
  81974. */
  81975. multiplyByFloats(x: number, y: number): Vector2;
  81976. /**
  81977. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81978. * @param otherVector defines the other vector
  81979. * @returns a new Vector2
  81980. */
  81981. divide(otherVector: Vector2): Vector2;
  81982. /**
  81983. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81984. * @param otherVector defines the other vector
  81985. * @param result defines the target vector
  81986. * @returns the unmodified current Vector2
  81987. */
  81988. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81989. /**
  81990. * Divides the current Vector2 coordinates by the given ones
  81991. * @param otherVector defines the other vector
  81992. * @returns the current updated Vector2
  81993. */
  81994. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81995. /**
  81996. * Gets a new Vector2 with current Vector2 negated coordinates
  81997. * @returns a new Vector2
  81998. */
  81999. negate(): Vector2;
  82000. /**
  82001. * Negate this vector in place
  82002. * @returns this
  82003. */
  82004. negateInPlace(): Vector2;
  82005. /**
  82006. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82007. * @param result defines the Vector3 object where to store the result
  82008. * @returns the current Vector2
  82009. */
  82010. negateToRef(result: Vector2): Vector2;
  82011. /**
  82012. * Multiply the Vector2 coordinates by scale
  82013. * @param scale defines the scaling factor
  82014. * @returns the current updated Vector2
  82015. */
  82016. scaleInPlace(scale: number): Vector2;
  82017. /**
  82018. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82019. * @param scale defines the scaling factor
  82020. * @returns a new Vector2
  82021. */
  82022. scale(scale: number): Vector2;
  82023. /**
  82024. * Scale the current Vector2 values by a factor to a given Vector2
  82025. * @param scale defines the scale factor
  82026. * @param result defines the Vector2 object where to store the result
  82027. * @returns the unmodified current Vector2
  82028. */
  82029. scaleToRef(scale: number, result: Vector2): Vector2;
  82030. /**
  82031. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82032. * @param scale defines the scale factor
  82033. * @param result defines the Vector2 object where to store the result
  82034. * @returns the unmodified current Vector2
  82035. */
  82036. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82037. /**
  82038. * Gets a boolean if two vectors are equals
  82039. * @param otherVector defines the other vector
  82040. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82041. */
  82042. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82043. /**
  82044. * Gets a boolean if two vectors are equals (using an epsilon value)
  82045. * @param otherVector defines the other vector
  82046. * @param epsilon defines the minimal distance to consider equality
  82047. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82048. */
  82049. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82050. /**
  82051. * Gets a new Vector2 from current Vector2 floored values
  82052. * @returns a new Vector2
  82053. */
  82054. floor(): Vector2;
  82055. /**
  82056. * Gets a new Vector2 from current Vector2 floored values
  82057. * @returns a new Vector2
  82058. */
  82059. fract(): Vector2;
  82060. /**
  82061. * Gets the length of the vector
  82062. * @returns the vector length (float)
  82063. */
  82064. length(): number;
  82065. /**
  82066. * Gets the vector squared length
  82067. * @returns the vector squared length (float)
  82068. */
  82069. lengthSquared(): number;
  82070. /**
  82071. * Normalize the vector
  82072. * @returns the current updated Vector2
  82073. */
  82074. normalize(): Vector2;
  82075. /**
  82076. * Gets a new Vector2 copied from the Vector2
  82077. * @returns a new Vector2
  82078. */
  82079. clone(): Vector2;
  82080. /**
  82081. * Gets a new Vector2(0, 0)
  82082. * @returns a new Vector2
  82083. */
  82084. static Zero(): Vector2;
  82085. /**
  82086. * Gets a new Vector2(1, 1)
  82087. * @returns a new Vector2
  82088. */
  82089. static One(): Vector2;
  82090. /**
  82091. * Gets a new Vector2 set from the given index element of the given array
  82092. * @param array defines the data source
  82093. * @param offset defines the offset in the data source
  82094. * @returns a new Vector2
  82095. */
  82096. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82097. /**
  82098. * Sets "result" from the given index element of the given array
  82099. * @param array defines the data source
  82100. * @param offset defines the offset in the data source
  82101. * @param result defines the target vector
  82102. */
  82103. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82104. /**
  82105. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82106. * @param value1 defines 1st point of control
  82107. * @param value2 defines 2nd point of control
  82108. * @param value3 defines 3rd point of control
  82109. * @param value4 defines 4th point of control
  82110. * @param amount defines the interpolation factor
  82111. * @returns a new Vector2
  82112. */
  82113. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82114. /**
  82115. * 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".
  82116. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82117. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82118. * @param value defines the value to clamp
  82119. * @param min defines the lower limit
  82120. * @param max defines the upper limit
  82121. * @returns a new Vector2
  82122. */
  82123. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82124. /**
  82125. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82126. * @param value1 defines the 1st control point
  82127. * @param tangent1 defines the outgoing tangent
  82128. * @param value2 defines the 2nd control point
  82129. * @param tangent2 defines the incoming tangent
  82130. * @param amount defines the interpolation factor
  82131. * @returns a new Vector2
  82132. */
  82133. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82134. /**
  82135. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82136. * @param start defines the start vector
  82137. * @param end defines the end vector
  82138. * @param amount defines the interpolation factor
  82139. * @returns a new Vector2
  82140. */
  82141. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82142. /**
  82143. * Gets the dot product of the vector "left" and the vector "right"
  82144. * @param left defines first vector
  82145. * @param right defines second vector
  82146. * @returns the dot product (float)
  82147. */
  82148. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82149. /**
  82150. * Returns a new Vector2 equal to the normalized given vector
  82151. * @param vector defines the vector to normalize
  82152. * @returns a new Vector2
  82153. */
  82154. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82155. /**
  82156. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82157. * @param left defines 1st vector
  82158. * @param right defines 2nd vector
  82159. * @returns a new Vector2
  82160. */
  82161. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82162. /**
  82163. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82164. * @param left defines 1st vector
  82165. * @param right defines 2nd vector
  82166. * @returns a new Vector2
  82167. */
  82168. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82169. /**
  82170. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82171. * @param vector defines the vector to transform
  82172. * @param transformation defines the matrix to apply
  82173. * @returns a new Vector2
  82174. */
  82175. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82176. /**
  82177. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82178. * @param vector defines the vector to transform
  82179. * @param transformation defines the matrix to apply
  82180. * @param result defines the target vector
  82181. */
  82182. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82183. /**
  82184. * Determines if a given vector is included in a triangle
  82185. * @param p defines the vector to test
  82186. * @param p0 defines 1st triangle point
  82187. * @param p1 defines 2nd triangle point
  82188. * @param p2 defines 3rd triangle point
  82189. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82190. */
  82191. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82192. /**
  82193. * Gets the distance between the vectors "value1" and "value2"
  82194. * @param value1 defines first vector
  82195. * @param value2 defines second vector
  82196. * @returns the distance between vectors
  82197. */
  82198. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82199. /**
  82200. * Returns the squared distance between the vectors "value1" and "value2"
  82201. * @param value1 defines first vector
  82202. * @param value2 defines second vector
  82203. * @returns the squared distance between vectors
  82204. */
  82205. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82206. /**
  82207. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82208. * @param value1 defines first vector
  82209. * @param value2 defines second vector
  82210. * @returns a new Vector2
  82211. */
  82212. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82213. /**
  82214. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82215. * @param p defines the middle point
  82216. * @param segA defines one point of the segment
  82217. * @param segB defines the other point of the segment
  82218. * @returns the shortest distance
  82219. */
  82220. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82221. }
  82222. /**
  82223. * Class used to store (x,y,z) vector representation
  82224. * A Vector3 is the main object used in 3D geometry
  82225. * It can represent etiher the coordinates of a point the space, either a direction
  82226. * Reminder: js uses a left handed forward facing system
  82227. */
  82228. export class Vector3 {
  82229. private static _UpReadOnly;
  82230. private static _ZeroReadOnly;
  82231. /** @hidden */
  82232. _x: number;
  82233. /** @hidden */
  82234. _y: number;
  82235. /** @hidden */
  82236. _z: number;
  82237. /** @hidden */
  82238. _isDirty: boolean;
  82239. /** Gets or sets the x coordinate */
  82240. get x(): number;
  82241. set x(value: number);
  82242. /** Gets or sets the y coordinate */
  82243. get y(): number;
  82244. set y(value: number);
  82245. /** Gets or sets the z coordinate */
  82246. get z(): number;
  82247. set z(value: number);
  82248. /**
  82249. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82250. * @param x defines the first coordinates (on X axis)
  82251. * @param y defines the second coordinates (on Y axis)
  82252. * @param z defines the third coordinates (on Z axis)
  82253. */
  82254. constructor(x?: number, y?: number, z?: number);
  82255. /**
  82256. * Creates a string representation of the Vector3
  82257. * @returns a string with the Vector3 coordinates.
  82258. */
  82259. toString(): string;
  82260. /**
  82261. * Gets the class name
  82262. * @returns the string "Vector3"
  82263. */
  82264. getClassName(): string;
  82265. /**
  82266. * Creates the Vector3 hash code
  82267. * @returns a number which tends to be unique between Vector3 instances
  82268. */
  82269. getHashCode(): number;
  82270. /**
  82271. * Creates an array containing three elements : the coordinates of the Vector3
  82272. * @returns a new array of numbers
  82273. */
  82274. asArray(): number[];
  82275. /**
  82276. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82277. * @param array defines the destination array
  82278. * @param index defines the offset in the destination array
  82279. * @returns the current Vector3
  82280. */
  82281. toArray(array: FloatArray, index?: number): Vector3;
  82282. /**
  82283. * Update the current vector from an array
  82284. * @param array defines the destination array
  82285. * @param index defines the offset in the destination array
  82286. * @returns the current Vector3
  82287. */
  82288. fromArray(array: FloatArray, index?: number): Vector3;
  82289. /**
  82290. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82291. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82292. */
  82293. toQuaternion(): Quaternion;
  82294. /**
  82295. * Adds the given vector to the current Vector3
  82296. * @param otherVector defines the second operand
  82297. * @returns the current updated Vector3
  82298. */
  82299. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82300. /**
  82301. * Adds the given coordinates to the current Vector3
  82302. * @param x defines the x coordinate of the operand
  82303. * @param y defines the y coordinate of the operand
  82304. * @param z defines the z coordinate of the operand
  82305. * @returns the current updated Vector3
  82306. */
  82307. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82308. /**
  82309. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82310. * @param otherVector defines the second operand
  82311. * @returns the resulting Vector3
  82312. */
  82313. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82314. /**
  82315. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82316. * @param otherVector defines the second operand
  82317. * @param result defines the Vector3 object where to store the result
  82318. * @returns the current Vector3
  82319. */
  82320. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82321. /**
  82322. * Subtract the given vector from the current Vector3
  82323. * @param otherVector defines the second operand
  82324. * @returns the current updated Vector3
  82325. */
  82326. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82327. /**
  82328. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82329. * @param otherVector defines the second operand
  82330. * @returns the resulting Vector3
  82331. */
  82332. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82333. /**
  82334. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82335. * @param otherVector defines the second operand
  82336. * @param result defines the Vector3 object where to store the result
  82337. * @returns the current Vector3
  82338. */
  82339. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82340. /**
  82341. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82342. * @param x defines the x coordinate of the operand
  82343. * @param y defines the y coordinate of the operand
  82344. * @param z defines the z coordinate of the operand
  82345. * @returns the resulting Vector3
  82346. */
  82347. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82348. /**
  82349. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82350. * @param x defines the x coordinate of the operand
  82351. * @param y defines the y coordinate of the operand
  82352. * @param z defines the z coordinate of the operand
  82353. * @param result defines the Vector3 object where to store the result
  82354. * @returns the current Vector3
  82355. */
  82356. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82357. /**
  82358. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82359. * @returns a new Vector3
  82360. */
  82361. negate(): Vector3;
  82362. /**
  82363. * Negate this vector in place
  82364. * @returns this
  82365. */
  82366. negateInPlace(): Vector3;
  82367. /**
  82368. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82369. * @param result defines the Vector3 object where to store the result
  82370. * @returns the current Vector3
  82371. */
  82372. negateToRef(result: Vector3): Vector3;
  82373. /**
  82374. * Multiplies the Vector3 coordinates by the float "scale"
  82375. * @param scale defines the multiplier factor
  82376. * @returns the current updated Vector3
  82377. */
  82378. scaleInPlace(scale: number): Vector3;
  82379. /**
  82380. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82381. * @param scale defines the multiplier factor
  82382. * @returns a new Vector3
  82383. */
  82384. scale(scale: number): Vector3;
  82385. /**
  82386. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82387. * @param scale defines the multiplier factor
  82388. * @param result defines the Vector3 object where to store the result
  82389. * @returns the current Vector3
  82390. */
  82391. scaleToRef(scale: number, result: Vector3): Vector3;
  82392. /**
  82393. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82394. * @param scale defines the scale factor
  82395. * @param result defines the Vector3 object where to store the result
  82396. * @returns the unmodified current Vector3
  82397. */
  82398. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82399. /**
  82400. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82401. * @param origin defines the origin of the projection ray
  82402. * @param plane defines the plane to project to
  82403. * @returns the projected vector3
  82404. */
  82405. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82406. /**
  82407. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82408. * @param origin defines the origin of the projection ray
  82409. * @param plane defines the plane to project to
  82410. * @param result defines the Vector3 where to store the result
  82411. */
  82412. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82413. /**
  82414. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82415. * @param otherVector defines the second operand
  82416. * @returns true if both vectors are equals
  82417. */
  82418. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82419. /**
  82420. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82421. * @param otherVector defines the second operand
  82422. * @param epsilon defines the minimal distance to define values as equals
  82423. * @returns true if both vectors are distant less than epsilon
  82424. */
  82425. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82426. /**
  82427. * Returns true if the current Vector3 coordinates equals the given floats
  82428. * @param x defines the x coordinate of the operand
  82429. * @param y defines the y coordinate of the operand
  82430. * @param z defines the z coordinate of the operand
  82431. * @returns true if both vectors are equals
  82432. */
  82433. equalsToFloats(x: number, y: number, z: number): boolean;
  82434. /**
  82435. * Multiplies the current Vector3 coordinates by the given ones
  82436. * @param otherVector defines the second operand
  82437. * @returns the current updated Vector3
  82438. */
  82439. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82440. /**
  82441. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82442. * @param otherVector defines the second operand
  82443. * @returns the new Vector3
  82444. */
  82445. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82446. /**
  82447. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82448. * @param otherVector defines the second operand
  82449. * @param result defines the Vector3 object where to store the result
  82450. * @returns the current Vector3
  82451. */
  82452. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82453. /**
  82454. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82455. * @param x defines the x coordinate of the operand
  82456. * @param y defines the y coordinate of the operand
  82457. * @param z defines the z coordinate of the operand
  82458. * @returns the new Vector3
  82459. */
  82460. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82461. /**
  82462. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82463. * @param otherVector defines the second operand
  82464. * @returns the new Vector3
  82465. */
  82466. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82467. /**
  82468. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82469. * @param otherVector defines the second operand
  82470. * @param result defines the Vector3 object where to store the result
  82471. * @returns the current Vector3
  82472. */
  82473. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82474. /**
  82475. * Divides the current Vector3 coordinates by the given ones.
  82476. * @param otherVector defines the second operand
  82477. * @returns the current updated Vector3
  82478. */
  82479. divideInPlace(otherVector: Vector3): Vector3;
  82480. /**
  82481. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82482. * @param other defines the second operand
  82483. * @returns the current updated Vector3
  82484. */
  82485. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82486. /**
  82487. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82488. * @param other defines the second operand
  82489. * @returns the current updated Vector3
  82490. */
  82491. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82492. /**
  82493. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82494. * @param x defines the x coordinate of the operand
  82495. * @param y defines the y coordinate of the operand
  82496. * @param z defines the z coordinate of the operand
  82497. * @returns the current updated Vector3
  82498. */
  82499. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82500. /**
  82501. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82502. * @param x defines the x coordinate of the operand
  82503. * @param y defines the y coordinate of the operand
  82504. * @param z defines the z coordinate of the operand
  82505. * @returns the current updated Vector3
  82506. */
  82507. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82508. /**
  82509. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82510. * Check if is non uniform within a certain amount of decimal places to account for this
  82511. * @param epsilon the amount the values can differ
  82512. * @returns if the the vector is non uniform to a certain number of decimal places
  82513. */
  82514. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82515. /**
  82516. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82517. */
  82518. get isNonUniform(): boolean;
  82519. /**
  82520. * Gets a new Vector3 from current Vector3 floored values
  82521. * @returns a new Vector3
  82522. */
  82523. floor(): Vector3;
  82524. /**
  82525. * Gets a new Vector3 from current Vector3 floored values
  82526. * @returns a new Vector3
  82527. */
  82528. fract(): Vector3;
  82529. /**
  82530. * Gets the length of the Vector3
  82531. * @returns the length of the Vector3
  82532. */
  82533. length(): number;
  82534. /**
  82535. * Gets the squared length of the Vector3
  82536. * @returns squared length of the Vector3
  82537. */
  82538. lengthSquared(): number;
  82539. /**
  82540. * Normalize the current Vector3.
  82541. * Please note that this is an in place operation.
  82542. * @returns the current updated Vector3
  82543. */
  82544. normalize(): Vector3;
  82545. /**
  82546. * Reorders the x y z properties of the vector in place
  82547. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82548. * @returns the current updated vector
  82549. */
  82550. reorderInPlace(order: string): this;
  82551. /**
  82552. * Rotates the vector around 0,0,0 by a quaternion
  82553. * @param quaternion the rotation quaternion
  82554. * @param result vector to store the result
  82555. * @returns the resulting vector
  82556. */
  82557. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82558. /**
  82559. * Rotates a vector around a given point
  82560. * @param quaternion the rotation quaternion
  82561. * @param point the point to rotate around
  82562. * @param result vector to store the result
  82563. * @returns the resulting vector
  82564. */
  82565. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82566. /**
  82567. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82568. * The cross product is then orthogonal to both current and "other"
  82569. * @param other defines the right operand
  82570. * @returns the cross product
  82571. */
  82572. cross(other: Vector3): Vector3;
  82573. /**
  82574. * Normalize the current Vector3 with the given input length.
  82575. * Please note that this is an in place operation.
  82576. * @param len the length of the vector
  82577. * @returns the current updated Vector3
  82578. */
  82579. normalizeFromLength(len: number): Vector3;
  82580. /**
  82581. * Normalize the current Vector3 to a new vector
  82582. * @returns the new Vector3
  82583. */
  82584. normalizeToNew(): Vector3;
  82585. /**
  82586. * Normalize the current Vector3 to the reference
  82587. * @param reference define the Vector3 to update
  82588. * @returns the updated Vector3
  82589. */
  82590. normalizeToRef(reference: Vector3): Vector3;
  82591. /**
  82592. * Creates a new Vector3 copied from the current Vector3
  82593. * @returns the new Vector3
  82594. */
  82595. clone(): Vector3;
  82596. /**
  82597. * Copies the given vector coordinates to the current Vector3 ones
  82598. * @param source defines the source Vector3
  82599. * @returns the current updated Vector3
  82600. */
  82601. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82602. /**
  82603. * Copies the given floats to the current Vector3 coordinates
  82604. * @param x defines the x coordinate of the operand
  82605. * @param y defines the y coordinate of the operand
  82606. * @param z defines the z coordinate of the operand
  82607. * @returns the current updated Vector3
  82608. */
  82609. copyFromFloats(x: number, y: number, z: number): Vector3;
  82610. /**
  82611. * Copies the given floats to the current Vector3 coordinates
  82612. * @param x defines the x coordinate of the operand
  82613. * @param y defines the y coordinate of the operand
  82614. * @param z defines the z coordinate of the operand
  82615. * @returns the current updated Vector3
  82616. */
  82617. set(x: number, y: number, z: number): Vector3;
  82618. /**
  82619. * Copies the given float to the current Vector3 coordinates
  82620. * @param v defines the x, y and z coordinates of the operand
  82621. * @returns the current updated Vector3
  82622. */
  82623. setAll(v: number): Vector3;
  82624. /**
  82625. * Get the clip factor between two vectors
  82626. * @param vector0 defines the first operand
  82627. * @param vector1 defines the second operand
  82628. * @param axis defines the axis to use
  82629. * @param size defines the size along the axis
  82630. * @returns the clip factor
  82631. */
  82632. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82633. /**
  82634. * Get angle between two vectors
  82635. * @param vector0 angle between vector0 and vector1
  82636. * @param vector1 angle between vector0 and vector1
  82637. * @param normal direction of the normal
  82638. * @return the angle between vector0 and vector1
  82639. */
  82640. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82641. /**
  82642. * Returns a new Vector3 set from the index "offset" of the given array
  82643. * @param array defines the source array
  82644. * @param offset defines the offset in the source array
  82645. * @returns the new Vector3
  82646. */
  82647. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82648. /**
  82649. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82650. * @param array defines the source array
  82651. * @param offset defines the offset in the source array
  82652. * @returns the new Vector3
  82653. * @deprecated Please use FromArray instead.
  82654. */
  82655. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82656. /**
  82657. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82658. * @param array defines the source array
  82659. * @param offset defines the offset in the source array
  82660. * @param result defines the Vector3 where to store the result
  82661. */
  82662. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82663. /**
  82664. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82665. * @param array defines the source array
  82666. * @param offset defines the offset in the source array
  82667. * @param result defines the Vector3 where to store the result
  82668. * @deprecated Please use FromArrayToRef instead.
  82669. */
  82670. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82671. /**
  82672. * Sets the given vector "result" with the given floats.
  82673. * @param x defines the x coordinate of the source
  82674. * @param y defines the y coordinate of the source
  82675. * @param z defines the z coordinate of the source
  82676. * @param result defines the Vector3 where to store the result
  82677. */
  82678. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82679. /**
  82680. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82681. * @returns a new empty Vector3
  82682. */
  82683. static Zero(): Vector3;
  82684. /**
  82685. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82686. * @returns a new unit Vector3
  82687. */
  82688. static One(): Vector3;
  82689. /**
  82690. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82691. * @returns a new up Vector3
  82692. */
  82693. static Up(): Vector3;
  82694. /**
  82695. * Gets a up Vector3 that must not be updated
  82696. */
  82697. static get UpReadOnly(): DeepImmutable<Vector3>;
  82698. /**
  82699. * Gets a zero Vector3 that must not be updated
  82700. */
  82701. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82702. /**
  82703. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82704. * @returns a new down Vector3
  82705. */
  82706. static Down(): Vector3;
  82707. /**
  82708. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82709. * @param rightHandedSystem is the scene right-handed (negative z)
  82710. * @returns a new forward Vector3
  82711. */
  82712. static Forward(rightHandedSystem?: boolean): Vector3;
  82713. /**
  82714. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82715. * @param rightHandedSystem is the scene right-handed (negative-z)
  82716. * @returns a new forward Vector3
  82717. */
  82718. static Backward(rightHandedSystem?: boolean): Vector3;
  82719. /**
  82720. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82721. * @returns a new right Vector3
  82722. */
  82723. static Right(): Vector3;
  82724. /**
  82725. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82726. * @returns a new left Vector3
  82727. */
  82728. static Left(): Vector3;
  82729. /**
  82730. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82731. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82732. * @param vector defines the Vector3 to transform
  82733. * @param transformation defines the transformation matrix
  82734. * @returns the transformed Vector3
  82735. */
  82736. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82737. /**
  82738. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82739. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82740. * @param vector defines the Vector3 to transform
  82741. * @param transformation defines the transformation matrix
  82742. * @param result defines the Vector3 where to store the result
  82743. */
  82744. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82745. /**
  82746. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82747. * This method computes tranformed coordinates only, not transformed direction vectors
  82748. * @param x define the x coordinate of the source vector
  82749. * @param y define the y coordinate of the source vector
  82750. * @param z define the z coordinate of the source vector
  82751. * @param transformation defines the transformation matrix
  82752. * @param result defines the Vector3 where to store the result
  82753. */
  82754. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82755. /**
  82756. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82757. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82758. * @param vector defines the Vector3 to transform
  82759. * @param transformation defines the transformation matrix
  82760. * @returns the new Vector3
  82761. */
  82762. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82763. /**
  82764. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82765. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82766. * @param vector defines the Vector3 to transform
  82767. * @param transformation defines the transformation matrix
  82768. * @param result defines the Vector3 where to store the result
  82769. */
  82770. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82771. /**
  82772. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82773. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82774. * @param x define the x coordinate of the source vector
  82775. * @param y define the y coordinate of the source vector
  82776. * @param z define the z coordinate of the source vector
  82777. * @param transformation defines the transformation matrix
  82778. * @param result defines the Vector3 where to store the result
  82779. */
  82780. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82781. /**
  82782. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82783. * @param value1 defines the first control point
  82784. * @param value2 defines the second control point
  82785. * @param value3 defines the third control point
  82786. * @param value4 defines the fourth control point
  82787. * @param amount defines the amount on the spline to use
  82788. * @returns the new Vector3
  82789. */
  82790. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82791. /**
  82792. * 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"
  82793. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82794. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82795. * @param value defines the current value
  82796. * @param min defines the lower range value
  82797. * @param max defines the upper range value
  82798. * @returns the new Vector3
  82799. */
  82800. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82801. /**
  82802. * 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"
  82803. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82804. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82805. * @param value defines the current value
  82806. * @param min defines the lower range value
  82807. * @param max defines the upper range value
  82808. * @param result defines the Vector3 where to store the result
  82809. */
  82810. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82811. /**
  82812. * Checks if a given vector is inside a specific range
  82813. * @param v defines the vector to test
  82814. * @param min defines the minimum range
  82815. * @param max defines the maximum range
  82816. */
  82817. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82818. /**
  82819. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82820. * @param value1 defines the first control point
  82821. * @param tangent1 defines the first tangent vector
  82822. * @param value2 defines the second control point
  82823. * @param tangent2 defines the second tangent vector
  82824. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82825. * @returns the new Vector3
  82826. */
  82827. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82828. /**
  82829. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82830. * @param start defines the start value
  82831. * @param end defines the end value
  82832. * @param amount max defines amount between both (between 0 and 1)
  82833. * @returns the new Vector3
  82834. */
  82835. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82836. /**
  82837. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82838. * @param start defines the start value
  82839. * @param end defines the end value
  82840. * @param amount max defines amount between both (between 0 and 1)
  82841. * @param result defines the Vector3 where to store the result
  82842. */
  82843. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82844. /**
  82845. * Returns the dot product (float) between the vectors "left" and "right"
  82846. * @param left defines the left operand
  82847. * @param right defines the right operand
  82848. * @returns the dot product
  82849. */
  82850. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82851. /**
  82852. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82853. * The cross product is then orthogonal to both "left" and "right"
  82854. * @param left defines the left operand
  82855. * @param right defines the right operand
  82856. * @returns the cross product
  82857. */
  82858. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82859. /**
  82860. * Sets the given vector "result" with the cross product of "left" and "right"
  82861. * The cross product is then orthogonal to both "left" and "right"
  82862. * @param left defines the left operand
  82863. * @param right defines the right operand
  82864. * @param result defines the Vector3 where to store the result
  82865. */
  82866. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82867. /**
  82868. * Returns a new Vector3 as the normalization of the given vector
  82869. * @param vector defines the Vector3 to normalize
  82870. * @returns the new Vector3
  82871. */
  82872. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82873. /**
  82874. * Sets the given vector "result" with the normalization of the given first vector
  82875. * @param vector defines the Vector3 to normalize
  82876. * @param result defines the Vector3 where to store the result
  82877. */
  82878. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82879. /**
  82880. * Project a Vector3 onto screen space
  82881. * @param vector defines the Vector3 to project
  82882. * @param world defines the world matrix to use
  82883. * @param transform defines the transform (view x projection) matrix to use
  82884. * @param viewport defines the screen viewport to use
  82885. * @returns the new Vector3
  82886. */
  82887. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82888. /** @hidden */
  82889. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82890. /**
  82891. * Unproject from screen space to object space
  82892. * @param source defines the screen space Vector3 to use
  82893. * @param viewportWidth defines the current width of the viewport
  82894. * @param viewportHeight defines the current height of the viewport
  82895. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82896. * @param transform defines the transform (view x projection) matrix to use
  82897. * @returns the new Vector3
  82898. */
  82899. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82900. /**
  82901. * Unproject from screen space to object space
  82902. * @param source defines the screen space Vector3 to use
  82903. * @param viewportWidth defines the current width of the viewport
  82904. * @param viewportHeight defines the current height of the viewport
  82905. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82906. * @param view defines the view matrix to use
  82907. * @param projection defines the projection matrix to use
  82908. * @returns the new Vector3
  82909. */
  82910. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82911. /**
  82912. * Unproject from screen space to object space
  82913. * @param source defines the screen space Vector3 to use
  82914. * @param viewportWidth defines the current width of the viewport
  82915. * @param viewportHeight defines the current height of the viewport
  82916. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82917. * @param view defines the view matrix to use
  82918. * @param projection defines the projection matrix to use
  82919. * @param result defines the Vector3 where to store the result
  82920. */
  82921. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82922. /**
  82923. * Unproject from screen space to object space
  82924. * @param sourceX defines the screen space x coordinate to use
  82925. * @param sourceY defines the screen space y coordinate to use
  82926. * @param sourceZ defines the screen space z coordinate to use
  82927. * @param viewportWidth defines the current width of the viewport
  82928. * @param viewportHeight defines the current height of the viewport
  82929. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82930. * @param view defines the view matrix to use
  82931. * @param projection defines the projection matrix to use
  82932. * @param result defines the Vector3 where to store the result
  82933. */
  82934. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82935. /**
  82936. * Gets the minimal coordinate values between two Vector3
  82937. * @param left defines the first operand
  82938. * @param right defines the second operand
  82939. * @returns the new Vector3
  82940. */
  82941. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82942. /**
  82943. * Gets the maximal coordinate values between two Vector3
  82944. * @param left defines the first operand
  82945. * @param right defines the second operand
  82946. * @returns the new Vector3
  82947. */
  82948. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82949. /**
  82950. * Returns the distance between the vectors "value1" and "value2"
  82951. * @param value1 defines the first operand
  82952. * @param value2 defines the second operand
  82953. * @returns the distance
  82954. */
  82955. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82956. /**
  82957. * Returns the squared distance between the vectors "value1" and "value2"
  82958. * @param value1 defines the first operand
  82959. * @param value2 defines the second operand
  82960. * @returns the squared distance
  82961. */
  82962. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82963. /**
  82964. * Returns a new Vector3 located at the center between "value1" and "value2"
  82965. * @param value1 defines the first operand
  82966. * @param value2 defines the second operand
  82967. * @returns the new Vector3
  82968. */
  82969. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82970. /**
  82971. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82972. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82973. * to something in order to rotate it from its local system to the given target system
  82974. * Note: axis1, axis2 and axis3 are normalized during this operation
  82975. * @param axis1 defines the first axis
  82976. * @param axis2 defines the second axis
  82977. * @param axis3 defines the third axis
  82978. * @returns a new Vector3
  82979. */
  82980. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82981. /**
  82982. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82983. * @param axis1 defines the first axis
  82984. * @param axis2 defines the second axis
  82985. * @param axis3 defines the third axis
  82986. * @param ref defines the Vector3 where to store the result
  82987. */
  82988. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82989. }
  82990. /**
  82991. * Vector4 class created for EulerAngle class conversion to Quaternion
  82992. */
  82993. export class Vector4 {
  82994. /** x value of the vector */
  82995. x: number;
  82996. /** y value of the vector */
  82997. y: number;
  82998. /** z value of the vector */
  82999. z: number;
  83000. /** w value of the vector */
  83001. w: number;
  83002. /**
  83003. * Creates a Vector4 object from the given floats.
  83004. * @param x x value of the vector
  83005. * @param y y value of the vector
  83006. * @param z z value of the vector
  83007. * @param w w value of the vector
  83008. */
  83009. constructor(
  83010. /** x value of the vector */
  83011. x: number,
  83012. /** y value of the vector */
  83013. y: number,
  83014. /** z value of the vector */
  83015. z: number,
  83016. /** w value of the vector */
  83017. w: number);
  83018. /**
  83019. * Returns the string with the Vector4 coordinates.
  83020. * @returns a string containing all the vector values
  83021. */
  83022. toString(): string;
  83023. /**
  83024. * Returns the string "Vector4".
  83025. * @returns "Vector4"
  83026. */
  83027. getClassName(): string;
  83028. /**
  83029. * Returns the Vector4 hash code.
  83030. * @returns a unique hash code
  83031. */
  83032. getHashCode(): number;
  83033. /**
  83034. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83035. * @returns the resulting array
  83036. */
  83037. asArray(): number[];
  83038. /**
  83039. * Populates the given array from the given index with the Vector4 coordinates.
  83040. * @param array array to populate
  83041. * @param index index of the array to start at (default: 0)
  83042. * @returns the Vector4.
  83043. */
  83044. toArray(array: FloatArray, index?: number): Vector4;
  83045. /**
  83046. * Update the current vector from an array
  83047. * @param array defines the destination array
  83048. * @param index defines the offset in the destination array
  83049. * @returns the current Vector3
  83050. */
  83051. fromArray(array: FloatArray, index?: number): Vector4;
  83052. /**
  83053. * Adds the given vector to the current Vector4.
  83054. * @param otherVector the vector to add
  83055. * @returns the updated Vector4.
  83056. */
  83057. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83058. /**
  83059. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83060. * @param otherVector the vector to add
  83061. * @returns the resulting vector
  83062. */
  83063. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83064. /**
  83065. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83066. * @param otherVector the vector to add
  83067. * @param result the vector to store the result
  83068. * @returns the current Vector4.
  83069. */
  83070. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83071. /**
  83072. * Subtract in place the given vector from the current Vector4.
  83073. * @param otherVector the vector to subtract
  83074. * @returns the updated Vector4.
  83075. */
  83076. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83077. /**
  83078. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83079. * @param otherVector the vector to add
  83080. * @returns the new vector with the result
  83081. */
  83082. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83083. /**
  83084. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83085. * @param otherVector the vector to subtract
  83086. * @param result the vector to store the result
  83087. * @returns the current Vector4.
  83088. */
  83089. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83090. /**
  83091. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83092. */
  83093. /**
  83094. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83095. * @param x value to subtract
  83096. * @param y value to subtract
  83097. * @param z value to subtract
  83098. * @param w value to subtract
  83099. * @returns new vector containing the result
  83100. */
  83101. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83102. /**
  83103. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83104. * @param x value to subtract
  83105. * @param y value to subtract
  83106. * @param z value to subtract
  83107. * @param w value to subtract
  83108. * @param result the vector to store the result in
  83109. * @returns the current Vector4.
  83110. */
  83111. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83112. /**
  83113. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83114. * @returns a new vector with the negated values
  83115. */
  83116. negate(): Vector4;
  83117. /**
  83118. * Negate this vector in place
  83119. * @returns this
  83120. */
  83121. negateInPlace(): Vector4;
  83122. /**
  83123. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83124. * @param result defines the Vector3 object where to store the result
  83125. * @returns the current Vector4
  83126. */
  83127. negateToRef(result: Vector4): Vector4;
  83128. /**
  83129. * Multiplies the current Vector4 coordinates by scale (float).
  83130. * @param scale the number to scale with
  83131. * @returns the updated Vector4.
  83132. */
  83133. scaleInPlace(scale: number): Vector4;
  83134. /**
  83135. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83136. * @param scale the number to scale with
  83137. * @returns a new vector with the result
  83138. */
  83139. scale(scale: number): Vector4;
  83140. /**
  83141. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83142. * @param scale the number to scale with
  83143. * @param result a vector to store the result in
  83144. * @returns the current Vector4.
  83145. */
  83146. scaleToRef(scale: number, result: Vector4): Vector4;
  83147. /**
  83148. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83149. * @param scale defines the scale factor
  83150. * @param result defines the Vector4 object where to store the result
  83151. * @returns the unmodified current Vector4
  83152. */
  83153. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83154. /**
  83155. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83156. * @param otherVector the vector to compare against
  83157. * @returns true if they are equal
  83158. */
  83159. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83160. /**
  83161. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83162. * @param otherVector vector to compare against
  83163. * @param epsilon (Default: very small number)
  83164. * @returns true if they are equal
  83165. */
  83166. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83167. /**
  83168. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83169. * @param x x value to compare against
  83170. * @param y y value to compare against
  83171. * @param z z value to compare against
  83172. * @param w w value to compare against
  83173. * @returns true if equal
  83174. */
  83175. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83176. /**
  83177. * Multiplies in place the current Vector4 by the given one.
  83178. * @param otherVector vector to multiple with
  83179. * @returns the updated Vector4.
  83180. */
  83181. multiplyInPlace(otherVector: Vector4): Vector4;
  83182. /**
  83183. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83184. * @param otherVector vector to multiple with
  83185. * @returns resulting new vector
  83186. */
  83187. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83188. /**
  83189. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83190. * @param otherVector vector to multiple with
  83191. * @param result vector to store the result
  83192. * @returns the current Vector4.
  83193. */
  83194. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83195. /**
  83196. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83197. * @param x x value multiply with
  83198. * @param y y value multiply with
  83199. * @param z z value multiply with
  83200. * @param w w value multiply with
  83201. * @returns resulting new vector
  83202. */
  83203. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83204. /**
  83205. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83206. * @param otherVector vector to devide with
  83207. * @returns resulting new vector
  83208. */
  83209. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83210. /**
  83211. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83212. * @param otherVector vector to devide with
  83213. * @param result vector to store the result
  83214. * @returns the current Vector4.
  83215. */
  83216. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83217. /**
  83218. * Divides the current Vector3 coordinates by the given ones.
  83219. * @param otherVector vector to devide with
  83220. * @returns the updated Vector3.
  83221. */
  83222. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83223. /**
  83224. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83225. * @param other defines the second operand
  83226. * @returns the current updated Vector4
  83227. */
  83228. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83229. /**
  83230. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83231. * @param other defines the second operand
  83232. * @returns the current updated Vector4
  83233. */
  83234. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83235. /**
  83236. * Gets a new Vector4 from current Vector4 floored values
  83237. * @returns a new Vector4
  83238. */
  83239. floor(): Vector4;
  83240. /**
  83241. * Gets a new Vector4 from current Vector3 floored values
  83242. * @returns a new Vector4
  83243. */
  83244. fract(): Vector4;
  83245. /**
  83246. * Returns the Vector4 length (float).
  83247. * @returns the length
  83248. */
  83249. length(): number;
  83250. /**
  83251. * Returns the Vector4 squared length (float).
  83252. * @returns the length squared
  83253. */
  83254. lengthSquared(): number;
  83255. /**
  83256. * Normalizes in place the Vector4.
  83257. * @returns the updated Vector4.
  83258. */
  83259. normalize(): Vector4;
  83260. /**
  83261. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83262. * @returns this converted to a new vector3
  83263. */
  83264. toVector3(): Vector3;
  83265. /**
  83266. * Returns a new Vector4 copied from the current one.
  83267. * @returns the new cloned vector
  83268. */
  83269. clone(): Vector4;
  83270. /**
  83271. * Updates the current Vector4 with the given one coordinates.
  83272. * @param source the source vector to copy from
  83273. * @returns the updated Vector4.
  83274. */
  83275. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83276. /**
  83277. * Updates the current Vector4 coordinates with the given floats.
  83278. * @param x float to copy from
  83279. * @param y float to copy from
  83280. * @param z float to copy from
  83281. * @param w float to copy from
  83282. * @returns the updated Vector4.
  83283. */
  83284. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83285. /**
  83286. * Updates the current Vector4 coordinates with the given floats.
  83287. * @param x float to set from
  83288. * @param y float to set from
  83289. * @param z float to set from
  83290. * @param w float to set from
  83291. * @returns the updated Vector4.
  83292. */
  83293. set(x: number, y: number, z: number, w: number): Vector4;
  83294. /**
  83295. * Copies the given float to the current Vector3 coordinates
  83296. * @param v defines the x, y, z and w coordinates of the operand
  83297. * @returns the current updated Vector3
  83298. */
  83299. setAll(v: number): Vector4;
  83300. /**
  83301. * Returns a new Vector4 set from the starting index of the given array.
  83302. * @param array the array to pull values from
  83303. * @param offset the offset into the array to start at
  83304. * @returns the new vector
  83305. */
  83306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83307. /**
  83308. * Updates the given vector "result" from the starting index of the given array.
  83309. * @param array the array to pull values from
  83310. * @param offset the offset into the array to start at
  83311. * @param result the vector to store the result in
  83312. */
  83313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83314. /**
  83315. * Updates the given vector "result" from the starting index of the given Float32Array.
  83316. * @param array the array to pull values from
  83317. * @param offset the offset into the array to start at
  83318. * @param result the vector to store the result in
  83319. */
  83320. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83321. /**
  83322. * Updates the given vector "result" coordinates from the given floats.
  83323. * @param x float to set from
  83324. * @param y float to set from
  83325. * @param z float to set from
  83326. * @param w float to set from
  83327. * @param result the vector to the floats in
  83328. */
  83329. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83330. /**
  83331. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83332. * @returns the new vector
  83333. */
  83334. static Zero(): Vector4;
  83335. /**
  83336. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83337. * @returns the new vector
  83338. */
  83339. static One(): Vector4;
  83340. /**
  83341. * Returns a new normalized Vector4 from the given one.
  83342. * @param vector the vector to normalize
  83343. * @returns the vector
  83344. */
  83345. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83346. /**
  83347. * Updates the given vector "result" from the normalization of the given one.
  83348. * @param vector the vector to normalize
  83349. * @param result the vector to store the result in
  83350. */
  83351. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83352. /**
  83353. * Returns a vector with the minimum values from the left and right vectors
  83354. * @param left left vector to minimize
  83355. * @param right right vector to minimize
  83356. * @returns a new vector with the minimum of the left and right vector values
  83357. */
  83358. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83359. /**
  83360. * Returns a vector with the maximum values from the left and right vectors
  83361. * @param left left vector to maximize
  83362. * @param right right vector to maximize
  83363. * @returns a new vector with the maximum of the left and right vector values
  83364. */
  83365. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83366. /**
  83367. * Returns the distance (float) between the vectors "value1" and "value2".
  83368. * @param value1 value to calulate the distance between
  83369. * @param value2 value to calulate the distance between
  83370. * @return the distance between the two vectors
  83371. */
  83372. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83373. /**
  83374. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83375. * @param value1 value to calulate the distance between
  83376. * @param value2 value to calulate the distance between
  83377. * @return the distance between the two vectors squared
  83378. */
  83379. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83380. /**
  83381. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83382. * @param value1 value to calulate the center between
  83383. * @param value2 value to calulate the center between
  83384. * @return the center between the two vectors
  83385. */
  83386. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83387. /**
  83388. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83389. * This methods computes transformed normalized direction vectors only.
  83390. * @param vector the vector to transform
  83391. * @param transformation the transformation matrix to apply
  83392. * @returns the new vector
  83393. */
  83394. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83395. /**
  83396. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83397. * This methods computes transformed normalized direction vectors only.
  83398. * @param vector the vector to transform
  83399. * @param transformation the transformation matrix to apply
  83400. * @param result the vector to store the result in
  83401. */
  83402. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83403. /**
  83404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83405. * This methods computes transformed normalized direction vectors only.
  83406. * @param x value to transform
  83407. * @param y value to transform
  83408. * @param z value to transform
  83409. * @param w value to transform
  83410. * @param transformation the transformation matrix to apply
  83411. * @param result the vector to store the results in
  83412. */
  83413. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83414. /**
  83415. * Creates a new Vector4 from a Vector3
  83416. * @param source defines the source data
  83417. * @param w defines the 4th component (default is 0)
  83418. * @returns a new Vector4
  83419. */
  83420. static FromVector3(source: Vector3, w?: number): Vector4;
  83421. }
  83422. /**
  83423. * Class used to store quaternion data
  83424. * @see https://en.wikipedia.org/wiki/Quaternion
  83425. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83426. */
  83427. export class Quaternion {
  83428. /** @hidden */
  83429. _x: number;
  83430. /** @hidden */
  83431. _y: number;
  83432. /** @hidden */
  83433. _z: number;
  83434. /** @hidden */
  83435. _w: number;
  83436. /** @hidden */
  83437. _isDirty: boolean;
  83438. /** Gets or sets the x coordinate */
  83439. get x(): number;
  83440. set x(value: number);
  83441. /** Gets or sets the y coordinate */
  83442. get y(): number;
  83443. set y(value: number);
  83444. /** Gets or sets the z coordinate */
  83445. get z(): number;
  83446. set z(value: number);
  83447. /** Gets or sets the w coordinate */
  83448. get w(): number;
  83449. set w(value: number);
  83450. /**
  83451. * Creates a new Quaternion from the given floats
  83452. * @param x defines the first component (0 by default)
  83453. * @param y defines the second component (0 by default)
  83454. * @param z defines the third component (0 by default)
  83455. * @param w defines the fourth component (1.0 by default)
  83456. */
  83457. constructor(x?: number, y?: number, z?: number, w?: number);
  83458. /**
  83459. * Gets a string representation for the current quaternion
  83460. * @returns a string with the Quaternion coordinates
  83461. */
  83462. toString(): string;
  83463. /**
  83464. * Gets the class name of the quaternion
  83465. * @returns the string "Quaternion"
  83466. */
  83467. getClassName(): string;
  83468. /**
  83469. * Gets a hash code for this quaternion
  83470. * @returns the quaternion hash code
  83471. */
  83472. getHashCode(): number;
  83473. /**
  83474. * Copy the quaternion to an array
  83475. * @returns a new array populated with 4 elements from the quaternion coordinates
  83476. */
  83477. asArray(): number[];
  83478. /**
  83479. * Check if two quaternions are equals
  83480. * @param otherQuaternion defines the second operand
  83481. * @return true if the current quaternion and the given one coordinates are strictly equals
  83482. */
  83483. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83484. /**
  83485. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83486. * @param otherQuaternion defines the other quaternion
  83487. * @param epsilon defines the minimal distance to consider equality
  83488. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83489. */
  83490. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83491. /**
  83492. * Clone the current quaternion
  83493. * @returns a new quaternion copied from the current one
  83494. */
  83495. clone(): Quaternion;
  83496. /**
  83497. * Copy a quaternion to the current one
  83498. * @param other defines the other quaternion
  83499. * @returns the updated current quaternion
  83500. */
  83501. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83502. /**
  83503. * Updates the current quaternion with the given float coordinates
  83504. * @param x defines the x coordinate
  83505. * @param y defines the y coordinate
  83506. * @param z defines the z coordinate
  83507. * @param w defines the w coordinate
  83508. * @returns the updated current quaternion
  83509. */
  83510. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83511. /**
  83512. * Updates the current quaternion from the given float coordinates
  83513. * @param x defines the x coordinate
  83514. * @param y defines the y coordinate
  83515. * @param z defines the z coordinate
  83516. * @param w defines the w coordinate
  83517. * @returns the updated current quaternion
  83518. */
  83519. set(x: number, y: number, z: number, w: number): Quaternion;
  83520. /**
  83521. * Adds two quaternions
  83522. * @param other defines the second operand
  83523. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83524. */
  83525. add(other: DeepImmutable<Quaternion>): Quaternion;
  83526. /**
  83527. * Add a quaternion to the current one
  83528. * @param other defines the quaternion to add
  83529. * @returns the current quaternion
  83530. */
  83531. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83532. /**
  83533. * Subtract two quaternions
  83534. * @param other defines the second operand
  83535. * @returns a new quaternion as the subtraction result of the given one from the current one
  83536. */
  83537. subtract(other: Quaternion): Quaternion;
  83538. /**
  83539. * Multiplies the current quaternion by a scale factor
  83540. * @param value defines the scale factor
  83541. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83542. */
  83543. scale(value: number): Quaternion;
  83544. /**
  83545. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83546. * @param scale defines the scale factor
  83547. * @param result defines the Quaternion object where to store the result
  83548. * @returns the unmodified current quaternion
  83549. */
  83550. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83551. /**
  83552. * Multiplies in place the current quaternion by a scale factor
  83553. * @param value defines the scale factor
  83554. * @returns the current modified quaternion
  83555. */
  83556. scaleInPlace(value: number): Quaternion;
  83557. /**
  83558. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83559. * @param scale defines the scale factor
  83560. * @param result defines the Quaternion object where to store the result
  83561. * @returns the unmodified current quaternion
  83562. */
  83563. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83564. /**
  83565. * Multiplies two quaternions
  83566. * @param q1 defines the second operand
  83567. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83568. */
  83569. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83570. /**
  83571. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83572. * @param q1 defines the second operand
  83573. * @param result defines the target quaternion
  83574. * @returns the current quaternion
  83575. */
  83576. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83577. /**
  83578. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83579. * @param q1 defines the second operand
  83580. * @returns the currentupdated quaternion
  83581. */
  83582. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83583. /**
  83584. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83585. * @param ref defines the target quaternion
  83586. * @returns the current quaternion
  83587. */
  83588. conjugateToRef(ref: Quaternion): Quaternion;
  83589. /**
  83590. * Conjugates in place (1-q) the current quaternion
  83591. * @returns the current updated quaternion
  83592. */
  83593. conjugateInPlace(): Quaternion;
  83594. /**
  83595. * Conjugates in place (1-q) the current quaternion
  83596. * @returns a new quaternion
  83597. */
  83598. conjugate(): Quaternion;
  83599. /**
  83600. * Gets length of current quaternion
  83601. * @returns the quaternion length (float)
  83602. */
  83603. length(): number;
  83604. /**
  83605. * Normalize in place the current quaternion
  83606. * @returns the current updated quaternion
  83607. */
  83608. normalize(): Quaternion;
  83609. /**
  83610. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83611. * @param order is a reserved parameter and is ignore for now
  83612. * @returns a new Vector3 containing the Euler angles
  83613. */
  83614. toEulerAngles(order?: string): Vector3;
  83615. /**
  83616. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83617. * @param result defines the vector which will be filled with the Euler angles
  83618. * @param order is a reserved parameter and is ignore for now
  83619. * @returns the current unchanged quaternion
  83620. */
  83621. toEulerAnglesToRef(result: Vector3): Quaternion;
  83622. /**
  83623. * Updates the given rotation matrix with the current quaternion values
  83624. * @param result defines the target matrix
  83625. * @returns the current unchanged quaternion
  83626. */
  83627. toRotationMatrix(result: Matrix): Quaternion;
  83628. /**
  83629. * Updates the current quaternion from the given rotation matrix values
  83630. * @param matrix defines the source matrix
  83631. * @returns the current updated quaternion
  83632. */
  83633. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83634. /**
  83635. * Creates a new quaternion from a rotation matrix
  83636. * @param matrix defines the source matrix
  83637. * @returns a new quaternion created from the given rotation matrix values
  83638. */
  83639. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83640. /**
  83641. * Updates the given quaternion with the given rotation matrix values
  83642. * @param matrix defines the source matrix
  83643. * @param result defines the target quaternion
  83644. */
  83645. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83646. /**
  83647. * Returns the dot product (float) between the quaternions "left" and "right"
  83648. * @param left defines the left operand
  83649. * @param right defines the right operand
  83650. * @returns the dot product
  83651. */
  83652. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83653. /**
  83654. * Checks if the two quaternions are close to each other
  83655. * @param quat0 defines the first quaternion to check
  83656. * @param quat1 defines the second quaternion to check
  83657. * @returns true if the two quaternions are close to each other
  83658. */
  83659. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83660. /**
  83661. * Creates an empty quaternion
  83662. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83663. */
  83664. static Zero(): Quaternion;
  83665. /**
  83666. * Inverse a given quaternion
  83667. * @param q defines the source quaternion
  83668. * @returns a new quaternion as the inverted current quaternion
  83669. */
  83670. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83671. /**
  83672. * Inverse a given quaternion
  83673. * @param q defines the source quaternion
  83674. * @param result the quaternion the result will be stored in
  83675. * @returns the result quaternion
  83676. */
  83677. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83678. /**
  83679. * Creates an identity quaternion
  83680. * @returns the identity quaternion
  83681. */
  83682. static Identity(): Quaternion;
  83683. /**
  83684. * Gets a boolean indicating if the given quaternion is identity
  83685. * @param quaternion defines the quaternion to check
  83686. * @returns true if the quaternion is identity
  83687. */
  83688. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83689. /**
  83690. * Creates a quaternion from a rotation around an axis
  83691. * @param axis defines the axis to use
  83692. * @param angle defines the angle to use
  83693. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83694. */
  83695. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83696. /**
  83697. * Creates a rotation around an axis and stores it into the given quaternion
  83698. * @param axis defines the axis to use
  83699. * @param angle defines the angle to use
  83700. * @param result defines the target quaternion
  83701. * @returns the target quaternion
  83702. */
  83703. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83704. /**
  83705. * Creates a new quaternion from data stored into an array
  83706. * @param array defines the data source
  83707. * @param offset defines the offset in the source array where the data starts
  83708. * @returns a new quaternion
  83709. */
  83710. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83711. /**
  83712. * Updates the given quaternion "result" from the starting index of the given array.
  83713. * @param array the array to pull values from
  83714. * @param offset the offset into the array to start at
  83715. * @param result the quaternion to store the result in
  83716. */
  83717. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83718. /**
  83719. * Create a quaternion from Euler rotation angles
  83720. * @param x Pitch
  83721. * @param y Yaw
  83722. * @param z Roll
  83723. * @returns the new Quaternion
  83724. */
  83725. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83726. /**
  83727. * Updates a quaternion from Euler rotation angles
  83728. * @param x Pitch
  83729. * @param y Yaw
  83730. * @param z Roll
  83731. * @param result the quaternion to store the result
  83732. * @returns the updated quaternion
  83733. */
  83734. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83735. /**
  83736. * Create a quaternion from Euler rotation vector
  83737. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83738. * @returns the new Quaternion
  83739. */
  83740. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83741. /**
  83742. * Updates a quaternion from Euler rotation vector
  83743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83744. * @param result the quaternion to store the result
  83745. * @returns the updated quaternion
  83746. */
  83747. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83748. /**
  83749. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83750. * @param yaw defines the rotation around Y axis
  83751. * @param pitch defines the rotation around X axis
  83752. * @param roll defines the rotation around Z axis
  83753. * @returns the new quaternion
  83754. */
  83755. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83756. /**
  83757. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83758. * @param yaw defines the rotation around Y axis
  83759. * @param pitch defines the rotation around X axis
  83760. * @param roll defines the rotation around Z axis
  83761. * @param result defines the target quaternion
  83762. */
  83763. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83764. /**
  83765. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83766. * @param alpha defines the rotation around first axis
  83767. * @param beta defines the rotation around second axis
  83768. * @param gamma defines the rotation around third axis
  83769. * @returns the new quaternion
  83770. */
  83771. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83772. /**
  83773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83774. * @param alpha defines the rotation around first axis
  83775. * @param beta defines the rotation around second axis
  83776. * @param gamma defines the rotation around third axis
  83777. * @param result defines the target quaternion
  83778. */
  83779. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83780. /**
  83781. * 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)
  83782. * @param axis1 defines the first axis
  83783. * @param axis2 defines the second axis
  83784. * @param axis3 defines the third axis
  83785. * @returns the new quaternion
  83786. */
  83787. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83788. /**
  83789. * 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
  83790. * @param axis1 defines the first axis
  83791. * @param axis2 defines the second axis
  83792. * @param axis3 defines the third axis
  83793. * @param ref defines the target quaternion
  83794. */
  83795. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83796. /**
  83797. * Interpolates between two quaternions
  83798. * @param left defines first quaternion
  83799. * @param right defines second quaternion
  83800. * @param amount defines the gradient to use
  83801. * @returns the new interpolated quaternion
  83802. */
  83803. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83804. /**
  83805. * Interpolates between two quaternions and stores it into a target quaternion
  83806. * @param left defines first quaternion
  83807. * @param right defines second quaternion
  83808. * @param amount defines the gradient to use
  83809. * @param result defines the target quaternion
  83810. */
  83811. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83812. /**
  83813. * Interpolate between two quaternions using Hermite interpolation
  83814. * @param value1 defines first quaternion
  83815. * @param tangent1 defines the incoming tangent
  83816. * @param value2 defines second quaternion
  83817. * @param tangent2 defines the outgoing tangent
  83818. * @param amount defines the target quaternion
  83819. * @returns the new interpolated quaternion
  83820. */
  83821. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83822. }
  83823. /**
  83824. * Class used to store matrix data (4x4)
  83825. */
  83826. export class Matrix {
  83827. /**
  83828. * Gets the precision of matrix computations
  83829. */
  83830. static get Use64Bits(): boolean;
  83831. private static _updateFlagSeed;
  83832. private static _identityReadOnly;
  83833. private _isIdentity;
  83834. private _isIdentityDirty;
  83835. private _isIdentity3x2;
  83836. private _isIdentity3x2Dirty;
  83837. /**
  83838. * Gets the update flag of the matrix which is an unique number for the matrix.
  83839. * It will be incremented every time the matrix data change.
  83840. * You can use it to speed the comparison between two versions of the same matrix.
  83841. */
  83842. updateFlag: number;
  83843. private readonly _m;
  83844. /**
  83845. * Gets the internal data of the matrix
  83846. */
  83847. get m(): DeepImmutable<Float32Array | Array<number>>;
  83848. /** @hidden */
  83849. _markAsUpdated(): void;
  83850. /** @hidden */
  83851. private _updateIdentityStatus;
  83852. /**
  83853. * Creates an empty matrix (filled with zeros)
  83854. */
  83855. constructor();
  83856. /**
  83857. * Check if the current matrix is identity
  83858. * @returns true is the matrix is the identity matrix
  83859. */
  83860. isIdentity(): boolean;
  83861. /**
  83862. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83863. * @returns true is the matrix is the identity matrix
  83864. */
  83865. isIdentityAs3x2(): boolean;
  83866. /**
  83867. * Gets the determinant of the matrix
  83868. * @returns the matrix determinant
  83869. */
  83870. determinant(): number;
  83871. /**
  83872. * Returns the matrix as a Float32Array or Array<number>
  83873. * @returns the matrix underlying array
  83874. */
  83875. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83876. /**
  83877. * Returns the matrix as a Float32Array or Array<number>
  83878. * @returns the matrix underlying array.
  83879. */
  83880. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83881. /**
  83882. * Inverts the current matrix in place
  83883. * @returns the current inverted matrix
  83884. */
  83885. invert(): Matrix;
  83886. /**
  83887. * Sets all the matrix elements to zero
  83888. * @returns the current matrix
  83889. */
  83890. reset(): Matrix;
  83891. /**
  83892. * Adds the current matrix with a second one
  83893. * @param other defines the matrix to add
  83894. * @returns a new matrix as the addition of the current matrix and the given one
  83895. */
  83896. add(other: DeepImmutable<Matrix>): Matrix;
  83897. /**
  83898. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83899. * @param other defines the matrix to add
  83900. * @param result defines the target matrix
  83901. * @returns the current matrix
  83902. */
  83903. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83904. /**
  83905. * Adds in place the given matrix to the current matrix
  83906. * @param other defines the second operand
  83907. * @returns the current updated matrix
  83908. */
  83909. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83910. /**
  83911. * Sets the given matrix to the current inverted Matrix
  83912. * @param other defines the target matrix
  83913. * @returns the unmodified current matrix
  83914. */
  83915. invertToRef(other: Matrix): Matrix;
  83916. /**
  83917. * add a value at the specified position in the current Matrix
  83918. * @param index the index of the value within the matrix. between 0 and 15.
  83919. * @param value the value to be added
  83920. * @returns the current updated matrix
  83921. */
  83922. addAtIndex(index: number, value: number): Matrix;
  83923. /**
  83924. * mutiply the specified position in the current Matrix by a value
  83925. * @param index the index of the value within the matrix. between 0 and 15.
  83926. * @param value the value to be added
  83927. * @returns the current updated matrix
  83928. */
  83929. multiplyAtIndex(index: number, value: number): Matrix;
  83930. /**
  83931. * Inserts the translation vector (using 3 floats) in the current matrix
  83932. * @param x defines the 1st component of the translation
  83933. * @param y defines the 2nd component of the translation
  83934. * @param z defines the 3rd component of the translation
  83935. * @returns the current updated matrix
  83936. */
  83937. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83938. /**
  83939. * Adds the translation vector (using 3 floats) in the current matrix
  83940. * @param x defines the 1st component of the translation
  83941. * @param y defines the 2nd component of the translation
  83942. * @param z defines the 3rd component of the translation
  83943. * @returns the current updated matrix
  83944. */
  83945. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83946. /**
  83947. * Inserts the translation vector in the current matrix
  83948. * @param vector3 defines the translation to insert
  83949. * @returns the current updated matrix
  83950. */
  83951. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83952. /**
  83953. * Gets the translation value of the current matrix
  83954. * @returns a new Vector3 as the extracted translation from the matrix
  83955. */
  83956. getTranslation(): Vector3;
  83957. /**
  83958. * Fill a Vector3 with the extracted translation from the matrix
  83959. * @param result defines the Vector3 where to store the translation
  83960. * @returns the current matrix
  83961. */
  83962. getTranslationToRef(result: Vector3): Matrix;
  83963. /**
  83964. * Remove rotation and scaling part from the matrix
  83965. * @returns the updated matrix
  83966. */
  83967. removeRotationAndScaling(): Matrix;
  83968. /**
  83969. * Multiply two matrices
  83970. * @param other defines the second operand
  83971. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83972. */
  83973. multiply(other: DeepImmutable<Matrix>): Matrix;
  83974. /**
  83975. * Copy the current matrix from the given one
  83976. * @param other defines the source matrix
  83977. * @returns the current updated matrix
  83978. */
  83979. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83980. /**
  83981. * Populates the given array from the starting index with the current matrix values
  83982. * @param array defines the target array
  83983. * @param offset defines the offset in the target array where to start storing values
  83984. * @returns the current matrix
  83985. */
  83986. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83987. /**
  83988. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83989. * @param other defines the second operand
  83990. * @param result defines the matrix where to store the multiplication
  83991. * @returns the current matrix
  83992. */
  83993. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83994. /**
  83995. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83996. * @param other defines the second operand
  83997. * @param result defines the array where to store the multiplication
  83998. * @param offset defines the offset in the target array where to start storing values
  83999. * @returns the current matrix
  84000. */
  84001. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84002. /**
  84003. * Check equality between this matrix and a second one
  84004. * @param value defines the second matrix to compare
  84005. * @returns true is the current matrix and the given one values are strictly equal
  84006. */
  84007. equals(value: DeepImmutable<Matrix>): boolean;
  84008. /**
  84009. * Clone the current matrix
  84010. * @returns a new matrix from the current matrix
  84011. */
  84012. clone(): Matrix;
  84013. /**
  84014. * Returns the name of the current matrix class
  84015. * @returns the string "Matrix"
  84016. */
  84017. getClassName(): string;
  84018. /**
  84019. * Gets the hash code of the current matrix
  84020. * @returns the hash code
  84021. */
  84022. getHashCode(): number;
  84023. /**
  84024. * Decomposes the current Matrix into a translation, rotation and scaling components
  84025. * @param scale defines the scale vector3 given as a reference to update
  84026. * @param rotation defines the rotation quaternion given as a reference to update
  84027. * @param translation defines the translation vector3 given as a reference to update
  84028. * @returns true if operation was successful
  84029. */
  84030. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84031. /**
  84032. * Gets specific row of the matrix
  84033. * @param index defines the number of the row to get
  84034. * @returns the index-th row of the current matrix as a new Vector4
  84035. */
  84036. getRow(index: number): Nullable<Vector4>;
  84037. /**
  84038. * Sets the index-th row of the current matrix to the vector4 values
  84039. * @param index defines the number of the row to set
  84040. * @param row defines the target vector4
  84041. * @returns the updated current matrix
  84042. */
  84043. setRow(index: number, row: Vector4): Matrix;
  84044. /**
  84045. * Compute the transpose of the matrix
  84046. * @returns the new transposed matrix
  84047. */
  84048. transpose(): Matrix;
  84049. /**
  84050. * Compute the transpose of the matrix and store it in a given matrix
  84051. * @param result defines the target matrix
  84052. * @returns the current matrix
  84053. */
  84054. transposeToRef(result: Matrix): Matrix;
  84055. /**
  84056. * Sets the index-th row of the current matrix with the given 4 x float values
  84057. * @param index defines the row index
  84058. * @param x defines the x component to set
  84059. * @param y defines the y component to set
  84060. * @param z defines the z component to set
  84061. * @param w defines the w component to set
  84062. * @returns the updated current matrix
  84063. */
  84064. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84065. /**
  84066. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84067. * @param scale defines the scale factor
  84068. * @returns a new matrix
  84069. */
  84070. scale(scale: number): Matrix;
  84071. /**
  84072. * Scale the current matrix values by a factor to a given result matrix
  84073. * @param scale defines the scale factor
  84074. * @param result defines the matrix to store the result
  84075. * @returns the current matrix
  84076. */
  84077. scaleToRef(scale: number, result: Matrix): Matrix;
  84078. /**
  84079. * Scale the current matrix values by a factor and add the result to a given matrix
  84080. * @param scale defines the scale factor
  84081. * @param result defines the Matrix to store the result
  84082. * @returns the current matrix
  84083. */
  84084. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84085. /**
  84086. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84087. * @param ref matrix to store the result
  84088. */
  84089. toNormalMatrix(ref: Matrix): void;
  84090. /**
  84091. * Gets only rotation part of the current matrix
  84092. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84093. */
  84094. getRotationMatrix(): Matrix;
  84095. /**
  84096. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84097. * @param result defines the target matrix to store data to
  84098. * @returns the current matrix
  84099. */
  84100. getRotationMatrixToRef(result: Matrix): Matrix;
  84101. /**
  84102. * Toggles model matrix from being right handed to left handed in place and vice versa
  84103. */
  84104. toggleModelMatrixHandInPlace(): void;
  84105. /**
  84106. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84107. */
  84108. toggleProjectionMatrixHandInPlace(): void;
  84109. /**
  84110. * Creates a matrix from an array
  84111. * @param array defines the source array
  84112. * @param offset defines an offset in the source array
  84113. * @returns a new Matrix set from the starting index of the given array
  84114. */
  84115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84116. /**
  84117. * Copy the content of an array into a given matrix
  84118. * @param array defines the source array
  84119. * @param offset defines an offset in the source array
  84120. * @param result defines the target matrix
  84121. */
  84122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84123. /**
  84124. * Stores an array into a matrix after having multiplied each component by a given factor
  84125. * @param array defines the source array
  84126. * @param offset defines the offset in the source array
  84127. * @param scale defines the scaling factor
  84128. * @param result defines the target matrix
  84129. */
  84130. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84131. /**
  84132. * Gets an identity matrix that must not be updated
  84133. */
  84134. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84135. /**
  84136. * Stores a list of values (16) inside a given matrix
  84137. * @param initialM11 defines 1st value of 1st row
  84138. * @param initialM12 defines 2nd value of 1st row
  84139. * @param initialM13 defines 3rd value of 1st row
  84140. * @param initialM14 defines 4th value of 1st row
  84141. * @param initialM21 defines 1st value of 2nd row
  84142. * @param initialM22 defines 2nd value of 2nd row
  84143. * @param initialM23 defines 3rd value of 2nd row
  84144. * @param initialM24 defines 4th value of 2nd row
  84145. * @param initialM31 defines 1st value of 3rd row
  84146. * @param initialM32 defines 2nd value of 3rd row
  84147. * @param initialM33 defines 3rd value of 3rd row
  84148. * @param initialM34 defines 4th value of 3rd row
  84149. * @param initialM41 defines 1st value of 4th row
  84150. * @param initialM42 defines 2nd value of 4th row
  84151. * @param initialM43 defines 3rd value of 4th row
  84152. * @param initialM44 defines 4th value of 4th row
  84153. * @param result defines the target matrix
  84154. */
  84155. 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;
  84156. /**
  84157. * Creates new matrix from a list of values (16)
  84158. * @param initialM11 defines 1st value of 1st row
  84159. * @param initialM12 defines 2nd value of 1st row
  84160. * @param initialM13 defines 3rd value of 1st row
  84161. * @param initialM14 defines 4th value of 1st row
  84162. * @param initialM21 defines 1st value of 2nd row
  84163. * @param initialM22 defines 2nd value of 2nd row
  84164. * @param initialM23 defines 3rd value of 2nd row
  84165. * @param initialM24 defines 4th value of 2nd row
  84166. * @param initialM31 defines 1st value of 3rd row
  84167. * @param initialM32 defines 2nd value of 3rd row
  84168. * @param initialM33 defines 3rd value of 3rd row
  84169. * @param initialM34 defines 4th value of 3rd row
  84170. * @param initialM41 defines 1st value of 4th row
  84171. * @param initialM42 defines 2nd value of 4th row
  84172. * @param initialM43 defines 3rd value of 4th row
  84173. * @param initialM44 defines 4th value of 4th row
  84174. * @returns the new matrix
  84175. */
  84176. 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;
  84177. /**
  84178. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84179. * @param scale defines the scale vector3
  84180. * @param rotation defines the rotation quaternion
  84181. * @param translation defines the translation vector3
  84182. * @returns a new matrix
  84183. */
  84184. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84185. /**
  84186. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84187. * @param scale defines the scale vector3
  84188. * @param rotation defines the rotation quaternion
  84189. * @param translation defines the translation vector3
  84190. * @param result defines the target matrix
  84191. */
  84192. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84193. /**
  84194. * Creates a new identity matrix
  84195. * @returns a new identity matrix
  84196. */
  84197. static Identity(): Matrix;
  84198. /**
  84199. * Creates a new identity matrix and stores the result in a given matrix
  84200. * @param result defines the target matrix
  84201. */
  84202. static IdentityToRef(result: Matrix): void;
  84203. /**
  84204. * Creates a new zero matrix
  84205. * @returns a new zero matrix
  84206. */
  84207. static Zero(): Matrix;
  84208. /**
  84209. * Creates a new rotation matrix for "angle" radians around the X axis
  84210. * @param angle defines the angle (in radians) to use
  84211. * @return the new matrix
  84212. */
  84213. static RotationX(angle: number): Matrix;
  84214. /**
  84215. * Creates a new matrix as the invert of a given matrix
  84216. * @param source defines the source matrix
  84217. * @returns the new matrix
  84218. */
  84219. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84220. /**
  84221. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84222. * @param angle defines the angle (in radians) to use
  84223. * @param result defines the target matrix
  84224. */
  84225. static RotationXToRef(angle: number, result: Matrix): void;
  84226. /**
  84227. * Creates a new rotation matrix for "angle" radians around the Y axis
  84228. * @param angle defines the angle (in radians) to use
  84229. * @return the new matrix
  84230. */
  84231. static RotationY(angle: number): Matrix;
  84232. /**
  84233. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84234. * @param angle defines the angle (in radians) to use
  84235. * @param result defines the target matrix
  84236. */
  84237. static RotationYToRef(angle: number, result: Matrix): void;
  84238. /**
  84239. * Creates a new rotation matrix for "angle" radians around the Z axis
  84240. * @param angle defines the angle (in radians) to use
  84241. * @return the new matrix
  84242. */
  84243. static RotationZ(angle: number): Matrix;
  84244. /**
  84245. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84246. * @param angle defines the angle (in radians) to use
  84247. * @param result defines the target matrix
  84248. */
  84249. static RotationZToRef(angle: number, result: Matrix): void;
  84250. /**
  84251. * Creates a new rotation matrix for "angle" radians around the given axis
  84252. * @param axis defines the axis to use
  84253. * @param angle defines the angle (in radians) to use
  84254. * @return the new matrix
  84255. */
  84256. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84257. /**
  84258. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84259. * @param axis defines the axis to use
  84260. * @param angle defines the angle (in radians) to use
  84261. * @param result defines the target matrix
  84262. */
  84263. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84264. /**
  84265. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84266. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84267. * @param from defines the vector to align
  84268. * @param to defines the vector to align to
  84269. * @param result defines the target matrix
  84270. */
  84271. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84272. /**
  84273. * Creates a rotation matrix
  84274. * @param yaw defines the yaw angle in radians (Y axis)
  84275. * @param pitch defines the pitch angle in radians (X axis)
  84276. * @param roll defines the roll angle in radians (Z axis)
  84277. * @returns the new rotation matrix
  84278. */
  84279. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84280. /**
  84281. * Creates a rotation matrix and stores it in a given matrix
  84282. * @param yaw defines the yaw angle in radians (Y axis)
  84283. * @param pitch defines the pitch angle in radians (X axis)
  84284. * @param roll defines the roll angle in radians (Z axis)
  84285. * @param result defines the target matrix
  84286. */
  84287. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84288. /**
  84289. * Creates a scaling matrix
  84290. * @param x defines the scale factor on X axis
  84291. * @param y defines the scale factor on Y axis
  84292. * @param z defines the scale factor on Z axis
  84293. * @returns the new matrix
  84294. */
  84295. static Scaling(x: number, y: number, z: number): Matrix;
  84296. /**
  84297. * Creates a scaling matrix and stores it in a given matrix
  84298. * @param x defines the scale factor on X axis
  84299. * @param y defines the scale factor on Y axis
  84300. * @param z defines the scale factor on Z axis
  84301. * @param result defines the target matrix
  84302. */
  84303. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84304. /**
  84305. * Creates a translation matrix
  84306. * @param x defines the translation on X axis
  84307. * @param y defines the translation on Y axis
  84308. * @param z defines the translationon Z axis
  84309. * @returns the new matrix
  84310. */
  84311. static Translation(x: number, y: number, z: number): Matrix;
  84312. /**
  84313. * Creates a translation matrix and stores it in a given matrix
  84314. * @param x defines the translation on X axis
  84315. * @param y defines the translation on Y axis
  84316. * @param z defines the translationon Z axis
  84317. * @param result defines the target matrix
  84318. */
  84319. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84320. /**
  84321. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84322. * @param startValue defines the start value
  84323. * @param endValue defines the end value
  84324. * @param gradient defines the gradient factor
  84325. * @returns the new matrix
  84326. */
  84327. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84328. /**
  84329. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84330. * @param startValue defines the start value
  84331. * @param endValue defines the end value
  84332. * @param gradient defines the gradient factor
  84333. * @param result defines the Matrix object where to store data
  84334. */
  84335. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84336. /**
  84337. * Builds a new matrix whose values are computed by:
  84338. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84339. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84340. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84341. * @param startValue defines the first matrix
  84342. * @param endValue defines the second matrix
  84343. * @param gradient defines the gradient between the two matrices
  84344. * @returns the new matrix
  84345. */
  84346. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84347. /**
  84348. * Update a matrix to values which are computed by:
  84349. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84350. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84351. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84352. * @param startValue defines the first matrix
  84353. * @param endValue defines the second matrix
  84354. * @param gradient defines the gradient between the two matrices
  84355. * @param result defines the target matrix
  84356. */
  84357. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84358. /**
  84359. * 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"
  84360. * This function works in left handed mode
  84361. * @param eye defines the final position of the entity
  84362. * @param target defines where the entity should look at
  84363. * @param up defines the up vector for the entity
  84364. * @returns the new matrix
  84365. */
  84366. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84367. /**
  84368. * 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".
  84369. * This function works in left handed mode
  84370. * @param eye defines the final position of the entity
  84371. * @param target defines where the entity should look at
  84372. * @param up defines the up vector for the entity
  84373. * @param result defines the target matrix
  84374. */
  84375. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84376. /**
  84377. * 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"
  84378. * This function works in right handed mode
  84379. * @param eye defines the final position of the entity
  84380. * @param target defines where the entity should look at
  84381. * @param up defines the up vector for the entity
  84382. * @returns the new matrix
  84383. */
  84384. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84385. /**
  84386. * 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".
  84387. * This function works in right handed mode
  84388. * @param eye defines the final position of the entity
  84389. * @param target defines where the entity should look at
  84390. * @param up defines the up vector for the entity
  84391. * @param result defines the target matrix
  84392. */
  84393. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84394. /**
  84395. * Create a left-handed orthographic projection matrix
  84396. * @param width defines the viewport width
  84397. * @param height defines the viewport height
  84398. * @param znear defines the near clip plane
  84399. * @param zfar defines the far clip plane
  84400. * @returns a new matrix as a left-handed orthographic projection matrix
  84401. */
  84402. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84403. /**
  84404. * Store a left-handed orthographic projection to a given matrix
  84405. * @param width defines the viewport width
  84406. * @param height defines the viewport height
  84407. * @param znear defines the near clip plane
  84408. * @param zfar defines the far clip plane
  84409. * @param result defines the target matrix
  84410. */
  84411. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84412. /**
  84413. * Create a left-handed orthographic projection matrix
  84414. * @param left defines the viewport left coordinate
  84415. * @param right defines the viewport right coordinate
  84416. * @param bottom defines the viewport bottom coordinate
  84417. * @param top defines the viewport top coordinate
  84418. * @param znear defines the near clip plane
  84419. * @param zfar defines the far clip plane
  84420. * @returns a new matrix as a left-handed orthographic projection matrix
  84421. */
  84422. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84423. /**
  84424. * Stores a left-handed orthographic projection into a given matrix
  84425. * @param left defines the viewport left coordinate
  84426. * @param right defines the viewport right coordinate
  84427. * @param bottom defines the viewport bottom coordinate
  84428. * @param top defines the viewport top coordinate
  84429. * @param znear defines the near clip plane
  84430. * @param zfar defines the far clip plane
  84431. * @param result defines the target matrix
  84432. */
  84433. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84434. /**
  84435. * Creates a right-handed orthographic projection matrix
  84436. * @param left defines the viewport left coordinate
  84437. * @param right defines the viewport right coordinate
  84438. * @param bottom defines the viewport bottom coordinate
  84439. * @param top defines the viewport top coordinate
  84440. * @param znear defines the near clip plane
  84441. * @param zfar defines the far clip plane
  84442. * @returns a new matrix as a right-handed orthographic projection matrix
  84443. */
  84444. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84445. /**
  84446. * Stores a right-handed orthographic projection into a given matrix
  84447. * @param left defines the viewport left coordinate
  84448. * @param right defines the viewport right coordinate
  84449. * @param bottom defines the viewport bottom coordinate
  84450. * @param top defines the viewport top coordinate
  84451. * @param znear defines the near clip plane
  84452. * @param zfar defines the far clip plane
  84453. * @param result defines the target matrix
  84454. */
  84455. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84456. /**
  84457. * Creates a left-handed perspective projection matrix
  84458. * @param width defines the viewport width
  84459. * @param height defines the viewport height
  84460. * @param znear defines the near clip plane
  84461. * @param zfar defines the far clip plane
  84462. * @returns a new matrix as a left-handed perspective projection matrix
  84463. */
  84464. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84465. /**
  84466. * Creates a left-handed perspective projection matrix
  84467. * @param fov defines the horizontal field of view
  84468. * @param aspect defines the aspect ratio
  84469. * @param znear defines the near clip plane
  84470. * @param zfar defines the far clip plane
  84471. * @returns a new matrix as a left-handed perspective projection matrix
  84472. */
  84473. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84474. /**
  84475. * Stores a left-handed perspective projection into a given matrix
  84476. * @param fov defines the horizontal field of view
  84477. * @param aspect defines the aspect ratio
  84478. * @param znear defines the near clip plane
  84479. * @param zfar defines the far clip plane
  84480. * @param result defines the target matrix
  84481. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84482. */
  84483. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84484. /**
  84485. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84486. * @param fov defines the horizontal field of view
  84487. * @param aspect defines the aspect ratio
  84488. * @param znear defines the near clip plane
  84489. * @param zfar not used as infinity is used as far clip
  84490. * @param result defines the target matrix
  84491. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84492. */
  84493. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84494. /**
  84495. * Creates a right-handed perspective projection matrix
  84496. * @param fov defines the horizontal field of view
  84497. * @param aspect defines the aspect ratio
  84498. * @param znear defines the near clip plane
  84499. * @param zfar defines the far clip plane
  84500. * @returns a new matrix as a right-handed perspective projection matrix
  84501. */
  84502. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84503. /**
  84504. * Stores a right-handed perspective projection into a given matrix
  84505. * @param fov defines the horizontal field of view
  84506. * @param aspect defines the aspect ratio
  84507. * @param znear defines the near clip plane
  84508. * @param zfar defines the far clip plane
  84509. * @param result defines the target matrix
  84510. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84511. */
  84512. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84513. /**
  84514. * Stores a right-handed perspective projection into a given matrix
  84515. * @param fov defines the horizontal field of view
  84516. * @param aspect defines the aspect ratio
  84517. * @param znear defines the near clip plane
  84518. * @param zfar not used as infinity is used as far clip
  84519. * @param result defines the target matrix
  84520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84521. */
  84522. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84523. /**
  84524. * Stores a perspective projection for WebVR info a given matrix
  84525. * @param fov defines the field of view
  84526. * @param znear defines the near clip plane
  84527. * @param zfar defines the far clip plane
  84528. * @param result defines the target matrix
  84529. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84530. */
  84531. static PerspectiveFovWebVRToRef(fov: {
  84532. upDegrees: number;
  84533. downDegrees: number;
  84534. leftDegrees: number;
  84535. rightDegrees: number;
  84536. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84537. /**
  84538. * Computes a complete transformation matrix
  84539. * @param viewport defines the viewport to use
  84540. * @param world defines the world matrix
  84541. * @param view defines the view matrix
  84542. * @param projection defines the projection matrix
  84543. * @param zmin defines the near clip plane
  84544. * @param zmax defines the far clip plane
  84545. * @returns the transformation matrix
  84546. */
  84547. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84548. /**
  84549. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84550. * @param matrix defines the matrix to use
  84551. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84552. */
  84553. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84554. /**
  84555. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84556. * @param matrix defines the matrix to use
  84557. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84558. */
  84559. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84560. /**
  84561. * Compute the transpose of a given matrix
  84562. * @param matrix defines the matrix to transpose
  84563. * @returns the new matrix
  84564. */
  84565. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84566. /**
  84567. * Compute the transpose of a matrix and store it in a target matrix
  84568. * @param matrix defines the matrix to transpose
  84569. * @param result defines the target matrix
  84570. */
  84571. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84572. /**
  84573. * Computes a reflection matrix from a plane
  84574. * @param plane defines the reflection plane
  84575. * @returns a new matrix
  84576. */
  84577. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84578. /**
  84579. * Computes a reflection matrix from a plane
  84580. * @param plane defines the reflection plane
  84581. * @param result defines the target matrix
  84582. */
  84583. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84584. /**
  84585. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84586. * @param xaxis defines the value of the 1st axis
  84587. * @param yaxis defines the value of the 2nd axis
  84588. * @param zaxis defines the value of the 3rd axis
  84589. * @param result defines the target matrix
  84590. */
  84591. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84592. /**
  84593. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84594. * @param quat defines the quaternion to use
  84595. * @param result defines the target matrix
  84596. */
  84597. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84598. }
  84599. /**
  84600. * @hidden
  84601. */
  84602. export class TmpVectors {
  84603. static Vector2: Vector2[];
  84604. static Vector3: Vector3[];
  84605. static Vector4: Vector4[];
  84606. static Quaternion: Quaternion[];
  84607. static Matrix: Matrix[];
  84608. }
  84609. }
  84610. declare module BABYLON {
  84611. /**
  84612. * Defines potential orientation for back face culling
  84613. */
  84614. export enum Orientation {
  84615. /**
  84616. * Clockwise
  84617. */
  84618. CW = 0,
  84619. /** Counter clockwise */
  84620. CCW = 1
  84621. }
  84622. /** Class used to represent a Bezier curve */
  84623. export class BezierCurve {
  84624. /**
  84625. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84626. * @param t defines the time
  84627. * @param x1 defines the left coordinate on X axis
  84628. * @param y1 defines the left coordinate on Y axis
  84629. * @param x2 defines the right coordinate on X axis
  84630. * @param y2 defines the right coordinate on Y axis
  84631. * @returns the interpolated value
  84632. */
  84633. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84634. }
  84635. /**
  84636. * Defines angle representation
  84637. */
  84638. export class Angle {
  84639. private _radians;
  84640. /**
  84641. * Creates an Angle object of "radians" radians (float).
  84642. * @param radians the angle in radians
  84643. */
  84644. constructor(radians: number);
  84645. /**
  84646. * Get value in degrees
  84647. * @returns the Angle value in degrees (float)
  84648. */
  84649. degrees(): number;
  84650. /**
  84651. * Get value in radians
  84652. * @returns the Angle value in radians (float)
  84653. */
  84654. radians(): number;
  84655. /**
  84656. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84657. * @param a defines first point as the origin
  84658. * @param b defines point
  84659. * @returns a new Angle
  84660. */
  84661. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84662. /**
  84663. * Gets a new Angle object from the given float in radians
  84664. * @param radians defines the angle value in radians
  84665. * @returns a new Angle
  84666. */
  84667. static FromRadians(radians: number): Angle;
  84668. /**
  84669. * Gets a new Angle object from the given float in degrees
  84670. * @param degrees defines the angle value in degrees
  84671. * @returns a new Angle
  84672. */
  84673. static FromDegrees(degrees: number): Angle;
  84674. }
  84675. /**
  84676. * This represents an arc in a 2d space.
  84677. */
  84678. export class Arc2 {
  84679. /** Defines the start point of the arc */
  84680. startPoint: Vector2;
  84681. /** Defines the mid point of the arc */
  84682. midPoint: Vector2;
  84683. /** Defines the end point of the arc */
  84684. endPoint: Vector2;
  84685. /**
  84686. * Defines the center point of the arc.
  84687. */
  84688. centerPoint: Vector2;
  84689. /**
  84690. * Defines the radius of the arc.
  84691. */
  84692. radius: number;
  84693. /**
  84694. * Defines the angle of the arc (from mid point to end point).
  84695. */
  84696. angle: Angle;
  84697. /**
  84698. * Defines the start angle of the arc (from start point to middle point).
  84699. */
  84700. startAngle: Angle;
  84701. /**
  84702. * Defines the orientation of the arc (clock wise/counter clock wise).
  84703. */
  84704. orientation: Orientation;
  84705. /**
  84706. * Creates an Arc object from the three given points : start, middle and end.
  84707. * @param startPoint Defines the start point of the arc
  84708. * @param midPoint Defines the midlle point of the arc
  84709. * @param endPoint Defines the end point of the arc
  84710. */
  84711. constructor(
  84712. /** Defines the start point of the arc */
  84713. startPoint: Vector2,
  84714. /** Defines the mid point of the arc */
  84715. midPoint: Vector2,
  84716. /** Defines the end point of the arc */
  84717. endPoint: Vector2);
  84718. }
  84719. /**
  84720. * Represents a 2D path made up of multiple 2D points
  84721. */
  84722. export class Path2 {
  84723. private _points;
  84724. private _length;
  84725. /**
  84726. * If the path start and end point are the same
  84727. */
  84728. closed: boolean;
  84729. /**
  84730. * Creates a Path2 object from the starting 2D coordinates x and y.
  84731. * @param x the starting points x value
  84732. * @param y the starting points y value
  84733. */
  84734. constructor(x: number, y: number);
  84735. /**
  84736. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84737. * @param x the added points x value
  84738. * @param y the added points y value
  84739. * @returns the updated Path2.
  84740. */
  84741. addLineTo(x: number, y: number): Path2;
  84742. /**
  84743. * 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.
  84744. * @param midX middle point x value
  84745. * @param midY middle point y value
  84746. * @param endX end point x value
  84747. * @param endY end point y value
  84748. * @param numberOfSegments (default: 36)
  84749. * @returns the updated Path2.
  84750. */
  84751. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84752. /**
  84753. * Closes the Path2.
  84754. * @returns the Path2.
  84755. */
  84756. close(): Path2;
  84757. /**
  84758. * Gets the sum of the distance between each sequential point in the path
  84759. * @returns the Path2 total length (float).
  84760. */
  84761. length(): number;
  84762. /**
  84763. * Gets the points which construct the path
  84764. * @returns the Path2 internal array of points.
  84765. */
  84766. getPoints(): Vector2[];
  84767. /**
  84768. * Retreives the point at the distance aways from the starting point
  84769. * @param normalizedLengthPosition the length along the path to retreive the point from
  84770. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84771. */
  84772. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84773. /**
  84774. * Creates a new path starting from an x and y position
  84775. * @param x starting x value
  84776. * @param y starting y value
  84777. * @returns a new Path2 starting at the coordinates (x, y).
  84778. */
  84779. static StartingAt(x: number, y: number): Path2;
  84780. }
  84781. /**
  84782. * Represents a 3D path made up of multiple 3D points
  84783. */
  84784. export class Path3D {
  84785. /**
  84786. * an array of Vector3, the curve axis of the Path3D
  84787. */
  84788. path: Vector3[];
  84789. private _curve;
  84790. private _distances;
  84791. private _tangents;
  84792. private _normals;
  84793. private _binormals;
  84794. private _raw;
  84795. private _alignTangentsWithPath;
  84796. private readonly _pointAtData;
  84797. /**
  84798. * new Path3D(path, normal, raw)
  84799. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84800. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84801. * @param path an array of Vector3, the curve axis of the Path3D
  84802. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84803. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84804. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84805. */
  84806. constructor(
  84807. /**
  84808. * an array of Vector3, the curve axis of the Path3D
  84809. */
  84810. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84811. /**
  84812. * Returns the Path3D array of successive Vector3 designing its curve.
  84813. * @returns the Path3D array of successive Vector3 designing its curve.
  84814. */
  84815. getCurve(): Vector3[];
  84816. /**
  84817. * Returns the Path3D array of successive Vector3 designing its curve.
  84818. * @returns the Path3D array of successive Vector3 designing its curve.
  84819. */
  84820. getPoints(): Vector3[];
  84821. /**
  84822. * @returns the computed length (float) of the path.
  84823. */
  84824. length(): number;
  84825. /**
  84826. * Returns an array populated with tangent vectors on each Path3D curve point.
  84827. * @returns an array populated with tangent vectors on each Path3D curve point.
  84828. */
  84829. getTangents(): Vector3[];
  84830. /**
  84831. * Returns an array populated with normal vectors on each Path3D curve point.
  84832. * @returns an array populated with normal vectors on each Path3D curve point.
  84833. */
  84834. getNormals(): Vector3[];
  84835. /**
  84836. * Returns an array populated with binormal vectors on each Path3D curve point.
  84837. * @returns an array populated with binormal vectors on each Path3D curve point.
  84838. */
  84839. getBinormals(): Vector3[];
  84840. /**
  84841. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84842. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84843. */
  84844. getDistances(): number[];
  84845. /**
  84846. * Returns an interpolated point along this path
  84847. * @param position the position of the point along this path, from 0.0 to 1.0
  84848. * @returns a new Vector3 as the point
  84849. */
  84850. getPointAt(position: number): Vector3;
  84851. /**
  84852. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84853. * @param position the position of the point along this path, from 0.0 to 1.0
  84854. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84855. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84856. */
  84857. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84858. /**
  84859. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84860. * @param position the position of the point along this path, from 0.0 to 1.0
  84861. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84862. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84863. */
  84864. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84865. /**
  84866. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84867. * @param position the position of the point along this path, from 0.0 to 1.0
  84868. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84869. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84870. */
  84871. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84872. /**
  84873. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84874. * @param position the position of the point along this path, from 0.0 to 1.0
  84875. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84876. */
  84877. getDistanceAt(position: number): number;
  84878. /**
  84879. * Returns the array index of the previous point of an interpolated point along this path
  84880. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84881. * @returns the array index
  84882. */
  84883. getPreviousPointIndexAt(position: number): number;
  84884. /**
  84885. * 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)
  84886. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84887. * @returns the sub position
  84888. */
  84889. getSubPositionAt(position: number): number;
  84890. /**
  84891. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84892. * @param target the vector of which to get the closest position to
  84893. * @returns the position of the closest virtual point on this path to the target vector
  84894. */
  84895. getClosestPositionTo(target: Vector3): number;
  84896. /**
  84897. * Returns a sub path (slice) of this path
  84898. * @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
  84899. * @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
  84900. * @returns a sub path (slice) of this path
  84901. */
  84902. slice(start?: number, end?: number): Path3D;
  84903. /**
  84904. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84905. * @param path path which all values are copied into the curves points
  84906. * @param firstNormal which should be projected onto the curve
  84907. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84908. * @returns the same object updated.
  84909. */
  84910. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84911. private _compute;
  84912. private _getFirstNonNullVector;
  84913. private _getLastNonNullVector;
  84914. private _normalVector;
  84915. /**
  84916. * Updates the point at data for an interpolated point along this curve
  84917. * @param position the position of the point along this curve, from 0.0 to 1.0
  84918. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84919. * @returns the (updated) point at data
  84920. */
  84921. private _updatePointAtData;
  84922. /**
  84923. * Updates the point at data from the specified parameters
  84924. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84925. * @param point the interpolated point
  84926. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84927. */
  84928. private _setPointAtData;
  84929. /**
  84930. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84931. */
  84932. private _updateInterpolationMatrix;
  84933. }
  84934. /**
  84935. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84936. * A Curve3 is designed from a series of successive Vector3.
  84937. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84938. */
  84939. export class Curve3 {
  84940. private _points;
  84941. private _length;
  84942. /**
  84943. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84944. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84945. * @param v1 (Vector3) the control point
  84946. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84947. * @param nbPoints (integer) the wanted number of points in the curve
  84948. * @returns the created Curve3
  84949. */
  84950. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84951. /**
  84952. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84953. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84954. * @param v1 (Vector3) the first control point
  84955. * @param v2 (Vector3) the second control point
  84956. * @param v3 (Vector3) the end point of the Cubic Bezier
  84957. * @param nbPoints (integer) the wanted number of points in the curve
  84958. * @returns the created Curve3
  84959. */
  84960. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84961. /**
  84962. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84963. * @param p1 (Vector3) the origin point of the Hermite Spline
  84964. * @param t1 (Vector3) the tangent vector at the origin point
  84965. * @param p2 (Vector3) the end point of the Hermite Spline
  84966. * @param t2 (Vector3) the tangent vector at the end point
  84967. * @param nbPoints (integer) the wanted number of points in the curve
  84968. * @returns the created Curve3
  84969. */
  84970. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84971. /**
  84972. * Returns a Curve3 object along a CatmullRom Spline curve :
  84973. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84974. * @param nbPoints (integer) the wanted number of points between each curve control points
  84975. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84976. * @returns the created Curve3
  84977. */
  84978. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84979. /**
  84980. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84981. * A Curve3 is designed from a series of successive Vector3.
  84982. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84983. * @param points points which make up the curve
  84984. */
  84985. constructor(points: Vector3[]);
  84986. /**
  84987. * @returns the Curve3 stored array of successive Vector3
  84988. */
  84989. getPoints(): Vector3[];
  84990. /**
  84991. * @returns the computed length (float) of the curve.
  84992. */
  84993. length(): number;
  84994. /**
  84995. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84996. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84997. * curveA and curveB keep unchanged.
  84998. * @param curve the curve to continue from this curve
  84999. * @returns the newly constructed curve
  85000. */
  85001. continue(curve: DeepImmutable<Curve3>): Curve3;
  85002. private _computeLength;
  85003. }
  85004. }
  85005. declare module BABYLON {
  85006. /**
  85007. * This represents the main contract an easing function should follow.
  85008. * Easing functions are used throughout the animation system.
  85009. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85010. */
  85011. export interface IEasingFunction {
  85012. /**
  85013. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85014. * of the easing function.
  85015. * The link below provides some of the most common examples of easing functions.
  85016. * @see https://easings.net/
  85017. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85018. * @returns the corresponding value on the curve defined by the easing function
  85019. */
  85020. ease(gradient: number): number;
  85021. }
  85022. /**
  85023. * Base class used for every default easing function.
  85024. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85025. */
  85026. export class EasingFunction implements IEasingFunction {
  85027. /**
  85028. * Interpolation follows the mathematical formula associated with the easing function.
  85029. */
  85030. static readonly EASINGMODE_EASEIN: number;
  85031. /**
  85032. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85033. */
  85034. static readonly EASINGMODE_EASEOUT: number;
  85035. /**
  85036. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85037. */
  85038. static readonly EASINGMODE_EASEINOUT: number;
  85039. private _easingMode;
  85040. /**
  85041. * Sets the easing mode of the current function.
  85042. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85043. */
  85044. setEasingMode(easingMode: number): void;
  85045. /**
  85046. * Gets the current easing mode.
  85047. * @returns the easing mode
  85048. */
  85049. getEasingMode(): number;
  85050. /**
  85051. * @hidden
  85052. */
  85053. easeInCore(gradient: number): number;
  85054. /**
  85055. * Given an input gradient between 0 and 1, this returns the corresponding value
  85056. * of the easing function.
  85057. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85058. * @returns the corresponding value on the curve defined by the easing function
  85059. */
  85060. ease(gradient: number): number;
  85061. }
  85062. /**
  85063. * Easing function with a circle shape (see link below).
  85064. * @see https://easings.net/#easeInCirc
  85065. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85066. */
  85067. export class CircleEase extends EasingFunction implements IEasingFunction {
  85068. /** @hidden */
  85069. easeInCore(gradient: number): number;
  85070. }
  85071. /**
  85072. * Easing function with a ease back shape (see link below).
  85073. * @see https://easings.net/#easeInBack
  85074. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85075. */
  85076. export class BackEase extends EasingFunction implements IEasingFunction {
  85077. /** Defines the amplitude of the function */
  85078. amplitude: number;
  85079. /**
  85080. * Instantiates a back ease easing
  85081. * @see https://easings.net/#easeInBack
  85082. * @param amplitude Defines the amplitude of the function
  85083. */
  85084. constructor(
  85085. /** Defines the amplitude of the function */
  85086. amplitude?: number);
  85087. /** @hidden */
  85088. easeInCore(gradient: number): number;
  85089. }
  85090. /**
  85091. * Easing function with a bouncing shape (see link below).
  85092. * @see https://easings.net/#easeInBounce
  85093. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85094. */
  85095. export class BounceEase extends EasingFunction implements IEasingFunction {
  85096. /** Defines the number of bounces */
  85097. bounces: number;
  85098. /** Defines the amplitude of the bounce */
  85099. bounciness: number;
  85100. /**
  85101. * Instantiates a bounce easing
  85102. * @see https://easings.net/#easeInBounce
  85103. * @param bounces Defines the number of bounces
  85104. * @param bounciness Defines the amplitude of the bounce
  85105. */
  85106. constructor(
  85107. /** Defines the number of bounces */
  85108. bounces?: number,
  85109. /** Defines the amplitude of the bounce */
  85110. bounciness?: number);
  85111. /** @hidden */
  85112. easeInCore(gradient: number): number;
  85113. }
  85114. /**
  85115. * Easing function with a power of 3 shape (see link below).
  85116. * @see https://easings.net/#easeInCubic
  85117. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85118. */
  85119. export class CubicEase extends EasingFunction implements IEasingFunction {
  85120. /** @hidden */
  85121. easeInCore(gradient: number): number;
  85122. }
  85123. /**
  85124. * Easing function with an elastic shape (see link below).
  85125. * @see https://easings.net/#easeInElastic
  85126. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85127. */
  85128. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85129. /** Defines the number of oscillations*/
  85130. oscillations: number;
  85131. /** Defines the amplitude of the oscillations*/
  85132. springiness: number;
  85133. /**
  85134. * Instantiates an elastic easing function
  85135. * @see https://easings.net/#easeInElastic
  85136. * @param oscillations Defines the number of oscillations
  85137. * @param springiness Defines the amplitude of the oscillations
  85138. */
  85139. constructor(
  85140. /** Defines the number of oscillations*/
  85141. oscillations?: number,
  85142. /** Defines the amplitude of the oscillations*/
  85143. springiness?: number);
  85144. /** @hidden */
  85145. easeInCore(gradient: number): number;
  85146. }
  85147. /**
  85148. * Easing function with an exponential shape (see link below).
  85149. * @see https://easings.net/#easeInExpo
  85150. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85151. */
  85152. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85153. /** Defines the exponent of the function */
  85154. exponent: number;
  85155. /**
  85156. * Instantiates an exponential easing function
  85157. * @see https://easings.net/#easeInExpo
  85158. * @param exponent Defines the exponent of the function
  85159. */
  85160. constructor(
  85161. /** Defines the exponent of the function */
  85162. exponent?: number);
  85163. /** @hidden */
  85164. easeInCore(gradient: number): number;
  85165. }
  85166. /**
  85167. * Easing function with a power shape (see link below).
  85168. * @see https://easings.net/#easeInQuad
  85169. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85170. */
  85171. export class PowerEase extends EasingFunction implements IEasingFunction {
  85172. /** Defines the power of the function */
  85173. power: number;
  85174. /**
  85175. * Instantiates an power base easing function
  85176. * @see https://easings.net/#easeInQuad
  85177. * @param power Defines the power of the function
  85178. */
  85179. constructor(
  85180. /** Defines the power of the function */
  85181. power?: number);
  85182. /** @hidden */
  85183. easeInCore(gradient: number): number;
  85184. }
  85185. /**
  85186. * Easing function with a power of 2 shape (see link below).
  85187. * @see https://easings.net/#easeInQuad
  85188. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85189. */
  85190. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85191. /** @hidden */
  85192. easeInCore(gradient: number): number;
  85193. }
  85194. /**
  85195. * Easing function with a power of 4 shape (see link below).
  85196. * @see https://easings.net/#easeInQuart
  85197. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85198. */
  85199. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85200. /** @hidden */
  85201. easeInCore(gradient: number): number;
  85202. }
  85203. /**
  85204. * Easing function with a power of 5 shape (see link below).
  85205. * @see https://easings.net/#easeInQuint
  85206. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85207. */
  85208. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85209. /** @hidden */
  85210. easeInCore(gradient: number): number;
  85211. }
  85212. /**
  85213. * Easing function with a sin shape (see link below).
  85214. * @see https://easings.net/#easeInSine
  85215. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85216. */
  85217. export class SineEase extends EasingFunction implements IEasingFunction {
  85218. /** @hidden */
  85219. easeInCore(gradient: number): number;
  85220. }
  85221. /**
  85222. * Easing function with a bezier shape (see link below).
  85223. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85224. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85225. */
  85226. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85227. /** Defines the x component of the start tangent in the bezier curve */
  85228. x1: number;
  85229. /** Defines the y component of the start tangent in the bezier curve */
  85230. y1: number;
  85231. /** Defines the x component of the end tangent in the bezier curve */
  85232. x2: number;
  85233. /** Defines the y component of the end tangent in the bezier curve */
  85234. y2: number;
  85235. /**
  85236. * Instantiates a bezier function
  85237. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85238. * @param x1 Defines the x component of the start tangent in the bezier curve
  85239. * @param y1 Defines the y component of the start tangent in the bezier curve
  85240. * @param x2 Defines the x component of the end tangent in the bezier curve
  85241. * @param y2 Defines the y component of the end tangent in the bezier curve
  85242. */
  85243. constructor(
  85244. /** Defines the x component of the start tangent in the bezier curve */
  85245. x1?: number,
  85246. /** Defines the y component of the start tangent in the bezier curve */
  85247. y1?: number,
  85248. /** Defines the x component of the end tangent in the bezier curve */
  85249. x2?: number,
  85250. /** Defines the y component of the end tangent in the bezier curve */
  85251. y2?: number);
  85252. /** @hidden */
  85253. easeInCore(gradient: number): number;
  85254. }
  85255. }
  85256. declare module BABYLON {
  85257. /**
  85258. * Class used to hold a RBG color
  85259. */
  85260. export class Color3 {
  85261. /**
  85262. * Defines the red component (between 0 and 1, default is 0)
  85263. */
  85264. r: number;
  85265. /**
  85266. * Defines the green component (between 0 and 1, default is 0)
  85267. */
  85268. g: number;
  85269. /**
  85270. * Defines the blue component (between 0 and 1, default is 0)
  85271. */
  85272. b: number;
  85273. /**
  85274. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85275. * @param r defines the red component (between 0 and 1, default is 0)
  85276. * @param g defines the green component (between 0 and 1, default is 0)
  85277. * @param b defines the blue component (between 0 and 1, default is 0)
  85278. */
  85279. constructor(
  85280. /**
  85281. * Defines the red component (between 0 and 1, default is 0)
  85282. */
  85283. r?: number,
  85284. /**
  85285. * Defines the green component (between 0 and 1, default is 0)
  85286. */
  85287. g?: number,
  85288. /**
  85289. * Defines the blue component (between 0 and 1, default is 0)
  85290. */
  85291. b?: number);
  85292. /**
  85293. * Creates a string with the Color3 current values
  85294. * @returns the string representation of the Color3 object
  85295. */
  85296. toString(): string;
  85297. /**
  85298. * Returns the string "Color3"
  85299. * @returns "Color3"
  85300. */
  85301. getClassName(): string;
  85302. /**
  85303. * Compute the Color3 hash code
  85304. * @returns an unique number that can be used to hash Color3 objects
  85305. */
  85306. getHashCode(): number;
  85307. /**
  85308. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85309. * @param array defines the array where to store the r,g,b components
  85310. * @param index defines an optional index in the target array to define where to start storing values
  85311. * @returns the current Color3 object
  85312. */
  85313. toArray(array: FloatArray, index?: number): Color3;
  85314. /**
  85315. * Update the current color with values stored in an array from the starting index of the given array
  85316. * @param array defines the source array
  85317. * @param offset defines an offset in the source array
  85318. * @returns the current Color3 object
  85319. */
  85320. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85321. /**
  85322. * Returns a new Color4 object from the current Color3 and the given alpha
  85323. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85324. * @returns a new Color4 object
  85325. */
  85326. toColor4(alpha?: number): Color4;
  85327. /**
  85328. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85329. * @returns the new array
  85330. */
  85331. asArray(): number[];
  85332. /**
  85333. * Returns the luminance value
  85334. * @returns a float value
  85335. */
  85336. toLuminance(): number;
  85337. /**
  85338. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85339. * @param otherColor defines the second operand
  85340. * @returns the new Color3 object
  85341. */
  85342. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85343. /**
  85344. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85345. * @param otherColor defines the second operand
  85346. * @param result defines the Color3 object where to store the result
  85347. * @returns the current Color3
  85348. */
  85349. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85350. /**
  85351. * Determines equality between Color3 objects
  85352. * @param otherColor defines the second operand
  85353. * @returns true if the rgb values are equal to the given ones
  85354. */
  85355. equals(otherColor: DeepImmutable<Color3>): boolean;
  85356. /**
  85357. * Determines equality between the current Color3 object and a set of r,b,g values
  85358. * @param r defines the red component to check
  85359. * @param g defines the green component to check
  85360. * @param b defines the blue component to check
  85361. * @returns true if the rgb values are equal to the given ones
  85362. */
  85363. equalsFloats(r: number, g: number, b: number): boolean;
  85364. /**
  85365. * Multiplies in place each rgb value by scale
  85366. * @param scale defines the scaling factor
  85367. * @returns the updated Color3
  85368. */
  85369. scale(scale: number): Color3;
  85370. /**
  85371. * Multiplies the rgb values by scale and stores the result into "result"
  85372. * @param scale defines the scaling factor
  85373. * @param result defines the Color3 object where to store the result
  85374. * @returns the unmodified current Color3
  85375. */
  85376. scaleToRef(scale: number, result: Color3): Color3;
  85377. /**
  85378. * Scale the current Color3 values by a factor and add the result to a given Color3
  85379. * @param scale defines the scale factor
  85380. * @param result defines color to store the result into
  85381. * @returns the unmodified current Color3
  85382. */
  85383. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85384. /**
  85385. * Clamps the rgb values by the min and max values and stores the result into "result"
  85386. * @param min defines minimum clamping value (default is 0)
  85387. * @param max defines maximum clamping value (default is 1)
  85388. * @param result defines color to store the result into
  85389. * @returns the original Color3
  85390. */
  85391. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85392. /**
  85393. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85394. * @param otherColor defines the second operand
  85395. * @returns the new Color3
  85396. */
  85397. add(otherColor: DeepImmutable<Color3>): Color3;
  85398. /**
  85399. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85400. * @param otherColor defines the second operand
  85401. * @param result defines Color3 object to store the result into
  85402. * @returns the unmodified current Color3
  85403. */
  85404. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85405. /**
  85406. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85407. * @param otherColor defines the second operand
  85408. * @returns the new Color3
  85409. */
  85410. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85411. /**
  85412. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85413. * @param otherColor defines the second operand
  85414. * @param result defines Color3 object to store the result into
  85415. * @returns the unmodified current Color3
  85416. */
  85417. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85418. /**
  85419. * Copy the current object
  85420. * @returns a new Color3 copied the current one
  85421. */
  85422. clone(): Color3;
  85423. /**
  85424. * Copies the rgb values from the source in the current Color3
  85425. * @param source defines the source Color3 object
  85426. * @returns the updated Color3 object
  85427. */
  85428. copyFrom(source: DeepImmutable<Color3>): Color3;
  85429. /**
  85430. * Updates the Color3 rgb values from the given floats
  85431. * @param r defines the red component to read from
  85432. * @param g defines the green component to read from
  85433. * @param b defines the blue component to read from
  85434. * @returns the current Color3 object
  85435. */
  85436. copyFromFloats(r: number, g: number, b: number): Color3;
  85437. /**
  85438. * Updates the Color3 rgb values from the given floats
  85439. * @param r defines the red component to read from
  85440. * @param g defines the green component to read from
  85441. * @param b defines the blue component to read from
  85442. * @returns the current Color3 object
  85443. */
  85444. set(r: number, g: number, b: number): Color3;
  85445. /**
  85446. * Compute the Color3 hexadecimal code as a string
  85447. * @returns a string containing the hexadecimal representation of the Color3 object
  85448. */
  85449. toHexString(): string;
  85450. /**
  85451. * Computes a new Color3 converted from the current one to linear space
  85452. * @returns a new Color3 object
  85453. */
  85454. toLinearSpace(): Color3;
  85455. /**
  85456. * Converts current color in rgb space to HSV values
  85457. * @returns a new color3 representing the HSV values
  85458. */
  85459. toHSV(): Color3;
  85460. /**
  85461. * Converts current color in rgb space to HSV values
  85462. * @param result defines the Color3 where to store the HSV values
  85463. */
  85464. toHSVToRef(result: Color3): void;
  85465. /**
  85466. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85467. * @param convertedColor defines the Color3 object where to store the linear space version
  85468. * @returns the unmodified Color3
  85469. */
  85470. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85471. /**
  85472. * Computes a new Color3 converted from the current one to gamma space
  85473. * @returns a new Color3 object
  85474. */
  85475. toGammaSpace(): Color3;
  85476. /**
  85477. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85478. * @param convertedColor defines the Color3 object where to store the gamma space version
  85479. * @returns the unmodified Color3
  85480. */
  85481. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85482. private static _BlackReadOnly;
  85483. /**
  85484. * Convert Hue, saturation and value to a Color3 (RGB)
  85485. * @param hue defines the hue
  85486. * @param saturation defines the saturation
  85487. * @param value defines the value
  85488. * @param result defines the Color3 where to store the RGB values
  85489. */
  85490. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85491. /**
  85492. * Creates a new Color3 from the string containing valid hexadecimal values
  85493. * @param hex defines a string containing valid hexadecimal values
  85494. * @returns a new Color3 object
  85495. */
  85496. static FromHexString(hex: string): Color3;
  85497. /**
  85498. * Creates a new Color3 from the starting index of the given array
  85499. * @param array defines the source array
  85500. * @param offset defines an offset in the source array
  85501. * @returns a new Color3 object
  85502. */
  85503. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85504. /**
  85505. * Creates a new Color3 from the starting index element of the given array
  85506. * @param array defines the source array to read from
  85507. * @param offset defines the offset in the source array
  85508. * @param result defines the target Color3 object
  85509. */
  85510. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85511. /**
  85512. * Creates a new Color3 from integer values (< 256)
  85513. * @param r defines the red component to read from (value between 0 and 255)
  85514. * @param g defines the green component to read from (value between 0 and 255)
  85515. * @param b defines the blue component to read from (value between 0 and 255)
  85516. * @returns a new Color3 object
  85517. */
  85518. static FromInts(r: number, g: number, b: number): Color3;
  85519. /**
  85520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85521. * @param start defines the start Color3 value
  85522. * @param end defines the end Color3 value
  85523. * @param amount defines the gradient value between start and end
  85524. * @returns a new Color3 object
  85525. */
  85526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85527. /**
  85528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85529. * @param left defines the start value
  85530. * @param right defines the end value
  85531. * @param amount defines the gradient factor
  85532. * @param result defines the Color3 object where to store the result
  85533. */
  85534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85535. /**
  85536. * Returns a Color3 value containing a red color
  85537. * @returns a new Color3 object
  85538. */
  85539. static Red(): Color3;
  85540. /**
  85541. * Returns a Color3 value containing a green color
  85542. * @returns a new Color3 object
  85543. */
  85544. static Green(): Color3;
  85545. /**
  85546. * Returns a Color3 value containing a blue color
  85547. * @returns a new Color3 object
  85548. */
  85549. static Blue(): Color3;
  85550. /**
  85551. * Returns a Color3 value containing a black color
  85552. * @returns a new Color3 object
  85553. */
  85554. static Black(): Color3;
  85555. /**
  85556. * Gets a Color3 value containing a black color that must not be updated
  85557. */
  85558. static get BlackReadOnly(): DeepImmutable<Color3>;
  85559. /**
  85560. * Returns a Color3 value containing a white color
  85561. * @returns a new Color3 object
  85562. */
  85563. static White(): Color3;
  85564. /**
  85565. * Returns a Color3 value containing a purple color
  85566. * @returns a new Color3 object
  85567. */
  85568. static Purple(): Color3;
  85569. /**
  85570. * Returns a Color3 value containing a magenta color
  85571. * @returns a new Color3 object
  85572. */
  85573. static Magenta(): Color3;
  85574. /**
  85575. * Returns a Color3 value containing a yellow color
  85576. * @returns a new Color3 object
  85577. */
  85578. static Yellow(): Color3;
  85579. /**
  85580. * Returns a Color3 value containing a gray color
  85581. * @returns a new Color3 object
  85582. */
  85583. static Gray(): Color3;
  85584. /**
  85585. * Returns a Color3 value containing a teal color
  85586. * @returns a new Color3 object
  85587. */
  85588. static Teal(): Color3;
  85589. /**
  85590. * Returns a Color3 value containing a random color
  85591. * @returns a new Color3 object
  85592. */
  85593. static Random(): Color3;
  85594. }
  85595. /**
  85596. * Class used to hold a RBGA color
  85597. */
  85598. export class Color4 {
  85599. /**
  85600. * Defines the red component (between 0 and 1, default is 0)
  85601. */
  85602. r: number;
  85603. /**
  85604. * Defines the green component (between 0 and 1, default is 0)
  85605. */
  85606. g: number;
  85607. /**
  85608. * Defines the blue component (between 0 and 1, default is 0)
  85609. */
  85610. b: number;
  85611. /**
  85612. * Defines the alpha component (between 0 and 1, default is 1)
  85613. */
  85614. a: number;
  85615. /**
  85616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85617. * @param r defines the red component (between 0 and 1, default is 0)
  85618. * @param g defines the green component (between 0 and 1, default is 0)
  85619. * @param b defines the blue component (between 0 and 1, default is 0)
  85620. * @param a defines the alpha component (between 0 and 1, default is 1)
  85621. */
  85622. constructor(
  85623. /**
  85624. * Defines the red component (between 0 and 1, default is 0)
  85625. */
  85626. r?: number,
  85627. /**
  85628. * Defines the green component (between 0 and 1, default is 0)
  85629. */
  85630. g?: number,
  85631. /**
  85632. * Defines the blue component (between 0 and 1, default is 0)
  85633. */
  85634. b?: number,
  85635. /**
  85636. * Defines the alpha component (between 0 and 1, default is 1)
  85637. */
  85638. a?: number);
  85639. /**
  85640. * Adds in place the given Color4 values to the current Color4 object
  85641. * @param right defines the second operand
  85642. * @returns the current updated Color4 object
  85643. */
  85644. addInPlace(right: DeepImmutable<Color4>): Color4;
  85645. /**
  85646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85647. * @returns the new array
  85648. */
  85649. asArray(): number[];
  85650. /**
  85651. * Stores from the starting index in the given array the Color4 successive values
  85652. * @param array defines the array where to store the r,g,b components
  85653. * @param index defines an optional index in the target array to define where to start storing values
  85654. * @returns the current Color4 object
  85655. */
  85656. toArray(array: number[], index?: number): Color4;
  85657. /**
  85658. * Update the current color with values stored in an array from the starting index of the given array
  85659. * @param array defines the source array
  85660. * @param offset defines an offset in the source array
  85661. * @returns the current Color4 object
  85662. */
  85663. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85664. /**
  85665. * Determines equality between Color4 objects
  85666. * @param otherColor defines the second operand
  85667. * @returns true if the rgba values are equal to the given ones
  85668. */
  85669. equals(otherColor: DeepImmutable<Color4>): boolean;
  85670. /**
  85671. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85672. * @param right defines the second operand
  85673. * @returns a new Color4 object
  85674. */
  85675. add(right: DeepImmutable<Color4>): Color4;
  85676. /**
  85677. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85678. * @param right defines the second operand
  85679. * @returns a new Color4 object
  85680. */
  85681. subtract(right: DeepImmutable<Color4>): Color4;
  85682. /**
  85683. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85684. * @param right defines the second operand
  85685. * @param result defines the Color4 object where to store the result
  85686. * @returns the current Color4 object
  85687. */
  85688. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85689. /**
  85690. * Creates a new Color4 with the current Color4 values multiplied by scale
  85691. * @param scale defines the scaling factor to apply
  85692. * @returns a new Color4 object
  85693. */
  85694. scale(scale: number): Color4;
  85695. /**
  85696. * Multiplies the current Color4 values by scale and stores the result in "result"
  85697. * @param scale defines the scaling factor to apply
  85698. * @param result defines the Color4 object where to store the result
  85699. * @returns the current unmodified Color4
  85700. */
  85701. scaleToRef(scale: number, result: Color4): Color4;
  85702. /**
  85703. * Scale the current Color4 values by a factor and add the result to a given Color4
  85704. * @param scale defines the scale factor
  85705. * @param result defines the Color4 object where to store the result
  85706. * @returns the unmodified current Color4
  85707. */
  85708. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85709. /**
  85710. * Clamps the rgb values by the min and max values and stores the result into "result"
  85711. * @param min defines minimum clamping value (default is 0)
  85712. * @param max defines maximum clamping value (default is 1)
  85713. * @param result defines color to store the result into.
  85714. * @returns the cuurent Color4
  85715. */
  85716. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85717. /**
  85718. * Multipy an Color4 value by another and return a new Color4 object
  85719. * @param color defines the Color4 value to multiply by
  85720. * @returns a new Color4 object
  85721. */
  85722. multiply(color: Color4): Color4;
  85723. /**
  85724. * Multipy a Color4 value by another and push the result in a reference value
  85725. * @param color defines the Color4 value to multiply by
  85726. * @param result defines the Color4 to fill the result in
  85727. * @returns the result Color4
  85728. */
  85729. multiplyToRef(color: Color4, result: Color4): Color4;
  85730. /**
  85731. * Creates a string with the Color4 current values
  85732. * @returns the string representation of the Color4 object
  85733. */
  85734. toString(): string;
  85735. /**
  85736. * Returns the string "Color4"
  85737. * @returns "Color4"
  85738. */
  85739. getClassName(): string;
  85740. /**
  85741. * Compute the Color4 hash code
  85742. * @returns an unique number that can be used to hash Color4 objects
  85743. */
  85744. getHashCode(): number;
  85745. /**
  85746. * Creates a new Color4 copied from the current one
  85747. * @returns a new Color4 object
  85748. */
  85749. clone(): Color4;
  85750. /**
  85751. * Copies the given Color4 values into the current one
  85752. * @param source defines the source Color4 object
  85753. * @returns the current updated Color4 object
  85754. */
  85755. copyFrom(source: Color4): Color4;
  85756. /**
  85757. * Copies the given float values into the current one
  85758. * @param r defines the red component to read from
  85759. * @param g defines the green component to read from
  85760. * @param b defines the blue component to read from
  85761. * @param a defines the alpha component to read from
  85762. * @returns the current updated Color4 object
  85763. */
  85764. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85765. /**
  85766. * Copies the given float values into the current one
  85767. * @param r defines the red component to read from
  85768. * @param g defines the green component to read from
  85769. * @param b defines the blue component to read from
  85770. * @param a defines the alpha component to read from
  85771. * @returns the current updated Color4 object
  85772. */
  85773. set(r: number, g: number, b: number, a: number): Color4;
  85774. /**
  85775. * Compute the Color4 hexadecimal code as a string
  85776. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85777. * @returns a string containing the hexadecimal representation of the Color4 object
  85778. */
  85779. toHexString(returnAsColor3?: boolean): string;
  85780. /**
  85781. * Computes a new Color4 converted from the current one to linear space
  85782. * @returns a new Color4 object
  85783. */
  85784. toLinearSpace(): Color4;
  85785. /**
  85786. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85787. * @param convertedColor defines the Color4 object where to store the linear space version
  85788. * @returns the unmodified Color4
  85789. */
  85790. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85791. /**
  85792. * Computes a new Color4 converted from the current one to gamma space
  85793. * @returns a new Color4 object
  85794. */
  85795. toGammaSpace(): Color4;
  85796. /**
  85797. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85798. * @param convertedColor defines the Color4 object where to store the gamma space version
  85799. * @returns the unmodified Color4
  85800. */
  85801. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85802. /**
  85803. * Creates a new Color4 from the string containing valid hexadecimal values
  85804. * @param hex defines a string containing valid hexadecimal values
  85805. * @returns a new Color4 object
  85806. */
  85807. static FromHexString(hex: string): Color4;
  85808. /**
  85809. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85810. * @param left defines the start value
  85811. * @param right defines the end value
  85812. * @param amount defines the gradient factor
  85813. * @returns a new Color4 object
  85814. */
  85815. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85816. /**
  85817. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85818. * @param left defines the start value
  85819. * @param right defines the end value
  85820. * @param amount defines the gradient factor
  85821. * @param result defines the Color4 object where to store data
  85822. */
  85823. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85824. /**
  85825. * Creates a new Color4 from a Color3 and an alpha value
  85826. * @param color3 defines the source Color3 to read from
  85827. * @param alpha defines the alpha component (1.0 by default)
  85828. * @returns a new Color4 object
  85829. */
  85830. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85831. /**
  85832. * Creates a new Color4 from the starting index element of the given array
  85833. * @param array defines the source array to read from
  85834. * @param offset defines the offset in the source array
  85835. * @returns a new Color4 object
  85836. */
  85837. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85838. /**
  85839. * Creates a new Color4 from the starting index element of the given array
  85840. * @param array defines the source array to read from
  85841. * @param offset defines the offset in the source array
  85842. * @param result defines the target Color4 object
  85843. */
  85844. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85845. /**
  85846. * Creates a new Color3 from integer values (< 256)
  85847. * @param r defines the red component to read from (value between 0 and 255)
  85848. * @param g defines the green component to read from (value between 0 and 255)
  85849. * @param b defines the blue component to read from (value between 0 and 255)
  85850. * @param a defines the alpha component to read from (value between 0 and 255)
  85851. * @returns a new Color3 object
  85852. */
  85853. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85854. /**
  85855. * Check the content of a given array and convert it to an array containing RGBA data
  85856. * If the original array was already containing count * 4 values then it is returned directly
  85857. * @param colors defines the array to check
  85858. * @param count defines the number of RGBA data to expect
  85859. * @returns an array containing count * 4 values (RGBA)
  85860. */
  85861. static CheckColors4(colors: number[], count: number): number[];
  85862. }
  85863. /**
  85864. * @hidden
  85865. */
  85866. export class TmpColors {
  85867. static Color3: Color3[];
  85868. static Color4: Color4[];
  85869. }
  85870. }
  85871. declare module BABYLON {
  85872. /**
  85873. * Defines an interface which represents an animation key frame
  85874. */
  85875. export interface IAnimationKey {
  85876. /**
  85877. * Frame of the key frame
  85878. */
  85879. frame: number;
  85880. /**
  85881. * Value at the specifies key frame
  85882. */
  85883. value: any;
  85884. /**
  85885. * The input tangent for the cubic hermite spline
  85886. */
  85887. inTangent?: any;
  85888. /**
  85889. * The output tangent for the cubic hermite spline
  85890. */
  85891. outTangent?: any;
  85892. /**
  85893. * The animation interpolation type
  85894. */
  85895. interpolation?: AnimationKeyInterpolation;
  85896. }
  85897. /**
  85898. * Enum for the animation key frame interpolation type
  85899. */
  85900. export enum AnimationKeyInterpolation {
  85901. /**
  85902. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85903. */
  85904. STEP = 1
  85905. }
  85906. }
  85907. declare module BABYLON {
  85908. /**
  85909. * Represents the range of an animation
  85910. */
  85911. export class AnimationRange {
  85912. /**The name of the animation range**/
  85913. name: string;
  85914. /**The starting frame of the animation */
  85915. from: number;
  85916. /**The ending frame of the animation*/
  85917. to: number;
  85918. /**
  85919. * Initializes the range of an animation
  85920. * @param name The name of the animation range
  85921. * @param from The starting frame of the animation
  85922. * @param to The ending frame of the animation
  85923. */
  85924. constructor(
  85925. /**The name of the animation range**/
  85926. name: string,
  85927. /**The starting frame of the animation */
  85928. from: number,
  85929. /**The ending frame of the animation*/
  85930. to: number);
  85931. /**
  85932. * Makes a copy of the animation range
  85933. * @returns A copy of the animation range
  85934. */
  85935. clone(): AnimationRange;
  85936. }
  85937. }
  85938. declare module BABYLON {
  85939. /**
  85940. * Composed of a frame, and an action function
  85941. */
  85942. export class AnimationEvent {
  85943. /** The frame for which the event is triggered **/
  85944. frame: number;
  85945. /** The event to perform when triggered **/
  85946. action: (currentFrame: number) => void;
  85947. /** Specifies if the event should be triggered only once**/
  85948. onlyOnce?: boolean | undefined;
  85949. /**
  85950. * Specifies if the animation event is done
  85951. */
  85952. isDone: boolean;
  85953. /**
  85954. * Initializes the animation event
  85955. * @param frame The frame for which the event is triggered
  85956. * @param action The event to perform when triggered
  85957. * @param onlyOnce Specifies if the event should be triggered only once
  85958. */
  85959. constructor(
  85960. /** The frame for which the event is triggered **/
  85961. frame: number,
  85962. /** The event to perform when triggered **/
  85963. action: (currentFrame: number) => void,
  85964. /** Specifies if the event should be triggered only once**/
  85965. onlyOnce?: boolean | undefined);
  85966. /** @hidden */
  85967. _clone(): AnimationEvent;
  85968. }
  85969. }
  85970. declare module BABYLON {
  85971. /**
  85972. * Interface used to define a behavior
  85973. */
  85974. export interface Behavior<T> {
  85975. /** gets or sets behavior's name */
  85976. name: string;
  85977. /**
  85978. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85979. */
  85980. init(): void;
  85981. /**
  85982. * Called when the behavior is attached to a target
  85983. * @param target defines the target where the behavior is attached to
  85984. */
  85985. attach(target: T): void;
  85986. /**
  85987. * Called when the behavior is detached from its target
  85988. */
  85989. detach(): void;
  85990. }
  85991. /**
  85992. * Interface implemented by classes supporting behaviors
  85993. */
  85994. export interface IBehaviorAware<T> {
  85995. /**
  85996. * Attach a behavior
  85997. * @param behavior defines the behavior to attach
  85998. * @returns the current host
  85999. */
  86000. addBehavior(behavior: Behavior<T>): T;
  86001. /**
  86002. * Remove a behavior from the current object
  86003. * @param behavior defines the behavior to detach
  86004. * @returns the current host
  86005. */
  86006. removeBehavior(behavior: Behavior<T>): T;
  86007. /**
  86008. * Gets a behavior using its name to search
  86009. * @param name defines the name to search
  86010. * @returns the behavior or null if not found
  86011. */
  86012. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86013. }
  86014. }
  86015. declare module BABYLON {
  86016. /**
  86017. * Defines an array and its length.
  86018. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86019. */
  86020. export interface ISmartArrayLike<T> {
  86021. /**
  86022. * The data of the array.
  86023. */
  86024. data: Array<T>;
  86025. /**
  86026. * The active length of the array.
  86027. */
  86028. length: number;
  86029. }
  86030. /**
  86031. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86032. */
  86033. export class SmartArray<T> implements ISmartArrayLike<T> {
  86034. /**
  86035. * The full set of data from the array.
  86036. */
  86037. data: Array<T>;
  86038. /**
  86039. * The active length of the array.
  86040. */
  86041. length: number;
  86042. protected _id: number;
  86043. /**
  86044. * Instantiates a Smart Array.
  86045. * @param capacity defines the default capacity of the array.
  86046. */
  86047. constructor(capacity: number);
  86048. /**
  86049. * Pushes a value at the end of the active data.
  86050. * @param value defines the object to push in the array.
  86051. */
  86052. push(value: T): void;
  86053. /**
  86054. * Iterates over the active data and apply the lambda to them.
  86055. * @param func defines the action to apply on each value.
  86056. */
  86057. forEach(func: (content: T) => void): void;
  86058. /**
  86059. * Sorts the full sets of data.
  86060. * @param compareFn defines the comparison function to apply.
  86061. */
  86062. sort(compareFn: (a: T, b: T) => number): void;
  86063. /**
  86064. * Resets the active data to an empty array.
  86065. */
  86066. reset(): void;
  86067. /**
  86068. * Releases all the data from the array as well as the array.
  86069. */
  86070. dispose(): void;
  86071. /**
  86072. * Concats the active data with a given array.
  86073. * @param array defines the data to concatenate with.
  86074. */
  86075. concat(array: any): void;
  86076. /**
  86077. * Returns the position of a value in the active data.
  86078. * @param value defines the value to find the index for
  86079. * @returns the index if found in the active data otherwise -1
  86080. */
  86081. indexOf(value: T): number;
  86082. /**
  86083. * Returns whether an element is part of the active data.
  86084. * @param value defines the value to look for
  86085. * @returns true if found in the active data otherwise false
  86086. */
  86087. contains(value: T): boolean;
  86088. private static _GlobalId;
  86089. }
  86090. /**
  86091. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86092. * The data in this array can only be present once
  86093. */
  86094. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86095. private _duplicateId;
  86096. /**
  86097. * Pushes a value at the end of the active data.
  86098. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86099. * @param value defines the object to push in the array.
  86100. */
  86101. push(value: T): void;
  86102. /**
  86103. * Pushes a value at the end of the active data.
  86104. * If the data is already present, it won t be added again
  86105. * @param value defines the object to push in the array.
  86106. * @returns true if added false if it was already present
  86107. */
  86108. pushNoDuplicate(value: T): boolean;
  86109. /**
  86110. * Resets the active data to an empty array.
  86111. */
  86112. reset(): void;
  86113. /**
  86114. * Concats the active data with a given array.
  86115. * This ensures no dupplicate will be present in the result.
  86116. * @param array defines the data to concatenate with.
  86117. */
  86118. concatWithNoDuplicate(array: any): void;
  86119. }
  86120. }
  86121. declare module BABYLON {
  86122. /**
  86123. * @ignore
  86124. * This is a list of all the different input types that are available in the application.
  86125. * Fo instance: ArcRotateCameraGamepadInput...
  86126. */
  86127. export var CameraInputTypes: {};
  86128. /**
  86129. * This is the contract to implement in order to create a new input class.
  86130. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86131. */
  86132. export interface ICameraInput<TCamera extends Camera> {
  86133. /**
  86134. * Defines the camera the input is attached to.
  86135. */
  86136. camera: Nullable<TCamera>;
  86137. /**
  86138. * Gets the class name of the current intput.
  86139. * @returns the class name
  86140. */
  86141. getClassName(): string;
  86142. /**
  86143. * Get the friendly name associated with the input class.
  86144. * @returns the input friendly name
  86145. */
  86146. getSimpleName(): string;
  86147. /**
  86148. * Attach the input controls to a specific dom element to get the input from.
  86149. * @param element Defines the element the controls should be listened from
  86150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86151. */
  86152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86153. /**
  86154. * Detach the current controls from the specified dom element.
  86155. * @param element Defines the element to stop listening the inputs from
  86156. */
  86157. detachControl(element: Nullable<HTMLElement>): void;
  86158. /**
  86159. * Update the current camera state depending on the inputs that have been used this frame.
  86160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86161. */
  86162. checkInputs?: () => void;
  86163. }
  86164. /**
  86165. * Represents a map of input types to input instance or input index to input instance.
  86166. */
  86167. export interface CameraInputsMap<TCamera extends Camera> {
  86168. /**
  86169. * Accessor to the input by input type.
  86170. */
  86171. [name: string]: ICameraInput<TCamera>;
  86172. /**
  86173. * Accessor to the input by input index.
  86174. */
  86175. [idx: number]: ICameraInput<TCamera>;
  86176. }
  86177. /**
  86178. * This represents the input manager used within a camera.
  86179. * It helps dealing with all the different kind of input attached to a camera.
  86180. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86181. */
  86182. export class CameraInputsManager<TCamera extends Camera> {
  86183. /**
  86184. * Defines the list of inputs attahed to the camera.
  86185. */
  86186. attached: CameraInputsMap<TCamera>;
  86187. /**
  86188. * Defines the dom element the camera is collecting inputs from.
  86189. * This is null if the controls have not been attached.
  86190. */
  86191. attachedElement: Nullable<HTMLElement>;
  86192. /**
  86193. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86194. */
  86195. noPreventDefault: boolean;
  86196. /**
  86197. * Defined the camera the input manager belongs to.
  86198. */
  86199. camera: TCamera;
  86200. /**
  86201. * Update the current camera state depending on the inputs that have been used this frame.
  86202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86203. */
  86204. checkInputs: () => void;
  86205. /**
  86206. * Instantiate a new Camera Input Manager.
  86207. * @param camera Defines the camera the input manager blongs to
  86208. */
  86209. constructor(camera: TCamera);
  86210. /**
  86211. * Add an input method to a camera
  86212. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86213. * @param input camera input method
  86214. */
  86215. add(input: ICameraInput<TCamera>): void;
  86216. /**
  86217. * Remove a specific input method from a camera
  86218. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86219. * @param inputToRemove camera input method
  86220. */
  86221. remove(inputToRemove: ICameraInput<TCamera>): void;
  86222. /**
  86223. * Remove a specific input type from a camera
  86224. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86225. * @param inputType the type of the input to remove
  86226. */
  86227. removeByType(inputType: string): void;
  86228. private _addCheckInputs;
  86229. /**
  86230. * Attach the input controls to the currently attached dom element to listen the events from.
  86231. * @param input Defines the input to attach
  86232. */
  86233. attachInput(input: ICameraInput<TCamera>): void;
  86234. /**
  86235. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86236. * @param element Defines the dom element to collect the events from
  86237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86238. */
  86239. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86240. /**
  86241. * Detach the current manager inputs controls from a specific dom element.
  86242. * @param element Defines the dom element to collect the events from
  86243. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86244. */
  86245. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86246. /**
  86247. * Rebuild the dynamic inputCheck function from the current list of
  86248. * defined inputs in the manager.
  86249. */
  86250. rebuildInputCheck(): void;
  86251. /**
  86252. * Remove all attached input methods from a camera
  86253. */
  86254. clear(): void;
  86255. /**
  86256. * Serialize the current input manager attached to a camera.
  86257. * This ensures than once parsed,
  86258. * the input associated to the camera will be identical to the current ones
  86259. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86260. */
  86261. serialize(serializedCamera: any): void;
  86262. /**
  86263. * Parses an input manager serialized JSON to restore the previous list of inputs
  86264. * and states associated to a camera.
  86265. * @param parsedCamera Defines the JSON to parse
  86266. */
  86267. parse(parsedCamera: any): void;
  86268. }
  86269. }
  86270. declare module BABYLON {
  86271. /**
  86272. * Class used to store data that will be store in GPU memory
  86273. */
  86274. export class Buffer {
  86275. private _engine;
  86276. private _buffer;
  86277. /** @hidden */
  86278. _data: Nullable<DataArray>;
  86279. private _updatable;
  86280. private _instanced;
  86281. private _divisor;
  86282. /**
  86283. * Gets the byte stride.
  86284. */
  86285. readonly byteStride: number;
  86286. /**
  86287. * Constructor
  86288. * @param engine the engine
  86289. * @param data the data to use for this buffer
  86290. * @param updatable whether the data is updatable
  86291. * @param stride the stride (optional)
  86292. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86293. * @param instanced whether the buffer is instanced (optional)
  86294. * @param useBytes set to true if the stride in in bytes (optional)
  86295. * @param divisor sets an optional divisor for instances (1 by default)
  86296. */
  86297. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86298. /**
  86299. * Create a new VertexBuffer based on the current buffer
  86300. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86301. * @param offset defines offset in the buffer (0 by default)
  86302. * @param size defines the size in floats of attributes (position is 3 for instance)
  86303. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86304. * @param instanced defines if the vertex buffer contains indexed data
  86305. * @param useBytes defines if the offset and stride are in bytes *
  86306. * @param divisor sets an optional divisor for instances (1 by default)
  86307. * @returns the new vertex buffer
  86308. */
  86309. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86310. /**
  86311. * Gets a boolean indicating if the Buffer is updatable?
  86312. * @returns true if the buffer is updatable
  86313. */
  86314. isUpdatable(): boolean;
  86315. /**
  86316. * Gets current buffer's data
  86317. * @returns a DataArray or null
  86318. */
  86319. getData(): Nullable<DataArray>;
  86320. /**
  86321. * Gets underlying native buffer
  86322. * @returns underlying native buffer
  86323. */
  86324. getBuffer(): Nullable<DataBuffer>;
  86325. /**
  86326. * Gets the stride in float32 units (i.e. byte stride / 4).
  86327. * May not be an integer if the byte stride is not divisible by 4.
  86328. * @returns the stride in float32 units
  86329. * @deprecated Please use byteStride instead.
  86330. */
  86331. getStrideSize(): number;
  86332. /**
  86333. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86334. * @param data defines the data to store
  86335. */
  86336. create(data?: Nullable<DataArray>): void;
  86337. /** @hidden */
  86338. _rebuild(): void;
  86339. /**
  86340. * Update current buffer data
  86341. * @param data defines the data to store
  86342. */
  86343. update(data: DataArray): void;
  86344. /**
  86345. * Updates the data directly.
  86346. * @param data the new data
  86347. * @param offset the new offset
  86348. * @param vertexCount the vertex count (optional)
  86349. * @param useBytes set to true if the offset is in bytes
  86350. */
  86351. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86352. /**
  86353. * Release all resources
  86354. */
  86355. dispose(): void;
  86356. }
  86357. /**
  86358. * Specialized buffer used to store vertex data
  86359. */
  86360. export class VertexBuffer {
  86361. /** @hidden */
  86362. _buffer: Buffer;
  86363. private _kind;
  86364. private _size;
  86365. private _ownsBuffer;
  86366. private _instanced;
  86367. private _instanceDivisor;
  86368. /**
  86369. * The byte type.
  86370. */
  86371. static readonly BYTE: number;
  86372. /**
  86373. * The unsigned byte type.
  86374. */
  86375. static readonly UNSIGNED_BYTE: number;
  86376. /**
  86377. * The short type.
  86378. */
  86379. static readonly SHORT: number;
  86380. /**
  86381. * The unsigned short type.
  86382. */
  86383. static readonly UNSIGNED_SHORT: number;
  86384. /**
  86385. * The integer type.
  86386. */
  86387. static readonly INT: number;
  86388. /**
  86389. * The unsigned integer type.
  86390. */
  86391. static readonly UNSIGNED_INT: number;
  86392. /**
  86393. * The float type.
  86394. */
  86395. static readonly FLOAT: number;
  86396. /**
  86397. * Gets or sets the instance divisor when in instanced mode
  86398. */
  86399. get instanceDivisor(): number;
  86400. set instanceDivisor(value: number);
  86401. /**
  86402. * Gets the byte stride.
  86403. */
  86404. readonly byteStride: number;
  86405. /**
  86406. * Gets the byte offset.
  86407. */
  86408. readonly byteOffset: number;
  86409. /**
  86410. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86411. */
  86412. readonly normalized: boolean;
  86413. /**
  86414. * Gets the data type of each component in the array.
  86415. */
  86416. readonly type: number;
  86417. /**
  86418. * Constructor
  86419. * @param engine the engine
  86420. * @param data the data to use for this vertex buffer
  86421. * @param kind the vertex buffer kind
  86422. * @param updatable whether the data is updatable
  86423. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86424. * @param stride the stride (optional)
  86425. * @param instanced whether the buffer is instanced (optional)
  86426. * @param offset the offset of the data (optional)
  86427. * @param size the number of components (optional)
  86428. * @param type the type of the component (optional)
  86429. * @param normalized whether the data contains normalized data (optional)
  86430. * @param useBytes set to true if stride and offset are in bytes (optional)
  86431. * @param divisor defines the instance divisor to use (1 by default)
  86432. */
  86433. 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);
  86434. /** @hidden */
  86435. _rebuild(): void;
  86436. /**
  86437. * Returns the kind of the VertexBuffer (string)
  86438. * @returns a string
  86439. */
  86440. getKind(): string;
  86441. /**
  86442. * Gets a boolean indicating if the VertexBuffer is updatable?
  86443. * @returns true if the buffer is updatable
  86444. */
  86445. isUpdatable(): boolean;
  86446. /**
  86447. * Gets current buffer's data
  86448. * @returns a DataArray or null
  86449. */
  86450. getData(): Nullable<DataArray>;
  86451. /**
  86452. * Gets underlying native buffer
  86453. * @returns underlying native buffer
  86454. */
  86455. getBuffer(): Nullable<DataBuffer>;
  86456. /**
  86457. * Gets the stride in float32 units (i.e. byte stride / 4).
  86458. * May not be an integer if the byte stride is not divisible by 4.
  86459. * @returns the stride in float32 units
  86460. * @deprecated Please use byteStride instead.
  86461. */
  86462. getStrideSize(): number;
  86463. /**
  86464. * Returns the offset as a multiple of the type byte length.
  86465. * @returns the offset in bytes
  86466. * @deprecated Please use byteOffset instead.
  86467. */
  86468. getOffset(): number;
  86469. /**
  86470. * Returns the number of components per vertex attribute (integer)
  86471. * @returns the size in float
  86472. */
  86473. getSize(): number;
  86474. /**
  86475. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86476. * @returns true if this buffer is instanced
  86477. */
  86478. getIsInstanced(): boolean;
  86479. /**
  86480. * Returns the instancing divisor, zero for non-instanced (integer).
  86481. * @returns a number
  86482. */
  86483. getInstanceDivisor(): number;
  86484. /**
  86485. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86486. * @param data defines the data to store
  86487. */
  86488. create(data?: DataArray): void;
  86489. /**
  86490. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86491. * This function will create a new buffer if the current one is not updatable
  86492. * @param data defines the data to store
  86493. */
  86494. update(data: DataArray): void;
  86495. /**
  86496. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86497. * Returns the directly updated WebGLBuffer.
  86498. * @param data the new data
  86499. * @param offset the new offset
  86500. * @param useBytes set to true if the offset is in bytes
  86501. */
  86502. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86503. /**
  86504. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86505. */
  86506. dispose(): void;
  86507. /**
  86508. * Enumerates each value of this vertex buffer as numbers.
  86509. * @param count the number of values to enumerate
  86510. * @param callback the callback function called for each value
  86511. */
  86512. forEach(count: number, callback: (value: number, index: number) => void): void;
  86513. /**
  86514. * Positions
  86515. */
  86516. static readonly PositionKind: string;
  86517. /**
  86518. * Normals
  86519. */
  86520. static readonly NormalKind: string;
  86521. /**
  86522. * Tangents
  86523. */
  86524. static readonly TangentKind: string;
  86525. /**
  86526. * Texture coordinates
  86527. */
  86528. static readonly UVKind: string;
  86529. /**
  86530. * Texture coordinates 2
  86531. */
  86532. static readonly UV2Kind: string;
  86533. /**
  86534. * Texture coordinates 3
  86535. */
  86536. static readonly UV3Kind: string;
  86537. /**
  86538. * Texture coordinates 4
  86539. */
  86540. static readonly UV4Kind: string;
  86541. /**
  86542. * Texture coordinates 5
  86543. */
  86544. static readonly UV5Kind: string;
  86545. /**
  86546. * Texture coordinates 6
  86547. */
  86548. static readonly UV6Kind: string;
  86549. /**
  86550. * Colors
  86551. */
  86552. static readonly ColorKind: string;
  86553. /**
  86554. * Matrix indices (for bones)
  86555. */
  86556. static readonly MatricesIndicesKind: string;
  86557. /**
  86558. * Matrix weights (for bones)
  86559. */
  86560. static readonly MatricesWeightsKind: string;
  86561. /**
  86562. * Additional matrix indices (for bones)
  86563. */
  86564. static readonly MatricesIndicesExtraKind: string;
  86565. /**
  86566. * Additional matrix weights (for bones)
  86567. */
  86568. static readonly MatricesWeightsExtraKind: string;
  86569. /**
  86570. * Deduces the stride given a kind.
  86571. * @param kind The kind string to deduce
  86572. * @returns The deduced stride
  86573. */
  86574. static DeduceStride(kind: string): number;
  86575. /**
  86576. * Gets the byte length of the given type.
  86577. * @param type the type
  86578. * @returns the number of bytes
  86579. */
  86580. static GetTypeByteLength(type: number): number;
  86581. /**
  86582. * Enumerates each value of the given parameters as numbers.
  86583. * @param data the data to enumerate
  86584. * @param byteOffset the byte offset of the data
  86585. * @param byteStride the byte stride of the data
  86586. * @param componentCount the number of components per element
  86587. * @param componentType the type of the component
  86588. * @param count the number of values to enumerate
  86589. * @param normalized whether the data is normalized
  86590. * @param callback the callback function called for each value
  86591. */
  86592. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86593. private static _GetFloatValue;
  86594. }
  86595. }
  86596. declare module BABYLON {
  86597. /**
  86598. * @hidden
  86599. */
  86600. export class IntersectionInfo {
  86601. bu: Nullable<number>;
  86602. bv: Nullable<number>;
  86603. distance: number;
  86604. faceId: number;
  86605. subMeshId: number;
  86606. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86607. }
  86608. }
  86609. declare module BABYLON {
  86610. /**
  86611. * Class used to store bounding sphere information
  86612. */
  86613. export class BoundingSphere {
  86614. /**
  86615. * Gets the center of the bounding sphere in local space
  86616. */
  86617. readonly center: Vector3;
  86618. /**
  86619. * Radius of the bounding sphere in local space
  86620. */
  86621. radius: number;
  86622. /**
  86623. * Gets the center of the bounding sphere in world space
  86624. */
  86625. readonly centerWorld: Vector3;
  86626. /**
  86627. * Radius of the bounding sphere in world space
  86628. */
  86629. radiusWorld: number;
  86630. /**
  86631. * Gets the minimum vector in local space
  86632. */
  86633. readonly minimum: Vector3;
  86634. /**
  86635. * Gets the maximum vector in local space
  86636. */
  86637. readonly maximum: Vector3;
  86638. private _worldMatrix;
  86639. private static readonly TmpVector3;
  86640. /**
  86641. * Creates a new bounding sphere
  86642. * @param min defines the minimum vector (in local space)
  86643. * @param max defines the maximum vector (in local space)
  86644. * @param worldMatrix defines the new world matrix
  86645. */
  86646. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86647. /**
  86648. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86649. * @param min defines the new minimum vector (in local space)
  86650. * @param max defines the new maximum vector (in local space)
  86651. * @param worldMatrix defines the new world matrix
  86652. */
  86653. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86654. /**
  86655. * Scale the current bounding sphere by applying a scale factor
  86656. * @param factor defines the scale factor to apply
  86657. * @returns the current bounding box
  86658. */
  86659. scale(factor: number): BoundingSphere;
  86660. /**
  86661. * Gets the world matrix of the bounding box
  86662. * @returns a matrix
  86663. */
  86664. getWorldMatrix(): DeepImmutable<Matrix>;
  86665. /** @hidden */
  86666. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86667. /**
  86668. * Tests if the bounding sphere is intersecting the frustum planes
  86669. * @param frustumPlanes defines the frustum planes to test
  86670. * @returns true if there is an intersection
  86671. */
  86672. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86673. /**
  86674. * Tests if the bounding sphere center is in between the frustum planes.
  86675. * Used for optimistic fast inclusion.
  86676. * @param frustumPlanes defines the frustum planes to test
  86677. * @returns true if the sphere center is in between the frustum planes
  86678. */
  86679. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86680. /**
  86681. * Tests if a point is inside the bounding sphere
  86682. * @param point defines the point to test
  86683. * @returns true if the point is inside the bounding sphere
  86684. */
  86685. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86686. /**
  86687. * Checks if two sphere intersct
  86688. * @param sphere0 sphere 0
  86689. * @param sphere1 sphere 1
  86690. * @returns true if the speres intersect
  86691. */
  86692. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86693. }
  86694. }
  86695. declare module BABYLON {
  86696. /**
  86697. * Class used to store bounding box information
  86698. */
  86699. export class BoundingBox implements ICullable {
  86700. /**
  86701. * Gets the 8 vectors representing the bounding box in local space
  86702. */
  86703. readonly vectors: Vector3[];
  86704. /**
  86705. * Gets the center of the bounding box in local space
  86706. */
  86707. readonly center: Vector3;
  86708. /**
  86709. * Gets the center of the bounding box in world space
  86710. */
  86711. readonly centerWorld: Vector3;
  86712. /**
  86713. * Gets the extend size in local space
  86714. */
  86715. readonly extendSize: Vector3;
  86716. /**
  86717. * Gets the extend size in world space
  86718. */
  86719. readonly extendSizeWorld: Vector3;
  86720. /**
  86721. * Gets the OBB (object bounding box) directions
  86722. */
  86723. readonly directions: Vector3[];
  86724. /**
  86725. * Gets the 8 vectors representing the bounding box in world space
  86726. */
  86727. readonly vectorsWorld: Vector3[];
  86728. /**
  86729. * Gets the minimum vector in world space
  86730. */
  86731. readonly minimumWorld: Vector3;
  86732. /**
  86733. * Gets the maximum vector in world space
  86734. */
  86735. readonly maximumWorld: Vector3;
  86736. /**
  86737. * Gets the minimum vector in local space
  86738. */
  86739. readonly minimum: Vector3;
  86740. /**
  86741. * Gets the maximum vector in local space
  86742. */
  86743. readonly maximum: Vector3;
  86744. private _worldMatrix;
  86745. private static readonly TmpVector3;
  86746. /**
  86747. * @hidden
  86748. */
  86749. _tag: number;
  86750. /**
  86751. * Creates a new bounding box
  86752. * @param min defines the minimum vector (in local space)
  86753. * @param max defines the maximum vector (in local space)
  86754. * @param worldMatrix defines the new world matrix
  86755. */
  86756. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86757. /**
  86758. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86759. * @param min defines the new minimum vector (in local space)
  86760. * @param max defines the new maximum vector (in local space)
  86761. * @param worldMatrix defines the new world matrix
  86762. */
  86763. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86764. /**
  86765. * Scale the current bounding box by applying a scale factor
  86766. * @param factor defines the scale factor to apply
  86767. * @returns the current bounding box
  86768. */
  86769. scale(factor: number): BoundingBox;
  86770. /**
  86771. * Gets the world matrix of the bounding box
  86772. * @returns a matrix
  86773. */
  86774. getWorldMatrix(): DeepImmutable<Matrix>;
  86775. /** @hidden */
  86776. _update(world: DeepImmutable<Matrix>): void;
  86777. /**
  86778. * Tests if the bounding box is intersecting the frustum planes
  86779. * @param frustumPlanes defines the frustum planes to test
  86780. * @returns true if there is an intersection
  86781. */
  86782. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86783. /**
  86784. * Tests if the bounding box is entirely inside the frustum planes
  86785. * @param frustumPlanes defines the frustum planes to test
  86786. * @returns true if there is an inclusion
  86787. */
  86788. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86789. /**
  86790. * Tests if a point is inside the bounding box
  86791. * @param point defines the point to test
  86792. * @returns true if the point is inside the bounding box
  86793. */
  86794. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86795. /**
  86796. * Tests if the bounding box intersects with a bounding sphere
  86797. * @param sphere defines the sphere to test
  86798. * @returns true if there is an intersection
  86799. */
  86800. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86801. /**
  86802. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86803. * @param min defines the min vector to use
  86804. * @param max defines the max vector to use
  86805. * @returns true if there is an intersection
  86806. */
  86807. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86808. /**
  86809. * Tests if two bounding boxes are intersections
  86810. * @param box0 defines the first box to test
  86811. * @param box1 defines the second box to test
  86812. * @returns true if there is an intersection
  86813. */
  86814. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86815. /**
  86816. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86817. * @param minPoint defines the minimum vector of the bounding box
  86818. * @param maxPoint defines the maximum vector of the bounding box
  86819. * @param sphereCenter defines the sphere center
  86820. * @param sphereRadius defines the sphere radius
  86821. * @returns true if there is an intersection
  86822. */
  86823. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86824. /**
  86825. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86826. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86827. * @param frustumPlanes defines the frustum planes to test
  86828. * @return true if there is an inclusion
  86829. */
  86830. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86831. /**
  86832. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86833. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86834. * @param frustumPlanes defines the frustum planes to test
  86835. * @return true if there is an intersection
  86836. */
  86837. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86838. }
  86839. }
  86840. declare module BABYLON {
  86841. /** @hidden */
  86842. export class Collider {
  86843. /** Define if a collision was found */
  86844. collisionFound: boolean;
  86845. /**
  86846. * Define last intersection point in local space
  86847. */
  86848. intersectionPoint: Vector3;
  86849. /**
  86850. * Define last collided mesh
  86851. */
  86852. collidedMesh: Nullable<AbstractMesh>;
  86853. private _collisionPoint;
  86854. private _planeIntersectionPoint;
  86855. private _tempVector;
  86856. private _tempVector2;
  86857. private _tempVector3;
  86858. private _tempVector4;
  86859. private _edge;
  86860. private _baseToVertex;
  86861. private _destinationPoint;
  86862. private _slidePlaneNormal;
  86863. private _displacementVector;
  86864. /** @hidden */
  86865. _radius: Vector3;
  86866. /** @hidden */
  86867. _retry: number;
  86868. private _velocity;
  86869. private _basePoint;
  86870. private _epsilon;
  86871. /** @hidden */
  86872. _velocityWorldLength: number;
  86873. /** @hidden */
  86874. _basePointWorld: Vector3;
  86875. private _velocityWorld;
  86876. private _normalizedVelocity;
  86877. /** @hidden */
  86878. _initialVelocity: Vector3;
  86879. /** @hidden */
  86880. _initialPosition: Vector3;
  86881. private _nearestDistance;
  86882. private _collisionMask;
  86883. get collisionMask(): number;
  86884. set collisionMask(mask: number);
  86885. /**
  86886. * Gets the plane normal used to compute the sliding response (in local space)
  86887. */
  86888. get slidePlaneNormal(): Vector3;
  86889. /** @hidden */
  86890. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86891. /** @hidden */
  86892. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86893. /** @hidden */
  86894. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86895. /** @hidden */
  86896. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86897. /** @hidden */
  86898. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86899. /** @hidden */
  86900. _getResponse(pos: Vector3, vel: Vector3): void;
  86901. }
  86902. }
  86903. declare module BABYLON {
  86904. /**
  86905. * Interface for cullable objects
  86906. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86907. */
  86908. export interface ICullable {
  86909. /**
  86910. * Checks if the object or part of the object is in the frustum
  86911. * @param frustumPlanes Camera near/planes
  86912. * @returns true if the object is in frustum otherwise false
  86913. */
  86914. isInFrustum(frustumPlanes: Plane[]): boolean;
  86915. /**
  86916. * Checks if a cullable object (mesh...) is in the camera frustum
  86917. * Unlike isInFrustum this cheks the full bounding box
  86918. * @param frustumPlanes Camera near/planes
  86919. * @returns true if the object is in frustum otherwise false
  86920. */
  86921. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86922. }
  86923. /**
  86924. * Info for a bounding data of a mesh
  86925. */
  86926. export class BoundingInfo implements ICullable {
  86927. /**
  86928. * Bounding box for the mesh
  86929. */
  86930. readonly boundingBox: BoundingBox;
  86931. /**
  86932. * Bounding sphere for the mesh
  86933. */
  86934. readonly boundingSphere: BoundingSphere;
  86935. private _isLocked;
  86936. private static readonly TmpVector3;
  86937. /**
  86938. * Constructs bounding info
  86939. * @param minimum min vector of the bounding box/sphere
  86940. * @param maximum max vector of the bounding box/sphere
  86941. * @param worldMatrix defines the new world matrix
  86942. */
  86943. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86944. /**
  86945. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86946. * @param min defines the new minimum vector (in local space)
  86947. * @param max defines the new maximum vector (in local space)
  86948. * @param worldMatrix defines the new world matrix
  86949. */
  86950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86951. /**
  86952. * min vector of the bounding box/sphere
  86953. */
  86954. get minimum(): Vector3;
  86955. /**
  86956. * max vector of the bounding box/sphere
  86957. */
  86958. get maximum(): Vector3;
  86959. /**
  86960. * If the info is locked and won't be updated to avoid perf overhead
  86961. */
  86962. get isLocked(): boolean;
  86963. set isLocked(value: boolean);
  86964. /**
  86965. * Updates the bounding sphere and box
  86966. * @param world world matrix to be used to update
  86967. */
  86968. update(world: DeepImmutable<Matrix>): void;
  86969. /**
  86970. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86971. * @param center New center of the bounding info
  86972. * @param extend New extend of the bounding info
  86973. * @returns the current bounding info
  86974. */
  86975. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86976. /**
  86977. * Scale the current bounding info by applying a scale factor
  86978. * @param factor defines the scale factor to apply
  86979. * @returns the current bounding info
  86980. */
  86981. scale(factor: number): BoundingInfo;
  86982. /**
  86983. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86984. * @param frustumPlanes defines the frustum to test
  86985. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86986. * @returns true if the bounding info is in the frustum planes
  86987. */
  86988. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86989. /**
  86990. * Gets the world distance between the min and max points of the bounding box
  86991. */
  86992. get diagonalLength(): number;
  86993. /**
  86994. * Checks if a cullable object (mesh...) is in the camera frustum
  86995. * Unlike isInFrustum this cheks the full bounding box
  86996. * @param frustumPlanes Camera near/planes
  86997. * @returns true if the object is in frustum otherwise false
  86998. */
  86999. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87000. /** @hidden */
  87001. _checkCollision(collider: Collider): boolean;
  87002. /**
  87003. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87004. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87005. * @param point the point to check intersection with
  87006. * @returns if the point intersects
  87007. */
  87008. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87009. /**
  87010. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87011. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87012. * @param boundingInfo the bounding info to check intersection with
  87013. * @param precise if the intersection should be done using OBB
  87014. * @returns if the bounding info intersects
  87015. */
  87016. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87017. }
  87018. }
  87019. declare module BABYLON {
  87020. /**
  87021. * Extracts minimum and maximum values from a list of indexed positions
  87022. * @param positions defines the positions to use
  87023. * @param indices defines the indices to the positions
  87024. * @param indexStart defines the start index
  87025. * @param indexCount defines the end index
  87026. * @param bias defines bias value to add to the result
  87027. * @return minimum and maximum values
  87028. */
  87029. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87030. minimum: Vector3;
  87031. maximum: Vector3;
  87032. };
  87033. /**
  87034. * Extracts minimum and maximum values from a list of positions
  87035. * @param positions defines the positions to use
  87036. * @param start defines the start index in the positions array
  87037. * @param count defines the number of positions to handle
  87038. * @param bias defines bias value to add to the result
  87039. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87040. * @return minimum and maximum values
  87041. */
  87042. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87043. minimum: Vector3;
  87044. maximum: Vector3;
  87045. };
  87046. }
  87047. declare module BABYLON {
  87048. /** @hidden */
  87049. export class WebGLDataBuffer extends DataBuffer {
  87050. private _buffer;
  87051. constructor(resource: WebGLBuffer);
  87052. get underlyingResource(): any;
  87053. }
  87054. }
  87055. declare module BABYLON {
  87056. /** @hidden */
  87057. export class WebGLPipelineContext implements IPipelineContext {
  87058. engine: ThinEngine;
  87059. program: Nullable<WebGLProgram>;
  87060. context?: WebGLRenderingContext;
  87061. vertexShader?: WebGLShader;
  87062. fragmentShader?: WebGLShader;
  87063. isParallelCompiled: boolean;
  87064. onCompiled?: () => void;
  87065. transformFeedback?: WebGLTransformFeedback | null;
  87066. vertexCompilationError: Nullable<string>;
  87067. fragmentCompilationError: Nullable<string>;
  87068. programLinkError: Nullable<string>;
  87069. programValidationError: Nullable<string>;
  87070. get isAsync(): boolean;
  87071. get isReady(): boolean;
  87072. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87073. _getVertexShaderCode(): string | null;
  87074. _getFragmentShaderCode(): string | null;
  87075. }
  87076. }
  87077. declare module BABYLON {
  87078. interface ThinEngine {
  87079. /**
  87080. * Create an uniform buffer
  87081. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87082. * @param elements defines the content of the uniform buffer
  87083. * @returns the webGL uniform buffer
  87084. */
  87085. createUniformBuffer(elements: FloatArray): DataBuffer;
  87086. /**
  87087. * Create a dynamic uniform buffer
  87088. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87089. * @param elements defines the content of the uniform buffer
  87090. * @returns the webGL uniform buffer
  87091. */
  87092. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87093. /**
  87094. * Update an existing uniform buffer
  87095. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87096. * @param uniformBuffer defines the target uniform buffer
  87097. * @param elements defines the content to update
  87098. * @param offset defines the offset in the uniform buffer where update should start
  87099. * @param count defines the size of the data to update
  87100. */
  87101. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87102. /**
  87103. * Bind an uniform buffer to the current webGL context
  87104. * @param buffer defines the buffer to bind
  87105. */
  87106. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87107. /**
  87108. * Bind a buffer to the current webGL context at a given location
  87109. * @param buffer defines the buffer to bind
  87110. * @param location defines the index where to bind the buffer
  87111. */
  87112. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87113. /**
  87114. * Bind a specific block at a given index in a specific shader program
  87115. * @param pipelineContext defines the pipeline context to use
  87116. * @param blockName defines the block name
  87117. * @param index defines the index where to bind the block
  87118. */
  87119. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87120. }
  87121. }
  87122. declare module BABYLON {
  87123. /**
  87124. * Uniform buffer objects.
  87125. *
  87126. * Handles blocks of uniform on the GPU.
  87127. *
  87128. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87129. *
  87130. * For more information, please refer to :
  87131. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87132. */
  87133. export class UniformBuffer {
  87134. private _engine;
  87135. private _buffer;
  87136. private _data;
  87137. private _bufferData;
  87138. private _dynamic?;
  87139. private _uniformLocations;
  87140. private _uniformSizes;
  87141. private _uniformLocationPointer;
  87142. private _needSync;
  87143. private _noUBO;
  87144. private _currentEffect;
  87145. /** @hidden */
  87146. _alreadyBound: boolean;
  87147. private static _MAX_UNIFORM_SIZE;
  87148. private static _tempBuffer;
  87149. /**
  87150. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87151. * This is dynamic to allow compat with webgl 1 and 2.
  87152. * You will need to pass the name of the uniform as well as the value.
  87153. */
  87154. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87155. /**
  87156. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87157. * This is dynamic to allow compat with webgl 1 and 2.
  87158. * You will need to pass the name of the uniform as well as the value.
  87159. */
  87160. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87161. /**
  87162. * Lambda to Update a single float in a uniform buffer.
  87163. * This is dynamic to allow compat with webgl 1 and 2.
  87164. * You will need to pass the name of the uniform as well as the value.
  87165. */
  87166. updateFloat: (name: string, x: number) => void;
  87167. /**
  87168. * Lambda to Update a vec2 of float in a uniform buffer.
  87169. * This is dynamic to allow compat with webgl 1 and 2.
  87170. * You will need to pass the name of the uniform as well as the value.
  87171. */
  87172. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87173. /**
  87174. * Lambda to Update a vec3 of float in a uniform buffer.
  87175. * This is dynamic to allow compat with webgl 1 and 2.
  87176. * You will need to pass the name of the uniform as well as the value.
  87177. */
  87178. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87179. /**
  87180. * Lambda to Update a vec4 of float in a uniform buffer.
  87181. * This is dynamic to allow compat with webgl 1 and 2.
  87182. * You will need to pass the name of the uniform as well as the value.
  87183. */
  87184. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87185. /**
  87186. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87187. * This is dynamic to allow compat with webgl 1 and 2.
  87188. * You will need to pass the name of the uniform as well as the value.
  87189. */
  87190. updateMatrix: (name: string, mat: Matrix) => void;
  87191. /**
  87192. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87193. * This is dynamic to allow compat with webgl 1 and 2.
  87194. * You will need to pass the name of the uniform as well as the value.
  87195. */
  87196. updateVector3: (name: string, vector: Vector3) => void;
  87197. /**
  87198. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87199. * This is dynamic to allow compat with webgl 1 and 2.
  87200. * You will need to pass the name of the uniform as well as the value.
  87201. */
  87202. updateVector4: (name: string, vector: Vector4) => void;
  87203. /**
  87204. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87205. * This is dynamic to allow compat with webgl 1 and 2.
  87206. * You will need to pass the name of the uniform as well as the value.
  87207. */
  87208. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87209. /**
  87210. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87211. * This is dynamic to allow compat with webgl 1 and 2.
  87212. * You will need to pass the name of the uniform as well as the value.
  87213. */
  87214. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87215. /**
  87216. * Instantiates a new Uniform buffer objects.
  87217. *
  87218. * Handles blocks of uniform on the GPU.
  87219. *
  87220. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87221. *
  87222. * For more information, please refer to :
  87223. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87224. * @param engine Define the engine the buffer is associated with
  87225. * @param data Define the data contained in the buffer
  87226. * @param dynamic Define if the buffer is updatable
  87227. */
  87228. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87229. /**
  87230. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87231. * or just falling back on setUniformXXX calls.
  87232. */
  87233. get useUbo(): boolean;
  87234. /**
  87235. * Indicates if the WebGL underlying uniform buffer is in sync
  87236. * with the javascript cache data.
  87237. */
  87238. get isSync(): boolean;
  87239. /**
  87240. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87241. * Also, a dynamic UniformBuffer will disable cache verification and always
  87242. * update the underlying WebGL uniform buffer to the GPU.
  87243. * @returns if Dynamic, otherwise false
  87244. */
  87245. isDynamic(): boolean;
  87246. /**
  87247. * The data cache on JS side.
  87248. * @returns the underlying data as a float array
  87249. */
  87250. getData(): Float32Array;
  87251. /**
  87252. * The underlying WebGL Uniform buffer.
  87253. * @returns the webgl buffer
  87254. */
  87255. getBuffer(): Nullable<DataBuffer>;
  87256. /**
  87257. * std140 layout specifies how to align data within an UBO structure.
  87258. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87259. * for specs.
  87260. */
  87261. private _fillAlignment;
  87262. /**
  87263. * Adds an uniform in the buffer.
  87264. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87265. * for the layout to be correct !
  87266. * @param name Name of the uniform, as used in the uniform block in the shader.
  87267. * @param size Data size, or data directly.
  87268. */
  87269. addUniform(name: string, size: number | number[]): void;
  87270. /**
  87271. * Adds a Matrix 4x4 to the uniform buffer.
  87272. * @param name Name of the uniform, as used in the uniform block in the shader.
  87273. * @param mat A 4x4 matrix.
  87274. */
  87275. addMatrix(name: string, mat: Matrix): void;
  87276. /**
  87277. * Adds a vec2 to the uniform buffer.
  87278. * @param name Name of the uniform, as used in the uniform block in the shader.
  87279. * @param x Define the x component value of the vec2
  87280. * @param y Define the y component value of the vec2
  87281. */
  87282. addFloat2(name: string, x: number, y: number): void;
  87283. /**
  87284. * Adds a vec3 to the uniform buffer.
  87285. * @param name Name of the uniform, as used in the uniform block in the shader.
  87286. * @param x Define the x component value of the vec3
  87287. * @param y Define the y component value of the vec3
  87288. * @param z Define the z component value of the vec3
  87289. */
  87290. addFloat3(name: string, x: number, y: number, z: number): void;
  87291. /**
  87292. * Adds a vec3 to the uniform buffer.
  87293. * @param name Name of the uniform, as used in the uniform block in the shader.
  87294. * @param color Define the vec3 from a Color
  87295. */
  87296. addColor3(name: string, color: Color3): void;
  87297. /**
  87298. * Adds a vec4 to the uniform buffer.
  87299. * @param name Name of the uniform, as used in the uniform block in the shader.
  87300. * @param color Define the rgb components from a Color
  87301. * @param alpha Define the a component of the vec4
  87302. */
  87303. addColor4(name: string, color: Color3, alpha: number): void;
  87304. /**
  87305. * Adds a vec3 to the uniform buffer.
  87306. * @param name Name of the uniform, as used in the uniform block in the shader.
  87307. * @param vector Define the vec3 components from a Vector
  87308. */
  87309. addVector3(name: string, vector: Vector3): void;
  87310. /**
  87311. * Adds a Matrix 3x3 to the uniform buffer.
  87312. * @param name Name of the uniform, as used in the uniform block in the shader.
  87313. */
  87314. addMatrix3x3(name: string): void;
  87315. /**
  87316. * Adds a Matrix 2x2 to the uniform buffer.
  87317. * @param name Name of the uniform, as used in the uniform block in the shader.
  87318. */
  87319. addMatrix2x2(name: string): void;
  87320. /**
  87321. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87322. */
  87323. create(): void;
  87324. /** @hidden */
  87325. _rebuild(): void;
  87326. /**
  87327. * Updates the WebGL Uniform Buffer on the GPU.
  87328. * If the `dynamic` flag is set to true, no cache comparison is done.
  87329. * Otherwise, the buffer will be updated only if the cache differs.
  87330. */
  87331. update(): void;
  87332. /**
  87333. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87334. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87335. * @param data Define the flattened data
  87336. * @param size Define the size of the data.
  87337. */
  87338. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87339. private _valueCache;
  87340. private _cacheMatrix;
  87341. private _updateMatrix3x3ForUniform;
  87342. private _updateMatrix3x3ForEffect;
  87343. private _updateMatrix2x2ForEffect;
  87344. private _updateMatrix2x2ForUniform;
  87345. private _updateFloatForEffect;
  87346. private _updateFloatForUniform;
  87347. private _updateFloat2ForEffect;
  87348. private _updateFloat2ForUniform;
  87349. private _updateFloat3ForEffect;
  87350. private _updateFloat3ForUniform;
  87351. private _updateFloat4ForEffect;
  87352. private _updateFloat4ForUniform;
  87353. private _updateMatrixForEffect;
  87354. private _updateMatrixForUniform;
  87355. private _updateVector3ForEffect;
  87356. private _updateVector3ForUniform;
  87357. private _updateVector4ForEffect;
  87358. private _updateVector4ForUniform;
  87359. private _updateColor3ForEffect;
  87360. private _updateColor3ForUniform;
  87361. private _updateColor4ForEffect;
  87362. private _updateColor4ForUniform;
  87363. /**
  87364. * Sets a sampler uniform on the effect.
  87365. * @param name Define the name of the sampler.
  87366. * @param texture Define the texture to set in the sampler
  87367. */
  87368. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87369. /**
  87370. * Directly updates the value of the uniform in the cache AND on the GPU.
  87371. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87372. * @param data Define the flattened data
  87373. */
  87374. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87375. /**
  87376. * Binds this uniform buffer to an effect.
  87377. * @param effect Define the effect to bind the buffer to
  87378. * @param name Name of the uniform block in the shader.
  87379. */
  87380. bindToEffect(effect: Effect, name: string): void;
  87381. /**
  87382. * Disposes the uniform buffer.
  87383. */
  87384. dispose(): void;
  87385. }
  87386. }
  87387. declare module BABYLON {
  87388. /**
  87389. * Enum that determines the text-wrapping mode to use.
  87390. */
  87391. export enum InspectableType {
  87392. /**
  87393. * Checkbox for booleans
  87394. */
  87395. Checkbox = 0,
  87396. /**
  87397. * Sliders for numbers
  87398. */
  87399. Slider = 1,
  87400. /**
  87401. * Vector3
  87402. */
  87403. Vector3 = 2,
  87404. /**
  87405. * Quaternions
  87406. */
  87407. Quaternion = 3,
  87408. /**
  87409. * Color3
  87410. */
  87411. Color3 = 4,
  87412. /**
  87413. * String
  87414. */
  87415. String = 5
  87416. }
  87417. /**
  87418. * Interface used to define custom inspectable properties.
  87419. * This interface is used by the inspector to display custom property grids
  87420. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87421. */
  87422. export interface IInspectable {
  87423. /**
  87424. * Gets the label to display
  87425. */
  87426. label: string;
  87427. /**
  87428. * Gets the name of the property to edit
  87429. */
  87430. propertyName: string;
  87431. /**
  87432. * Gets the type of the editor to use
  87433. */
  87434. type: InspectableType;
  87435. /**
  87436. * Gets the minimum value of the property when using in "slider" mode
  87437. */
  87438. min?: number;
  87439. /**
  87440. * Gets the maximum value of the property when using in "slider" mode
  87441. */
  87442. max?: number;
  87443. /**
  87444. * Gets the setp to use when using in "slider" mode
  87445. */
  87446. step?: number;
  87447. }
  87448. }
  87449. declare module BABYLON {
  87450. /**
  87451. * Class used to provide helper for timing
  87452. */
  87453. export class TimingTools {
  87454. /**
  87455. * Polyfill for setImmediate
  87456. * @param action defines the action to execute after the current execution block
  87457. */
  87458. static SetImmediate(action: () => void): void;
  87459. }
  87460. }
  87461. declare module BABYLON {
  87462. /**
  87463. * Class used to enable instatition of objects by class name
  87464. */
  87465. export class InstantiationTools {
  87466. /**
  87467. * Use this object to register external classes like custom textures or material
  87468. * to allow the laoders to instantiate them
  87469. */
  87470. static RegisteredExternalClasses: {
  87471. [key: string]: Object;
  87472. };
  87473. /**
  87474. * Tries to instantiate a new object from a given class name
  87475. * @param className defines the class name to instantiate
  87476. * @returns the new object or null if the system was not able to do the instantiation
  87477. */
  87478. static Instantiate(className: string): any;
  87479. }
  87480. }
  87481. declare module BABYLON {
  87482. /**
  87483. * Define options used to create a depth texture
  87484. */
  87485. export class DepthTextureCreationOptions {
  87486. /** Specifies whether or not a stencil should be allocated in the texture */
  87487. generateStencil?: boolean;
  87488. /** Specifies whether or not bilinear filtering is enable on the texture */
  87489. bilinearFiltering?: boolean;
  87490. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87491. comparisonFunction?: number;
  87492. /** Specifies if the created texture is a cube texture */
  87493. isCube?: boolean;
  87494. }
  87495. }
  87496. declare module BABYLON {
  87497. interface ThinEngine {
  87498. /**
  87499. * Creates a depth stencil cube texture.
  87500. * This is only available in WebGL 2.
  87501. * @param size The size of face edge in the cube texture.
  87502. * @param options The options defining the cube texture.
  87503. * @returns The cube texture
  87504. */
  87505. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  87506. /**
  87507. * Creates a cube texture
  87508. * @param rootUrl defines the url where the files to load is located
  87509. * @param scene defines the current scene
  87510. * @param files defines the list of files to load (1 per face)
  87511. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87512. * @param onLoad defines an optional callback raised when the texture is loaded
  87513. * @param onError defines an optional callback raised if there is an issue to load the texture
  87514. * @param format defines the format of the data
  87515. * @param forcedExtension defines the extension to use to pick the right loader
  87516. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87517. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87518. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87519. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87520. * @returns the cube texture as an InternalTexture
  87521. */
  87522. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  87523. /**
  87524. * Creates a cube texture
  87525. * @param rootUrl defines the url where the files to load is located
  87526. * @param scene defines the current scene
  87527. * @param files defines the list of files to load (1 per face)
  87528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87529. * @param onLoad defines an optional callback raised when the texture is loaded
  87530. * @param onError defines an optional callback raised if there is an issue to load the texture
  87531. * @param format defines the format of the data
  87532. * @param forcedExtension defines the extension to use to pick the right loader
  87533. * @returns the cube texture as an InternalTexture
  87534. */
  87535. 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;
  87536. /**
  87537. * Creates a cube texture
  87538. * @param rootUrl defines the url where the files to load is located
  87539. * @param scene defines the current scene
  87540. * @param files defines the list of files to load (1 per face)
  87541. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87542. * @param onLoad defines an optional callback raised when the texture is loaded
  87543. * @param onError defines an optional callback raised if there is an issue to load the texture
  87544. * @param format defines the format of the data
  87545. * @param forcedExtension defines the extension to use to pick the right loader
  87546. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87547. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87548. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87549. * @returns the cube texture as an InternalTexture
  87550. */
  87551. 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;
  87552. /** @hidden */
  87553. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87554. /** @hidden */
  87555. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87556. /** @hidden */
  87557. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87558. /** @hidden */
  87559. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87560. /**
  87561. * @hidden
  87562. */
  87563. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87564. }
  87565. }
  87566. declare module BABYLON {
  87567. /**
  87568. * Class for creating a cube texture
  87569. */
  87570. export class CubeTexture extends BaseTexture {
  87571. private _delayedOnLoad;
  87572. /**
  87573. * Observable triggered once the texture has been loaded.
  87574. */
  87575. onLoadObservable: Observable<CubeTexture>;
  87576. /**
  87577. * The url of the texture
  87578. */
  87579. url: string;
  87580. /**
  87581. * Gets or sets the center of the bounding box associated with the cube texture.
  87582. * It must define where the camera used to render the texture was set
  87583. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87584. */
  87585. boundingBoxPosition: Vector3;
  87586. private _boundingBoxSize;
  87587. /**
  87588. * Gets or sets the size of the bounding box associated with the cube texture
  87589. * When defined, the cubemap will switch to local mode
  87590. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87591. * @example https://www.babylonjs-playground.com/#RNASML
  87592. */
  87593. set boundingBoxSize(value: Vector3);
  87594. /**
  87595. * Returns the bounding box size
  87596. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87597. */
  87598. get boundingBoxSize(): Vector3;
  87599. protected _rotationY: number;
  87600. /**
  87601. * Sets texture matrix rotation angle around Y axis in radians.
  87602. */
  87603. set rotationY(value: number);
  87604. /**
  87605. * Gets texture matrix rotation angle around Y axis radians.
  87606. */
  87607. get rotationY(): number;
  87608. /**
  87609. * Are mip maps generated for this texture or not.
  87610. */
  87611. get noMipmap(): boolean;
  87612. private _noMipmap;
  87613. private _files;
  87614. protected _forcedExtension: Nullable<string>;
  87615. private _extensions;
  87616. private _textureMatrix;
  87617. private _format;
  87618. private _createPolynomials;
  87619. /**
  87620. * Creates a cube texture from an array of image urls
  87621. * @param files defines an array of image urls
  87622. * @param scene defines the hosting scene
  87623. * @param noMipmap specifies if mip maps are not used
  87624. * @returns a cube texture
  87625. */
  87626. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87627. /**
  87628. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87629. * @param url defines the url of the prefiltered texture
  87630. * @param scene defines the scene the texture is attached to
  87631. * @param forcedExtension defines the extension of the file if different from the url
  87632. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87633. * @return the prefiltered texture
  87634. */
  87635. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87636. /**
  87637. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87638. * as prefiltered data.
  87639. * @param rootUrl defines the url of the texture or the root name of the six images
  87640. * @param null defines the scene or engine the texture is attached to
  87641. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87642. * @param noMipmap defines if mipmaps should be created or not
  87643. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87644. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87645. * @param onError defines a callback triggered in case of error during load
  87646. * @param format defines the internal format to use for the texture once loaded
  87647. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87648. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87649. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87650. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87651. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87652. * @return the cube texture
  87653. */
  87654. 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);
  87655. /**
  87656. * Get the current class name of the texture useful for serialization or dynamic coding.
  87657. * @returns "CubeTexture"
  87658. */
  87659. getClassName(): string;
  87660. /**
  87661. * Update the url (and optional buffer) of this texture if url was null during construction.
  87662. * @param url the url of the texture
  87663. * @param forcedExtension defines the extension to use
  87664. * @param onLoad callback called when the texture is loaded (defaults to null)
  87665. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87666. */
  87667. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87668. /**
  87669. * Delays loading of the cube texture
  87670. * @param forcedExtension defines the extension to use
  87671. */
  87672. delayLoad(forcedExtension?: string): void;
  87673. /**
  87674. * Returns the reflection texture matrix
  87675. * @returns the reflection texture matrix
  87676. */
  87677. getReflectionTextureMatrix(): Matrix;
  87678. /**
  87679. * Sets the reflection texture matrix
  87680. * @param value Reflection texture matrix
  87681. */
  87682. setReflectionTextureMatrix(value: Matrix): void;
  87683. /**
  87684. * Parses text to create a cube texture
  87685. * @param parsedTexture define the serialized text to read from
  87686. * @param scene defines the hosting scene
  87687. * @param rootUrl defines the root url of the cube texture
  87688. * @returns a cube texture
  87689. */
  87690. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87691. /**
  87692. * Makes a clone, or deep copy, of the cube texture
  87693. * @returns a new cube texture
  87694. */
  87695. clone(): CubeTexture;
  87696. }
  87697. }
  87698. declare module BABYLON {
  87699. /**
  87700. * Manages the defines for the Material
  87701. */
  87702. export class MaterialDefines {
  87703. /** @hidden */
  87704. protected _keys: string[];
  87705. private _isDirty;
  87706. /** @hidden */
  87707. _renderId: number;
  87708. /** @hidden */
  87709. _areLightsDirty: boolean;
  87710. /** @hidden */
  87711. _areLightsDisposed: boolean;
  87712. /** @hidden */
  87713. _areAttributesDirty: boolean;
  87714. /** @hidden */
  87715. _areTexturesDirty: boolean;
  87716. /** @hidden */
  87717. _areFresnelDirty: boolean;
  87718. /** @hidden */
  87719. _areMiscDirty: boolean;
  87720. /** @hidden */
  87721. _areImageProcessingDirty: boolean;
  87722. /** @hidden */
  87723. _normals: boolean;
  87724. /** @hidden */
  87725. _uvs: boolean;
  87726. /** @hidden */
  87727. _needNormals: boolean;
  87728. /** @hidden */
  87729. _needUVs: boolean;
  87730. [id: string]: any;
  87731. /**
  87732. * Specifies if the material needs to be re-calculated
  87733. */
  87734. get isDirty(): boolean;
  87735. /**
  87736. * Marks the material to indicate that it has been re-calculated
  87737. */
  87738. markAsProcessed(): void;
  87739. /**
  87740. * Marks the material to indicate that it needs to be re-calculated
  87741. */
  87742. markAsUnprocessed(): void;
  87743. /**
  87744. * Marks the material to indicate all of its defines need to be re-calculated
  87745. */
  87746. markAllAsDirty(): void;
  87747. /**
  87748. * Marks the material to indicate that image processing needs to be re-calculated
  87749. */
  87750. markAsImageProcessingDirty(): void;
  87751. /**
  87752. * Marks the material to indicate the lights need to be re-calculated
  87753. * @param disposed Defines whether the light is dirty due to dispose or not
  87754. */
  87755. markAsLightDirty(disposed?: boolean): void;
  87756. /**
  87757. * Marks the attribute state as changed
  87758. */
  87759. markAsAttributesDirty(): void;
  87760. /**
  87761. * Marks the texture state as changed
  87762. */
  87763. markAsTexturesDirty(): void;
  87764. /**
  87765. * Marks the fresnel state as changed
  87766. */
  87767. markAsFresnelDirty(): void;
  87768. /**
  87769. * Marks the misc state as changed
  87770. */
  87771. markAsMiscDirty(): void;
  87772. /**
  87773. * Rebuilds the material defines
  87774. */
  87775. rebuild(): void;
  87776. /**
  87777. * Specifies if two material defines are equal
  87778. * @param other - A material define instance to compare to
  87779. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87780. */
  87781. isEqual(other: MaterialDefines): boolean;
  87782. /**
  87783. * Clones this instance's defines to another instance
  87784. * @param other - material defines to clone values to
  87785. */
  87786. cloneTo(other: MaterialDefines): void;
  87787. /**
  87788. * Resets the material define values
  87789. */
  87790. reset(): void;
  87791. /**
  87792. * Converts the material define values to a string
  87793. * @returns - String of material define information
  87794. */
  87795. toString(): string;
  87796. }
  87797. }
  87798. declare module BABYLON {
  87799. /**
  87800. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87801. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87802. * 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;
  87803. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87804. */
  87805. export class ColorCurves {
  87806. private _dirty;
  87807. private _tempColor;
  87808. private _globalCurve;
  87809. private _highlightsCurve;
  87810. private _midtonesCurve;
  87811. private _shadowsCurve;
  87812. private _positiveCurve;
  87813. private _negativeCurve;
  87814. private _globalHue;
  87815. private _globalDensity;
  87816. private _globalSaturation;
  87817. private _globalExposure;
  87818. /**
  87819. * Gets the global Hue value.
  87820. * 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).
  87821. */
  87822. get globalHue(): number;
  87823. /**
  87824. * Sets the global Hue value.
  87825. * 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).
  87826. */
  87827. set globalHue(value: number);
  87828. /**
  87829. * Gets the global Density value.
  87830. * 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.
  87831. * Values less than zero provide a filter of opposite hue.
  87832. */
  87833. get globalDensity(): number;
  87834. /**
  87835. * Sets the global Density value.
  87836. * 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.
  87837. * Values less than zero provide a filter of opposite hue.
  87838. */
  87839. set globalDensity(value: number);
  87840. /**
  87841. * Gets the global Saturation value.
  87842. * 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.
  87843. */
  87844. get globalSaturation(): number;
  87845. /**
  87846. * Sets the global Saturation value.
  87847. * 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.
  87848. */
  87849. set globalSaturation(value: number);
  87850. /**
  87851. * Gets the global Exposure value.
  87852. * 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.
  87853. */
  87854. get globalExposure(): number;
  87855. /**
  87856. * Sets the global Exposure value.
  87857. * 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.
  87858. */
  87859. set globalExposure(value: number);
  87860. private _highlightsHue;
  87861. private _highlightsDensity;
  87862. private _highlightsSaturation;
  87863. private _highlightsExposure;
  87864. /**
  87865. * Gets the highlights Hue value.
  87866. * 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).
  87867. */
  87868. get highlightsHue(): number;
  87869. /**
  87870. * Sets the highlights Hue value.
  87871. * 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).
  87872. */
  87873. set highlightsHue(value: number);
  87874. /**
  87875. * Gets the highlights Density value.
  87876. * 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.
  87877. * Values less than zero provide a filter of opposite hue.
  87878. */
  87879. get highlightsDensity(): number;
  87880. /**
  87881. * Sets the highlights Density value.
  87882. * 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.
  87883. * Values less than zero provide a filter of opposite hue.
  87884. */
  87885. set highlightsDensity(value: number);
  87886. /**
  87887. * Gets the highlights Saturation value.
  87888. * 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.
  87889. */
  87890. get highlightsSaturation(): number;
  87891. /**
  87892. * Sets the highlights Saturation value.
  87893. * 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.
  87894. */
  87895. set highlightsSaturation(value: number);
  87896. /**
  87897. * Gets the highlights Exposure value.
  87898. * 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.
  87899. */
  87900. get highlightsExposure(): number;
  87901. /**
  87902. * Sets the highlights Exposure value.
  87903. * 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.
  87904. */
  87905. set highlightsExposure(value: number);
  87906. private _midtonesHue;
  87907. private _midtonesDensity;
  87908. private _midtonesSaturation;
  87909. private _midtonesExposure;
  87910. /**
  87911. * Gets the midtones Hue value.
  87912. * 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).
  87913. */
  87914. get midtonesHue(): number;
  87915. /**
  87916. * Sets the midtones Hue value.
  87917. * 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).
  87918. */
  87919. set midtonesHue(value: number);
  87920. /**
  87921. * Gets the midtones Density value.
  87922. * 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.
  87923. * Values less than zero provide a filter of opposite hue.
  87924. */
  87925. get midtonesDensity(): number;
  87926. /**
  87927. * Sets the midtones Density value.
  87928. * 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.
  87929. * Values less than zero provide a filter of opposite hue.
  87930. */
  87931. set midtonesDensity(value: number);
  87932. /**
  87933. * Gets the midtones Saturation value.
  87934. * 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.
  87935. */
  87936. get midtonesSaturation(): number;
  87937. /**
  87938. * Sets the midtones Saturation value.
  87939. * 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.
  87940. */
  87941. set midtonesSaturation(value: number);
  87942. /**
  87943. * Gets the midtones Exposure value.
  87944. * 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.
  87945. */
  87946. get midtonesExposure(): number;
  87947. /**
  87948. * Sets the midtones Exposure value.
  87949. * 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.
  87950. */
  87951. set midtonesExposure(value: number);
  87952. private _shadowsHue;
  87953. private _shadowsDensity;
  87954. private _shadowsSaturation;
  87955. private _shadowsExposure;
  87956. /**
  87957. * Gets the shadows Hue value.
  87958. * 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).
  87959. */
  87960. get shadowsHue(): number;
  87961. /**
  87962. * Sets the shadows Hue value.
  87963. * 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).
  87964. */
  87965. set shadowsHue(value: number);
  87966. /**
  87967. * Gets the shadows Density value.
  87968. * 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.
  87969. * Values less than zero provide a filter of opposite hue.
  87970. */
  87971. get shadowsDensity(): number;
  87972. /**
  87973. * Sets the shadows Density value.
  87974. * 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.
  87975. * Values less than zero provide a filter of opposite hue.
  87976. */
  87977. set shadowsDensity(value: number);
  87978. /**
  87979. * Gets the shadows Saturation value.
  87980. * 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.
  87981. */
  87982. get shadowsSaturation(): number;
  87983. /**
  87984. * Sets the shadows Saturation value.
  87985. * 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.
  87986. */
  87987. set shadowsSaturation(value: number);
  87988. /**
  87989. * Gets the shadows Exposure value.
  87990. * 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.
  87991. */
  87992. get shadowsExposure(): number;
  87993. /**
  87994. * Sets the shadows Exposure value.
  87995. * 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.
  87996. */
  87997. set shadowsExposure(value: number);
  87998. /**
  87999. * Returns the class name
  88000. * @returns The class name
  88001. */
  88002. getClassName(): string;
  88003. /**
  88004. * Binds the color curves to the shader.
  88005. * @param colorCurves The color curve to bind
  88006. * @param effect The effect to bind to
  88007. * @param positiveUniform The positive uniform shader parameter
  88008. * @param neutralUniform The neutral uniform shader parameter
  88009. * @param negativeUniform The negative uniform shader parameter
  88010. */
  88011. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88012. /**
  88013. * Prepare the list of uniforms associated with the ColorCurves effects.
  88014. * @param uniformsList The list of uniforms used in the effect
  88015. */
  88016. static PrepareUniforms(uniformsList: string[]): void;
  88017. /**
  88018. * Returns color grading data based on a hue, density, saturation and exposure value.
  88019. * @param filterHue The hue of the color filter.
  88020. * @param filterDensity The density of the color filter.
  88021. * @param saturation The saturation.
  88022. * @param exposure The exposure.
  88023. * @param result The result data container.
  88024. */
  88025. private getColorGradingDataToRef;
  88026. /**
  88027. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88028. * @param value The input slider value in range [-100,100].
  88029. * @returns Adjusted value.
  88030. */
  88031. private static applyColorGradingSliderNonlinear;
  88032. /**
  88033. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88034. * @param hue The hue (H) input.
  88035. * @param saturation The saturation (S) input.
  88036. * @param brightness The brightness (B) input.
  88037. * @result An RGBA color represented as Vector4.
  88038. */
  88039. private static fromHSBToRef;
  88040. /**
  88041. * Returns a value clamped between min and max
  88042. * @param value The value to clamp
  88043. * @param min The minimum of value
  88044. * @param max The maximum of value
  88045. * @returns The clamped value.
  88046. */
  88047. private static clamp;
  88048. /**
  88049. * Clones the current color curve instance.
  88050. * @return The cloned curves
  88051. */
  88052. clone(): ColorCurves;
  88053. /**
  88054. * Serializes the current color curve instance to a json representation.
  88055. * @return a JSON representation
  88056. */
  88057. serialize(): any;
  88058. /**
  88059. * Parses the color curve from a json representation.
  88060. * @param source the JSON source to parse
  88061. * @return The parsed curves
  88062. */
  88063. static Parse(source: any): ColorCurves;
  88064. }
  88065. }
  88066. declare module BABYLON {
  88067. /**
  88068. * Interface to follow in your material defines to integrate easily the
  88069. * Image proccessing functions.
  88070. * @hidden
  88071. */
  88072. export interface IImageProcessingConfigurationDefines {
  88073. IMAGEPROCESSING: boolean;
  88074. VIGNETTE: boolean;
  88075. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88076. VIGNETTEBLENDMODEOPAQUE: boolean;
  88077. TONEMAPPING: boolean;
  88078. TONEMAPPING_ACES: boolean;
  88079. CONTRAST: boolean;
  88080. EXPOSURE: boolean;
  88081. COLORCURVES: boolean;
  88082. COLORGRADING: boolean;
  88083. COLORGRADING3D: boolean;
  88084. SAMPLER3DGREENDEPTH: boolean;
  88085. SAMPLER3DBGRMAP: boolean;
  88086. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88087. }
  88088. /**
  88089. * @hidden
  88090. */
  88091. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88092. IMAGEPROCESSING: boolean;
  88093. VIGNETTE: boolean;
  88094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88095. VIGNETTEBLENDMODEOPAQUE: boolean;
  88096. TONEMAPPING: boolean;
  88097. TONEMAPPING_ACES: boolean;
  88098. CONTRAST: boolean;
  88099. COLORCURVES: boolean;
  88100. COLORGRADING: boolean;
  88101. COLORGRADING3D: boolean;
  88102. SAMPLER3DGREENDEPTH: boolean;
  88103. SAMPLER3DBGRMAP: boolean;
  88104. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88105. EXPOSURE: boolean;
  88106. constructor();
  88107. }
  88108. /**
  88109. * This groups together the common properties used for image processing either in direct forward pass
  88110. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88111. * or not.
  88112. */
  88113. export class ImageProcessingConfiguration {
  88114. /**
  88115. * Default tone mapping applied in BabylonJS.
  88116. */
  88117. static readonly TONEMAPPING_STANDARD: number;
  88118. /**
  88119. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88120. * to other engines rendering to increase portability.
  88121. */
  88122. static readonly TONEMAPPING_ACES: number;
  88123. /**
  88124. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88125. */
  88126. colorCurves: Nullable<ColorCurves>;
  88127. private _colorCurvesEnabled;
  88128. /**
  88129. * Gets wether the color curves effect is enabled.
  88130. */
  88131. get colorCurvesEnabled(): boolean;
  88132. /**
  88133. * Sets wether the color curves effect is enabled.
  88134. */
  88135. set colorCurvesEnabled(value: boolean);
  88136. private _colorGradingTexture;
  88137. /**
  88138. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88139. */
  88140. get colorGradingTexture(): Nullable<BaseTexture>;
  88141. /**
  88142. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88143. */
  88144. set colorGradingTexture(value: Nullable<BaseTexture>);
  88145. private _colorGradingEnabled;
  88146. /**
  88147. * Gets wether the color grading effect is enabled.
  88148. */
  88149. get colorGradingEnabled(): boolean;
  88150. /**
  88151. * Sets wether the color grading effect is enabled.
  88152. */
  88153. set colorGradingEnabled(value: boolean);
  88154. private _colorGradingWithGreenDepth;
  88155. /**
  88156. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88157. */
  88158. get colorGradingWithGreenDepth(): boolean;
  88159. /**
  88160. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88161. */
  88162. set colorGradingWithGreenDepth(value: boolean);
  88163. private _colorGradingBGR;
  88164. /**
  88165. * Gets wether the color grading texture contains BGR values.
  88166. */
  88167. get colorGradingBGR(): boolean;
  88168. /**
  88169. * Sets wether the color grading texture contains BGR values.
  88170. */
  88171. set colorGradingBGR(value: boolean);
  88172. /** @hidden */
  88173. _exposure: number;
  88174. /**
  88175. * Gets the Exposure used in the effect.
  88176. */
  88177. get exposure(): number;
  88178. /**
  88179. * Sets the Exposure used in the effect.
  88180. */
  88181. set exposure(value: number);
  88182. private _toneMappingEnabled;
  88183. /**
  88184. * Gets wether the tone mapping effect is enabled.
  88185. */
  88186. get toneMappingEnabled(): boolean;
  88187. /**
  88188. * Sets wether the tone mapping effect is enabled.
  88189. */
  88190. set toneMappingEnabled(value: boolean);
  88191. private _toneMappingType;
  88192. /**
  88193. * Gets the type of tone mapping effect.
  88194. */
  88195. get toneMappingType(): number;
  88196. /**
  88197. * Sets the type of tone mapping effect used in BabylonJS.
  88198. */
  88199. set toneMappingType(value: number);
  88200. protected _contrast: number;
  88201. /**
  88202. * Gets the contrast used in the effect.
  88203. */
  88204. get contrast(): number;
  88205. /**
  88206. * Sets the contrast used in the effect.
  88207. */
  88208. set contrast(value: number);
  88209. /**
  88210. * Vignette stretch size.
  88211. */
  88212. vignetteStretch: number;
  88213. /**
  88214. * Vignette centre X Offset.
  88215. */
  88216. vignetteCentreX: number;
  88217. /**
  88218. * Vignette centre Y Offset.
  88219. */
  88220. vignetteCentreY: number;
  88221. /**
  88222. * Vignette weight or intensity of the vignette effect.
  88223. */
  88224. vignetteWeight: number;
  88225. /**
  88226. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88227. * if vignetteEnabled is set to true.
  88228. */
  88229. vignetteColor: Color4;
  88230. /**
  88231. * Camera field of view used by the Vignette effect.
  88232. */
  88233. vignetteCameraFov: number;
  88234. private _vignetteBlendMode;
  88235. /**
  88236. * Gets the vignette blend mode allowing different kind of effect.
  88237. */
  88238. get vignetteBlendMode(): number;
  88239. /**
  88240. * Sets the vignette blend mode allowing different kind of effect.
  88241. */
  88242. set vignetteBlendMode(value: number);
  88243. private _vignetteEnabled;
  88244. /**
  88245. * Gets wether the vignette effect is enabled.
  88246. */
  88247. get vignetteEnabled(): boolean;
  88248. /**
  88249. * Sets wether the vignette effect is enabled.
  88250. */
  88251. set vignetteEnabled(value: boolean);
  88252. private _applyByPostProcess;
  88253. /**
  88254. * Gets wether the image processing is applied through a post process or not.
  88255. */
  88256. get applyByPostProcess(): boolean;
  88257. /**
  88258. * Sets wether the image processing is applied through a post process or not.
  88259. */
  88260. set applyByPostProcess(value: boolean);
  88261. private _isEnabled;
  88262. /**
  88263. * Gets wether the image processing is enabled or not.
  88264. */
  88265. get isEnabled(): boolean;
  88266. /**
  88267. * Sets wether the image processing is enabled or not.
  88268. */
  88269. set isEnabled(value: boolean);
  88270. /**
  88271. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88272. */
  88273. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88274. /**
  88275. * Method called each time the image processing information changes requires to recompile the effect.
  88276. */
  88277. protected _updateParameters(): void;
  88278. /**
  88279. * Gets the current class name.
  88280. * @return "ImageProcessingConfiguration"
  88281. */
  88282. getClassName(): string;
  88283. /**
  88284. * Prepare the list of uniforms associated with the Image Processing effects.
  88285. * @param uniforms The list of uniforms used in the effect
  88286. * @param defines the list of defines currently in use
  88287. */
  88288. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88289. /**
  88290. * Prepare the list of samplers associated with the Image Processing effects.
  88291. * @param samplersList The list of uniforms used in the effect
  88292. * @param defines the list of defines currently in use
  88293. */
  88294. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88295. /**
  88296. * Prepare the list of defines associated to the shader.
  88297. * @param defines the list of defines to complete
  88298. * @param forPostProcess Define if we are currently in post process mode or not
  88299. */
  88300. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88301. /**
  88302. * Returns true if all the image processing information are ready.
  88303. * @returns True if ready, otherwise, false
  88304. */
  88305. isReady(): boolean;
  88306. /**
  88307. * Binds the image processing to the shader.
  88308. * @param effect The effect to bind to
  88309. * @param overrideAspectRatio Override the aspect ratio of the effect
  88310. */
  88311. bind(effect: Effect, overrideAspectRatio?: number): void;
  88312. /**
  88313. * Clones the current image processing instance.
  88314. * @return The cloned image processing
  88315. */
  88316. clone(): ImageProcessingConfiguration;
  88317. /**
  88318. * Serializes the current image processing instance to a json representation.
  88319. * @return a JSON representation
  88320. */
  88321. serialize(): any;
  88322. /**
  88323. * Parses the image processing from a json representation.
  88324. * @param source the JSON source to parse
  88325. * @return The parsed image processing
  88326. */
  88327. static Parse(source: any): ImageProcessingConfiguration;
  88328. private static _VIGNETTEMODE_MULTIPLY;
  88329. private static _VIGNETTEMODE_OPAQUE;
  88330. /**
  88331. * Used to apply the vignette as a mix with the pixel color.
  88332. */
  88333. static get VIGNETTEMODE_MULTIPLY(): number;
  88334. /**
  88335. * Used to apply the vignette as a replacement of the pixel color.
  88336. */
  88337. static get VIGNETTEMODE_OPAQUE(): number;
  88338. }
  88339. }
  88340. declare module BABYLON {
  88341. /** @hidden */
  88342. export var postprocessVertexShader: {
  88343. name: string;
  88344. shader: string;
  88345. };
  88346. }
  88347. declare module BABYLON {
  88348. interface ThinEngine {
  88349. /**
  88350. * Creates a new render target texture
  88351. * @param size defines the size of the texture
  88352. * @param options defines the options used to create the texture
  88353. * @returns a new render target texture stored in an InternalTexture
  88354. */
  88355. createRenderTargetTexture(size: number | {
  88356. width: number;
  88357. height: number;
  88358. layers?: number;
  88359. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88360. /**
  88361. * Creates a depth stencil texture.
  88362. * This is only available in WebGL 2 or with the depth texture extension available.
  88363. * @param size The size of face edge in the texture.
  88364. * @param options The options defining the texture.
  88365. * @returns The texture
  88366. */
  88367. createDepthStencilTexture(size: number | {
  88368. width: number;
  88369. height: number;
  88370. layers?: number;
  88371. }, options: DepthTextureCreationOptions): InternalTexture;
  88372. /** @hidden */
  88373. _createDepthStencilTexture(size: number | {
  88374. width: number;
  88375. height: number;
  88376. layers?: number;
  88377. }, options: DepthTextureCreationOptions): InternalTexture;
  88378. }
  88379. }
  88380. declare module BABYLON {
  88381. /**
  88382. * Defines the kind of connection point for node based material
  88383. */
  88384. export enum NodeMaterialBlockConnectionPointTypes {
  88385. /** Float */
  88386. Float = 1,
  88387. /** Int */
  88388. Int = 2,
  88389. /** Vector2 */
  88390. Vector2 = 4,
  88391. /** Vector3 */
  88392. Vector3 = 8,
  88393. /** Vector4 */
  88394. Vector4 = 16,
  88395. /** Color3 */
  88396. Color3 = 32,
  88397. /** Color4 */
  88398. Color4 = 64,
  88399. /** Matrix */
  88400. Matrix = 128,
  88401. /** Custom object */
  88402. Object = 256,
  88403. /** Detect type based on connection */
  88404. AutoDetect = 1024,
  88405. /** Output type that will be defined by input type */
  88406. BasedOnInput = 2048
  88407. }
  88408. }
  88409. declare module BABYLON {
  88410. /**
  88411. * Enum used to define the target of a block
  88412. */
  88413. export enum NodeMaterialBlockTargets {
  88414. /** Vertex shader */
  88415. Vertex = 1,
  88416. /** Fragment shader */
  88417. Fragment = 2,
  88418. /** Neutral */
  88419. Neutral = 4,
  88420. /** Vertex and Fragment */
  88421. VertexAndFragment = 3
  88422. }
  88423. }
  88424. declare module BABYLON {
  88425. /**
  88426. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88427. */
  88428. export enum NodeMaterialBlockConnectionPointMode {
  88429. /** Value is an uniform */
  88430. Uniform = 0,
  88431. /** Value is a mesh attribute */
  88432. Attribute = 1,
  88433. /** Value is a varying between vertex and fragment shaders */
  88434. Varying = 2,
  88435. /** Mode is undefined */
  88436. Undefined = 3
  88437. }
  88438. }
  88439. declare module BABYLON {
  88440. /**
  88441. * Enum used to define system values e.g. values automatically provided by the system
  88442. */
  88443. export enum NodeMaterialSystemValues {
  88444. /** World */
  88445. World = 1,
  88446. /** View */
  88447. View = 2,
  88448. /** Projection */
  88449. Projection = 3,
  88450. /** ViewProjection */
  88451. ViewProjection = 4,
  88452. /** WorldView */
  88453. WorldView = 5,
  88454. /** WorldViewProjection */
  88455. WorldViewProjection = 6,
  88456. /** CameraPosition */
  88457. CameraPosition = 7,
  88458. /** Fog Color */
  88459. FogColor = 8,
  88460. /** Delta time */
  88461. DeltaTime = 9
  88462. }
  88463. }
  88464. declare module BABYLON {
  88465. /** Defines supported spaces */
  88466. export enum Space {
  88467. /** Local (object) space */
  88468. LOCAL = 0,
  88469. /** World space */
  88470. WORLD = 1,
  88471. /** Bone space */
  88472. BONE = 2
  88473. }
  88474. /** Defines the 3 main axes */
  88475. export class Axis {
  88476. /** X axis */
  88477. static X: Vector3;
  88478. /** Y axis */
  88479. static Y: Vector3;
  88480. /** Z axis */
  88481. static Z: Vector3;
  88482. }
  88483. }
  88484. declare module BABYLON {
  88485. /**
  88486. * Represents a camera frustum
  88487. */
  88488. export class Frustum {
  88489. /**
  88490. * Gets the planes representing the frustum
  88491. * @param transform matrix to be applied to the returned planes
  88492. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  88493. */
  88494. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  88495. /**
  88496. * Gets the near frustum plane transformed by the transform matrix
  88497. * @param transform transformation matrix to be applied to the resulting frustum plane
  88498. * @param frustumPlane the resuling frustum plane
  88499. */
  88500. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88501. /**
  88502. * Gets the far frustum plane transformed by the transform matrix
  88503. * @param transform transformation matrix to be applied to the resulting frustum plane
  88504. * @param frustumPlane the resuling frustum plane
  88505. */
  88506. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88507. /**
  88508. * Gets the left frustum plane transformed by the transform matrix
  88509. * @param transform transformation matrix to be applied to the resulting frustum plane
  88510. * @param frustumPlane the resuling frustum plane
  88511. */
  88512. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88513. /**
  88514. * Gets the right frustum plane transformed by the transform matrix
  88515. * @param transform transformation matrix to be applied to the resulting frustum plane
  88516. * @param frustumPlane the resuling frustum plane
  88517. */
  88518. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88519. /**
  88520. * Gets the top frustum plane transformed by the transform matrix
  88521. * @param transform transformation matrix to be applied to the resulting frustum plane
  88522. * @param frustumPlane the resuling frustum plane
  88523. */
  88524. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88525. /**
  88526. * Gets the bottom frustum plane transformed by the transform matrix
  88527. * @param transform transformation matrix to be applied to the resulting frustum plane
  88528. * @param frustumPlane the resuling frustum plane
  88529. */
  88530. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88531. /**
  88532. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88533. * @param transform transformation matrix to be applied to the resulting frustum planes
  88534. * @param frustumPlanes the resuling frustum planes
  88535. */
  88536. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88537. }
  88538. }
  88539. declare module BABYLON {
  88540. /**
  88541. * Interface for the size containing width and height
  88542. */
  88543. export interface ISize {
  88544. /**
  88545. * Width
  88546. */
  88547. width: number;
  88548. /**
  88549. * Heighht
  88550. */
  88551. height: number;
  88552. }
  88553. /**
  88554. * Size containing widht and height
  88555. */
  88556. export class Size implements ISize {
  88557. /**
  88558. * Width
  88559. */
  88560. width: number;
  88561. /**
  88562. * Height
  88563. */
  88564. height: number;
  88565. /**
  88566. * Creates a Size object from the given width and height (floats).
  88567. * @param width width of the new size
  88568. * @param height height of the new size
  88569. */
  88570. constructor(width: number, height: number);
  88571. /**
  88572. * Returns a string with the Size width and height
  88573. * @returns a string with the Size width and height
  88574. */
  88575. toString(): string;
  88576. /**
  88577. * "Size"
  88578. * @returns the string "Size"
  88579. */
  88580. getClassName(): string;
  88581. /**
  88582. * Returns the Size hash code.
  88583. * @returns a hash code for a unique width and height
  88584. */
  88585. getHashCode(): number;
  88586. /**
  88587. * Updates the current size from the given one.
  88588. * @param src the given size
  88589. */
  88590. copyFrom(src: Size): void;
  88591. /**
  88592. * Updates in place the current Size from the given floats.
  88593. * @param width width of the new size
  88594. * @param height height of the new size
  88595. * @returns the updated Size.
  88596. */
  88597. copyFromFloats(width: number, height: number): Size;
  88598. /**
  88599. * Updates in place the current Size from the given floats.
  88600. * @param width width to set
  88601. * @param height height to set
  88602. * @returns the updated Size.
  88603. */
  88604. set(width: number, height: number): Size;
  88605. /**
  88606. * Multiplies the width and height by numbers
  88607. * @param w factor to multiple the width by
  88608. * @param h factor to multiple the height by
  88609. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88610. */
  88611. multiplyByFloats(w: number, h: number): Size;
  88612. /**
  88613. * Clones the size
  88614. * @returns a new Size copied from the given one.
  88615. */
  88616. clone(): Size;
  88617. /**
  88618. * True if the current Size and the given one width and height are strictly equal.
  88619. * @param other the other size to compare against
  88620. * @returns True if the current Size and the given one width and height are strictly equal.
  88621. */
  88622. equals(other: Size): boolean;
  88623. /**
  88624. * The surface of the Size : width * height (float).
  88625. */
  88626. get surface(): number;
  88627. /**
  88628. * Create a new size of zero
  88629. * @returns a new Size set to (0.0, 0.0)
  88630. */
  88631. static Zero(): Size;
  88632. /**
  88633. * Sums the width and height of two sizes
  88634. * @param otherSize size to add to this size
  88635. * @returns a new Size set as the addition result of the current Size and the given one.
  88636. */
  88637. add(otherSize: Size): Size;
  88638. /**
  88639. * Subtracts the width and height of two
  88640. * @param otherSize size to subtract to this size
  88641. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88642. */
  88643. subtract(otherSize: Size): Size;
  88644. /**
  88645. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88646. * @param start starting size to lerp between
  88647. * @param end end size to lerp between
  88648. * @param amount amount to lerp between the start and end values
  88649. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88650. */
  88651. static Lerp(start: Size, end: Size, amount: number): Size;
  88652. }
  88653. }
  88654. declare module BABYLON {
  88655. /**
  88656. * Contains position and normal vectors for a vertex
  88657. */
  88658. export class PositionNormalVertex {
  88659. /** the position of the vertex (defaut: 0,0,0) */
  88660. position: Vector3;
  88661. /** the normal of the vertex (defaut: 0,1,0) */
  88662. normal: Vector3;
  88663. /**
  88664. * Creates a PositionNormalVertex
  88665. * @param position the position of the vertex (defaut: 0,0,0)
  88666. * @param normal the normal of the vertex (defaut: 0,1,0)
  88667. */
  88668. constructor(
  88669. /** the position of the vertex (defaut: 0,0,0) */
  88670. position?: Vector3,
  88671. /** the normal of the vertex (defaut: 0,1,0) */
  88672. normal?: Vector3);
  88673. /**
  88674. * Clones the PositionNormalVertex
  88675. * @returns the cloned PositionNormalVertex
  88676. */
  88677. clone(): PositionNormalVertex;
  88678. }
  88679. /**
  88680. * Contains position, normal and uv vectors for a vertex
  88681. */
  88682. export class PositionNormalTextureVertex {
  88683. /** the position of the vertex (defaut: 0,0,0) */
  88684. position: Vector3;
  88685. /** the normal of the vertex (defaut: 0,1,0) */
  88686. normal: Vector3;
  88687. /** the uv of the vertex (default: 0,0) */
  88688. uv: Vector2;
  88689. /**
  88690. * Creates a PositionNormalTextureVertex
  88691. * @param position the position of the vertex (defaut: 0,0,0)
  88692. * @param normal the normal of the vertex (defaut: 0,1,0)
  88693. * @param uv the uv of the vertex (default: 0,0)
  88694. */
  88695. constructor(
  88696. /** the position of the vertex (defaut: 0,0,0) */
  88697. position?: Vector3,
  88698. /** the normal of the vertex (defaut: 0,1,0) */
  88699. normal?: Vector3,
  88700. /** the uv of the vertex (default: 0,0) */
  88701. uv?: Vector2);
  88702. /**
  88703. * Clones the PositionNormalTextureVertex
  88704. * @returns the cloned PositionNormalTextureVertex
  88705. */
  88706. clone(): PositionNormalTextureVertex;
  88707. }
  88708. }
  88709. declare module BABYLON {
  88710. /**
  88711. * Enum defining the type of animations supported by InputBlock
  88712. */
  88713. export enum AnimatedInputBlockTypes {
  88714. /** No animation */
  88715. None = 0,
  88716. /** Time based animation. Will only work for floats */
  88717. Time = 1
  88718. }
  88719. }
  88720. declare module BABYLON {
  88721. /**
  88722. * Interface describing all the common properties and methods a shadow light needs to implement.
  88723. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88724. * as well as binding the different shadow properties to the effects.
  88725. */
  88726. export interface IShadowLight extends Light {
  88727. /**
  88728. * The light id in the scene (used in scene.findLighById for instance)
  88729. */
  88730. id: string;
  88731. /**
  88732. * The position the shdow will be casted from.
  88733. */
  88734. position: Vector3;
  88735. /**
  88736. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88737. */
  88738. direction: Vector3;
  88739. /**
  88740. * The transformed position. Position of the light in world space taking parenting in account.
  88741. */
  88742. transformedPosition: Vector3;
  88743. /**
  88744. * The transformed direction. Direction of the light in world space taking parenting in account.
  88745. */
  88746. transformedDirection: Vector3;
  88747. /**
  88748. * The friendly name of the light in the scene.
  88749. */
  88750. name: string;
  88751. /**
  88752. * Defines the shadow projection clipping minimum z value.
  88753. */
  88754. shadowMinZ: number;
  88755. /**
  88756. * Defines the shadow projection clipping maximum z value.
  88757. */
  88758. shadowMaxZ: number;
  88759. /**
  88760. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88761. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88762. */
  88763. computeTransformedInformation(): boolean;
  88764. /**
  88765. * Gets the scene the light belongs to.
  88766. * @returns The scene
  88767. */
  88768. getScene(): Scene;
  88769. /**
  88770. * Callback defining a custom Projection Matrix Builder.
  88771. * This can be used to override the default projection matrix computation.
  88772. */
  88773. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88774. /**
  88775. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88776. * @param matrix The materix to updated with the projection information
  88777. * @param viewMatrix The transform matrix of the light
  88778. * @param renderList The list of mesh to render in the map
  88779. * @returns The current light
  88780. */
  88781. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88782. /**
  88783. * Gets the current depth scale used in ESM.
  88784. * @returns The scale
  88785. */
  88786. getDepthScale(): number;
  88787. /**
  88788. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88789. * @returns true if a cube texture needs to be use
  88790. */
  88791. needCube(): boolean;
  88792. /**
  88793. * Detects if the projection matrix requires to be recomputed this frame.
  88794. * @returns true if it requires to be recomputed otherwise, false.
  88795. */
  88796. needProjectionMatrixCompute(): boolean;
  88797. /**
  88798. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88799. */
  88800. forceProjectionMatrixCompute(): void;
  88801. /**
  88802. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88803. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88804. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88805. */
  88806. getShadowDirection(faceIndex?: number): Vector3;
  88807. /**
  88808. * Gets the minZ used for shadow according to both the scene and the light.
  88809. * @param activeCamera The camera we are returning the min for
  88810. * @returns the depth min z
  88811. */
  88812. getDepthMinZ(activeCamera: Camera): number;
  88813. /**
  88814. * Gets the maxZ used for shadow according to both the scene and the light.
  88815. * @param activeCamera The camera we are returning the max for
  88816. * @returns the depth max z
  88817. */
  88818. getDepthMaxZ(activeCamera: Camera): number;
  88819. }
  88820. /**
  88821. * Base implementation IShadowLight
  88822. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88823. */
  88824. export abstract class ShadowLight extends Light implements IShadowLight {
  88825. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88826. protected _position: Vector3;
  88827. protected _setPosition(value: Vector3): void;
  88828. /**
  88829. * Sets the position the shadow will be casted from. Also use as the light position for both
  88830. * point and spot lights.
  88831. */
  88832. get position(): Vector3;
  88833. /**
  88834. * Sets the position the shadow will be casted from. Also use as the light position for both
  88835. * point and spot lights.
  88836. */
  88837. set position(value: Vector3);
  88838. protected _direction: Vector3;
  88839. protected _setDirection(value: Vector3): void;
  88840. /**
  88841. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88842. * Also use as the light direction on spot and directional lights.
  88843. */
  88844. get direction(): Vector3;
  88845. /**
  88846. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88847. * Also use as the light direction on spot and directional lights.
  88848. */
  88849. set direction(value: Vector3);
  88850. protected _shadowMinZ: number;
  88851. /**
  88852. * Gets the shadow projection clipping minimum z value.
  88853. */
  88854. get shadowMinZ(): number;
  88855. /**
  88856. * Sets the shadow projection clipping minimum z value.
  88857. */
  88858. set shadowMinZ(value: number);
  88859. protected _shadowMaxZ: number;
  88860. /**
  88861. * Sets the shadow projection clipping maximum z value.
  88862. */
  88863. get shadowMaxZ(): number;
  88864. /**
  88865. * Gets the shadow projection clipping maximum z value.
  88866. */
  88867. set shadowMaxZ(value: number);
  88868. /**
  88869. * Callback defining a custom Projection Matrix Builder.
  88870. * This can be used to override the default projection matrix computation.
  88871. */
  88872. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88873. /**
  88874. * The transformed position. Position of the light in world space taking parenting in account.
  88875. */
  88876. transformedPosition: Vector3;
  88877. /**
  88878. * The transformed direction. Direction of the light in world space taking parenting in account.
  88879. */
  88880. transformedDirection: Vector3;
  88881. private _needProjectionMatrixCompute;
  88882. /**
  88883. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88884. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88885. */
  88886. computeTransformedInformation(): boolean;
  88887. /**
  88888. * Return the depth scale used for the shadow map.
  88889. * @returns the depth scale.
  88890. */
  88891. getDepthScale(): number;
  88892. /**
  88893. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88894. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88895. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88896. */
  88897. getShadowDirection(faceIndex?: number): Vector3;
  88898. /**
  88899. * Returns the ShadowLight absolute position in the World.
  88900. * @returns the position vector in world space
  88901. */
  88902. getAbsolutePosition(): Vector3;
  88903. /**
  88904. * Sets the ShadowLight direction toward the passed target.
  88905. * @param target The point to target in local space
  88906. * @returns the updated ShadowLight direction
  88907. */
  88908. setDirectionToTarget(target: Vector3): Vector3;
  88909. /**
  88910. * Returns the light rotation in euler definition.
  88911. * @returns the x y z rotation in local space.
  88912. */
  88913. getRotation(): Vector3;
  88914. /**
  88915. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88916. * @returns true if a cube texture needs to be use
  88917. */
  88918. needCube(): boolean;
  88919. /**
  88920. * Detects if the projection matrix requires to be recomputed this frame.
  88921. * @returns true if it requires to be recomputed otherwise, false.
  88922. */
  88923. needProjectionMatrixCompute(): boolean;
  88924. /**
  88925. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88926. */
  88927. forceProjectionMatrixCompute(): void;
  88928. /** @hidden */
  88929. _initCache(): void;
  88930. /** @hidden */
  88931. _isSynchronized(): boolean;
  88932. /**
  88933. * Computes the world matrix of the node
  88934. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88935. * @returns the world matrix
  88936. */
  88937. computeWorldMatrix(force?: boolean): Matrix;
  88938. /**
  88939. * Gets the minZ used for shadow according to both the scene and the light.
  88940. * @param activeCamera The camera we are returning the min for
  88941. * @returns the depth min z
  88942. */
  88943. getDepthMinZ(activeCamera: Camera): number;
  88944. /**
  88945. * Gets the maxZ used for shadow according to both the scene and the light.
  88946. * @param activeCamera The camera we are returning the max for
  88947. * @returns the depth max z
  88948. */
  88949. getDepthMaxZ(activeCamera: Camera): number;
  88950. /**
  88951. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88952. * @param matrix The materix to updated with the projection information
  88953. * @param viewMatrix The transform matrix of the light
  88954. * @param renderList The list of mesh to render in the map
  88955. * @returns The current light
  88956. */
  88957. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88958. }
  88959. }
  88960. declare module BABYLON {
  88961. /** @hidden */
  88962. export var packingFunctions: {
  88963. name: string;
  88964. shader: string;
  88965. };
  88966. }
  88967. declare module BABYLON {
  88968. /** @hidden */
  88969. export var bayerDitherFunctions: {
  88970. name: string;
  88971. shader: string;
  88972. };
  88973. }
  88974. declare module BABYLON {
  88975. /** @hidden */
  88976. export var shadowMapFragmentDeclaration: {
  88977. name: string;
  88978. shader: string;
  88979. };
  88980. }
  88981. declare module BABYLON {
  88982. /** @hidden */
  88983. export var clipPlaneFragmentDeclaration: {
  88984. name: string;
  88985. shader: string;
  88986. };
  88987. }
  88988. declare module BABYLON {
  88989. /** @hidden */
  88990. export var clipPlaneFragment: {
  88991. name: string;
  88992. shader: string;
  88993. };
  88994. }
  88995. declare module BABYLON {
  88996. /** @hidden */
  88997. export var shadowMapFragment: {
  88998. name: string;
  88999. shader: string;
  89000. };
  89001. }
  89002. declare module BABYLON {
  89003. /** @hidden */
  89004. export var shadowMapPixelShader: {
  89005. name: string;
  89006. shader: string;
  89007. };
  89008. }
  89009. declare module BABYLON {
  89010. /** @hidden */
  89011. export var bonesDeclaration: {
  89012. name: string;
  89013. shader: string;
  89014. };
  89015. }
  89016. declare module BABYLON {
  89017. /** @hidden */
  89018. export var morphTargetsVertexGlobalDeclaration: {
  89019. name: string;
  89020. shader: string;
  89021. };
  89022. }
  89023. declare module BABYLON {
  89024. /** @hidden */
  89025. export var morphTargetsVertexDeclaration: {
  89026. name: string;
  89027. shader: string;
  89028. };
  89029. }
  89030. declare module BABYLON {
  89031. /** @hidden */
  89032. export var instancesDeclaration: {
  89033. name: string;
  89034. shader: string;
  89035. };
  89036. }
  89037. declare module BABYLON {
  89038. /** @hidden */
  89039. export var helperFunctions: {
  89040. name: string;
  89041. shader: string;
  89042. };
  89043. }
  89044. declare module BABYLON {
  89045. /** @hidden */
  89046. export var shadowMapVertexDeclaration: {
  89047. name: string;
  89048. shader: string;
  89049. };
  89050. }
  89051. declare module BABYLON {
  89052. /** @hidden */
  89053. export var clipPlaneVertexDeclaration: {
  89054. name: string;
  89055. shader: string;
  89056. };
  89057. }
  89058. declare module BABYLON {
  89059. /** @hidden */
  89060. export var morphTargetsVertex: {
  89061. name: string;
  89062. shader: string;
  89063. };
  89064. }
  89065. declare module BABYLON {
  89066. /** @hidden */
  89067. export var instancesVertex: {
  89068. name: string;
  89069. shader: string;
  89070. };
  89071. }
  89072. declare module BABYLON {
  89073. /** @hidden */
  89074. export var bonesVertex: {
  89075. name: string;
  89076. shader: string;
  89077. };
  89078. }
  89079. declare module BABYLON {
  89080. /** @hidden */
  89081. export var shadowMapVertexNormalBias: {
  89082. name: string;
  89083. shader: string;
  89084. };
  89085. }
  89086. declare module BABYLON {
  89087. /** @hidden */
  89088. export var shadowMapVertexMetric: {
  89089. name: string;
  89090. shader: string;
  89091. };
  89092. }
  89093. declare module BABYLON {
  89094. /** @hidden */
  89095. export var clipPlaneVertex: {
  89096. name: string;
  89097. shader: string;
  89098. };
  89099. }
  89100. declare module BABYLON {
  89101. /** @hidden */
  89102. export var shadowMapVertexShader: {
  89103. name: string;
  89104. shader: string;
  89105. };
  89106. }
  89107. declare module BABYLON {
  89108. /** @hidden */
  89109. export var depthBoxBlurPixelShader: {
  89110. name: string;
  89111. shader: string;
  89112. };
  89113. }
  89114. declare module BABYLON {
  89115. /** @hidden */
  89116. export var shadowMapFragmentSoftTransparentShadow: {
  89117. name: string;
  89118. shader: string;
  89119. };
  89120. }
  89121. declare module BABYLON {
  89122. /**
  89123. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89124. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89125. */
  89126. export class EffectFallbacks implements IEffectFallbacks {
  89127. private _defines;
  89128. private _currentRank;
  89129. private _maxRank;
  89130. private _mesh;
  89131. /**
  89132. * Removes the fallback from the bound mesh.
  89133. */
  89134. unBindMesh(): void;
  89135. /**
  89136. * Adds a fallback on the specified property.
  89137. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89138. * @param define The name of the define in the shader
  89139. */
  89140. addFallback(rank: number, define: string): void;
  89141. /**
  89142. * Sets the mesh to use CPU skinning when needing to fallback.
  89143. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89144. * @param mesh The mesh to use the fallbacks.
  89145. */
  89146. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89147. /**
  89148. * Checks to see if more fallbacks are still availible.
  89149. */
  89150. get hasMoreFallbacks(): boolean;
  89151. /**
  89152. * Removes the defines that should be removed when falling back.
  89153. * @param currentDefines defines the current define statements for the shader.
  89154. * @param effect defines the current effect we try to compile
  89155. * @returns The resulting defines with defines of the current rank removed.
  89156. */
  89157. reduce(currentDefines: string, effect: Effect): string;
  89158. }
  89159. }
  89160. declare module BABYLON {
  89161. /**
  89162. * Interface used to define Action
  89163. */
  89164. export interface IAction {
  89165. /**
  89166. * Trigger for the action
  89167. */
  89168. trigger: number;
  89169. /** Options of the trigger */
  89170. triggerOptions: any;
  89171. /**
  89172. * Gets the trigger parameters
  89173. * @returns the trigger parameters
  89174. */
  89175. getTriggerParameter(): any;
  89176. /**
  89177. * Internal only - executes current action event
  89178. * @hidden
  89179. */
  89180. _executeCurrent(evt?: ActionEvent): void;
  89181. /**
  89182. * Serialize placeholder for child classes
  89183. * @param parent of child
  89184. * @returns the serialized object
  89185. */
  89186. serialize(parent: any): any;
  89187. /**
  89188. * Internal only
  89189. * @hidden
  89190. */
  89191. _prepare(): void;
  89192. /**
  89193. * Internal only - manager for action
  89194. * @hidden
  89195. */
  89196. _actionManager: Nullable<AbstractActionManager>;
  89197. /**
  89198. * Adds action to chain of actions, may be a DoNothingAction
  89199. * @param action defines the next action to execute
  89200. * @returns The action passed in
  89201. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89202. */
  89203. then(action: IAction): IAction;
  89204. }
  89205. /**
  89206. * The action to be carried out following a trigger
  89207. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89208. */
  89209. export class Action implements IAction {
  89210. /** the trigger, with or without parameters, for the action */
  89211. triggerOptions: any;
  89212. /**
  89213. * Trigger for the action
  89214. */
  89215. trigger: number;
  89216. /**
  89217. * Internal only - manager for action
  89218. * @hidden
  89219. */
  89220. _actionManager: ActionManager;
  89221. private _nextActiveAction;
  89222. private _child;
  89223. private _condition?;
  89224. private _triggerParameter;
  89225. /**
  89226. * An event triggered prior to action being executed.
  89227. */
  89228. onBeforeExecuteObservable: Observable<Action>;
  89229. /**
  89230. * Creates a new Action
  89231. * @param triggerOptions the trigger, with or without parameters, for the action
  89232. * @param condition an optional determinant of action
  89233. */
  89234. constructor(
  89235. /** the trigger, with or without parameters, for the action */
  89236. triggerOptions: any, condition?: Condition);
  89237. /**
  89238. * Internal only
  89239. * @hidden
  89240. */
  89241. _prepare(): void;
  89242. /**
  89243. * Gets the trigger parameters
  89244. * @returns the trigger parameters
  89245. */
  89246. getTriggerParameter(): any;
  89247. /**
  89248. * Internal only - executes current action event
  89249. * @hidden
  89250. */
  89251. _executeCurrent(evt?: ActionEvent): void;
  89252. /**
  89253. * Execute placeholder for child classes
  89254. * @param evt optional action event
  89255. */
  89256. execute(evt?: ActionEvent): void;
  89257. /**
  89258. * Skips to next active action
  89259. */
  89260. skipToNextActiveAction(): void;
  89261. /**
  89262. * Adds action to chain of actions, may be a DoNothingAction
  89263. * @param action defines the next action to execute
  89264. * @returns The action passed in
  89265. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89266. */
  89267. then(action: Action): Action;
  89268. /**
  89269. * Internal only
  89270. * @hidden
  89271. */
  89272. _getProperty(propertyPath: string): string;
  89273. /**
  89274. * Internal only
  89275. * @hidden
  89276. */
  89277. _getEffectiveTarget(target: any, propertyPath: string): any;
  89278. /**
  89279. * Serialize placeholder for child classes
  89280. * @param parent of child
  89281. * @returns the serialized object
  89282. */
  89283. serialize(parent: any): any;
  89284. /**
  89285. * Internal only called by serialize
  89286. * @hidden
  89287. */
  89288. protected _serialize(serializedAction: any, parent?: any): any;
  89289. /**
  89290. * Internal only
  89291. * @hidden
  89292. */
  89293. static _SerializeValueAsString: (value: any) => string;
  89294. /**
  89295. * Internal only
  89296. * @hidden
  89297. */
  89298. static _GetTargetProperty: (target: Scene | Node) => {
  89299. name: string;
  89300. targetType: string;
  89301. value: string;
  89302. };
  89303. }
  89304. }
  89305. declare module BABYLON {
  89306. /**
  89307. * A Condition applied to an Action
  89308. */
  89309. export class Condition {
  89310. /**
  89311. * Internal only - manager for action
  89312. * @hidden
  89313. */
  89314. _actionManager: ActionManager;
  89315. /**
  89316. * Internal only
  89317. * @hidden
  89318. */
  89319. _evaluationId: number;
  89320. /**
  89321. * Internal only
  89322. * @hidden
  89323. */
  89324. _currentResult: boolean;
  89325. /**
  89326. * Creates a new Condition
  89327. * @param actionManager the manager of the action the condition is applied to
  89328. */
  89329. constructor(actionManager: ActionManager);
  89330. /**
  89331. * Check if the current condition is valid
  89332. * @returns a boolean
  89333. */
  89334. isValid(): boolean;
  89335. /**
  89336. * Internal only
  89337. * @hidden
  89338. */
  89339. _getProperty(propertyPath: string): string;
  89340. /**
  89341. * Internal only
  89342. * @hidden
  89343. */
  89344. _getEffectiveTarget(target: any, propertyPath: string): any;
  89345. /**
  89346. * Serialize placeholder for child classes
  89347. * @returns the serialized object
  89348. */
  89349. serialize(): any;
  89350. /**
  89351. * Internal only
  89352. * @hidden
  89353. */
  89354. protected _serialize(serializedCondition: any): any;
  89355. }
  89356. /**
  89357. * Defines specific conditional operators as extensions of Condition
  89358. */
  89359. export class ValueCondition extends Condition {
  89360. /** path to specify the property of the target the conditional operator uses */
  89361. propertyPath: string;
  89362. /** the value compared by the conditional operator against the current value of the property */
  89363. value: any;
  89364. /** the conditional operator, default ValueCondition.IsEqual */
  89365. operator: number;
  89366. /**
  89367. * Internal only
  89368. * @hidden
  89369. */
  89370. private static _IsEqual;
  89371. /**
  89372. * Internal only
  89373. * @hidden
  89374. */
  89375. private static _IsDifferent;
  89376. /**
  89377. * Internal only
  89378. * @hidden
  89379. */
  89380. private static _IsGreater;
  89381. /**
  89382. * Internal only
  89383. * @hidden
  89384. */
  89385. private static _IsLesser;
  89386. /**
  89387. * returns the number for IsEqual
  89388. */
  89389. static get IsEqual(): number;
  89390. /**
  89391. * Returns the number for IsDifferent
  89392. */
  89393. static get IsDifferent(): number;
  89394. /**
  89395. * Returns the number for IsGreater
  89396. */
  89397. static get IsGreater(): number;
  89398. /**
  89399. * Returns the number for IsLesser
  89400. */
  89401. static get IsLesser(): number;
  89402. /**
  89403. * Internal only The action manager for the condition
  89404. * @hidden
  89405. */
  89406. _actionManager: ActionManager;
  89407. /**
  89408. * Internal only
  89409. * @hidden
  89410. */
  89411. private _target;
  89412. /**
  89413. * Internal only
  89414. * @hidden
  89415. */
  89416. private _effectiveTarget;
  89417. /**
  89418. * Internal only
  89419. * @hidden
  89420. */
  89421. private _property;
  89422. /**
  89423. * Creates a new ValueCondition
  89424. * @param actionManager manager for the action the condition applies to
  89425. * @param target for the action
  89426. * @param propertyPath path to specify the property of the target the conditional operator uses
  89427. * @param value the value compared by the conditional operator against the current value of the property
  89428. * @param operator the conditional operator, default ValueCondition.IsEqual
  89429. */
  89430. constructor(actionManager: ActionManager, target: any,
  89431. /** path to specify the property of the target the conditional operator uses */
  89432. propertyPath: string,
  89433. /** the value compared by the conditional operator against the current value of the property */
  89434. value: any,
  89435. /** the conditional operator, default ValueCondition.IsEqual */
  89436. operator?: number);
  89437. /**
  89438. * Compares the given value with the property value for the specified conditional operator
  89439. * @returns the result of the comparison
  89440. */
  89441. isValid(): boolean;
  89442. /**
  89443. * Serialize the ValueCondition into a JSON compatible object
  89444. * @returns serialization object
  89445. */
  89446. serialize(): any;
  89447. /**
  89448. * Gets the name of the conditional operator for the ValueCondition
  89449. * @param operator the conditional operator
  89450. * @returns the name
  89451. */
  89452. static GetOperatorName(operator: number): string;
  89453. }
  89454. /**
  89455. * Defines a predicate condition as an extension of Condition
  89456. */
  89457. export class PredicateCondition extends Condition {
  89458. /** defines the predicate function used to validate the condition */
  89459. predicate: () => boolean;
  89460. /**
  89461. * Internal only - manager for action
  89462. * @hidden
  89463. */
  89464. _actionManager: ActionManager;
  89465. /**
  89466. * Creates a new PredicateCondition
  89467. * @param actionManager manager for the action the condition applies to
  89468. * @param predicate defines the predicate function used to validate the condition
  89469. */
  89470. constructor(actionManager: ActionManager,
  89471. /** defines the predicate function used to validate the condition */
  89472. predicate: () => boolean);
  89473. /**
  89474. * @returns the validity of the predicate condition
  89475. */
  89476. isValid(): boolean;
  89477. }
  89478. /**
  89479. * Defines a state condition as an extension of Condition
  89480. */
  89481. export class StateCondition extends Condition {
  89482. /** Value to compare with target state */
  89483. value: string;
  89484. /**
  89485. * Internal only - manager for action
  89486. * @hidden
  89487. */
  89488. _actionManager: ActionManager;
  89489. /**
  89490. * Internal only
  89491. * @hidden
  89492. */
  89493. private _target;
  89494. /**
  89495. * Creates a new StateCondition
  89496. * @param actionManager manager for the action the condition applies to
  89497. * @param target of the condition
  89498. * @param value to compare with target state
  89499. */
  89500. constructor(actionManager: ActionManager, target: any,
  89501. /** Value to compare with target state */
  89502. value: string);
  89503. /**
  89504. * Gets a boolean indicating if the current condition is met
  89505. * @returns the validity of the state
  89506. */
  89507. isValid(): boolean;
  89508. /**
  89509. * Serialize the StateCondition into a JSON compatible object
  89510. * @returns serialization object
  89511. */
  89512. serialize(): any;
  89513. }
  89514. }
  89515. declare module BABYLON {
  89516. /**
  89517. * This defines an action responsible to toggle a boolean once triggered.
  89518. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89519. */
  89520. export class SwitchBooleanAction extends Action {
  89521. /**
  89522. * The path to the boolean property in the target object
  89523. */
  89524. propertyPath: string;
  89525. private _target;
  89526. private _effectiveTarget;
  89527. private _property;
  89528. /**
  89529. * Instantiate the action
  89530. * @param triggerOptions defines the trigger options
  89531. * @param target defines the object containing the boolean
  89532. * @param propertyPath defines the path to the boolean property in the target object
  89533. * @param condition defines the trigger related conditions
  89534. */
  89535. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89536. /** @hidden */
  89537. _prepare(): void;
  89538. /**
  89539. * Execute the action toggle the boolean value.
  89540. */
  89541. execute(): void;
  89542. /**
  89543. * Serializes the actions and its related information.
  89544. * @param parent defines the object to serialize in
  89545. * @returns the serialized object
  89546. */
  89547. serialize(parent: any): any;
  89548. }
  89549. /**
  89550. * This defines an action responsible to set a the state field of the target
  89551. * to a desired value once triggered.
  89552. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89553. */
  89554. export class SetStateAction extends Action {
  89555. /**
  89556. * The value to store in the state field.
  89557. */
  89558. value: string;
  89559. private _target;
  89560. /**
  89561. * Instantiate the action
  89562. * @param triggerOptions defines the trigger options
  89563. * @param target defines the object containing the state property
  89564. * @param value defines the value to store in the state field
  89565. * @param condition defines the trigger related conditions
  89566. */
  89567. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89568. /**
  89569. * Execute the action and store the value on the target state property.
  89570. */
  89571. execute(): void;
  89572. /**
  89573. * Serializes the actions and its related information.
  89574. * @param parent defines the object to serialize in
  89575. * @returns the serialized object
  89576. */
  89577. serialize(parent: any): any;
  89578. }
  89579. /**
  89580. * This defines an action responsible to set a property of the target
  89581. * to a desired value once triggered.
  89582. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89583. */
  89584. export class SetValueAction extends Action {
  89585. /**
  89586. * The path of the property to set in the target.
  89587. */
  89588. propertyPath: string;
  89589. /**
  89590. * The value to set in the property
  89591. */
  89592. value: any;
  89593. private _target;
  89594. private _effectiveTarget;
  89595. private _property;
  89596. /**
  89597. * Instantiate the action
  89598. * @param triggerOptions defines the trigger options
  89599. * @param target defines the object containing the property
  89600. * @param propertyPath defines the path of the property to set in the target
  89601. * @param value defines the value to set in the property
  89602. * @param condition defines the trigger related conditions
  89603. */
  89604. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89605. /** @hidden */
  89606. _prepare(): void;
  89607. /**
  89608. * Execute the action and set the targetted property to the desired value.
  89609. */
  89610. execute(): void;
  89611. /**
  89612. * Serializes the actions and its related information.
  89613. * @param parent defines the object to serialize in
  89614. * @returns the serialized object
  89615. */
  89616. serialize(parent: any): any;
  89617. }
  89618. /**
  89619. * This defines an action responsible to increment the target value
  89620. * to a desired value once triggered.
  89621. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89622. */
  89623. export class IncrementValueAction extends Action {
  89624. /**
  89625. * The path of the property to increment in the target.
  89626. */
  89627. propertyPath: string;
  89628. /**
  89629. * The value we should increment the property by.
  89630. */
  89631. value: any;
  89632. private _target;
  89633. private _effectiveTarget;
  89634. private _property;
  89635. /**
  89636. * Instantiate the action
  89637. * @param triggerOptions defines the trigger options
  89638. * @param target defines the object containing the property
  89639. * @param propertyPath defines the path of the property to increment in the target
  89640. * @param value defines the value value we should increment the property by
  89641. * @param condition defines the trigger related conditions
  89642. */
  89643. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89644. /** @hidden */
  89645. _prepare(): void;
  89646. /**
  89647. * Execute the action and increment the target of the value amount.
  89648. */
  89649. execute(): void;
  89650. /**
  89651. * Serializes the actions and its related information.
  89652. * @param parent defines the object to serialize in
  89653. * @returns the serialized object
  89654. */
  89655. serialize(parent: any): any;
  89656. }
  89657. /**
  89658. * This defines an action responsible to start an animation once triggered.
  89659. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89660. */
  89661. export class PlayAnimationAction extends Action {
  89662. /**
  89663. * Where the animation should start (animation frame)
  89664. */
  89665. from: number;
  89666. /**
  89667. * Where the animation should stop (animation frame)
  89668. */
  89669. to: number;
  89670. /**
  89671. * Define if the animation should loop or stop after the first play.
  89672. */
  89673. loop?: boolean;
  89674. private _target;
  89675. /**
  89676. * Instantiate the action
  89677. * @param triggerOptions defines the trigger options
  89678. * @param target defines the target animation or animation name
  89679. * @param from defines from where the animation should start (animation frame)
  89680. * @param end defines where the animation should stop (animation frame)
  89681. * @param loop defines if the animation should loop or stop after the first play
  89682. * @param condition defines the trigger related conditions
  89683. */
  89684. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89685. /** @hidden */
  89686. _prepare(): void;
  89687. /**
  89688. * Execute the action and play the animation.
  89689. */
  89690. execute(): void;
  89691. /**
  89692. * Serializes the actions and its related information.
  89693. * @param parent defines the object to serialize in
  89694. * @returns the serialized object
  89695. */
  89696. serialize(parent: any): any;
  89697. }
  89698. /**
  89699. * This defines an action responsible to stop an animation once triggered.
  89700. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89701. */
  89702. export class StopAnimationAction extends Action {
  89703. private _target;
  89704. /**
  89705. * Instantiate the action
  89706. * @param triggerOptions defines the trigger options
  89707. * @param target defines the target animation or animation name
  89708. * @param condition defines the trigger related conditions
  89709. */
  89710. constructor(triggerOptions: any, target: any, condition?: Condition);
  89711. /** @hidden */
  89712. _prepare(): void;
  89713. /**
  89714. * Execute the action and stop the animation.
  89715. */
  89716. execute(): void;
  89717. /**
  89718. * Serializes the actions and its related information.
  89719. * @param parent defines the object to serialize in
  89720. * @returns the serialized object
  89721. */
  89722. serialize(parent: any): any;
  89723. }
  89724. /**
  89725. * This defines an action responsible that does nothing once triggered.
  89726. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89727. */
  89728. export class DoNothingAction extends Action {
  89729. /**
  89730. * Instantiate the action
  89731. * @param triggerOptions defines the trigger options
  89732. * @param condition defines the trigger related conditions
  89733. */
  89734. constructor(triggerOptions?: any, condition?: Condition);
  89735. /**
  89736. * Execute the action and do nothing.
  89737. */
  89738. execute(): void;
  89739. /**
  89740. * Serializes the actions and its related information.
  89741. * @param parent defines the object to serialize in
  89742. * @returns the serialized object
  89743. */
  89744. serialize(parent: any): any;
  89745. }
  89746. /**
  89747. * This defines an action responsible to trigger several actions once triggered.
  89748. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89749. */
  89750. export class CombineAction extends Action {
  89751. /**
  89752. * The list of aggregated animations to run.
  89753. */
  89754. children: Action[];
  89755. /**
  89756. * Instantiate the action
  89757. * @param triggerOptions defines the trigger options
  89758. * @param children defines the list of aggregated animations to run
  89759. * @param condition defines the trigger related conditions
  89760. */
  89761. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89762. /** @hidden */
  89763. _prepare(): void;
  89764. /**
  89765. * Execute the action and executes all the aggregated actions.
  89766. */
  89767. execute(evt: ActionEvent): void;
  89768. /**
  89769. * Serializes the actions and its related information.
  89770. * @param parent defines the object to serialize in
  89771. * @returns the serialized object
  89772. */
  89773. serialize(parent: any): any;
  89774. }
  89775. /**
  89776. * This defines an action responsible to run code (external event) once triggered.
  89777. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89778. */
  89779. export class ExecuteCodeAction extends Action {
  89780. /**
  89781. * The callback function to run.
  89782. */
  89783. func: (evt: ActionEvent) => void;
  89784. /**
  89785. * Instantiate the action
  89786. * @param triggerOptions defines the trigger options
  89787. * @param func defines the callback function to run
  89788. * @param condition defines the trigger related conditions
  89789. */
  89790. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89791. /**
  89792. * Execute the action and run the attached code.
  89793. */
  89794. execute(evt: ActionEvent): void;
  89795. }
  89796. /**
  89797. * This defines an action responsible to set the parent property of the target once triggered.
  89798. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89799. */
  89800. export class SetParentAction extends Action {
  89801. private _parent;
  89802. private _target;
  89803. /**
  89804. * Instantiate the action
  89805. * @param triggerOptions defines the trigger options
  89806. * @param target defines the target containing the parent property
  89807. * @param parent defines from where the animation should start (animation frame)
  89808. * @param condition defines the trigger related conditions
  89809. */
  89810. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89811. /** @hidden */
  89812. _prepare(): void;
  89813. /**
  89814. * Execute the action and set the parent property.
  89815. */
  89816. execute(): void;
  89817. /**
  89818. * Serializes the actions and its related information.
  89819. * @param parent defines the object to serialize in
  89820. * @returns the serialized object
  89821. */
  89822. serialize(parent: any): any;
  89823. }
  89824. }
  89825. declare module BABYLON {
  89826. /**
  89827. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89828. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89830. */
  89831. export class ActionManager extends AbstractActionManager {
  89832. /**
  89833. * Nothing
  89834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89835. */
  89836. static readonly NothingTrigger: number;
  89837. /**
  89838. * On pick
  89839. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89840. */
  89841. static readonly OnPickTrigger: number;
  89842. /**
  89843. * On left pick
  89844. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89845. */
  89846. static readonly OnLeftPickTrigger: number;
  89847. /**
  89848. * On right pick
  89849. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89850. */
  89851. static readonly OnRightPickTrigger: number;
  89852. /**
  89853. * On center pick
  89854. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89855. */
  89856. static readonly OnCenterPickTrigger: number;
  89857. /**
  89858. * On pick down
  89859. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89860. */
  89861. static readonly OnPickDownTrigger: number;
  89862. /**
  89863. * On double pick
  89864. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89865. */
  89866. static readonly OnDoublePickTrigger: number;
  89867. /**
  89868. * On pick up
  89869. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89870. */
  89871. static readonly OnPickUpTrigger: number;
  89872. /**
  89873. * On pick out.
  89874. * This trigger will only be raised if you also declared a OnPickDown
  89875. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89876. */
  89877. static readonly OnPickOutTrigger: number;
  89878. /**
  89879. * On long press
  89880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89881. */
  89882. static readonly OnLongPressTrigger: number;
  89883. /**
  89884. * On pointer over
  89885. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89886. */
  89887. static readonly OnPointerOverTrigger: number;
  89888. /**
  89889. * On pointer out
  89890. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89891. */
  89892. static readonly OnPointerOutTrigger: number;
  89893. /**
  89894. * On every frame
  89895. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89896. */
  89897. static readonly OnEveryFrameTrigger: number;
  89898. /**
  89899. * On intersection enter
  89900. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89901. */
  89902. static readonly OnIntersectionEnterTrigger: number;
  89903. /**
  89904. * On intersection exit
  89905. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89906. */
  89907. static readonly OnIntersectionExitTrigger: number;
  89908. /**
  89909. * On key down
  89910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89911. */
  89912. static readonly OnKeyDownTrigger: number;
  89913. /**
  89914. * On key up
  89915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89916. */
  89917. static readonly OnKeyUpTrigger: number;
  89918. private _scene;
  89919. /**
  89920. * Creates a new action manager
  89921. * @param scene defines the hosting scene
  89922. */
  89923. constructor(scene: Scene);
  89924. /**
  89925. * Releases all associated resources
  89926. */
  89927. dispose(): void;
  89928. /**
  89929. * Gets hosting scene
  89930. * @returns the hosting scene
  89931. */
  89932. getScene(): Scene;
  89933. /**
  89934. * Does this action manager handles actions of any of the given triggers
  89935. * @param triggers defines the triggers to be tested
  89936. * @return a boolean indicating whether one (or more) of the triggers is handled
  89937. */
  89938. hasSpecificTriggers(triggers: number[]): boolean;
  89939. /**
  89940. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89941. * speed.
  89942. * @param triggerA defines the trigger to be tested
  89943. * @param triggerB defines the trigger to be tested
  89944. * @return a boolean indicating whether one (or more) of the triggers is handled
  89945. */
  89946. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89947. /**
  89948. * Does this action manager handles actions of a given trigger
  89949. * @param trigger defines the trigger to be tested
  89950. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89951. * @return whether the trigger is handled
  89952. */
  89953. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89954. /**
  89955. * Does this action manager has pointer triggers
  89956. */
  89957. get hasPointerTriggers(): boolean;
  89958. /**
  89959. * Does this action manager has pick triggers
  89960. */
  89961. get hasPickTriggers(): boolean;
  89962. /**
  89963. * Registers an action to this action manager
  89964. * @param action defines the action to be registered
  89965. * @return the action amended (prepared) after registration
  89966. */
  89967. registerAction(action: IAction): Nullable<IAction>;
  89968. /**
  89969. * Unregisters an action to this action manager
  89970. * @param action defines the action to be unregistered
  89971. * @return a boolean indicating whether the action has been unregistered
  89972. */
  89973. unregisterAction(action: IAction): Boolean;
  89974. /**
  89975. * Process a specific trigger
  89976. * @param trigger defines the trigger to process
  89977. * @param evt defines the event details to be processed
  89978. */
  89979. processTrigger(trigger: number, evt?: IActionEvent): void;
  89980. /** @hidden */
  89981. _getEffectiveTarget(target: any, propertyPath: string): any;
  89982. /** @hidden */
  89983. _getProperty(propertyPath: string): string;
  89984. /**
  89985. * Serialize this manager to a JSON object
  89986. * @param name defines the property name to store this manager
  89987. * @returns a JSON representation of this manager
  89988. */
  89989. serialize(name: string): any;
  89990. /**
  89991. * Creates a new ActionManager from a JSON data
  89992. * @param parsedActions defines the JSON data to read from
  89993. * @param object defines the hosting mesh
  89994. * @param scene defines the hosting scene
  89995. */
  89996. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89997. /**
  89998. * Get a trigger name by index
  89999. * @param trigger defines the trigger index
  90000. * @returns a trigger name
  90001. */
  90002. static GetTriggerName(trigger: number): string;
  90003. }
  90004. }
  90005. declare module BABYLON {
  90006. /**
  90007. * Class used to represent a sprite
  90008. * @see https://doc.babylonjs.com/babylon101/sprites
  90009. */
  90010. export class Sprite implements IAnimatable {
  90011. /** defines the name */
  90012. name: string;
  90013. /** Gets or sets the current world position */
  90014. position: Vector3;
  90015. /** Gets or sets the main color */
  90016. color: Color4;
  90017. /** Gets or sets the width */
  90018. width: number;
  90019. /** Gets or sets the height */
  90020. height: number;
  90021. /** Gets or sets rotation angle */
  90022. angle: number;
  90023. /** Gets or sets the cell index in the sprite sheet */
  90024. cellIndex: number;
  90025. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90026. cellRef: string;
  90027. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90028. invertU: boolean;
  90029. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90030. invertV: boolean;
  90031. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90032. disposeWhenFinishedAnimating: boolean;
  90033. /** Gets the list of attached animations */
  90034. animations: Nullable<Array<Animation>>;
  90035. /** Gets or sets a boolean indicating if the sprite can be picked */
  90036. isPickable: boolean;
  90037. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90038. useAlphaForPicking: boolean;
  90039. /** @hidden */
  90040. _xOffset: number;
  90041. /** @hidden */
  90042. _yOffset: number;
  90043. /** @hidden */
  90044. _xSize: number;
  90045. /** @hidden */
  90046. _ySize: number;
  90047. /**
  90048. * Gets or sets the associated action manager
  90049. */
  90050. actionManager: Nullable<ActionManager>;
  90051. /**
  90052. * An event triggered when the control has been disposed
  90053. */
  90054. onDisposeObservable: Observable<Sprite>;
  90055. private _animationStarted;
  90056. private _loopAnimation;
  90057. private _fromIndex;
  90058. private _toIndex;
  90059. private _delay;
  90060. private _direction;
  90061. private _manager;
  90062. private _time;
  90063. private _onAnimationEnd;
  90064. /**
  90065. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90066. */
  90067. isVisible: boolean;
  90068. /**
  90069. * Gets or sets the sprite size
  90070. */
  90071. get size(): number;
  90072. set size(value: number);
  90073. /**
  90074. * Returns a boolean indicating if the animation is started
  90075. */
  90076. get animationStarted(): boolean;
  90077. /**
  90078. * Gets or sets the unique id of the sprite
  90079. */
  90080. uniqueId: number;
  90081. /**
  90082. * Gets the manager of this sprite
  90083. */
  90084. get manager(): ISpriteManager;
  90085. /**
  90086. * Creates a new Sprite
  90087. * @param name defines the name
  90088. * @param manager defines the manager
  90089. */
  90090. constructor(
  90091. /** defines the name */
  90092. name: string, manager: ISpriteManager);
  90093. /**
  90094. * Returns the string "Sprite"
  90095. * @returns "Sprite"
  90096. */
  90097. getClassName(): string;
  90098. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90099. get fromIndex(): number;
  90100. set fromIndex(value: number);
  90101. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90102. get toIndex(): number;
  90103. set toIndex(value: number);
  90104. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90105. get loopAnimation(): boolean;
  90106. set loopAnimation(value: boolean);
  90107. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90108. get delay(): number;
  90109. set delay(value: number);
  90110. /**
  90111. * Starts an animation
  90112. * @param from defines the initial key
  90113. * @param to defines the end key
  90114. * @param loop defines if the animation must loop
  90115. * @param delay defines the start delay (in ms)
  90116. * @param onAnimationEnd defines a callback to call when animation ends
  90117. */
  90118. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90119. /** Stops current animation (if any) */
  90120. stopAnimation(): void;
  90121. /** @hidden */
  90122. _animate(deltaTime: number): void;
  90123. /** Release associated resources */
  90124. dispose(): void;
  90125. /**
  90126. * Serializes the sprite to a JSON object
  90127. * @returns the JSON object
  90128. */
  90129. serialize(): any;
  90130. /**
  90131. * Parses a JSON object to create a new sprite
  90132. * @param parsedSprite The JSON object to parse
  90133. * @param manager defines the hosting manager
  90134. * @returns the new sprite
  90135. */
  90136. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90137. }
  90138. }
  90139. declare module BABYLON {
  90140. /**
  90141. * Information about the result of picking within a scene
  90142. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90143. */
  90144. export class PickingInfo {
  90145. /** @hidden */
  90146. _pickingUnavailable: boolean;
  90147. /**
  90148. * If the pick collided with an object
  90149. */
  90150. hit: boolean;
  90151. /**
  90152. * Distance away where the pick collided
  90153. */
  90154. distance: number;
  90155. /**
  90156. * The location of pick collision
  90157. */
  90158. pickedPoint: Nullable<Vector3>;
  90159. /**
  90160. * The mesh corresponding the the pick collision
  90161. */
  90162. pickedMesh: Nullable<AbstractMesh>;
  90163. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90164. bu: number;
  90165. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90166. bv: number;
  90167. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90168. faceId: number;
  90169. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90170. subMeshFaceId: number;
  90171. /** Id of the the submesh that was picked */
  90172. subMeshId: number;
  90173. /** If a sprite was picked, this will be the sprite the pick collided with */
  90174. pickedSprite: Nullable<Sprite>;
  90175. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90176. thinInstanceIndex: number;
  90177. /**
  90178. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90179. */
  90180. originMesh: Nullable<AbstractMesh>;
  90181. /**
  90182. * The ray that was used to perform the picking.
  90183. */
  90184. ray: Nullable<Ray>;
  90185. /**
  90186. * Gets the normal correspodning to the face the pick collided with
  90187. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90188. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90189. * @returns The normal correspodning to the face the pick collided with
  90190. */
  90191. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90192. /**
  90193. * Gets the texture coordinates of where the pick occured
  90194. * @returns the vector containing the coordnates of the texture
  90195. */
  90196. getTextureCoordinates(): Nullable<Vector2>;
  90197. }
  90198. }
  90199. declare module BABYLON {
  90200. /**
  90201. * Class representing a ray with position and direction
  90202. */
  90203. export class Ray {
  90204. /** origin point */
  90205. origin: Vector3;
  90206. /** direction */
  90207. direction: Vector3;
  90208. /** length of the ray */
  90209. length: number;
  90210. private static readonly _TmpVector3;
  90211. private _tmpRay;
  90212. /**
  90213. * Creates a new ray
  90214. * @param origin origin point
  90215. * @param direction direction
  90216. * @param length length of the ray
  90217. */
  90218. constructor(
  90219. /** origin point */
  90220. origin: Vector3,
  90221. /** direction */
  90222. direction: Vector3,
  90223. /** length of the ray */
  90224. length?: number);
  90225. /**
  90226. * Checks if the ray intersects a box
  90227. * This does not account for the ray lenght by design to improve perfs.
  90228. * @param minimum bound of the box
  90229. * @param maximum bound of the box
  90230. * @param intersectionTreshold extra extend to be added to the box in all direction
  90231. * @returns if the box was hit
  90232. */
  90233. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90234. /**
  90235. * Checks if the ray intersects a box
  90236. * This does not account for the ray lenght by design to improve perfs.
  90237. * @param box the bounding box to check
  90238. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90239. * @returns if the box was hit
  90240. */
  90241. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90242. /**
  90243. * If the ray hits a sphere
  90244. * @param sphere the bounding sphere to check
  90245. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90246. * @returns true if it hits the sphere
  90247. */
  90248. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90249. /**
  90250. * If the ray hits a triange
  90251. * @param vertex0 triangle vertex
  90252. * @param vertex1 triangle vertex
  90253. * @param vertex2 triangle vertex
  90254. * @returns intersection information if hit
  90255. */
  90256. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90257. /**
  90258. * Checks if ray intersects a plane
  90259. * @param plane the plane to check
  90260. * @returns the distance away it was hit
  90261. */
  90262. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90263. /**
  90264. * Calculate the intercept of a ray on a given axis
  90265. * @param axis to check 'x' | 'y' | 'z'
  90266. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90267. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90268. */
  90269. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90270. /**
  90271. * Checks if ray intersects a mesh
  90272. * @param mesh the mesh to check
  90273. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90274. * @returns picking info of the intersecton
  90275. */
  90276. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90277. /**
  90278. * Checks if ray intersects a mesh
  90279. * @param meshes the meshes to check
  90280. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90281. * @param results array to store result in
  90282. * @returns Array of picking infos
  90283. */
  90284. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90285. private _comparePickingInfo;
  90286. private static smallnum;
  90287. private static rayl;
  90288. /**
  90289. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90290. * @param sega the first point of the segment to test the intersection against
  90291. * @param segb the second point of the segment to test the intersection against
  90292. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90293. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90294. */
  90295. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90296. /**
  90297. * Update the ray from viewport position
  90298. * @param x position
  90299. * @param y y position
  90300. * @param viewportWidth viewport width
  90301. * @param viewportHeight viewport height
  90302. * @param world world matrix
  90303. * @param view view matrix
  90304. * @param projection projection matrix
  90305. * @returns this ray updated
  90306. */
  90307. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90308. /**
  90309. * Creates a ray with origin and direction of 0,0,0
  90310. * @returns the new ray
  90311. */
  90312. static Zero(): Ray;
  90313. /**
  90314. * Creates a new ray from screen space and viewport
  90315. * @param x position
  90316. * @param y y position
  90317. * @param viewportWidth viewport width
  90318. * @param viewportHeight viewport height
  90319. * @param world world matrix
  90320. * @param view view matrix
  90321. * @param projection projection matrix
  90322. * @returns new ray
  90323. */
  90324. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90325. /**
  90326. * 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
  90327. * transformed to the given world matrix.
  90328. * @param origin The origin point
  90329. * @param end The end point
  90330. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90331. * @returns the new ray
  90332. */
  90333. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90334. /**
  90335. * Transforms a ray by a matrix
  90336. * @param ray ray to transform
  90337. * @param matrix matrix to apply
  90338. * @returns the resulting new ray
  90339. */
  90340. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90341. /**
  90342. * Transforms a ray by a matrix
  90343. * @param ray ray to transform
  90344. * @param matrix matrix to apply
  90345. * @param result ray to store result in
  90346. */
  90347. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90348. /**
  90349. * Unproject a ray from screen space to object space
  90350. * @param sourceX defines the screen space x coordinate to use
  90351. * @param sourceY defines the screen space y coordinate to use
  90352. * @param viewportWidth defines the current width of the viewport
  90353. * @param viewportHeight defines the current height of the viewport
  90354. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90355. * @param view defines the view matrix to use
  90356. * @param projection defines the projection matrix to use
  90357. */
  90358. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90359. }
  90360. /**
  90361. * Type used to define predicate used to select faces when a mesh intersection is detected
  90362. */
  90363. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90364. interface Scene {
  90365. /** @hidden */
  90366. _tempPickingRay: Nullable<Ray>;
  90367. /** @hidden */
  90368. _cachedRayForTransform: Ray;
  90369. /** @hidden */
  90370. _pickWithRayInverseMatrix: Matrix;
  90371. /** @hidden */
  90372. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90373. /** @hidden */
  90374. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90375. /** @hidden */
  90376. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90377. }
  90378. }
  90379. declare module BABYLON {
  90380. /**
  90381. * Groups all the scene component constants in one place to ease maintenance.
  90382. * @hidden
  90383. */
  90384. export class SceneComponentConstants {
  90385. static readonly NAME_EFFECTLAYER: string;
  90386. static readonly NAME_LAYER: string;
  90387. static readonly NAME_LENSFLARESYSTEM: string;
  90388. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90389. static readonly NAME_PARTICLESYSTEM: string;
  90390. static readonly NAME_GAMEPAD: string;
  90391. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90392. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90393. static readonly NAME_PREPASSRENDERER: string;
  90394. static readonly NAME_DEPTHRENDERER: string;
  90395. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90396. static readonly NAME_SPRITE: string;
  90397. static readonly NAME_OUTLINERENDERER: string;
  90398. static readonly NAME_PROCEDURALTEXTURE: string;
  90399. static readonly NAME_SHADOWGENERATOR: string;
  90400. static readonly NAME_OCTREE: string;
  90401. static readonly NAME_PHYSICSENGINE: string;
  90402. static readonly NAME_AUDIO: string;
  90403. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90404. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90405. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90406. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90407. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90408. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90409. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90410. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90411. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90412. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90413. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90414. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90415. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90416. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90417. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90418. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90419. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90420. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90421. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90422. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90423. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90424. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90425. static readonly STEP_AFTERRENDER_AUDIO: number;
  90426. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90427. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90428. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90429. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90430. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90431. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90432. static readonly STEP_POINTERMOVE_SPRITE: number;
  90433. static readonly STEP_POINTERDOWN_SPRITE: number;
  90434. static readonly STEP_POINTERUP_SPRITE: number;
  90435. }
  90436. /**
  90437. * This represents a scene component.
  90438. *
  90439. * This is used to decouple the dependency the scene is having on the different workloads like
  90440. * layers, post processes...
  90441. */
  90442. export interface ISceneComponent {
  90443. /**
  90444. * The name of the component. Each component must have a unique name.
  90445. */
  90446. name: string;
  90447. /**
  90448. * The scene the component belongs to.
  90449. */
  90450. scene: Scene;
  90451. /**
  90452. * Register the component to one instance of a scene.
  90453. */
  90454. register(): void;
  90455. /**
  90456. * Rebuilds the elements related to this component in case of
  90457. * context lost for instance.
  90458. */
  90459. rebuild(): void;
  90460. /**
  90461. * Disposes the component and the associated ressources.
  90462. */
  90463. dispose(): void;
  90464. }
  90465. /**
  90466. * This represents a SERIALIZABLE scene component.
  90467. *
  90468. * This extends Scene Component to add Serialization methods on top.
  90469. */
  90470. export interface ISceneSerializableComponent extends ISceneComponent {
  90471. /**
  90472. * Adds all the elements from the container to the scene
  90473. * @param container the container holding the elements
  90474. */
  90475. addFromContainer(container: AbstractScene): void;
  90476. /**
  90477. * Removes all the elements in the container from the scene
  90478. * @param container contains the elements to remove
  90479. * @param dispose if the removed element should be disposed (default: false)
  90480. */
  90481. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  90482. /**
  90483. * Serializes the component data to the specified json object
  90484. * @param serializationObject The object to serialize to
  90485. */
  90486. serialize(serializationObject: any): void;
  90487. }
  90488. /**
  90489. * Strong typing of a Mesh related stage step action
  90490. */
  90491. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  90492. /**
  90493. * Strong typing of a Evaluate Sub Mesh related stage step action
  90494. */
  90495. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  90496. /**
  90497. * Strong typing of a Active Mesh related stage step action
  90498. */
  90499. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  90500. /**
  90501. * Strong typing of a Camera related stage step action
  90502. */
  90503. export type CameraStageAction = (camera: Camera) => void;
  90504. /**
  90505. * Strong typing of a Camera Frame buffer related stage step action
  90506. */
  90507. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  90508. /**
  90509. * Strong typing of a Render Target related stage step action
  90510. */
  90511. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90512. /**
  90513. * Strong typing of a RenderingGroup related stage step action
  90514. */
  90515. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90516. /**
  90517. * Strong typing of a Mesh Render related stage step action
  90518. */
  90519. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90520. /**
  90521. * Strong typing of a simple stage step action
  90522. */
  90523. export type SimpleStageAction = () => void;
  90524. /**
  90525. * Strong typing of a render target action.
  90526. */
  90527. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90528. /**
  90529. * Strong typing of a pointer move action.
  90530. */
  90531. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90532. /**
  90533. * Strong typing of a pointer up/down action.
  90534. */
  90535. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90536. /**
  90537. * Representation of a stage in the scene (Basically a list of ordered steps)
  90538. * @hidden
  90539. */
  90540. export class Stage<T extends Function> extends Array<{
  90541. index: number;
  90542. component: ISceneComponent;
  90543. action: T;
  90544. }> {
  90545. /**
  90546. * Hide ctor from the rest of the world.
  90547. * @param items The items to add.
  90548. */
  90549. private constructor();
  90550. /**
  90551. * Creates a new Stage.
  90552. * @returns A new instance of a Stage
  90553. */
  90554. static Create<T extends Function>(): Stage<T>;
  90555. /**
  90556. * Registers a step in an ordered way in the targeted stage.
  90557. * @param index Defines the position to register the step in
  90558. * @param component Defines the component attached to the step
  90559. * @param action Defines the action to launch during the step
  90560. */
  90561. registerStep(index: number, component: ISceneComponent, action: T): void;
  90562. /**
  90563. * Clears all the steps from the stage.
  90564. */
  90565. clear(): void;
  90566. }
  90567. }
  90568. declare module BABYLON {
  90569. interface Scene {
  90570. /** @hidden */
  90571. _pointerOverSprite: Nullable<Sprite>;
  90572. /** @hidden */
  90573. _pickedDownSprite: Nullable<Sprite>;
  90574. /** @hidden */
  90575. _tempSpritePickingRay: Nullable<Ray>;
  90576. /**
  90577. * All of the sprite managers added to this scene
  90578. * @see https://doc.babylonjs.com/babylon101/sprites
  90579. */
  90580. spriteManagers: Array<ISpriteManager>;
  90581. /**
  90582. * An event triggered when sprites rendering is about to start
  90583. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90584. */
  90585. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90586. /**
  90587. * An event triggered when sprites rendering is done
  90588. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90589. */
  90590. onAfterSpritesRenderingObservable: Observable<Scene>;
  90591. /** @hidden */
  90592. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90593. /** Launch a ray to try to pick a sprite in the scene
  90594. * @param x position on screen
  90595. * @param y position on screen
  90596. * @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
  90597. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90598. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90599. * @returns a PickingInfo
  90600. */
  90601. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90602. /** Use the given ray to pick a sprite in the scene
  90603. * @param ray The ray (in world space) to use to pick meshes
  90604. * @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
  90605. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90606. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90607. * @returns a PickingInfo
  90608. */
  90609. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90610. /** @hidden */
  90611. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90612. /** Launch a ray to try to pick sprites in the scene
  90613. * @param x position on screen
  90614. * @param y position on screen
  90615. * @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
  90616. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90617. * @returns a PickingInfo array
  90618. */
  90619. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90620. /** Use the given ray to pick sprites in the scene
  90621. * @param ray The ray (in world space) to use to pick meshes
  90622. * @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
  90623. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90624. * @returns a PickingInfo array
  90625. */
  90626. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90627. /**
  90628. * Force the sprite under the pointer
  90629. * @param sprite defines the sprite to use
  90630. */
  90631. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90632. /**
  90633. * Gets the sprite under the pointer
  90634. * @returns a Sprite or null if no sprite is under the pointer
  90635. */
  90636. getPointerOverSprite(): Nullable<Sprite>;
  90637. }
  90638. /**
  90639. * Defines the sprite scene component responsible to manage sprites
  90640. * in a given scene.
  90641. */
  90642. export class SpriteSceneComponent implements ISceneComponent {
  90643. /**
  90644. * The component name helpfull to identify the component in the list of scene components.
  90645. */
  90646. readonly name: string;
  90647. /**
  90648. * The scene the component belongs to.
  90649. */
  90650. scene: Scene;
  90651. /** @hidden */
  90652. private _spritePredicate;
  90653. /**
  90654. * Creates a new instance of the component for the given scene
  90655. * @param scene Defines the scene to register the component in
  90656. */
  90657. constructor(scene: Scene);
  90658. /**
  90659. * Registers the component in a given scene
  90660. */
  90661. register(): void;
  90662. /**
  90663. * Rebuilds the elements related to this component in case of
  90664. * context lost for instance.
  90665. */
  90666. rebuild(): void;
  90667. /**
  90668. * Disposes the component and the associated ressources.
  90669. */
  90670. dispose(): void;
  90671. private _pickSpriteButKeepRay;
  90672. private _pointerMove;
  90673. private _pointerDown;
  90674. private _pointerUp;
  90675. }
  90676. }
  90677. declare module BABYLON {
  90678. /** @hidden */
  90679. export var fogFragmentDeclaration: {
  90680. name: string;
  90681. shader: string;
  90682. };
  90683. }
  90684. declare module BABYLON {
  90685. /** @hidden */
  90686. export var fogFragment: {
  90687. name: string;
  90688. shader: string;
  90689. };
  90690. }
  90691. declare module BABYLON {
  90692. /** @hidden */
  90693. export var spritesPixelShader: {
  90694. name: string;
  90695. shader: string;
  90696. };
  90697. }
  90698. declare module BABYLON {
  90699. /** @hidden */
  90700. export var fogVertexDeclaration: {
  90701. name: string;
  90702. shader: string;
  90703. };
  90704. }
  90705. declare module BABYLON {
  90706. /** @hidden */
  90707. export var spritesVertexShader: {
  90708. name: string;
  90709. shader: string;
  90710. };
  90711. }
  90712. declare module BABYLON {
  90713. /**
  90714. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90715. */
  90716. export interface ISpriteManager extends IDisposable {
  90717. /**
  90718. * Gets manager's name
  90719. */
  90720. name: string;
  90721. /**
  90722. * Restricts the camera to viewing objects with the same layerMask.
  90723. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90724. */
  90725. layerMask: number;
  90726. /**
  90727. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90728. */
  90729. isPickable: boolean;
  90730. /**
  90731. * Gets the hosting scene
  90732. */
  90733. scene: Scene;
  90734. /**
  90735. * Specifies the rendering group id for this mesh (0 by default)
  90736. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90737. */
  90738. renderingGroupId: number;
  90739. /**
  90740. * Defines the list of sprites managed by the manager.
  90741. */
  90742. sprites: Array<Sprite>;
  90743. /**
  90744. * Gets or sets the spritesheet texture
  90745. */
  90746. texture: Texture;
  90747. /** Defines the default width of a cell in the spritesheet */
  90748. cellWidth: number;
  90749. /** Defines the default height of a cell in the spritesheet */
  90750. cellHeight: number;
  90751. /**
  90752. * Tests the intersection of a sprite with a specific ray.
  90753. * @param ray The ray we are sending to test the collision
  90754. * @param camera The camera space we are sending rays in
  90755. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90756. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90757. * @returns picking info or null.
  90758. */
  90759. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90760. /**
  90761. * Intersects the sprites with a ray
  90762. * @param ray defines the ray to intersect with
  90763. * @param camera defines the current active camera
  90764. * @param predicate defines a predicate used to select candidate sprites
  90765. * @returns null if no hit or a PickingInfo array
  90766. */
  90767. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90768. /**
  90769. * Renders the list of sprites on screen.
  90770. */
  90771. render(): void;
  90772. }
  90773. /**
  90774. * Class used to manage multiple sprites on the same spritesheet
  90775. * @see https://doc.babylonjs.com/babylon101/sprites
  90776. */
  90777. export class SpriteManager implements ISpriteManager {
  90778. /** defines the manager's name */
  90779. name: string;
  90780. /** Define the Url to load snippets */
  90781. static SnippetUrl: string;
  90782. /** Snippet ID if the manager was created from the snippet server */
  90783. snippetId: string;
  90784. /** Gets the list of sprites */
  90785. sprites: Sprite[];
  90786. /** Gets or sets the rendering group id (0 by default) */
  90787. renderingGroupId: number;
  90788. /** Gets or sets camera layer mask */
  90789. layerMask: number;
  90790. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90791. fogEnabled: boolean;
  90792. /** Gets or sets a boolean indicating if the sprites are pickable */
  90793. isPickable: boolean;
  90794. /** Defines the default width of a cell in the spritesheet */
  90795. cellWidth: number;
  90796. /** Defines the default height of a cell in the spritesheet */
  90797. cellHeight: number;
  90798. /** Associative array from JSON sprite data file */
  90799. private _cellData;
  90800. /** Array of sprite names from JSON sprite data file */
  90801. private _spriteMap;
  90802. /** True when packed cell data from JSON file is ready*/
  90803. private _packedAndReady;
  90804. private _textureContent;
  90805. private _useInstancing;
  90806. /**
  90807. * An event triggered when the manager is disposed.
  90808. */
  90809. onDisposeObservable: Observable<SpriteManager>;
  90810. private _onDisposeObserver;
  90811. /**
  90812. * Callback called when the manager is disposed
  90813. */
  90814. set onDispose(callback: () => void);
  90815. private _capacity;
  90816. private _fromPacked;
  90817. private _spriteTexture;
  90818. private _epsilon;
  90819. private _scene;
  90820. private _vertexData;
  90821. private _buffer;
  90822. private _vertexBuffers;
  90823. private _spriteBuffer;
  90824. private _indexBuffer;
  90825. private _effectBase;
  90826. private _effectFog;
  90827. private _vertexBufferSize;
  90828. /**
  90829. * Gets or sets the unique id of the sprite
  90830. */
  90831. uniqueId: number;
  90832. /**
  90833. * Gets the array of sprites
  90834. */
  90835. get children(): Sprite[];
  90836. /**
  90837. * Gets the hosting scene
  90838. */
  90839. get scene(): Scene;
  90840. /**
  90841. * Gets the capacity of the manager
  90842. */
  90843. get capacity(): number;
  90844. /**
  90845. * Gets or sets the spritesheet texture
  90846. */
  90847. get texture(): Texture;
  90848. set texture(value: Texture);
  90849. private _blendMode;
  90850. /**
  90851. * Blend mode use to render the particle, it can be any of
  90852. * the static Constants.ALPHA_x properties provided in this class.
  90853. * Default value is Constants.ALPHA_COMBINE
  90854. */
  90855. get blendMode(): number;
  90856. set blendMode(blendMode: number);
  90857. /** Disables writing to the depth buffer when rendering the sprites.
  90858. * It can be handy to disable depth writing when using textures without alpha channel
  90859. * and setting some specific blend modes.
  90860. */
  90861. disableDepthWrite: boolean;
  90862. /**
  90863. * Creates a new sprite manager
  90864. * @param name defines the manager's name
  90865. * @param imgUrl defines the sprite sheet url
  90866. * @param capacity defines the maximum allowed number of sprites
  90867. * @param cellSize defines the size of a sprite cell
  90868. * @param scene defines the hosting scene
  90869. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90870. * @param samplingMode defines the smapling mode to use with spritesheet
  90871. * @param fromPacked set to false; do not alter
  90872. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90873. */
  90874. constructor(
  90875. /** defines the manager's name */
  90876. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90877. /**
  90878. * Returns the string "SpriteManager"
  90879. * @returns "SpriteManager"
  90880. */
  90881. getClassName(): string;
  90882. private _makePacked;
  90883. private _appendSpriteVertex;
  90884. private _checkTextureAlpha;
  90885. /**
  90886. * Intersects the sprites with a ray
  90887. * @param ray defines the ray to intersect with
  90888. * @param camera defines the current active camera
  90889. * @param predicate defines a predicate used to select candidate sprites
  90890. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90891. * @returns null if no hit or a PickingInfo
  90892. */
  90893. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90894. /**
  90895. * Intersects the sprites with a ray
  90896. * @param ray defines the ray to intersect with
  90897. * @param camera defines the current active camera
  90898. * @param predicate defines a predicate used to select candidate sprites
  90899. * @returns null if no hit or a PickingInfo array
  90900. */
  90901. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90902. /**
  90903. * Render all child sprites
  90904. */
  90905. render(): void;
  90906. /**
  90907. * Release associated resources
  90908. */
  90909. dispose(): void;
  90910. /**
  90911. * Serializes the sprite manager to a JSON object
  90912. * @param serializeTexture defines if the texture must be serialized as well
  90913. * @returns the JSON object
  90914. */
  90915. serialize(serializeTexture?: boolean): any;
  90916. /**
  90917. * Parses a JSON object to create a new sprite manager.
  90918. * @param parsedManager The JSON object to parse
  90919. * @param scene The scene to create the sprite managerin
  90920. * @param rootUrl The root url to use to load external dependencies like texture
  90921. * @returns the new sprite manager
  90922. */
  90923. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90924. /**
  90925. * Creates a sprite manager from a snippet saved in a remote file
  90926. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90927. * @param url defines the url to load from
  90928. * @param scene defines the hosting scene
  90929. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90930. * @returns a promise that will resolve to the new sprite manager
  90931. */
  90932. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90933. /**
  90934. * Creates a sprite manager from a snippet saved by the sprite editor
  90935. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90936. * @param scene defines the hosting scene
  90937. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90938. * @returns a promise that will resolve to the new sprite manager
  90939. */
  90940. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90941. }
  90942. }
  90943. declare module BABYLON {
  90944. /** Interface used by value gradients (color, factor, ...) */
  90945. export interface IValueGradient {
  90946. /**
  90947. * Gets or sets the gradient value (between 0 and 1)
  90948. */
  90949. gradient: number;
  90950. }
  90951. /** Class used to store color4 gradient */
  90952. export class ColorGradient implements IValueGradient {
  90953. /**
  90954. * Gets or sets the gradient value (between 0 and 1)
  90955. */
  90956. gradient: number;
  90957. /**
  90958. * Gets or sets first associated color
  90959. */
  90960. color1: Color4;
  90961. /**
  90962. * Gets or sets second associated color
  90963. */
  90964. color2?: Color4 | undefined;
  90965. /**
  90966. * Creates a new color4 gradient
  90967. * @param gradient gets or sets the gradient value (between 0 and 1)
  90968. * @param color1 gets or sets first associated color
  90969. * @param color2 gets or sets first second color
  90970. */
  90971. constructor(
  90972. /**
  90973. * Gets or sets the gradient value (between 0 and 1)
  90974. */
  90975. gradient: number,
  90976. /**
  90977. * Gets or sets first associated color
  90978. */
  90979. color1: Color4,
  90980. /**
  90981. * Gets or sets second associated color
  90982. */
  90983. color2?: Color4 | undefined);
  90984. /**
  90985. * Will get a color picked randomly between color1 and color2.
  90986. * If color2 is undefined then color1 will be used
  90987. * @param result defines the target Color4 to store the result in
  90988. */
  90989. getColorToRef(result: Color4): void;
  90990. }
  90991. /** Class used to store color 3 gradient */
  90992. export class Color3Gradient implements IValueGradient {
  90993. /**
  90994. * Gets or sets the gradient value (between 0 and 1)
  90995. */
  90996. gradient: number;
  90997. /**
  90998. * Gets or sets the associated color
  90999. */
  91000. color: Color3;
  91001. /**
  91002. * Creates a new color3 gradient
  91003. * @param gradient gets or sets the gradient value (between 0 and 1)
  91004. * @param color gets or sets associated color
  91005. */
  91006. constructor(
  91007. /**
  91008. * Gets or sets the gradient value (between 0 and 1)
  91009. */
  91010. gradient: number,
  91011. /**
  91012. * Gets or sets the associated color
  91013. */
  91014. color: Color3);
  91015. }
  91016. /** Class used to store factor gradient */
  91017. export class FactorGradient implements IValueGradient {
  91018. /**
  91019. * Gets or sets the gradient value (between 0 and 1)
  91020. */
  91021. gradient: number;
  91022. /**
  91023. * Gets or sets first associated factor
  91024. */
  91025. factor1: number;
  91026. /**
  91027. * Gets or sets second associated factor
  91028. */
  91029. factor2?: number | undefined;
  91030. /**
  91031. * Creates a new factor gradient
  91032. * @param gradient gets or sets the gradient value (between 0 and 1)
  91033. * @param factor1 gets or sets first associated factor
  91034. * @param factor2 gets or sets second associated factor
  91035. */
  91036. constructor(
  91037. /**
  91038. * Gets or sets the gradient value (between 0 and 1)
  91039. */
  91040. gradient: number,
  91041. /**
  91042. * Gets or sets first associated factor
  91043. */
  91044. factor1: number,
  91045. /**
  91046. * Gets or sets second associated factor
  91047. */
  91048. factor2?: number | undefined);
  91049. /**
  91050. * Will get a number picked randomly between factor1 and factor2.
  91051. * If factor2 is undefined then factor1 will be used
  91052. * @returns the picked number
  91053. */
  91054. getFactor(): number;
  91055. }
  91056. /**
  91057. * Helper used to simplify some generic gradient tasks
  91058. */
  91059. export class GradientHelper {
  91060. /**
  91061. * Gets the current gradient from an array of IValueGradient
  91062. * @param ratio defines the current ratio to get
  91063. * @param gradients defines the array of IValueGradient
  91064. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91065. */
  91066. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91067. }
  91068. }
  91069. declare module BABYLON {
  91070. interface ThinEngine {
  91071. /**
  91072. * Creates a raw texture
  91073. * @param data defines the data to store in the texture
  91074. * @param width defines the width of the texture
  91075. * @param height defines the height of the texture
  91076. * @param format defines the format of the data
  91077. * @param generateMipMaps defines if the engine should generate the mip levels
  91078. * @param invertY defines if data must be stored with Y axis inverted
  91079. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91080. * @param compression defines the compression used (null by default)
  91081. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91082. * @returns the raw texture inside an InternalTexture
  91083. */
  91084. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91085. /**
  91086. * Update a raw texture
  91087. * @param texture defines the texture to update
  91088. * @param data defines the data to store in the texture
  91089. * @param format defines the format of the data
  91090. * @param invertY defines if data must be stored with Y axis inverted
  91091. */
  91092. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91093. /**
  91094. * Update a raw texture
  91095. * @param texture defines the texture to update
  91096. * @param data defines the data to store in the texture
  91097. * @param format defines the format of the data
  91098. * @param invertY defines if data must be stored with Y axis inverted
  91099. * @param compression defines the compression used (null by default)
  91100. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91101. */
  91102. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91103. /**
  91104. * Creates a new raw cube texture
  91105. * @param data defines the array of data to use to create each face
  91106. * @param size defines the size of the textures
  91107. * @param format defines the format of the data
  91108. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91109. * @param generateMipMaps defines if the engine should generate the mip levels
  91110. * @param invertY defines if data must be stored with Y axis inverted
  91111. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91112. * @param compression defines the compression used (null by default)
  91113. * @returns the cube texture as an InternalTexture
  91114. */
  91115. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91116. /**
  91117. * Update a raw cube texture
  91118. * @param texture defines the texture to udpdate
  91119. * @param data defines the data to store
  91120. * @param format defines the data format
  91121. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91122. * @param invertY defines if data must be stored with Y axis inverted
  91123. */
  91124. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91125. /**
  91126. * Update a raw cube texture
  91127. * @param texture defines the texture to udpdate
  91128. * @param data defines the data to store
  91129. * @param format defines the data format
  91130. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91131. * @param invertY defines if data must be stored with Y axis inverted
  91132. * @param compression defines the compression used (null by default)
  91133. */
  91134. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91135. /**
  91136. * Update a raw cube texture
  91137. * @param texture defines the texture to udpdate
  91138. * @param data defines the data to store
  91139. * @param format defines the data format
  91140. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91141. * @param invertY defines if data must be stored with Y axis inverted
  91142. * @param compression defines the compression used (null by default)
  91143. * @param level defines which level of the texture to update
  91144. */
  91145. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91146. /**
  91147. * Creates a new raw cube texture from a specified url
  91148. * @param url defines the url where the data is located
  91149. * @param scene defines the current scene
  91150. * @param size defines the size of the textures
  91151. * @param format defines the format of the data
  91152. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91153. * @param noMipmap defines if the engine should avoid generating the mip levels
  91154. * @param callback defines a callback used to extract texture data from loaded data
  91155. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91156. * @param onLoad defines a callback called when texture is loaded
  91157. * @param onError defines a callback called if there is an error
  91158. * @returns the cube texture as an InternalTexture
  91159. */
  91160. 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;
  91161. /**
  91162. * Creates a new raw cube texture from a specified url
  91163. * @param url defines the url where the data is located
  91164. * @param scene defines the current scene
  91165. * @param size defines the size of the textures
  91166. * @param format defines the format of the data
  91167. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91168. * @param noMipmap defines if the engine should avoid generating the mip levels
  91169. * @param callback defines a callback used to extract texture data from loaded data
  91170. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91171. * @param onLoad defines a callback called when texture is loaded
  91172. * @param onError defines a callback called if there is an error
  91173. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91174. * @param invertY defines if data must be stored with Y axis inverted
  91175. * @returns the cube texture as an InternalTexture
  91176. */
  91177. 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;
  91178. /**
  91179. * Creates a new raw 3D texture
  91180. * @param data defines the data used to create the texture
  91181. * @param width defines the width of the texture
  91182. * @param height defines the height of the texture
  91183. * @param depth defines the depth of the texture
  91184. * @param format defines the format of the texture
  91185. * @param generateMipMaps defines if the engine must generate mip levels
  91186. * @param invertY defines if data must be stored with Y axis inverted
  91187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91188. * @param compression defines the compressed used (can be null)
  91189. * @param textureType defines the compressed used (can be null)
  91190. * @returns a new raw 3D texture (stored in an InternalTexture)
  91191. */
  91192. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91193. /**
  91194. * Update a raw 3D texture
  91195. * @param texture defines the texture to update
  91196. * @param data defines the data to store
  91197. * @param format defines the data format
  91198. * @param invertY defines if data must be stored with Y axis inverted
  91199. */
  91200. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91201. /**
  91202. * Update a raw 3D texture
  91203. * @param texture defines the texture to update
  91204. * @param data defines the data to store
  91205. * @param format defines the data format
  91206. * @param invertY defines if data must be stored with Y axis inverted
  91207. * @param compression defines the used compression (can be null)
  91208. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91209. */
  91210. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91211. /**
  91212. * Creates a new raw 2D array texture
  91213. * @param data defines the data used to create the texture
  91214. * @param width defines the width of the texture
  91215. * @param height defines the height of the texture
  91216. * @param depth defines the number of layers of the texture
  91217. * @param format defines the format of the texture
  91218. * @param generateMipMaps defines if the engine must generate mip levels
  91219. * @param invertY defines if data must be stored with Y axis inverted
  91220. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91221. * @param compression defines the compressed used (can be null)
  91222. * @param textureType defines the compressed used (can be null)
  91223. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91224. */
  91225. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91226. /**
  91227. * Update a raw 2D array texture
  91228. * @param texture defines the texture to update
  91229. * @param data defines the data to store
  91230. * @param format defines the data format
  91231. * @param invertY defines if data must be stored with Y axis inverted
  91232. */
  91233. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91234. /**
  91235. * Update a raw 2D array texture
  91236. * @param texture defines the texture to update
  91237. * @param data defines the data to store
  91238. * @param format defines the data format
  91239. * @param invertY defines if data must be stored with Y axis inverted
  91240. * @param compression defines the used compression (can be null)
  91241. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91242. */
  91243. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91244. }
  91245. }
  91246. declare module BABYLON {
  91247. /**
  91248. * Raw texture can help creating a texture directly from an array of data.
  91249. * This can be super useful if you either get the data from an uncompressed source or
  91250. * if you wish to create your texture pixel by pixel.
  91251. */
  91252. export class RawTexture extends Texture {
  91253. /**
  91254. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91255. */
  91256. format: number;
  91257. /**
  91258. * Instantiates a new RawTexture.
  91259. * Raw texture can help creating a texture directly from an array of data.
  91260. * This can be super useful if you either get the data from an uncompressed source or
  91261. * if you wish to create your texture pixel by pixel.
  91262. * @param data define the array of data to use to create the texture
  91263. * @param width define the width of the texture
  91264. * @param height define the height of the texture
  91265. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91266. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91267. * @param generateMipMaps define whether mip maps should be generated or not
  91268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91270. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91271. */
  91272. constructor(data: ArrayBufferView, width: number, height: number,
  91273. /**
  91274. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91275. */
  91276. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91277. /**
  91278. * Updates the texture underlying data.
  91279. * @param data Define the new data of the texture
  91280. */
  91281. update(data: ArrayBufferView): void;
  91282. /**
  91283. * Creates a luminance texture from some data.
  91284. * @param data Define the texture data
  91285. * @param width Define the width of the texture
  91286. * @param height Define the height of the texture
  91287. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91288. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91289. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91290. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91291. * @returns the luminance texture
  91292. */
  91293. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91294. /**
  91295. * Creates a luminance alpha texture from some data.
  91296. * @param data Define the texture data
  91297. * @param width Define the width of the texture
  91298. * @param height Define the height of the texture
  91299. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91300. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91303. * @returns the luminance alpha texture
  91304. */
  91305. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91306. /**
  91307. * Creates an alpha texture from some data.
  91308. * @param data Define the texture data
  91309. * @param width Define the width of the texture
  91310. * @param height Define the height of the texture
  91311. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91312. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91315. * @returns the alpha texture
  91316. */
  91317. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91318. /**
  91319. * Creates a RGB texture from some data.
  91320. * @param data Define the texture data
  91321. * @param width Define the width of the texture
  91322. * @param height Define the height of the texture
  91323. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91324. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91325. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91326. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91327. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91328. * @returns the RGB alpha texture
  91329. */
  91330. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91331. /**
  91332. * Creates a RGBA texture from some data.
  91333. * @param data Define the texture data
  91334. * @param width Define the width of the texture
  91335. * @param height Define the height of the texture
  91336. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91337. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91338. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91339. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91340. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91341. * @returns the RGBA texture
  91342. */
  91343. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91344. /**
  91345. * Creates a R texture from some data.
  91346. * @param data Define the texture data
  91347. * @param width Define the width of the texture
  91348. * @param height Define the height of the texture
  91349. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91350. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91351. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91352. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91353. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91354. * @returns the R texture
  91355. */
  91356. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91357. }
  91358. }
  91359. declare module BABYLON {
  91360. interface ThinEngine {
  91361. /**
  91362. * Update a dynamic index buffer
  91363. * @param indexBuffer defines the target index buffer
  91364. * @param indices defines the data to update
  91365. * @param offset defines the offset in the target index buffer where update should start
  91366. */
  91367. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91368. /**
  91369. * Updates a dynamic vertex buffer.
  91370. * @param vertexBuffer the vertex buffer to update
  91371. * @param data the data used to update the vertex buffer
  91372. * @param byteOffset the byte offset of the data
  91373. * @param byteLength the byte length of the data
  91374. */
  91375. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91376. }
  91377. }
  91378. declare module BABYLON {
  91379. interface AbstractScene {
  91380. /**
  91381. * The list of procedural textures added to the scene
  91382. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91383. */
  91384. proceduralTextures: Array<ProceduralTexture>;
  91385. }
  91386. /**
  91387. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91388. * in a given scene.
  91389. */
  91390. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91391. /**
  91392. * The component name helpfull to identify the component in the list of scene components.
  91393. */
  91394. readonly name: string;
  91395. /**
  91396. * The scene the component belongs to.
  91397. */
  91398. scene: Scene;
  91399. /**
  91400. * Creates a new instance of the component for the given scene
  91401. * @param scene Defines the scene to register the component in
  91402. */
  91403. constructor(scene: Scene);
  91404. /**
  91405. * Registers the component in a given scene
  91406. */
  91407. register(): void;
  91408. /**
  91409. * Rebuilds the elements related to this component in case of
  91410. * context lost for instance.
  91411. */
  91412. rebuild(): void;
  91413. /**
  91414. * Disposes the component and the associated ressources.
  91415. */
  91416. dispose(): void;
  91417. private _beforeClear;
  91418. }
  91419. }
  91420. declare module BABYLON {
  91421. interface ThinEngine {
  91422. /**
  91423. * Creates a new render target cube texture
  91424. * @param size defines the size of the texture
  91425. * @param options defines the options used to create the texture
  91426. * @returns a new render target cube texture stored in an InternalTexture
  91427. */
  91428. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91429. }
  91430. }
  91431. declare module BABYLON {
  91432. /** @hidden */
  91433. export var proceduralVertexShader: {
  91434. name: string;
  91435. shader: string;
  91436. };
  91437. }
  91438. declare module BABYLON {
  91439. /**
  91440. * 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.
  91441. * This is the base class of any Procedural texture and contains most of the shareable code.
  91442. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91443. */
  91444. export class ProceduralTexture extends Texture {
  91445. /**
  91446. * Define if the texture is enabled or not (disabled texture will not render)
  91447. */
  91448. isEnabled: boolean;
  91449. /**
  91450. * Define if the texture must be cleared before rendering (default is true)
  91451. */
  91452. autoClear: boolean;
  91453. /**
  91454. * Callback called when the texture is generated
  91455. */
  91456. onGenerated: () => void;
  91457. /**
  91458. * Event raised when the texture is generated
  91459. */
  91460. onGeneratedObservable: Observable<ProceduralTexture>;
  91461. /** @hidden */
  91462. _generateMipMaps: boolean;
  91463. /** @hidden **/
  91464. _effect: Effect;
  91465. /** @hidden */
  91466. _textures: {
  91467. [key: string]: Texture;
  91468. };
  91469. /** @hidden */
  91470. protected _fallbackTexture: Nullable<Texture>;
  91471. private _size;
  91472. private _currentRefreshId;
  91473. private _frameId;
  91474. private _refreshRate;
  91475. private _vertexBuffers;
  91476. private _indexBuffer;
  91477. private _uniforms;
  91478. private _samplers;
  91479. private _fragment;
  91480. private _floats;
  91481. private _ints;
  91482. private _floatsArrays;
  91483. private _colors3;
  91484. private _colors4;
  91485. private _vectors2;
  91486. private _vectors3;
  91487. private _matrices;
  91488. private _fallbackTextureUsed;
  91489. private _fullEngine;
  91490. private _cachedDefines;
  91491. private _contentUpdateId;
  91492. private _contentData;
  91493. /**
  91494. * Instantiates a new procedural texture.
  91495. * 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.
  91496. * This is the base class of any Procedural texture and contains most of the shareable code.
  91497. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91498. * @param name Define the name of the texture
  91499. * @param size Define the size of the texture to create
  91500. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  91501. * @param scene Define the scene the texture belongs to
  91502. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  91503. * @param generateMipMaps Define if the texture should creates mip maps or not
  91504. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  91505. */
  91506. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  91507. /**
  91508. * The effect that is created when initializing the post process.
  91509. * @returns The created effect corresponding the the postprocess.
  91510. */
  91511. getEffect(): Effect;
  91512. /**
  91513. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91514. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91515. */
  91516. getContent(): Nullable<ArrayBufferView>;
  91517. private _createIndexBuffer;
  91518. /** @hidden */
  91519. _rebuild(): void;
  91520. /**
  91521. * Resets the texture in order to recreate its associated resources.
  91522. * This can be called in case of context loss
  91523. */
  91524. reset(): void;
  91525. protected _getDefines(): string;
  91526. /**
  91527. * Is the texture ready to be used ? (rendered at least once)
  91528. * @returns true if ready, otherwise, false.
  91529. */
  91530. isReady(): boolean;
  91531. /**
  91532. * Resets the refresh counter of the texture and start bak from scratch.
  91533. * Could be useful to regenerate the texture if it is setup to render only once.
  91534. */
  91535. resetRefreshCounter(): void;
  91536. /**
  91537. * Set the fragment shader to use in order to render the texture.
  91538. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91539. */
  91540. setFragment(fragment: any): void;
  91541. /**
  91542. * Define the refresh rate of the texture or the rendering frequency.
  91543. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91544. */
  91545. get refreshRate(): number;
  91546. set refreshRate(value: number);
  91547. /** @hidden */
  91548. _shouldRender(): boolean;
  91549. /**
  91550. * Get the size the texture is rendering at.
  91551. * @returns the size (texture is always squared)
  91552. */
  91553. getRenderSize(): number;
  91554. /**
  91555. * Resize the texture to new value.
  91556. * @param size Define the new size the texture should have
  91557. * @param generateMipMaps Define whether the new texture should create mip maps
  91558. */
  91559. resize(size: number, generateMipMaps: boolean): void;
  91560. private _checkUniform;
  91561. /**
  91562. * Set a texture in the shader program used to render.
  91563. * @param name Define the name of the uniform samplers as defined in the shader
  91564. * @param texture Define the texture to bind to this sampler
  91565. * @return the texture itself allowing "fluent" like uniform updates
  91566. */
  91567. setTexture(name: string, texture: Texture): ProceduralTexture;
  91568. /**
  91569. * Set a float in the shader.
  91570. * @param name Define the name of the uniform as defined in the shader
  91571. * @param value Define the value to give to the uniform
  91572. * @return the texture itself allowing "fluent" like uniform updates
  91573. */
  91574. setFloat(name: string, value: number): ProceduralTexture;
  91575. /**
  91576. * Set a int in the shader.
  91577. * @param name Define the name of the uniform as defined in the shader
  91578. * @param value Define the value to give to the uniform
  91579. * @return the texture itself allowing "fluent" like uniform updates
  91580. */
  91581. setInt(name: string, value: number): ProceduralTexture;
  91582. /**
  91583. * Set an array of floats in the shader.
  91584. * @param name Define the name of the uniform as defined in the shader
  91585. * @param value Define the value to give to the uniform
  91586. * @return the texture itself allowing "fluent" like uniform updates
  91587. */
  91588. setFloats(name: string, value: number[]): ProceduralTexture;
  91589. /**
  91590. * Set a vec3 in the shader from a Color3.
  91591. * @param name Define the name of the uniform as defined in the shader
  91592. * @param value Define the value to give to the uniform
  91593. * @return the texture itself allowing "fluent" like uniform updates
  91594. */
  91595. setColor3(name: string, value: Color3): ProceduralTexture;
  91596. /**
  91597. * Set a vec4 in the shader from a Color4.
  91598. * @param name Define the name of the uniform as defined in the shader
  91599. * @param value Define the value to give to the uniform
  91600. * @return the texture itself allowing "fluent" like uniform updates
  91601. */
  91602. setColor4(name: string, value: Color4): ProceduralTexture;
  91603. /**
  91604. * Set a vec2 in the shader from a Vector2.
  91605. * @param name Define the name of the uniform as defined in the shader
  91606. * @param value Define the value to give to the uniform
  91607. * @return the texture itself allowing "fluent" like uniform updates
  91608. */
  91609. setVector2(name: string, value: Vector2): ProceduralTexture;
  91610. /**
  91611. * Set a vec3 in the shader from a Vector3.
  91612. * @param name Define the name of the uniform as defined in the shader
  91613. * @param value Define the value to give to the uniform
  91614. * @return the texture itself allowing "fluent" like uniform updates
  91615. */
  91616. setVector3(name: string, value: Vector3): ProceduralTexture;
  91617. /**
  91618. * Set a mat4 in the shader from a MAtrix.
  91619. * @param name Define the name of the uniform as defined in the shader
  91620. * @param value Define the value to give to the uniform
  91621. * @return the texture itself allowing "fluent" like uniform updates
  91622. */
  91623. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91624. /**
  91625. * Render the texture to its associated render target.
  91626. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91627. */
  91628. render(useCameraPostProcess?: boolean): void;
  91629. /**
  91630. * Clone the texture.
  91631. * @returns the cloned texture
  91632. */
  91633. clone(): ProceduralTexture;
  91634. /**
  91635. * Dispose the texture and release its asoociated resources.
  91636. */
  91637. dispose(): void;
  91638. }
  91639. }
  91640. declare module BABYLON {
  91641. /**
  91642. * This represents the base class for particle system in Babylon.
  91643. * 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.
  91644. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91645. * @example https://doc.babylonjs.com/babylon101/particles
  91646. */
  91647. export class BaseParticleSystem {
  91648. /**
  91649. * Source color is added to the destination color without alpha affecting the result
  91650. */
  91651. static BLENDMODE_ONEONE: number;
  91652. /**
  91653. * Blend current color and particle color using particle’s alpha
  91654. */
  91655. static BLENDMODE_STANDARD: number;
  91656. /**
  91657. * Add current color and particle color multiplied by particle’s alpha
  91658. */
  91659. static BLENDMODE_ADD: number;
  91660. /**
  91661. * Multiply current color with particle color
  91662. */
  91663. static BLENDMODE_MULTIPLY: number;
  91664. /**
  91665. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91666. */
  91667. static BLENDMODE_MULTIPLYADD: number;
  91668. /**
  91669. * List of animations used by the particle system.
  91670. */
  91671. animations: Animation[];
  91672. /**
  91673. * Gets or sets the unique id of the particle system
  91674. */
  91675. uniqueId: number;
  91676. /**
  91677. * The id of the Particle system.
  91678. */
  91679. id: string;
  91680. /**
  91681. * The friendly name of the Particle system.
  91682. */
  91683. name: string;
  91684. /**
  91685. * Snippet ID if the particle system was created from the snippet server
  91686. */
  91687. snippetId: string;
  91688. /**
  91689. * The rendering group used by the Particle system to chose when to render.
  91690. */
  91691. renderingGroupId: number;
  91692. /**
  91693. * The emitter represents the Mesh or position we are attaching the particle system to.
  91694. */
  91695. emitter: Nullable<AbstractMesh | Vector3>;
  91696. /**
  91697. * The maximum number of particles to emit per frame
  91698. */
  91699. emitRate: number;
  91700. /**
  91701. * If you want to launch only a few particles at once, that can be done, as well.
  91702. */
  91703. manualEmitCount: number;
  91704. /**
  91705. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91706. */
  91707. updateSpeed: number;
  91708. /**
  91709. * The amount of time the particle system is running (depends of the overall update speed).
  91710. */
  91711. targetStopDuration: number;
  91712. /**
  91713. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91714. */
  91715. disposeOnStop: boolean;
  91716. /**
  91717. * Minimum power of emitting particles.
  91718. */
  91719. minEmitPower: number;
  91720. /**
  91721. * Maximum power of emitting particles.
  91722. */
  91723. maxEmitPower: number;
  91724. /**
  91725. * Minimum life time of emitting particles.
  91726. */
  91727. minLifeTime: number;
  91728. /**
  91729. * Maximum life time of emitting particles.
  91730. */
  91731. maxLifeTime: number;
  91732. /**
  91733. * Minimum Size of emitting particles.
  91734. */
  91735. minSize: number;
  91736. /**
  91737. * Maximum Size of emitting particles.
  91738. */
  91739. maxSize: number;
  91740. /**
  91741. * Minimum scale of emitting particles on X axis.
  91742. */
  91743. minScaleX: number;
  91744. /**
  91745. * Maximum scale of emitting particles on X axis.
  91746. */
  91747. maxScaleX: number;
  91748. /**
  91749. * Minimum scale of emitting particles on Y axis.
  91750. */
  91751. minScaleY: number;
  91752. /**
  91753. * Maximum scale of emitting particles on Y axis.
  91754. */
  91755. maxScaleY: number;
  91756. /**
  91757. * Gets or sets the minimal initial rotation in radians.
  91758. */
  91759. minInitialRotation: number;
  91760. /**
  91761. * Gets or sets the maximal initial rotation in radians.
  91762. */
  91763. maxInitialRotation: number;
  91764. /**
  91765. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91766. */
  91767. minAngularSpeed: number;
  91768. /**
  91769. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91770. */
  91771. maxAngularSpeed: number;
  91772. /**
  91773. * The texture used to render each particle. (this can be a spritesheet)
  91774. */
  91775. particleTexture: Nullable<BaseTexture>;
  91776. /**
  91777. * The layer mask we are rendering the particles through.
  91778. */
  91779. layerMask: number;
  91780. /**
  91781. * This can help using your own shader to render the particle system.
  91782. * The according effect will be created
  91783. */
  91784. customShader: any;
  91785. /**
  91786. * By default particle system starts as soon as they are created. This prevents the
  91787. * automatic start to happen and let you decide when to start emitting particles.
  91788. */
  91789. preventAutoStart: boolean;
  91790. private _noiseTexture;
  91791. /**
  91792. * Gets or sets a texture used to add random noise to particle positions
  91793. */
  91794. get noiseTexture(): Nullable<ProceduralTexture>;
  91795. set noiseTexture(value: Nullable<ProceduralTexture>);
  91796. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91797. noiseStrength: Vector3;
  91798. /**
  91799. * Callback triggered when the particle animation is ending.
  91800. */
  91801. onAnimationEnd: Nullable<() => void>;
  91802. /**
  91803. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91804. */
  91805. blendMode: number;
  91806. /**
  91807. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91808. * to override the particles.
  91809. */
  91810. forceDepthWrite: boolean;
  91811. /** 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 */
  91812. preWarmCycles: number;
  91813. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91814. preWarmStepOffset: number;
  91815. /**
  91816. * 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)
  91817. */
  91818. spriteCellChangeSpeed: number;
  91819. /**
  91820. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91821. */
  91822. startSpriteCellID: number;
  91823. /**
  91824. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91825. */
  91826. endSpriteCellID: number;
  91827. /**
  91828. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91829. */
  91830. spriteCellWidth: number;
  91831. /**
  91832. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91833. */
  91834. spriteCellHeight: number;
  91835. /**
  91836. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91837. */
  91838. spriteRandomStartCell: boolean;
  91839. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91840. translationPivot: Vector2;
  91841. /** @hidden */
  91842. protected _isAnimationSheetEnabled: boolean;
  91843. /**
  91844. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91845. */
  91846. beginAnimationOnStart: boolean;
  91847. /**
  91848. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91849. */
  91850. beginAnimationFrom: number;
  91851. /**
  91852. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91853. */
  91854. beginAnimationTo: number;
  91855. /**
  91856. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91857. */
  91858. beginAnimationLoop: boolean;
  91859. /**
  91860. * Gets or sets a world offset applied to all particles
  91861. */
  91862. worldOffset: Vector3;
  91863. /**
  91864. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91865. */
  91866. get isAnimationSheetEnabled(): boolean;
  91867. set isAnimationSheetEnabled(value: boolean);
  91868. /**
  91869. * Get hosting scene
  91870. * @returns the scene
  91871. */
  91872. getScene(): Nullable<Scene>;
  91873. /**
  91874. * You can use gravity if you want to give an orientation to your particles.
  91875. */
  91876. gravity: Vector3;
  91877. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91878. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91879. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91880. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91881. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91882. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91883. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91884. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91885. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91886. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91887. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91888. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91889. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91890. /**
  91891. * Defines the delay in milliseconds before starting the system (0 by default)
  91892. */
  91893. startDelay: number;
  91894. /**
  91895. * Gets the current list of drag gradients.
  91896. * You must use addDragGradient and removeDragGradient to udpate this list
  91897. * @returns the list of drag gradients
  91898. */
  91899. getDragGradients(): Nullable<Array<FactorGradient>>;
  91900. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91901. limitVelocityDamping: number;
  91902. /**
  91903. * Gets the current list of limit velocity gradients.
  91904. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91905. * @returns the list of limit velocity gradients
  91906. */
  91907. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91908. /**
  91909. * Gets the current list of color gradients.
  91910. * You must use addColorGradient and removeColorGradient to udpate this list
  91911. * @returns the list of color gradients
  91912. */
  91913. getColorGradients(): Nullable<Array<ColorGradient>>;
  91914. /**
  91915. * Gets the current list of size gradients.
  91916. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91917. * @returns the list of size gradients
  91918. */
  91919. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91920. /**
  91921. * Gets the current list of color remap gradients.
  91922. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91923. * @returns the list of color remap gradients
  91924. */
  91925. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91926. /**
  91927. * Gets the current list of alpha remap gradients.
  91928. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91929. * @returns the list of alpha remap gradients
  91930. */
  91931. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91932. /**
  91933. * Gets the current list of life time gradients.
  91934. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91935. * @returns the list of life time gradients
  91936. */
  91937. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91938. /**
  91939. * Gets the current list of angular speed gradients.
  91940. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91941. * @returns the list of angular speed gradients
  91942. */
  91943. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91944. /**
  91945. * Gets the current list of velocity gradients.
  91946. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91947. * @returns the list of velocity gradients
  91948. */
  91949. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91950. /**
  91951. * Gets the current list of start size gradients.
  91952. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91953. * @returns the list of start size gradients
  91954. */
  91955. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91956. /**
  91957. * Gets the current list of emit rate gradients.
  91958. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91959. * @returns the list of emit rate gradients
  91960. */
  91961. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91962. /**
  91963. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91964. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91965. */
  91966. get direction1(): Vector3;
  91967. set direction1(value: Vector3);
  91968. /**
  91969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91970. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91971. */
  91972. get direction2(): Vector3;
  91973. set direction2(value: Vector3);
  91974. /**
  91975. * 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.
  91976. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91977. */
  91978. get minEmitBox(): Vector3;
  91979. set minEmitBox(value: Vector3);
  91980. /**
  91981. * 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.
  91982. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91983. */
  91984. get maxEmitBox(): Vector3;
  91985. set maxEmitBox(value: Vector3);
  91986. /**
  91987. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91988. */
  91989. color1: Color4;
  91990. /**
  91991. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91992. */
  91993. color2: Color4;
  91994. /**
  91995. * Color the particle will have at the end of its lifetime
  91996. */
  91997. colorDead: Color4;
  91998. /**
  91999. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92000. */
  92001. textureMask: Color4;
  92002. /**
  92003. * The particle emitter type defines the emitter used by the particle system.
  92004. * It can be for example box, sphere, or cone...
  92005. */
  92006. particleEmitterType: IParticleEmitterType;
  92007. /** @hidden */
  92008. _isSubEmitter: boolean;
  92009. /**
  92010. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92011. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92012. */
  92013. billboardMode: number;
  92014. protected _isBillboardBased: boolean;
  92015. /**
  92016. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92017. */
  92018. get isBillboardBased(): boolean;
  92019. set isBillboardBased(value: boolean);
  92020. /**
  92021. * The scene the particle system belongs to.
  92022. */
  92023. protected _scene: Nullable<Scene>;
  92024. /**
  92025. * The engine the particle system belongs to.
  92026. */
  92027. protected _engine: ThinEngine;
  92028. /**
  92029. * Local cache of defines for image processing.
  92030. */
  92031. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92032. /**
  92033. * Default configuration related to image processing available in the standard Material.
  92034. */
  92035. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92036. /**
  92037. * Gets the image processing configuration used either in this material.
  92038. */
  92039. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92040. /**
  92041. * Sets the Default image processing configuration used either in the this material.
  92042. *
  92043. * If sets to null, the scene one is in use.
  92044. */
  92045. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92046. /**
  92047. * Attaches a new image processing configuration to the Standard Material.
  92048. * @param configuration
  92049. */
  92050. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92051. /** @hidden */
  92052. protected _reset(): void;
  92053. /** @hidden */
  92054. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92055. /**
  92056. * Instantiates a particle system.
  92057. * 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.
  92058. * @param name The name of the particle system
  92059. */
  92060. constructor(name: string);
  92061. /**
  92062. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92063. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92064. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92065. * @returns the emitter
  92066. */
  92067. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92068. /**
  92069. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92070. * @param radius The radius of the hemisphere to emit from
  92071. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92072. * @returns the emitter
  92073. */
  92074. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92075. /**
  92076. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92077. * @param radius The radius of the sphere to emit from
  92078. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92079. * @returns the emitter
  92080. */
  92081. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92082. /**
  92083. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92084. * @param radius The radius of the sphere to emit from
  92085. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92086. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92087. * @returns the emitter
  92088. */
  92089. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92090. /**
  92091. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92092. * @param radius The radius of the emission cylinder
  92093. * @param height The height of the emission cylinder
  92094. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92095. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92096. * @returns the emitter
  92097. */
  92098. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92099. /**
  92100. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92101. * @param radius The radius of the cylinder to emit from
  92102. * @param height The height of the emission cylinder
  92103. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92104. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92105. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92106. * @returns the emitter
  92107. */
  92108. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92109. /**
  92110. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92111. * @param radius The radius of the cone to emit from
  92112. * @param angle The base angle of the cone
  92113. * @returns the emitter
  92114. */
  92115. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92116. /**
  92117. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92118. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92119. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92120. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92121. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92122. * @returns the emitter
  92123. */
  92124. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92125. }
  92126. }
  92127. declare module BABYLON {
  92128. /**
  92129. * Type of sub emitter
  92130. */
  92131. export enum SubEmitterType {
  92132. /**
  92133. * Attached to the particle over it's lifetime
  92134. */
  92135. ATTACHED = 0,
  92136. /**
  92137. * Created when the particle dies
  92138. */
  92139. END = 1
  92140. }
  92141. /**
  92142. * Sub emitter class used to emit particles from an existing particle
  92143. */
  92144. export class SubEmitter {
  92145. /**
  92146. * the particle system to be used by the sub emitter
  92147. */
  92148. particleSystem: ParticleSystem;
  92149. /**
  92150. * Type of the submitter (Default: END)
  92151. */
  92152. type: SubEmitterType;
  92153. /**
  92154. * 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)
  92155. * Note: This only is supported when using an emitter of type Mesh
  92156. */
  92157. inheritDirection: boolean;
  92158. /**
  92159. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92160. */
  92161. inheritedVelocityAmount: number;
  92162. /**
  92163. * Creates a sub emitter
  92164. * @param particleSystem the particle system to be used by the sub emitter
  92165. */
  92166. constructor(
  92167. /**
  92168. * the particle system to be used by the sub emitter
  92169. */
  92170. particleSystem: ParticleSystem);
  92171. /**
  92172. * Clones the sub emitter
  92173. * @returns the cloned sub emitter
  92174. */
  92175. clone(): SubEmitter;
  92176. /**
  92177. * Serialize current object to a JSON object
  92178. * @returns the serialized object
  92179. */
  92180. serialize(): any;
  92181. /** @hidden */
  92182. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92183. /**
  92184. * Creates a new SubEmitter from a serialized JSON version
  92185. * @param serializationObject defines the JSON object to read from
  92186. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92187. * @param rootUrl defines the rootUrl for data loading
  92188. * @returns a new SubEmitter
  92189. */
  92190. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92191. /** Release associated resources */
  92192. dispose(): void;
  92193. }
  92194. }
  92195. declare module BABYLON {
  92196. /** @hidden */
  92197. export var imageProcessingDeclaration: {
  92198. name: string;
  92199. shader: string;
  92200. };
  92201. }
  92202. declare module BABYLON {
  92203. /** @hidden */
  92204. export var imageProcessingFunctions: {
  92205. name: string;
  92206. shader: string;
  92207. };
  92208. }
  92209. declare module BABYLON {
  92210. /** @hidden */
  92211. export var particlesPixelShader: {
  92212. name: string;
  92213. shader: string;
  92214. };
  92215. }
  92216. declare module BABYLON {
  92217. /** @hidden */
  92218. export var particlesVertexShader: {
  92219. name: string;
  92220. shader: string;
  92221. };
  92222. }
  92223. declare module BABYLON {
  92224. /**
  92225. * Interface used to define entities containing multiple clip planes
  92226. */
  92227. export interface IClipPlanesHolder {
  92228. /**
  92229. * Gets or sets the active clipplane 1
  92230. */
  92231. clipPlane: Nullable<Plane>;
  92232. /**
  92233. * Gets or sets the active clipplane 2
  92234. */
  92235. clipPlane2: Nullable<Plane>;
  92236. /**
  92237. * Gets or sets the active clipplane 3
  92238. */
  92239. clipPlane3: Nullable<Plane>;
  92240. /**
  92241. * Gets or sets the active clipplane 4
  92242. */
  92243. clipPlane4: Nullable<Plane>;
  92244. /**
  92245. * Gets or sets the active clipplane 5
  92246. */
  92247. clipPlane5: Nullable<Plane>;
  92248. /**
  92249. * Gets or sets the active clipplane 6
  92250. */
  92251. clipPlane6: Nullable<Plane>;
  92252. }
  92253. }
  92254. declare module BABYLON {
  92255. /**
  92256. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92257. *
  92258. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92259. *
  92260. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92261. */
  92262. export class ThinMaterialHelper {
  92263. /**
  92264. * Binds the clip plane information from the holder to the effect.
  92265. * @param effect The effect we are binding the data to
  92266. * @param holder The entity containing the clip plane information
  92267. */
  92268. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92269. }
  92270. }
  92271. declare module BABYLON {
  92272. interface ThinEngine {
  92273. /**
  92274. * Sets alpha constants used by some alpha blending modes
  92275. * @param r defines the red component
  92276. * @param g defines the green component
  92277. * @param b defines the blue component
  92278. * @param a defines the alpha component
  92279. */
  92280. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92281. /**
  92282. * Sets the current alpha mode
  92283. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92284. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92285. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92286. */
  92287. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92288. /**
  92289. * Gets the current alpha mode
  92290. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92291. * @returns the current alpha mode
  92292. */
  92293. getAlphaMode(): number;
  92294. /**
  92295. * Sets the current alpha equation
  92296. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92297. */
  92298. setAlphaEquation(equation: number): void;
  92299. /**
  92300. * Gets the current alpha equation.
  92301. * @returns the current alpha equation
  92302. */
  92303. getAlphaEquation(): number;
  92304. }
  92305. }
  92306. declare module BABYLON {
  92307. /**
  92308. * This represents a particle system in Babylon.
  92309. * 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.
  92310. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92311. * @example https://doc.babylonjs.com/babylon101/particles
  92312. */
  92313. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92314. /**
  92315. * Billboard mode will only apply to Y axis
  92316. */
  92317. static readonly BILLBOARDMODE_Y: number;
  92318. /**
  92319. * Billboard mode will apply to all axes
  92320. */
  92321. static readonly BILLBOARDMODE_ALL: number;
  92322. /**
  92323. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92324. */
  92325. static readonly BILLBOARDMODE_STRETCHED: number;
  92326. /**
  92327. * This function can be defined to provide custom update for active particles.
  92328. * This function will be called instead of regular update (age, position, color, etc.).
  92329. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92330. */
  92331. updateFunction: (particles: Particle[]) => void;
  92332. private _emitterWorldMatrix;
  92333. /**
  92334. * This function can be defined to specify initial direction for every new particle.
  92335. * It by default use the emitterType defined function
  92336. */
  92337. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92338. /**
  92339. * This function can be defined to specify initial position for every new particle.
  92340. * It by default use the emitterType defined function
  92341. */
  92342. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92343. /**
  92344. * @hidden
  92345. */
  92346. _inheritedVelocityOffset: Vector3;
  92347. /**
  92348. * An event triggered when the system is disposed
  92349. */
  92350. onDisposeObservable: Observable<IParticleSystem>;
  92351. private _onDisposeObserver;
  92352. /**
  92353. * Sets a callback that will be triggered when the system is disposed
  92354. */
  92355. set onDispose(callback: () => void);
  92356. private _particles;
  92357. private _epsilon;
  92358. private _capacity;
  92359. private _stockParticles;
  92360. private _newPartsExcess;
  92361. private _vertexData;
  92362. private _vertexBuffer;
  92363. private _vertexBuffers;
  92364. private _spriteBuffer;
  92365. private _indexBuffer;
  92366. private _effect;
  92367. private _customEffect;
  92368. private _cachedDefines;
  92369. private _scaledColorStep;
  92370. private _colorDiff;
  92371. private _scaledDirection;
  92372. private _scaledGravity;
  92373. private _currentRenderId;
  92374. private _alive;
  92375. private _useInstancing;
  92376. private _started;
  92377. private _stopped;
  92378. private _actualFrame;
  92379. private _scaledUpdateSpeed;
  92380. private _vertexBufferSize;
  92381. /** @hidden */
  92382. _currentEmitRateGradient: Nullable<FactorGradient>;
  92383. /** @hidden */
  92384. _currentEmitRate1: number;
  92385. /** @hidden */
  92386. _currentEmitRate2: number;
  92387. /** @hidden */
  92388. _currentStartSizeGradient: Nullable<FactorGradient>;
  92389. /** @hidden */
  92390. _currentStartSize1: number;
  92391. /** @hidden */
  92392. _currentStartSize2: number;
  92393. private readonly _rawTextureWidth;
  92394. private _rampGradientsTexture;
  92395. private _useRampGradients;
  92396. /** Gets or sets a matrix to use to compute projection */
  92397. defaultProjectionMatrix: Matrix;
  92398. /** Gets or sets a matrix to use to compute view */
  92399. defaultViewMatrix: Matrix;
  92400. /** Gets or sets a boolean indicating that ramp gradients must be used
  92401. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92402. */
  92403. get useRampGradients(): boolean;
  92404. set useRampGradients(value: boolean);
  92405. /**
  92406. * 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.
  92407. * 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: [])
  92408. */
  92409. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92410. private _subEmitters;
  92411. /**
  92412. * @hidden
  92413. * If the particle systems emitter should be disposed when the particle system is disposed
  92414. */
  92415. _disposeEmitterOnDispose: boolean;
  92416. /**
  92417. * The current active Sub-systems, this property is used by the root particle system only.
  92418. */
  92419. activeSubSystems: Array<ParticleSystem>;
  92420. /**
  92421. * Specifies if the particles are updated in emitter local space or world space
  92422. */
  92423. isLocal: boolean;
  92424. private _rootParticleSystem;
  92425. /**
  92426. * Gets the current list of active particles
  92427. */
  92428. get particles(): Particle[];
  92429. /**
  92430. * Gets the number of particles active at the same time.
  92431. * @returns The number of active particles.
  92432. */
  92433. getActiveCount(): number;
  92434. /**
  92435. * Returns the string "ParticleSystem"
  92436. * @returns a string containing the class name
  92437. */
  92438. getClassName(): string;
  92439. /**
  92440. * Gets a boolean indicating that the system is stopping
  92441. * @returns true if the system is currently stopping
  92442. */
  92443. isStopping(): boolean;
  92444. /**
  92445. * Gets the custom effect used to render the particles
  92446. * @param blendMode Blend mode for which the effect should be retrieved
  92447. * @returns The effect
  92448. */
  92449. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92450. /**
  92451. * Sets the custom effect used to render the particles
  92452. * @param effect The effect to set
  92453. * @param blendMode Blend mode for which the effect should be set
  92454. */
  92455. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92456. /** @hidden */
  92457. private _onBeforeDrawParticlesObservable;
  92458. /**
  92459. * Observable that will be called just before the particles are drawn
  92460. */
  92461. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92462. /**
  92463. * Gets the name of the particle vertex shader
  92464. */
  92465. get vertexShaderName(): string;
  92466. /**
  92467. * Instantiates a particle system.
  92468. * 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.
  92469. * @param name The name of the particle system
  92470. * @param capacity The max number of particles alive at the same time
  92471. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  92472. * @param customEffect a custom effect used to change the way particles are rendered by default
  92473. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  92474. * @param epsilon Offset used to render the particles
  92475. */
  92476. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  92477. private _addFactorGradient;
  92478. private _removeFactorGradient;
  92479. /**
  92480. * Adds a new life time gradient
  92481. * @param gradient defines the gradient to use (between 0 and 1)
  92482. * @param factor defines the life time factor to affect to the specified gradient
  92483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92484. * @returns the current particle system
  92485. */
  92486. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92487. /**
  92488. * Remove a specific life time gradient
  92489. * @param gradient defines the gradient to remove
  92490. * @returns the current particle system
  92491. */
  92492. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92493. /**
  92494. * Adds a new size gradient
  92495. * @param gradient defines the gradient to use (between 0 and 1)
  92496. * @param factor defines the size factor to affect to the specified gradient
  92497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92498. * @returns the current particle system
  92499. */
  92500. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92501. /**
  92502. * Remove a specific size gradient
  92503. * @param gradient defines the gradient to remove
  92504. * @returns the current particle system
  92505. */
  92506. removeSizeGradient(gradient: number): IParticleSystem;
  92507. /**
  92508. * Adds a new color remap gradient
  92509. * @param gradient defines the gradient to use (between 0 and 1)
  92510. * @param min defines the color remap minimal range
  92511. * @param max defines the color remap maximal range
  92512. * @returns the current particle system
  92513. */
  92514. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92515. /**
  92516. * Remove a specific color remap gradient
  92517. * @param gradient defines the gradient to remove
  92518. * @returns the current particle system
  92519. */
  92520. removeColorRemapGradient(gradient: number): IParticleSystem;
  92521. /**
  92522. * Adds a new alpha remap gradient
  92523. * @param gradient defines the gradient to use (between 0 and 1)
  92524. * @param min defines the alpha remap minimal range
  92525. * @param max defines the alpha remap maximal range
  92526. * @returns the current particle system
  92527. */
  92528. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92529. /**
  92530. * Remove a specific alpha remap gradient
  92531. * @param gradient defines the gradient to remove
  92532. * @returns the current particle system
  92533. */
  92534. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92535. /**
  92536. * Adds a new angular speed gradient
  92537. * @param gradient defines the gradient to use (between 0 and 1)
  92538. * @param factor defines the angular speed to affect to the specified gradient
  92539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92540. * @returns the current particle system
  92541. */
  92542. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92543. /**
  92544. * Remove a specific angular speed gradient
  92545. * @param gradient defines the gradient to remove
  92546. * @returns the current particle system
  92547. */
  92548. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92549. /**
  92550. * Adds a new velocity gradient
  92551. * @param gradient defines the gradient to use (between 0 and 1)
  92552. * @param factor defines the velocity to affect to the specified gradient
  92553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92554. * @returns the current particle system
  92555. */
  92556. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92557. /**
  92558. * Remove a specific velocity gradient
  92559. * @param gradient defines the gradient to remove
  92560. * @returns the current particle system
  92561. */
  92562. removeVelocityGradient(gradient: number): IParticleSystem;
  92563. /**
  92564. * Adds a new limit velocity gradient
  92565. * @param gradient defines the gradient to use (between 0 and 1)
  92566. * @param factor defines the limit velocity value to affect to the specified gradient
  92567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92568. * @returns the current particle system
  92569. */
  92570. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92571. /**
  92572. * Remove a specific limit velocity gradient
  92573. * @param gradient defines the gradient to remove
  92574. * @returns the current particle system
  92575. */
  92576. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92577. /**
  92578. * Adds a new drag gradient
  92579. * @param gradient defines the gradient to use (between 0 and 1)
  92580. * @param factor defines the drag value to affect to the specified gradient
  92581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92582. * @returns the current particle system
  92583. */
  92584. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92585. /**
  92586. * Remove a specific drag gradient
  92587. * @param gradient defines the gradient to remove
  92588. * @returns the current particle system
  92589. */
  92590. removeDragGradient(gradient: number): IParticleSystem;
  92591. /**
  92592. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92593. * @param gradient defines the gradient to use (between 0 and 1)
  92594. * @param factor defines the emit rate value to affect to the specified gradient
  92595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92596. * @returns the current particle system
  92597. */
  92598. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92599. /**
  92600. * Remove a specific emit rate gradient
  92601. * @param gradient defines the gradient to remove
  92602. * @returns the current particle system
  92603. */
  92604. removeEmitRateGradient(gradient: number): IParticleSystem;
  92605. /**
  92606. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92607. * @param gradient defines the gradient to use (between 0 and 1)
  92608. * @param factor defines the start size value to affect to the specified gradient
  92609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92610. * @returns the current particle system
  92611. */
  92612. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92613. /**
  92614. * Remove a specific start size gradient
  92615. * @param gradient defines the gradient to remove
  92616. * @returns the current particle system
  92617. */
  92618. removeStartSizeGradient(gradient: number): IParticleSystem;
  92619. private _createRampGradientTexture;
  92620. /**
  92621. * Gets the current list of ramp gradients.
  92622. * You must use addRampGradient and removeRampGradient to udpate this list
  92623. * @returns the list of ramp gradients
  92624. */
  92625. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92626. /** Force the system to rebuild all gradients that need to be resync */
  92627. forceRefreshGradients(): void;
  92628. private _syncRampGradientTexture;
  92629. /**
  92630. * Adds a new ramp gradient used to remap particle colors
  92631. * @param gradient defines the gradient to use (between 0 and 1)
  92632. * @param color defines the color to affect to the specified gradient
  92633. * @returns the current particle system
  92634. */
  92635. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92636. /**
  92637. * Remove a specific ramp gradient
  92638. * @param gradient defines the gradient to remove
  92639. * @returns the current particle system
  92640. */
  92641. removeRampGradient(gradient: number): ParticleSystem;
  92642. /**
  92643. * Adds a new color gradient
  92644. * @param gradient defines the gradient to use (between 0 and 1)
  92645. * @param color1 defines the color to affect to the specified gradient
  92646. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92647. * @returns this particle system
  92648. */
  92649. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92650. /**
  92651. * Remove a specific color gradient
  92652. * @param gradient defines the gradient to remove
  92653. * @returns this particle system
  92654. */
  92655. removeColorGradient(gradient: number): IParticleSystem;
  92656. private _fetchR;
  92657. protected _reset(): void;
  92658. private _resetEffect;
  92659. private _createVertexBuffers;
  92660. private _createIndexBuffer;
  92661. /**
  92662. * Gets the maximum number of particles active at the same time.
  92663. * @returns The max number of active particles.
  92664. */
  92665. getCapacity(): number;
  92666. /**
  92667. * Gets whether there are still active particles in the system.
  92668. * @returns True if it is alive, otherwise false.
  92669. */
  92670. isAlive(): boolean;
  92671. /**
  92672. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92673. * @returns True if it has been started, otherwise false.
  92674. */
  92675. isStarted(): boolean;
  92676. private _prepareSubEmitterInternalArray;
  92677. /**
  92678. * Starts the particle system and begins to emit
  92679. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92680. */
  92681. start(delay?: number): void;
  92682. /**
  92683. * Stops the particle system.
  92684. * @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.
  92685. */
  92686. stop(stopSubEmitters?: boolean): void;
  92687. /**
  92688. * Remove all active particles
  92689. */
  92690. reset(): void;
  92691. /**
  92692. * @hidden (for internal use only)
  92693. */
  92694. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92695. /**
  92696. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92697. * Its lifetime will start back at 0.
  92698. */
  92699. recycleParticle: (particle: Particle) => void;
  92700. private _stopSubEmitters;
  92701. private _createParticle;
  92702. private _removeFromRoot;
  92703. private _emitFromParticle;
  92704. private _update;
  92705. /** @hidden */
  92706. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92707. /** @hidden */
  92708. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92709. /**
  92710. * Fill the defines array according to the current settings of the particle system
  92711. * @param defines Array to be updated
  92712. * @param blendMode blend mode to take into account when updating the array
  92713. */
  92714. fillDefines(defines: Array<string>, blendMode: number): void;
  92715. /**
  92716. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92717. * @param uniforms Uniforms array to fill
  92718. * @param attributes Attributes array to fill
  92719. * @param samplers Samplers array to fill
  92720. */
  92721. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92722. /** @hidden */
  92723. private _getEffect;
  92724. /**
  92725. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92726. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92727. */
  92728. animate(preWarmOnly?: boolean): void;
  92729. private _appendParticleVertices;
  92730. /**
  92731. * Rebuilds the particle system.
  92732. */
  92733. rebuild(): void;
  92734. /**
  92735. * Is this system ready to be used/rendered
  92736. * @return true if the system is ready
  92737. */
  92738. isReady(): boolean;
  92739. private _render;
  92740. /**
  92741. * Renders the particle system in its current state.
  92742. * @returns the current number of particles
  92743. */
  92744. render(): number;
  92745. /**
  92746. * Disposes the particle system and free the associated resources
  92747. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92748. */
  92749. dispose(disposeTexture?: boolean): void;
  92750. /**
  92751. * Clones the particle system.
  92752. * @param name The name of the cloned object
  92753. * @param newEmitter The new emitter to use
  92754. * @returns the cloned particle system
  92755. */
  92756. clone(name: string, newEmitter: any): ParticleSystem;
  92757. /**
  92758. * Serializes the particle system to a JSON object
  92759. * @param serializeTexture defines if the texture must be serialized as well
  92760. * @returns the JSON object
  92761. */
  92762. serialize(serializeTexture?: boolean): any;
  92763. /** @hidden */
  92764. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92765. /** @hidden */
  92766. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92767. /**
  92768. * Parses a JSON object to create a particle system.
  92769. * @param parsedParticleSystem The JSON object to parse
  92770. * @param sceneOrEngine The scene or the engine to create the particle system in
  92771. * @param rootUrl The root url to use to load external dependencies like texture
  92772. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92773. * @returns the Parsed particle system
  92774. */
  92775. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92776. }
  92777. }
  92778. declare module BABYLON {
  92779. /**
  92780. * A particle represents one of the element emitted by a particle system.
  92781. * This is mainly define by its coordinates, direction, velocity and age.
  92782. */
  92783. export class Particle {
  92784. /**
  92785. * The particle system the particle belongs to.
  92786. */
  92787. particleSystem: ParticleSystem;
  92788. private static _Count;
  92789. /**
  92790. * Unique ID of the particle
  92791. */
  92792. id: number;
  92793. /**
  92794. * The world position of the particle in the scene.
  92795. */
  92796. position: Vector3;
  92797. /**
  92798. * The world direction of the particle in the scene.
  92799. */
  92800. direction: Vector3;
  92801. /**
  92802. * The color of the particle.
  92803. */
  92804. color: Color4;
  92805. /**
  92806. * The color change of the particle per step.
  92807. */
  92808. colorStep: Color4;
  92809. /**
  92810. * Defines how long will the life of the particle be.
  92811. */
  92812. lifeTime: number;
  92813. /**
  92814. * The current age of the particle.
  92815. */
  92816. age: number;
  92817. /**
  92818. * The current size of the particle.
  92819. */
  92820. size: number;
  92821. /**
  92822. * The current scale of the particle.
  92823. */
  92824. scale: Vector2;
  92825. /**
  92826. * The current angle of the particle.
  92827. */
  92828. angle: number;
  92829. /**
  92830. * Defines how fast is the angle changing.
  92831. */
  92832. angularSpeed: number;
  92833. /**
  92834. * Defines the cell index used by the particle to be rendered from a sprite.
  92835. */
  92836. cellIndex: number;
  92837. /**
  92838. * The information required to support color remapping
  92839. */
  92840. remapData: Vector4;
  92841. /** @hidden */
  92842. _randomCellOffset?: number;
  92843. /** @hidden */
  92844. _initialDirection: Nullable<Vector3>;
  92845. /** @hidden */
  92846. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92847. /** @hidden */
  92848. _initialStartSpriteCellID: number;
  92849. /** @hidden */
  92850. _initialEndSpriteCellID: number;
  92851. /** @hidden */
  92852. _currentColorGradient: Nullable<ColorGradient>;
  92853. /** @hidden */
  92854. _currentColor1: Color4;
  92855. /** @hidden */
  92856. _currentColor2: Color4;
  92857. /** @hidden */
  92858. _currentSizeGradient: Nullable<FactorGradient>;
  92859. /** @hidden */
  92860. _currentSize1: number;
  92861. /** @hidden */
  92862. _currentSize2: number;
  92863. /** @hidden */
  92864. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92865. /** @hidden */
  92866. _currentAngularSpeed1: number;
  92867. /** @hidden */
  92868. _currentAngularSpeed2: number;
  92869. /** @hidden */
  92870. _currentVelocityGradient: Nullable<FactorGradient>;
  92871. /** @hidden */
  92872. _currentVelocity1: number;
  92873. /** @hidden */
  92874. _currentVelocity2: number;
  92875. /** @hidden */
  92876. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92877. /** @hidden */
  92878. _currentLimitVelocity1: number;
  92879. /** @hidden */
  92880. _currentLimitVelocity2: number;
  92881. /** @hidden */
  92882. _currentDragGradient: Nullable<FactorGradient>;
  92883. /** @hidden */
  92884. _currentDrag1: number;
  92885. /** @hidden */
  92886. _currentDrag2: number;
  92887. /** @hidden */
  92888. _randomNoiseCoordinates1: Vector3;
  92889. /** @hidden */
  92890. _randomNoiseCoordinates2: Vector3;
  92891. /** @hidden */
  92892. _localPosition?: Vector3;
  92893. /**
  92894. * Creates a new instance Particle
  92895. * @param particleSystem the particle system the particle belongs to
  92896. */
  92897. constructor(
  92898. /**
  92899. * The particle system the particle belongs to.
  92900. */
  92901. particleSystem: ParticleSystem);
  92902. private updateCellInfoFromSystem;
  92903. /**
  92904. * Defines how the sprite cell index is updated for the particle
  92905. */
  92906. updateCellIndex(): void;
  92907. /** @hidden */
  92908. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  92909. /** @hidden */
  92910. _inheritParticleInfoToSubEmitters(): void;
  92911. /** @hidden */
  92912. _reset(): void;
  92913. /**
  92914. * Copy the properties of particle to another one.
  92915. * @param other the particle to copy the information to.
  92916. */
  92917. copyTo(other: Particle): void;
  92918. }
  92919. }
  92920. declare module BABYLON {
  92921. /**
  92922. * Particle emitter represents a volume emitting particles.
  92923. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  92924. */
  92925. export interface IParticleEmitterType {
  92926. /**
  92927. * Called by the particle System when the direction is computed for the created particle.
  92928. * @param worldMatrix is the world matrix of the particle system
  92929. * @param directionToUpdate is the direction vector to update with the result
  92930. * @param particle is the particle we are computed the direction for
  92931. * @param isLocal defines if the direction should be set in local space
  92932. */
  92933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92934. /**
  92935. * Called by the particle System when the position is computed for the created particle.
  92936. * @param worldMatrix is the world matrix of the particle system
  92937. * @param positionToUpdate is the position vector to update with the result
  92938. * @param particle is the particle we are computed the position for
  92939. * @param isLocal defines if the position should be set in local space
  92940. */
  92941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92942. /**
  92943. * Clones the current emitter and returns a copy of it
  92944. * @returns the new emitter
  92945. */
  92946. clone(): IParticleEmitterType;
  92947. /**
  92948. * Called by the GPUParticleSystem to setup the update shader
  92949. * @param effect defines the update shader
  92950. */
  92951. applyToShader(effect: Effect): void;
  92952. /**
  92953. * Returns a string to use to update the GPU particles update shader
  92954. * @returns the effect defines string
  92955. */
  92956. getEffectDefines(): string;
  92957. /**
  92958. * Returns a string representing the class name
  92959. * @returns a string containing the class name
  92960. */
  92961. getClassName(): string;
  92962. /**
  92963. * Serializes the particle system to a JSON object.
  92964. * @returns the JSON object
  92965. */
  92966. serialize(): any;
  92967. /**
  92968. * Parse properties from a JSON object
  92969. * @param serializationObject defines the JSON object
  92970. * @param scene defines the hosting scene
  92971. */
  92972. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92973. }
  92974. }
  92975. declare module BABYLON {
  92976. /**
  92977. * Particle emitter emitting particles from the inside of a box.
  92978. * It emits the particles randomly between 2 given directions.
  92979. */
  92980. export class BoxParticleEmitter implements IParticleEmitterType {
  92981. /**
  92982. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92983. */
  92984. direction1: Vector3;
  92985. /**
  92986. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92987. */
  92988. direction2: Vector3;
  92989. /**
  92990. * 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.
  92991. */
  92992. minEmitBox: Vector3;
  92993. /**
  92994. * 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.
  92995. */
  92996. maxEmitBox: Vector3;
  92997. /**
  92998. * Creates a new instance BoxParticleEmitter
  92999. */
  93000. constructor();
  93001. /**
  93002. * Called by the particle System when the direction is computed for the created particle.
  93003. * @param worldMatrix is the world matrix of the particle system
  93004. * @param directionToUpdate is the direction vector to update with the result
  93005. * @param particle is the particle we are computed the direction for
  93006. * @param isLocal defines if the direction should be set in local space
  93007. */
  93008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93009. /**
  93010. * Called by the particle System when the position is computed for the created particle.
  93011. * @param worldMatrix is the world matrix of the particle system
  93012. * @param positionToUpdate is the position vector to update with the result
  93013. * @param particle is the particle we are computed the position for
  93014. * @param isLocal defines if the position should be set in local space
  93015. */
  93016. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93017. /**
  93018. * Clones the current emitter and returns a copy of it
  93019. * @returns the new emitter
  93020. */
  93021. clone(): BoxParticleEmitter;
  93022. /**
  93023. * Called by the GPUParticleSystem to setup the update shader
  93024. * @param effect defines the update shader
  93025. */
  93026. applyToShader(effect: Effect): void;
  93027. /**
  93028. * Returns a string to use to update the GPU particles update shader
  93029. * @returns a string containng the defines string
  93030. */
  93031. getEffectDefines(): string;
  93032. /**
  93033. * Returns the string "BoxParticleEmitter"
  93034. * @returns a string containing the class name
  93035. */
  93036. getClassName(): string;
  93037. /**
  93038. * Serializes the particle system to a JSON object.
  93039. * @returns the JSON object
  93040. */
  93041. serialize(): any;
  93042. /**
  93043. * Parse properties from a JSON object
  93044. * @param serializationObject defines the JSON object
  93045. */
  93046. parse(serializationObject: any): void;
  93047. }
  93048. }
  93049. declare module BABYLON {
  93050. /**
  93051. * Particle emitter emitting particles from the inside of a cone.
  93052. * It emits the particles alongside the cone volume from the base to the particle.
  93053. * The emission direction might be randomized.
  93054. */
  93055. export class ConeParticleEmitter implements IParticleEmitterType {
  93056. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93057. directionRandomizer: number;
  93058. private _radius;
  93059. private _angle;
  93060. private _height;
  93061. /**
  93062. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93063. */
  93064. radiusRange: number;
  93065. /**
  93066. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93067. */
  93068. heightRange: number;
  93069. /**
  93070. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93071. */
  93072. emitFromSpawnPointOnly: boolean;
  93073. /**
  93074. * Gets or sets the radius of the emission cone
  93075. */
  93076. get radius(): number;
  93077. set radius(value: number);
  93078. /**
  93079. * Gets or sets the angle of the emission cone
  93080. */
  93081. get angle(): number;
  93082. set angle(value: number);
  93083. private _buildHeight;
  93084. /**
  93085. * Creates a new instance ConeParticleEmitter
  93086. * @param radius the radius of the emission cone (1 by default)
  93087. * @param angle the cone base angle (PI by default)
  93088. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93089. */
  93090. constructor(radius?: number, angle?: number,
  93091. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93092. directionRandomizer?: number);
  93093. /**
  93094. * Called by the particle System when the direction is computed for the created particle.
  93095. * @param worldMatrix is the world matrix of the particle system
  93096. * @param directionToUpdate is the direction vector to update with the result
  93097. * @param particle is the particle we are computed the direction for
  93098. * @param isLocal defines if the direction should be set in local space
  93099. */
  93100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93101. /**
  93102. * Called by the particle System when the position is computed for the created particle.
  93103. * @param worldMatrix is the world matrix of the particle system
  93104. * @param positionToUpdate is the position vector to update with the result
  93105. * @param particle is the particle we are computed the position for
  93106. * @param isLocal defines if the position should be set in local space
  93107. */
  93108. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93109. /**
  93110. * Clones the current emitter and returns a copy of it
  93111. * @returns the new emitter
  93112. */
  93113. clone(): ConeParticleEmitter;
  93114. /**
  93115. * Called by the GPUParticleSystem to setup the update shader
  93116. * @param effect defines the update shader
  93117. */
  93118. applyToShader(effect: Effect): void;
  93119. /**
  93120. * Returns a string to use to update the GPU particles update shader
  93121. * @returns a string containng the defines string
  93122. */
  93123. getEffectDefines(): string;
  93124. /**
  93125. * Returns the string "ConeParticleEmitter"
  93126. * @returns a string containing the class name
  93127. */
  93128. getClassName(): string;
  93129. /**
  93130. * Serializes the particle system to a JSON object.
  93131. * @returns the JSON object
  93132. */
  93133. serialize(): any;
  93134. /**
  93135. * Parse properties from a JSON object
  93136. * @param serializationObject defines the JSON object
  93137. */
  93138. parse(serializationObject: any): void;
  93139. }
  93140. }
  93141. declare module BABYLON {
  93142. /**
  93143. * Particle emitter emitting particles from the inside of a cylinder.
  93144. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93145. */
  93146. export class CylinderParticleEmitter implements IParticleEmitterType {
  93147. /**
  93148. * The radius of the emission cylinder.
  93149. */
  93150. radius: number;
  93151. /**
  93152. * The height of the emission cylinder.
  93153. */
  93154. height: number;
  93155. /**
  93156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93157. */
  93158. radiusRange: number;
  93159. /**
  93160. * How much to randomize the particle direction [0-1].
  93161. */
  93162. directionRandomizer: number;
  93163. /**
  93164. * Creates a new instance CylinderParticleEmitter
  93165. * @param radius the radius of the emission cylinder (1 by default)
  93166. * @param height the height of the emission cylinder (1 by default)
  93167. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93168. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93169. */
  93170. constructor(
  93171. /**
  93172. * The radius of the emission cylinder.
  93173. */
  93174. radius?: number,
  93175. /**
  93176. * The height of the emission cylinder.
  93177. */
  93178. height?: number,
  93179. /**
  93180. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93181. */
  93182. radiusRange?: number,
  93183. /**
  93184. * How much to randomize the particle direction [0-1].
  93185. */
  93186. directionRandomizer?: number);
  93187. /**
  93188. * Called by the particle System when the direction is computed for the created particle.
  93189. * @param worldMatrix is the world matrix of the particle system
  93190. * @param directionToUpdate is the direction vector to update with the result
  93191. * @param particle is the particle we are computed the direction for
  93192. * @param isLocal defines if the direction should be set in local space
  93193. */
  93194. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93195. /**
  93196. * Called by the particle System when the position is computed for the created particle.
  93197. * @param worldMatrix is the world matrix of the particle system
  93198. * @param positionToUpdate is the position vector to update with the result
  93199. * @param particle is the particle we are computed the position for
  93200. * @param isLocal defines if the position should be set in local space
  93201. */
  93202. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93203. /**
  93204. * Clones the current emitter and returns a copy of it
  93205. * @returns the new emitter
  93206. */
  93207. clone(): CylinderParticleEmitter;
  93208. /**
  93209. * Called by the GPUParticleSystem to setup the update shader
  93210. * @param effect defines the update shader
  93211. */
  93212. applyToShader(effect: Effect): void;
  93213. /**
  93214. * Returns a string to use to update the GPU particles update shader
  93215. * @returns a string containng the defines string
  93216. */
  93217. getEffectDefines(): string;
  93218. /**
  93219. * Returns the string "CylinderParticleEmitter"
  93220. * @returns a string containing the class name
  93221. */
  93222. getClassName(): string;
  93223. /**
  93224. * Serializes the particle system to a JSON object.
  93225. * @returns the JSON object
  93226. */
  93227. serialize(): any;
  93228. /**
  93229. * Parse properties from a JSON object
  93230. * @param serializationObject defines the JSON object
  93231. */
  93232. parse(serializationObject: any): void;
  93233. }
  93234. /**
  93235. * Particle emitter emitting particles from the inside of a cylinder.
  93236. * It emits the particles randomly between two vectors.
  93237. */
  93238. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93239. /**
  93240. * The min limit of the emission direction.
  93241. */
  93242. direction1: Vector3;
  93243. /**
  93244. * The max limit of the emission direction.
  93245. */
  93246. direction2: Vector3;
  93247. /**
  93248. * Creates a new instance CylinderDirectedParticleEmitter
  93249. * @param radius the radius of the emission cylinder (1 by default)
  93250. * @param height the height of the emission cylinder (1 by default)
  93251. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93252. * @param direction1 the min limit of the emission direction (up vector by default)
  93253. * @param direction2 the max limit of the emission direction (up vector by default)
  93254. */
  93255. constructor(radius?: number, height?: number, radiusRange?: number,
  93256. /**
  93257. * The min limit of the emission direction.
  93258. */
  93259. direction1?: Vector3,
  93260. /**
  93261. * The max limit of the emission direction.
  93262. */
  93263. direction2?: Vector3);
  93264. /**
  93265. * Called by the particle System when the direction is computed for the created particle.
  93266. * @param worldMatrix is the world matrix of the particle system
  93267. * @param directionToUpdate is the direction vector to update with the result
  93268. * @param particle is the particle we are computed the direction for
  93269. */
  93270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93271. /**
  93272. * Clones the current emitter and returns a copy of it
  93273. * @returns the new emitter
  93274. */
  93275. clone(): CylinderDirectedParticleEmitter;
  93276. /**
  93277. * Called by the GPUParticleSystem to setup the update shader
  93278. * @param effect defines the update shader
  93279. */
  93280. applyToShader(effect: Effect): void;
  93281. /**
  93282. * Returns a string to use to update the GPU particles update shader
  93283. * @returns a string containng the defines string
  93284. */
  93285. getEffectDefines(): string;
  93286. /**
  93287. * Returns the string "CylinderDirectedParticleEmitter"
  93288. * @returns a string containing the class name
  93289. */
  93290. getClassName(): string;
  93291. /**
  93292. * Serializes the particle system to a JSON object.
  93293. * @returns the JSON object
  93294. */
  93295. serialize(): any;
  93296. /**
  93297. * Parse properties from a JSON object
  93298. * @param serializationObject defines the JSON object
  93299. */
  93300. parse(serializationObject: any): void;
  93301. }
  93302. }
  93303. declare module BABYLON {
  93304. /**
  93305. * Particle emitter emitting particles from the inside of a hemisphere.
  93306. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93307. */
  93308. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93309. /**
  93310. * The radius of the emission hemisphere.
  93311. */
  93312. radius: number;
  93313. /**
  93314. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93315. */
  93316. radiusRange: number;
  93317. /**
  93318. * How much to randomize the particle direction [0-1].
  93319. */
  93320. directionRandomizer: number;
  93321. /**
  93322. * Creates a new instance HemisphericParticleEmitter
  93323. * @param radius the radius of the emission hemisphere (1 by default)
  93324. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93325. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93326. */
  93327. constructor(
  93328. /**
  93329. * The radius of the emission hemisphere.
  93330. */
  93331. radius?: number,
  93332. /**
  93333. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93334. */
  93335. radiusRange?: number,
  93336. /**
  93337. * How much to randomize the particle direction [0-1].
  93338. */
  93339. directionRandomizer?: number);
  93340. /**
  93341. * Called by the particle System when the direction is computed for the created particle.
  93342. * @param worldMatrix is the world matrix of the particle system
  93343. * @param directionToUpdate is the direction vector to update with the result
  93344. * @param particle is the particle we are computed the direction for
  93345. * @param isLocal defines if the direction should be set in local space
  93346. */
  93347. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93348. /**
  93349. * Called by the particle System when the position is computed for the created particle.
  93350. * @param worldMatrix is the world matrix of the particle system
  93351. * @param positionToUpdate is the position vector to update with the result
  93352. * @param particle is the particle we are computed the position for
  93353. * @param isLocal defines if the position should be set in local space
  93354. */
  93355. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93356. /**
  93357. * Clones the current emitter and returns a copy of it
  93358. * @returns the new emitter
  93359. */
  93360. clone(): HemisphericParticleEmitter;
  93361. /**
  93362. * Called by the GPUParticleSystem to setup the update shader
  93363. * @param effect defines the update shader
  93364. */
  93365. applyToShader(effect: Effect): void;
  93366. /**
  93367. * Returns a string to use to update the GPU particles update shader
  93368. * @returns a string containng the defines string
  93369. */
  93370. getEffectDefines(): string;
  93371. /**
  93372. * Returns the string "HemisphericParticleEmitter"
  93373. * @returns a string containing the class name
  93374. */
  93375. getClassName(): string;
  93376. /**
  93377. * Serializes the particle system to a JSON object.
  93378. * @returns the JSON object
  93379. */
  93380. serialize(): any;
  93381. /**
  93382. * Parse properties from a JSON object
  93383. * @param serializationObject defines the JSON object
  93384. */
  93385. parse(serializationObject: any): void;
  93386. }
  93387. }
  93388. declare module BABYLON {
  93389. /**
  93390. * Particle emitter emitting particles from a point.
  93391. * It emits the particles randomly between 2 given directions.
  93392. */
  93393. export class PointParticleEmitter implements IParticleEmitterType {
  93394. /**
  93395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93396. */
  93397. direction1: Vector3;
  93398. /**
  93399. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93400. */
  93401. direction2: Vector3;
  93402. /**
  93403. * Creates a new instance PointParticleEmitter
  93404. */
  93405. constructor();
  93406. /**
  93407. * Called by the particle System when the direction is computed for the created particle.
  93408. * @param worldMatrix is the world matrix of the particle system
  93409. * @param directionToUpdate is the direction vector to update with the result
  93410. * @param particle is the particle we are computed the direction for
  93411. * @param isLocal defines if the direction should be set in local space
  93412. */
  93413. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93414. /**
  93415. * Called by the particle System when the position is computed for the created particle.
  93416. * @param worldMatrix is the world matrix of the particle system
  93417. * @param positionToUpdate is the position vector to update with the result
  93418. * @param particle is the particle we are computed the position for
  93419. * @param isLocal defines if the position should be set in local space
  93420. */
  93421. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93422. /**
  93423. * Clones the current emitter and returns a copy of it
  93424. * @returns the new emitter
  93425. */
  93426. clone(): PointParticleEmitter;
  93427. /**
  93428. * Called by the GPUParticleSystem to setup the update shader
  93429. * @param effect defines the update shader
  93430. */
  93431. applyToShader(effect: Effect): void;
  93432. /**
  93433. * Returns a string to use to update the GPU particles update shader
  93434. * @returns a string containng the defines string
  93435. */
  93436. getEffectDefines(): string;
  93437. /**
  93438. * Returns the string "PointParticleEmitter"
  93439. * @returns a string containing the class name
  93440. */
  93441. getClassName(): string;
  93442. /**
  93443. * Serializes the particle system to a JSON object.
  93444. * @returns the JSON object
  93445. */
  93446. serialize(): any;
  93447. /**
  93448. * Parse properties from a JSON object
  93449. * @param serializationObject defines the JSON object
  93450. */
  93451. parse(serializationObject: any): void;
  93452. }
  93453. }
  93454. declare module BABYLON {
  93455. /**
  93456. * Particle emitter emitting particles from the inside of a sphere.
  93457. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93458. */
  93459. export class SphereParticleEmitter implements IParticleEmitterType {
  93460. /**
  93461. * The radius of the emission sphere.
  93462. */
  93463. radius: number;
  93464. /**
  93465. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93466. */
  93467. radiusRange: number;
  93468. /**
  93469. * How much to randomize the particle direction [0-1].
  93470. */
  93471. directionRandomizer: number;
  93472. /**
  93473. * Creates a new instance SphereParticleEmitter
  93474. * @param radius the radius of the emission sphere (1 by default)
  93475. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93476. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93477. */
  93478. constructor(
  93479. /**
  93480. * The radius of the emission sphere.
  93481. */
  93482. radius?: number,
  93483. /**
  93484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93485. */
  93486. radiusRange?: number,
  93487. /**
  93488. * How much to randomize the particle direction [0-1].
  93489. */
  93490. directionRandomizer?: number);
  93491. /**
  93492. * Called by the particle System when the direction is computed for the created particle.
  93493. * @param worldMatrix is the world matrix of the particle system
  93494. * @param directionToUpdate is the direction vector to update with the result
  93495. * @param particle is the particle we are computed the direction for
  93496. * @param isLocal defines if the direction should be set in local space
  93497. */
  93498. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93499. /**
  93500. * Called by the particle System when the position is computed for the created particle.
  93501. * @param worldMatrix is the world matrix of the particle system
  93502. * @param positionToUpdate is the position vector to update with the result
  93503. * @param particle is the particle we are computed the position for
  93504. * @param isLocal defines if the position should be set in local space
  93505. */
  93506. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93507. /**
  93508. * Clones the current emitter and returns a copy of it
  93509. * @returns the new emitter
  93510. */
  93511. clone(): SphereParticleEmitter;
  93512. /**
  93513. * Called by the GPUParticleSystem to setup the update shader
  93514. * @param effect defines the update shader
  93515. */
  93516. applyToShader(effect: Effect): void;
  93517. /**
  93518. * Returns a string to use to update the GPU particles update shader
  93519. * @returns a string containng the defines string
  93520. */
  93521. getEffectDefines(): string;
  93522. /**
  93523. * Returns the string "SphereParticleEmitter"
  93524. * @returns a string containing the class name
  93525. */
  93526. getClassName(): string;
  93527. /**
  93528. * Serializes the particle system to a JSON object.
  93529. * @returns the JSON object
  93530. */
  93531. serialize(): any;
  93532. /**
  93533. * Parse properties from a JSON object
  93534. * @param serializationObject defines the JSON object
  93535. */
  93536. parse(serializationObject: any): void;
  93537. }
  93538. /**
  93539. * Particle emitter emitting particles from the inside of a sphere.
  93540. * It emits the particles randomly between two vectors.
  93541. */
  93542. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93543. /**
  93544. * The min limit of the emission direction.
  93545. */
  93546. direction1: Vector3;
  93547. /**
  93548. * The max limit of the emission direction.
  93549. */
  93550. direction2: Vector3;
  93551. /**
  93552. * Creates a new instance SphereDirectedParticleEmitter
  93553. * @param radius the radius of the emission sphere (1 by default)
  93554. * @param direction1 the min limit of the emission direction (up vector by default)
  93555. * @param direction2 the max limit of the emission direction (up vector by default)
  93556. */
  93557. constructor(radius?: number,
  93558. /**
  93559. * The min limit of the emission direction.
  93560. */
  93561. direction1?: Vector3,
  93562. /**
  93563. * The max limit of the emission direction.
  93564. */
  93565. direction2?: Vector3);
  93566. /**
  93567. * Called by the particle System when the direction is computed for the created particle.
  93568. * @param worldMatrix is the world matrix of the particle system
  93569. * @param directionToUpdate is the direction vector to update with the result
  93570. * @param particle is the particle we are computed the direction for
  93571. */
  93572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93573. /**
  93574. * Clones the current emitter and returns a copy of it
  93575. * @returns the new emitter
  93576. */
  93577. clone(): SphereDirectedParticleEmitter;
  93578. /**
  93579. * Called by the GPUParticleSystem to setup the update shader
  93580. * @param effect defines the update shader
  93581. */
  93582. applyToShader(effect: Effect): void;
  93583. /**
  93584. * Returns a string to use to update the GPU particles update shader
  93585. * @returns a string containng the defines string
  93586. */
  93587. getEffectDefines(): string;
  93588. /**
  93589. * Returns the string "SphereDirectedParticleEmitter"
  93590. * @returns a string containing the class name
  93591. */
  93592. getClassName(): string;
  93593. /**
  93594. * Serializes the particle system to a JSON object.
  93595. * @returns the JSON object
  93596. */
  93597. serialize(): any;
  93598. /**
  93599. * Parse properties from a JSON object
  93600. * @param serializationObject defines the JSON object
  93601. */
  93602. parse(serializationObject: any): void;
  93603. }
  93604. }
  93605. declare module BABYLON {
  93606. /**
  93607. * Particle emitter emitting particles from a custom list of positions.
  93608. */
  93609. export class CustomParticleEmitter implements IParticleEmitterType {
  93610. /**
  93611. * Gets or sets the position generator that will create the inital position of each particle.
  93612. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93613. */
  93614. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93615. /**
  93616. * Gets or sets the destination generator that will create the final destination of each particle.
  93617. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93618. */
  93619. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93620. /**
  93621. * Creates a new instance CustomParticleEmitter
  93622. */
  93623. constructor();
  93624. /**
  93625. * Called by the particle System when the direction is computed for the created particle.
  93626. * @param worldMatrix is the world matrix of the particle system
  93627. * @param directionToUpdate is the direction vector to update with the result
  93628. * @param particle is the particle we are computed the direction for
  93629. * @param isLocal defines if the direction should be set in local space
  93630. */
  93631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93632. /**
  93633. * Called by the particle System when the position is computed for the created particle.
  93634. * @param worldMatrix is the world matrix of the particle system
  93635. * @param positionToUpdate is the position vector to update with the result
  93636. * @param particle is the particle we are computed the position for
  93637. * @param isLocal defines if the position should be set in local space
  93638. */
  93639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93640. /**
  93641. * Clones the current emitter and returns a copy of it
  93642. * @returns the new emitter
  93643. */
  93644. clone(): CustomParticleEmitter;
  93645. /**
  93646. * Called by the GPUParticleSystem to setup the update shader
  93647. * @param effect defines the update shader
  93648. */
  93649. applyToShader(effect: Effect): void;
  93650. /**
  93651. * Returns a string to use to update the GPU particles update shader
  93652. * @returns a string containng the defines string
  93653. */
  93654. getEffectDefines(): string;
  93655. /**
  93656. * Returns the string "PointParticleEmitter"
  93657. * @returns a string containing the class name
  93658. */
  93659. getClassName(): string;
  93660. /**
  93661. * Serializes the particle system to a JSON object.
  93662. * @returns the JSON object
  93663. */
  93664. serialize(): any;
  93665. /**
  93666. * Parse properties from a JSON object
  93667. * @param serializationObject defines the JSON object
  93668. */
  93669. parse(serializationObject: any): void;
  93670. }
  93671. }
  93672. declare module BABYLON {
  93673. /**
  93674. * Particle emitter emitting particles from the inside of a box.
  93675. * It emits the particles randomly between 2 given directions.
  93676. */
  93677. export class MeshParticleEmitter implements IParticleEmitterType {
  93678. private _indices;
  93679. private _positions;
  93680. private _normals;
  93681. private _storedNormal;
  93682. private _mesh;
  93683. /**
  93684. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93685. */
  93686. direction1: Vector3;
  93687. /**
  93688. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93689. */
  93690. direction2: Vector3;
  93691. /**
  93692. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93693. */
  93694. useMeshNormalsForDirection: boolean;
  93695. /** Defines the mesh to use as source */
  93696. get mesh(): Nullable<AbstractMesh>;
  93697. set mesh(value: Nullable<AbstractMesh>);
  93698. /**
  93699. * Creates a new instance MeshParticleEmitter
  93700. * @param mesh defines the mesh to use as source
  93701. */
  93702. constructor(mesh?: Nullable<AbstractMesh>);
  93703. /**
  93704. * Called by the particle System when the direction is computed for the created particle.
  93705. * @param worldMatrix is the world matrix of the particle system
  93706. * @param directionToUpdate is the direction vector to update with the result
  93707. * @param particle is the particle we are computed the direction for
  93708. * @param isLocal defines if the direction should be set in local space
  93709. */
  93710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93711. /**
  93712. * Called by the particle System when the position is computed for the created particle.
  93713. * @param worldMatrix is the world matrix of the particle system
  93714. * @param positionToUpdate is the position vector to update with the result
  93715. * @param particle is the particle we are computed the position for
  93716. * @param isLocal defines if the position should be set in local space
  93717. */
  93718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93719. /**
  93720. * Clones the current emitter and returns a copy of it
  93721. * @returns the new emitter
  93722. */
  93723. clone(): MeshParticleEmitter;
  93724. /**
  93725. * Called by the GPUParticleSystem to setup the update shader
  93726. * @param effect defines the update shader
  93727. */
  93728. applyToShader(effect: Effect): void;
  93729. /**
  93730. * Returns a string to use to update the GPU particles update shader
  93731. * @returns a string containng the defines string
  93732. */
  93733. getEffectDefines(): string;
  93734. /**
  93735. * Returns the string "BoxParticleEmitter"
  93736. * @returns a string containing the class name
  93737. */
  93738. getClassName(): string;
  93739. /**
  93740. * Serializes the particle system to a JSON object.
  93741. * @returns the JSON object
  93742. */
  93743. serialize(): any;
  93744. /**
  93745. * Parse properties from a JSON object
  93746. * @param serializationObject defines the JSON object
  93747. * @param scene defines the hosting scene
  93748. */
  93749. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93750. }
  93751. }
  93752. declare module BABYLON {
  93753. /**
  93754. * Interface representing a particle system in Babylon.js.
  93755. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93756. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93757. */
  93758. export interface IParticleSystem {
  93759. /**
  93760. * List of animations used by the particle system.
  93761. */
  93762. animations: Animation[];
  93763. /**
  93764. * The id of the Particle system.
  93765. */
  93766. id: string;
  93767. /**
  93768. * The name of the Particle system.
  93769. */
  93770. name: string;
  93771. /**
  93772. * The emitter represents the Mesh or position we are attaching the particle system to.
  93773. */
  93774. emitter: Nullable<AbstractMesh | Vector3>;
  93775. /**
  93776. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93777. */
  93778. isBillboardBased: boolean;
  93779. /**
  93780. * The rendering group used by the Particle system to chose when to render.
  93781. */
  93782. renderingGroupId: number;
  93783. /**
  93784. * The layer mask we are rendering the particles through.
  93785. */
  93786. layerMask: number;
  93787. /**
  93788. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93789. */
  93790. updateSpeed: number;
  93791. /**
  93792. * The amount of time the particle system is running (depends of the overall update speed).
  93793. */
  93794. targetStopDuration: number;
  93795. /**
  93796. * The texture used to render each particle. (this can be a spritesheet)
  93797. */
  93798. particleTexture: Nullable<BaseTexture>;
  93799. /**
  93800. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93801. */
  93802. blendMode: number;
  93803. /**
  93804. * Minimum life time of emitting particles.
  93805. */
  93806. minLifeTime: number;
  93807. /**
  93808. * Maximum life time of emitting particles.
  93809. */
  93810. maxLifeTime: number;
  93811. /**
  93812. * Minimum Size of emitting particles.
  93813. */
  93814. minSize: number;
  93815. /**
  93816. * Maximum Size of emitting particles.
  93817. */
  93818. maxSize: number;
  93819. /**
  93820. * Minimum scale of emitting particles on X axis.
  93821. */
  93822. minScaleX: number;
  93823. /**
  93824. * Maximum scale of emitting particles on X axis.
  93825. */
  93826. maxScaleX: number;
  93827. /**
  93828. * Minimum scale of emitting particles on Y axis.
  93829. */
  93830. minScaleY: number;
  93831. /**
  93832. * Maximum scale of emitting particles on Y axis.
  93833. */
  93834. maxScaleY: number;
  93835. /**
  93836. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93837. */
  93838. color1: Color4;
  93839. /**
  93840. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93841. */
  93842. color2: Color4;
  93843. /**
  93844. * Color the particle will have at the end of its lifetime.
  93845. */
  93846. colorDead: Color4;
  93847. /**
  93848. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93849. */
  93850. emitRate: number;
  93851. /**
  93852. * You can use gravity if you want to give an orientation to your particles.
  93853. */
  93854. gravity: Vector3;
  93855. /**
  93856. * Minimum power of emitting particles.
  93857. */
  93858. minEmitPower: number;
  93859. /**
  93860. * Maximum power of emitting particles.
  93861. */
  93862. maxEmitPower: number;
  93863. /**
  93864. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93865. */
  93866. minAngularSpeed: number;
  93867. /**
  93868. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93869. */
  93870. maxAngularSpeed: number;
  93871. /**
  93872. * Gets or sets the minimal initial rotation in radians.
  93873. */
  93874. minInitialRotation: number;
  93875. /**
  93876. * Gets or sets the maximal initial rotation in radians.
  93877. */
  93878. maxInitialRotation: number;
  93879. /**
  93880. * The particle emitter type defines the emitter used by the particle system.
  93881. * It can be for example box, sphere, or cone...
  93882. */
  93883. particleEmitterType: Nullable<IParticleEmitterType>;
  93884. /**
  93885. * Defines the delay in milliseconds before starting the system (0 by default)
  93886. */
  93887. startDelay: number;
  93888. /**
  93889. * 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
  93890. */
  93891. preWarmCycles: number;
  93892. /**
  93893. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  93894. */
  93895. preWarmStepOffset: number;
  93896. /**
  93897. * 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)
  93898. */
  93899. spriteCellChangeSpeed: number;
  93900. /**
  93901. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93902. */
  93903. startSpriteCellID: number;
  93904. /**
  93905. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93906. */
  93907. endSpriteCellID: number;
  93908. /**
  93909. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93910. */
  93911. spriteCellWidth: number;
  93912. /**
  93913. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93914. */
  93915. spriteCellHeight: number;
  93916. /**
  93917. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93918. */
  93919. spriteRandomStartCell: boolean;
  93920. /**
  93921. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  93922. */
  93923. isAnimationSheetEnabled: boolean;
  93924. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93925. translationPivot: Vector2;
  93926. /**
  93927. * Gets or sets a texture used to add random noise to particle positions
  93928. */
  93929. noiseTexture: Nullable<BaseTexture>;
  93930. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93931. noiseStrength: Vector3;
  93932. /**
  93933. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93934. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93935. */
  93936. billboardMode: number;
  93937. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93938. limitVelocityDamping: number;
  93939. /**
  93940. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93941. */
  93942. beginAnimationOnStart: boolean;
  93943. /**
  93944. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93945. */
  93946. beginAnimationFrom: number;
  93947. /**
  93948. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93949. */
  93950. beginAnimationTo: number;
  93951. /**
  93952. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93953. */
  93954. beginAnimationLoop: boolean;
  93955. /**
  93956. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93957. */
  93958. disposeOnStop: boolean;
  93959. /**
  93960. * Specifies if the particles are updated in emitter local space or world space
  93961. */
  93962. isLocal: boolean;
  93963. /** Snippet ID if the particle system was created from the snippet server */
  93964. snippetId: string;
  93965. /** Gets or sets a matrix to use to compute projection */
  93966. defaultProjectionMatrix: Matrix;
  93967. /**
  93968. * Gets the maximum number of particles active at the same time.
  93969. * @returns The max number of active particles.
  93970. */
  93971. getCapacity(): number;
  93972. /**
  93973. * Gets the number of particles active at the same time.
  93974. * @returns The number of active particles.
  93975. */
  93976. getActiveCount(): number;
  93977. /**
  93978. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93979. * @returns True if it has been started, otherwise false.
  93980. */
  93981. isStarted(): boolean;
  93982. /**
  93983. * Animates the particle system for this frame.
  93984. */
  93985. animate(): void;
  93986. /**
  93987. * Renders the particle system in its current state.
  93988. * @returns the current number of particles
  93989. */
  93990. render(): number;
  93991. /**
  93992. * Dispose the particle system and frees its associated resources.
  93993. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93994. */
  93995. dispose(disposeTexture?: boolean): void;
  93996. /**
  93997. * An event triggered when the system is disposed
  93998. */
  93999. onDisposeObservable: Observable<IParticleSystem>;
  94000. /**
  94001. * Clones the particle system.
  94002. * @param name The name of the cloned object
  94003. * @param newEmitter The new emitter to use
  94004. * @returns the cloned particle system
  94005. */
  94006. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94007. /**
  94008. * Serializes the particle system to a JSON object
  94009. * @param serializeTexture defines if the texture must be serialized as well
  94010. * @returns the JSON object
  94011. */
  94012. serialize(serializeTexture: boolean): any;
  94013. /**
  94014. * Rebuild the particle system
  94015. */
  94016. rebuild(): void;
  94017. /** Force the system to rebuild all gradients that need to be resync */
  94018. forceRefreshGradients(): void;
  94019. /**
  94020. * Starts the particle system and begins to emit
  94021. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94022. */
  94023. start(delay?: number): void;
  94024. /**
  94025. * Stops the particle system.
  94026. */
  94027. stop(): void;
  94028. /**
  94029. * Remove all active particles
  94030. */
  94031. reset(): void;
  94032. /**
  94033. * Gets a boolean indicating that the system is stopping
  94034. * @returns true if the system is currently stopping
  94035. */
  94036. isStopping(): boolean;
  94037. /**
  94038. * Is this system ready to be used/rendered
  94039. * @return true if the system is ready
  94040. */
  94041. isReady(): boolean;
  94042. /**
  94043. * Returns the string "ParticleSystem"
  94044. * @returns a string containing the class name
  94045. */
  94046. getClassName(): string;
  94047. /**
  94048. * Gets the custom effect used to render the particles
  94049. * @param blendMode Blend mode for which the effect should be retrieved
  94050. * @returns The effect
  94051. */
  94052. getCustomEffect(blendMode: number): Nullable<Effect>;
  94053. /**
  94054. * Sets the custom effect used to render the particles
  94055. * @param effect The effect to set
  94056. * @param blendMode Blend mode for which the effect should be set
  94057. */
  94058. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94059. /**
  94060. * Fill the defines array according to the current settings of the particle system
  94061. * @param defines Array to be updated
  94062. * @param blendMode blend mode to take into account when updating the array
  94063. */
  94064. fillDefines(defines: Array<string>, blendMode: number): void;
  94065. /**
  94066. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94067. * @param uniforms Uniforms array to fill
  94068. * @param attributes Attributes array to fill
  94069. * @param samplers Samplers array to fill
  94070. */
  94071. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94072. /**
  94073. * Observable that will be called just before the particles are drawn
  94074. */
  94075. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94076. /**
  94077. * Gets the name of the particle vertex shader
  94078. */
  94079. vertexShaderName: string;
  94080. /**
  94081. * Adds a new color gradient
  94082. * @param gradient defines the gradient to use (between 0 and 1)
  94083. * @param color1 defines the color to affect to the specified gradient
  94084. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94085. * @returns the current particle system
  94086. */
  94087. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94088. /**
  94089. * Remove a specific color gradient
  94090. * @param gradient defines the gradient to remove
  94091. * @returns the current particle system
  94092. */
  94093. removeColorGradient(gradient: number): IParticleSystem;
  94094. /**
  94095. * Adds a new size gradient
  94096. * @param gradient defines the gradient to use (between 0 and 1)
  94097. * @param factor defines the size factor to affect to the specified gradient
  94098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94099. * @returns the current particle system
  94100. */
  94101. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94102. /**
  94103. * Remove a specific size gradient
  94104. * @param gradient defines the gradient to remove
  94105. * @returns the current particle system
  94106. */
  94107. removeSizeGradient(gradient: number): IParticleSystem;
  94108. /**
  94109. * Gets the current list of color gradients.
  94110. * You must use addColorGradient and removeColorGradient to udpate this list
  94111. * @returns the list of color gradients
  94112. */
  94113. getColorGradients(): Nullable<Array<ColorGradient>>;
  94114. /**
  94115. * Gets the current list of size gradients.
  94116. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94117. * @returns the list of size gradients
  94118. */
  94119. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94120. /**
  94121. * Gets the current list of angular speed gradients.
  94122. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94123. * @returns the list of angular speed gradients
  94124. */
  94125. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94126. /**
  94127. * Adds a new angular speed gradient
  94128. * @param gradient defines the gradient to use (between 0 and 1)
  94129. * @param factor defines the angular speed to affect to the specified gradient
  94130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94131. * @returns the current particle system
  94132. */
  94133. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94134. /**
  94135. * Remove a specific angular speed gradient
  94136. * @param gradient defines the gradient to remove
  94137. * @returns the current particle system
  94138. */
  94139. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94140. /**
  94141. * Gets the current list of velocity gradients.
  94142. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94143. * @returns the list of velocity gradients
  94144. */
  94145. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94146. /**
  94147. * Adds a new velocity gradient
  94148. * @param gradient defines the gradient to use (between 0 and 1)
  94149. * @param factor defines the velocity to affect to the specified gradient
  94150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94151. * @returns the current particle system
  94152. */
  94153. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94154. /**
  94155. * Remove a specific velocity gradient
  94156. * @param gradient defines the gradient to remove
  94157. * @returns the current particle system
  94158. */
  94159. removeVelocityGradient(gradient: number): IParticleSystem;
  94160. /**
  94161. * Gets the current list of limit velocity gradients.
  94162. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94163. * @returns the list of limit velocity gradients
  94164. */
  94165. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94166. /**
  94167. * Adds a new limit velocity gradient
  94168. * @param gradient defines the gradient to use (between 0 and 1)
  94169. * @param factor defines the limit velocity to affect to the specified gradient
  94170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94171. * @returns the current particle system
  94172. */
  94173. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94174. /**
  94175. * Remove a specific limit velocity gradient
  94176. * @param gradient defines the gradient to remove
  94177. * @returns the current particle system
  94178. */
  94179. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94180. /**
  94181. * Adds a new drag gradient
  94182. * @param gradient defines the gradient to use (between 0 and 1)
  94183. * @param factor defines the drag to affect to the specified gradient
  94184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94185. * @returns the current particle system
  94186. */
  94187. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94188. /**
  94189. * Remove a specific drag gradient
  94190. * @param gradient defines the gradient to remove
  94191. * @returns the current particle system
  94192. */
  94193. removeDragGradient(gradient: number): IParticleSystem;
  94194. /**
  94195. * Gets the current list of drag gradients.
  94196. * You must use addDragGradient and removeDragGradient to udpate this list
  94197. * @returns the list of drag gradients
  94198. */
  94199. getDragGradients(): Nullable<Array<FactorGradient>>;
  94200. /**
  94201. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94202. * @param gradient defines the gradient to use (between 0 and 1)
  94203. * @param factor defines the emit rate to affect to the specified gradient
  94204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94205. * @returns the current particle system
  94206. */
  94207. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94208. /**
  94209. * Remove a specific emit rate gradient
  94210. * @param gradient defines the gradient to remove
  94211. * @returns the current particle system
  94212. */
  94213. removeEmitRateGradient(gradient: number): IParticleSystem;
  94214. /**
  94215. * Gets the current list of emit rate gradients.
  94216. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94217. * @returns the list of emit rate gradients
  94218. */
  94219. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94220. /**
  94221. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94222. * @param gradient defines the gradient to use (between 0 and 1)
  94223. * @param factor defines the start size to affect to the specified gradient
  94224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94225. * @returns the current particle system
  94226. */
  94227. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94228. /**
  94229. * Remove a specific start size gradient
  94230. * @param gradient defines the gradient to remove
  94231. * @returns the current particle system
  94232. */
  94233. removeStartSizeGradient(gradient: number): IParticleSystem;
  94234. /**
  94235. * Gets the current list of start size gradients.
  94236. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94237. * @returns the list of start size gradients
  94238. */
  94239. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94240. /**
  94241. * Adds a new life time gradient
  94242. * @param gradient defines the gradient to use (between 0 and 1)
  94243. * @param factor defines the life time factor to affect to the specified gradient
  94244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94245. * @returns the current particle system
  94246. */
  94247. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94248. /**
  94249. * Remove a specific life time gradient
  94250. * @param gradient defines the gradient to remove
  94251. * @returns the current particle system
  94252. */
  94253. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94254. /**
  94255. * Gets the current list of life time gradients.
  94256. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94257. * @returns the list of life time gradients
  94258. */
  94259. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94260. /**
  94261. * Gets the current list of color gradients.
  94262. * You must use addColorGradient and removeColorGradient to udpate this list
  94263. * @returns the list of color gradients
  94264. */
  94265. getColorGradients(): Nullable<Array<ColorGradient>>;
  94266. /**
  94267. * Adds a new ramp gradient used to remap particle colors
  94268. * @param gradient defines the gradient to use (between 0 and 1)
  94269. * @param color defines the color to affect to the specified gradient
  94270. * @returns the current particle system
  94271. */
  94272. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94273. /**
  94274. * Gets the current list of ramp gradients.
  94275. * You must use addRampGradient and removeRampGradient to udpate this list
  94276. * @returns the list of ramp gradients
  94277. */
  94278. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94279. /** Gets or sets a boolean indicating that ramp gradients must be used
  94280. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94281. */
  94282. useRampGradients: boolean;
  94283. /**
  94284. * Adds a new color remap gradient
  94285. * @param gradient defines the gradient to use (between 0 and 1)
  94286. * @param min defines the color remap minimal range
  94287. * @param max defines the color remap maximal range
  94288. * @returns the current particle system
  94289. */
  94290. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94291. /**
  94292. * Gets the current list of color remap gradients.
  94293. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94294. * @returns the list of color remap gradients
  94295. */
  94296. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94297. /**
  94298. * Adds a new alpha remap gradient
  94299. * @param gradient defines the gradient to use (between 0 and 1)
  94300. * @param min defines the alpha remap minimal range
  94301. * @param max defines the alpha remap maximal range
  94302. * @returns the current particle system
  94303. */
  94304. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94305. /**
  94306. * Gets the current list of alpha remap gradients.
  94307. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94308. * @returns the list of alpha remap gradients
  94309. */
  94310. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94311. /**
  94312. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94313. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94314. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94315. * @returns the emitter
  94316. */
  94317. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94318. /**
  94319. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94320. * @param radius The radius of the hemisphere to emit from
  94321. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94322. * @returns the emitter
  94323. */
  94324. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94325. /**
  94326. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94327. * @param radius The radius of the sphere to emit from
  94328. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94329. * @returns the emitter
  94330. */
  94331. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94332. /**
  94333. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94334. * @param radius The radius of the sphere to emit from
  94335. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94336. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94337. * @returns the emitter
  94338. */
  94339. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94340. /**
  94341. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94342. * @param radius The radius of the emission cylinder
  94343. * @param height The height of the emission cylinder
  94344. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94345. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94346. * @returns the emitter
  94347. */
  94348. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94349. /**
  94350. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94351. * @param radius The radius of the cylinder to emit from
  94352. * @param height The height of the emission cylinder
  94353. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94354. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94355. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94356. * @returns the emitter
  94357. */
  94358. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94359. /**
  94360. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94361. * @param radius The radius of the cone to emit from
  94362. * @param angle The base angle of the cone
  94363. * @returns the emitter
  94364. */
  94365. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94366. /**
  94367. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94368. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94369. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94370. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94371. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94372. * @returns the emitter
  94373. */
  94374. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94375. /**
  94376. * Get hosting scene
  94377. * @returns the scene
  94378. */
  94379. getScene(): Nullable<Scene>;
  94380. }
  94381. }
  94382. declare module BABYLON {
  94383. /**
  94384. * 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.
  94385. * @see https://doc.babylonjs.com/how_to/transformnode
  94386. */
  94387. export class TransformNode extends Node {
  94388. /**
  94389. * Object will not rotate to face the camera
  94390. */
  94391. static BILLBOARDMODE_NONE: number;
  94392. /**
  94393. * Object will rotate to face the camera but only on the x axis
  94394. */
  94395. static BILLBOARDMODE_X: number;
  94396. /**
  94397. * Object will rotate to face the camera but only on the y axis
  94398. */
  94399. static BILLBOARDMODE_Y: number;
  94400. /**
  94401. * Object will rotate to face the camera but only on the z axis
  94402. */
  94403. static BILLBOARDMODE_Z: number;
  94404. /**
  94405. * Object will rotate to face the camera
  94406. */
  94407. static BILLBOARDMODE_ALL: number;
  94408. /**
  94409. * Object will rotate to face the camera's position instead of orientation
  94410. */
  94411. static BILLBOARDMODE_USE_POSITION: number;
  94412. private static _TmpRotation;
  94413. private static _TmpScaling;
  94414. private static _TmpTranslation;
  94415. private _forward;
  94416. private _forwardInverted;
  94417. private _up;
  94418. private _right;
  94419. private _rightInverted;
  94420. private _position;
  94421. private _rotation;
  94422. private _rotationQuaternion;
  94423. protected _scaling: Vector3;
  94424. protected _isDirty: boolean;
  94425. private _transformToBoneReferal;
  94426. private _isAbsoluteSynced;
  94427. private _billboardMode;
  94428. /**
  94429. * Gets or sets the billboard mode. Default is 0.
  94430. *
  94431. * | Value | Type | Description |
  94432. * | --- | --- | --- |
  94433. * | 0 | BILLBOARDMODE_NONE | |
  94434. * | 1 | BILLBOARDMODE_X | |
  94435. * | 2 | BILLBOARDMODE_Y | |
  94436. * | 4 | BILLBOARDMODE_Z | |
  94437. * | 7 | BILLBOARDMODE_ALL | |
  94438. *
  94439. */
  94440. get billboardMode(): number;
  94441. set billboardMode(value: number);
  94442. private _preserveParentRotationForBillboard;
  94443. /**
  94444. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94445. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94446. */
  94447. get preserveParentRotationForBillboard(): boolean;
  94448. set preserveParentRotationForBillboard(value: boolean);
  94449. /**
  94450. * 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
  94451. */
  94452. scalingDeterminant: number;
  94453. private _infiniteDistance;
  94454. /**
  94455. * Gets or sets the distance of the object to max, often used by skybox
  94456. */
  94457. get infiniteDistance(): boolean;
  94458. set infiniteDistance(value: boolean);
  94459. /**
  94460. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94461. * By default the system will update normals to compensate
  94462. */
  94463. ignoreNonUniformScaling: boolean;
  94464. /**
  94465. * 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
  94466. */
  94467. reIntegrateRotationIntoRotationQuaternion: boolean;
  94468. /** @hidden */
  94469. _poseMatrix: Nullable<Matrix>;
  94470. /** @hidden */
  94471. _localMatrix: Matrix;
  94472. private _usePivotMatrix;
  94473. private _absolutePosition;
  94474. private _absoluteScaling;
  94475. private _absoluteRotationQuaternion;
  94476. private _pivotMatrix;
  94477. private _pivotMatrixInverse;
  94478. /** @hidden */
  94479. _postMultiplyPivotMatrix: boolean;
  94480. protected _isWorldMatrixFrozen: boolean;
  94481. /** @hidden */
  94482. _indexInSceneTransformNodesArray: number;
  94483. /**
  94484. * An event triggered after the world matrix is updated
  94485. */
  94486. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  94487. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  94488. /**
  94489. * Gets a string identifying the name of the class
  94490. * @returns "TransformNode" string
  94491. */
  94492. getClassName(): string;
  94493. /**
  94494. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94495. */
  94496. get position(): Vector3;
  94497. set position(newPosition: Vector3);
  94498. /**
  94499. * 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)).
  94500. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94501. */
  94502. get rotation(): Vector3;
  94503. set rotation(newRotation: Vector3);
  94504. /**
  94505. * 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)).
  94506. */
  94507. get scaling(): Vector3;
  94508. set scaling(newScaling: Vector3);
  94509. /**
  94510. * 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).
  94511. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94512. */
  94513. get rotationQuaternion(): Nullable<Quaternion>;
  94514. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94515. /**
  94516. * The forward direction of that transform in world space.
  94517. */
  94518. get forward(): Vector3;
  94519. /**
  94520. * The up direction of that transform in world space.
  94521. */
  94522. get up(): Vector3;
  94523. /**
  94524. * The right direction of that transform in world space.
  94525. */
  94526. get right(): Vector3;
  94527. /**
  94528. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94529. * @param matrix the matrix to copy the pose from
  94530. * @returns this TransformNode.
  94531. */
  94532. updatePoseMatrix(matrix: Matrix): TransformNode;
  94533. /**
  94534. * Returns the mesh Pose matrix.
  94535. * @returns the pose matrix
  94536. */
  94537. getPoseMatrix(): Matrix;
  94538. /** @hidden */
  94539. _isSynchronized(): boolean;
  94540. /** @hidden */
  94541. _initCache(): void;
  94542. /**
  94543. * Flag the transform node as dirty (Forcing it to update everything)
  94544. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94545. * @returns this transform node
  94546. */
  94547. markAsDirty(property: string): TransformNode;
  94548. /**
  94549. * Returns the current mesh absolute position.
  94550. * Returns a Vector3.
  94551. */
  94552. get absolutePosition(): Vector3;
  94553. /**
  94554. * Returns the current mesh absolute scaling.
  94555. * Returns a Vector3.
  94556. */
  94557. get absoluteScaling(): Vector3;
  94558. /**
  94559. * Returns the current mesh absolute rotation.
  94560. * Returns a Quaternion.
  94561. */
  94562. get absoluteRotationQuaternion(): Quaternion;
  94563. /**
  94564. * Sets a new matrix to apply before all other transformation
  94565. * @param matrix defines the transform matrix
  94566. * @returns the current TransformNode
  94567. */
  94568. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94569. /**
  94570. * Sets a new pivot matrix to the current node
  94571. * @param matrix defines the new pivot matrix to use
  94572. * @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
  94573. * @returns the current TransformNode
  94574. */
  94575. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94576. /**
  94577. * Returns the mesh pivot matrix.
  94578. * Default : Identity.
  94579. * @returns the matrix
  94580. */
  94581. getPivotMatrix(): Matrix;
  94582. /**
  94583. * Instantiate (when possible) or clone that node with its hierarchy
  94584. * @param newParent defines the new parent to use for the instance (or clone)
  94585. * @param options defines options to configure how copy is done
  94586. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94587. * @returns an instance (or a clone) of the current node with its hiearchy
  94588. */
  94589. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94590. doNotInstantiate: boolean;
  94591. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94592. /**
  94593. * Prevents the World matrix to be computed any longer
  94594. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94595. * @returns the TransformNode.
  94596. */
  94597. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94598. /**
  94599. * Allows back the World matrix computation.
  94600. * @returns the TransformNode.
  94601. */
  94602. unfreezeWorldMatrix(): this;
  94603. /**
  94604. * True if the World matrix has been frozen.
  94605. */
  94606. get isWorldMatrixFrozen(): boolean;
  94607. /**
  94608. * Retuns the mesh absolute position in the World.
  94609. * @returns a Vector3.
  94610. */
  94611. getAbsolutePosition(): Vector3;
  94612. /**
  94613. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94614. * @param absolutePosition the absolute position to set
  94615. * @returns the TransformNode.
  94616. */
  94617. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94618. /**
  94619. * Sets the mesh position in its local space.
  94620. * @param vector3 the position to set in localspace
  94621. * @returns the TransformNode.
  94622. */
  94623. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94624. /**
  94625. * Returns the mesh position in the local space from the current World matrix values.
  94626. * @returns a new Vector3.
  94627. */
  94628. getPositionExpressedInLocalSpace(): Vector3;
  94629. /**
  94630. * Translates the mesh along the passed Vector3 in its local space.
  94631. * @param vector3 the distance to translate in localspace
  94632. * @returns the TransformNode.
  94633. */
  94634. locallyTranslate(vector3: Vector3): TransformNode;
  94635. private static _lookAtVectorCache;
  94636. /**
  94637. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94638. * @param targetPoint the position (must be in same space as current mesh) to look at
  94639. * @param yawCor optional yaw (y-axis) correction in radians
  94640. * @param pitchCor optional pitch (x-axis) correction in radians
  94641. * @param rollCor optional roll (z-axis) correction in radians
  94642. * @param space the choosen space of the target
  94643. * @returns the TransformNode.
  94644. */
  94645. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94646. /**
  94647. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94648. * This Vector3 is expressed in the World space.
  94649. * @param localAxis axis to rotate
  94650. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94651. */
  94652. getDirection(localAxis: Vector3): Vector3;
  94653. /**
  94654. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94655. * localAxis is expressed in the mesh local space.
  94656. * result is computed in the Wordl space from the mesh World matrix.
  94657. * @param localAxis axis to rotate
  94658. * @param result the resulting transformnode
  94659. * @returns this TransformNode.
  94660. */
  94661. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94662. /**
  94663. * Sets this transform node rotation to the given local axis.
  94664. * @param localAxis the axis in local space
  94665. * @param yawCor optional yaw (y-axis) correction in radians
  94666. * @param pitchCor optional pitch (x-axis) correction in radians
  94667. * @param rollCor optional roll (z-axis) correction in radians
  94668. * @returns this TransformNode
  94669. */
  94670. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94671. /**
  94672. * Sets a new pivot point to the current node
  94673. * @param point defines the new pivot point to use
  94674. * @param space defines if the point is in world or local space (local by default)
  94675. * @returns the current TransformNode
  94676. */
  94677. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94678. /**
  94679. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94680. * @returns the pivot point
  94681. */
  94682. getPivotPoint(): Vector3;
  94683. /**
  94684. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94685. * @param result the vector3 to store the result
  94686. * @returns this TransformNode.
  94687. */
  94688. getPivotPointToRef(result: Vector3): TransformNode;
  94689. /**
  94690. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94691. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94692. */
  94693. getAbsolutePivotPoint(): Vector3;
  94694. /**
  94695. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94696. * @param result vector3 to store the result
  94697. * @returns this TransformNode.
  94698. */
  94699. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94700. /**
  94701. * Defines the passed node as the parent of the current node.
  94702. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94703. * @see https://doc.babylonjs.com/how_to/parenting
  94704. * @param node the node ot set as the parent
  94705. * @returns this TransformNode.
  94706. */
  94707. setParent(node: Nullable<Node>): TransformNode;
  94708. private _nonUniformScaling;
  94709. /**
  94710. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94711. */
  94712. get nonUniformScaling(): boolean;
  94713. /** @hidden */
  94714. _updateNonUniformScalingState(value: boolean): boolean;
  94715. /**
  94716. * Attach the current TransformNode to another TransformNode associated with a bone
  94717. * @param bone Bone affecting the TransformNode
  94718. * @param affectedTransformNode TransformNode associated with the bone
  94719. * @returns this object
  94720. */
  94721. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94722. /**
  94723. * Detach the transform node if its associated with a bone
  94724. * @returns this object
  94725. */
  94726. detachFromBone(): TransformNode;
  94727. private static _rotationAxisCache;
  94728. /**
  94729. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94730. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94731. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94732. * The passed axis is also normalized.
  94733. * @param axis the axis to rotate around
  94734. * @param amount the amount to rotate in radians
  94735. * @param space Space to rotate in (Default: local)
  94736. * @returns the TransformNode.
  94737. */
  94738. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94739. /**
  94740. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94741. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94742. * The passed axis is also normalized. .
  94743. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94744. * @param point the point to rotate around
  94745. * @param axis the axis to rotate around
  94746. * @param amount the amount to rotate in radians
  94747. * @returns the TransformNode
  94748. */
  94749. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94750. /**
  94751. * Translates the mesh along the axis vector for the passed distance in the given space.
  94752. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94753. * @param axis the axis to translate in
  94754. * @param distance the distance to translate
  94755. * @param space Space to rotate in (Default: local)
  94756. * @returns the TransformNode.
  94757. */
  94758. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94759. /**
  94760. * Adds a rotation step to the mesh current rotation.
  94761. * x, y, z are Euler angles expressed in radians.
  94762. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94763. * This means this rotation is made in the mesh local space only.
  94764. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94765. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94766. * ```javascript
  94767. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94768. * ```
  94769. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94770. * 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.
  94771. * @param x Rotation to add
  94772. * @param y Rotation to add
  94773. * @param z Rotation to add
  94774. * @returns the TransformNode.
  94775. */
  94776. addRotation(x: number, y: number, z: number): TransformNode;
  94777. /**
  94778. * @hidden
  94779. */
  94780. protected _getEffectiveParent(): Nullable<Node>;
  94781. /**
  94782. * Computes the world matrix of the node
  94783. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94784. * @returns the world matrix
  94785. */
  94786. computeWorldMatrix(force?: boolean): Matrix;
  94787. /**
  94788. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94789. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94790. */
  94791. resetLocalMatrix(independentOfChildren?: boolean): void;
  94792. protected _afterComputeWorldMatrix(): void;
  94793. /**
  94794. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94795. * @param func callback function to add
  94796. *
  94797. * @returns the TransformNode.
  94798. */
  94799. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94800. /**
  94801. * Removes a registered callback function.
  94802. * @param func callback function to remove
  94803. * @returns the TransformNode.
  94804. */
  94805. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94806. /**
  94807. * Gets the position of the current mesh in camera space
  94808. * @param camera defines the camera to use
  94809. * @returns a position
  94810. */
  94811. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94812. /**
  94813. * Returns the distance from the mesh to the active camera
  94814. * @param camera defines the camera to use
  94815. * @returns the distance
  94816. */
  94817. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94818. /**
  94819. * Clone the current transform node
  94820. * @param name Name of the new clone
  94821. * @param newParent New parent for the clone
  94822. * @param doNotCloneChildren Do not clone children hierarchy
  94823. * @returns the new transform node
  94824. */
  94825. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94826. /**
  94827. * Serializes the objects information.
  94828. * @param currentSerializationObject defines the object to serialize in
  94829. * @returns the serialized object
  94830. */
  94831. serialize(currentSerializationObject?: any): any;
  94832. /**
  94833. * Returns a new TransformNode object parsed from the source provided.
  94834. * @param parsedTransformNode is the source.
  94835. * @param scene the scne the object belongs to
  94836. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94837. * @returns a new TransformNode object parsed from the source provided.
  94838. */
  94839. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94840. /**
  94841. * Get all child-transformNodes of this node
  94842. * @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
  94843. * @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
  94844. * @returns an array of TransformNode
  94845. */
  94846. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94847. /**
  94848. * Releases resources associated with this transform node.
  94849. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94850. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94851. */
  94852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94853. /**
  94854. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94855. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94856. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94857. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94858. * @returns the current mesh
  94859. */
  94860. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94861. private _syncAbsoluteScalingAndRotation;
  94862. }
  94863. }
  94864. declare module BABYLON {
  94865. /**
  94866. * Class used to override all child animations of a given target
  94867. */
  94868. export class AnimationPropertiesOverride {
  94869. /**
  94870. * Gets or sets a value indicating if animation blending must be used
  94871. */
  94872. enableBlending: boolean;
  94873. /**
  94874. * Gets or sets the blending speed to use when enableBlending is true
  94875. */
  94876. blendingSpeed: number;
  94877. /**
  94878. * Gets or sets the default loop mode to use
  94879. */
  94880. loopMode: number;
  94881. }
  94882. }
  94883. declare module BABYLON {
  94884. /**
  94885. * Class used to store bone information
  94886. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94887. */
  94888. export class Bone extends Node {
  94889. /**
  94890. * defines the bone name
  94891. */
  94892. name: string;
  94893. private static _tmpVecs;
  94894. private static _tmpQuat;
  94895. private static _tmpMats;
  94896. /**
  94897. * Gets the list of child bones
  94898. */
  94899. children: Bone[];
  94900. /** Gets the animations associated with this bone */
  94901. animations: Animation[];
  94902. /**
  94903. * Gets or sets bone length
  94904. */
  94905. length: number;
  94906. /**
  94907. * @hidden Internal only
  94908. * Set this value to map this bone to a different index in the transform matrices
  94909. * Set this value to -1 to exclude the bone from the transform matrices
  94910. */
  94911. _index: Nullable<number>;
  94912. private _skeleton;
  94913. private _localMatrix;
  94914. private _restPose;
  94915. private _bindPose;
  94916. private _baseMatrix;
  94917. private _absoluteTransform;
  94918. private _invertedAbsoluteTransform;
  94919. private _parent;
  94920. private _scalingDeterminant;
  94921. private _worldTransform;
  94922. private _localScaling;
  94923. private _localRotation;
  94924. private _localPosition;
  94925. private _needToDecompose;
  94926. private _needToCompose;
  94927. /** @hidden */
  94928. _linkedTransformNode: Nullable<TransformNode>;
  94929. /** @hidden */
  94930. _waitingTransformNodeId: Nullable<string>;
  94931. /** @hidden */
  94932. get _matrix(): Matrix;
  94933. /** @hidden */
  94934. set _matrix(value: Matrix);
  94935. /**
  94936. * Create a new bone
  94937. * @param name defines the bone name
  94938. * @param skeleton defines the parent skeleton
  94939. * @param parentBone defines the parent (can be null if the bone is the root)
  94940. * @param localMatrix defines the local matrix
  94941. * @param restPose defines the rest pose matrix
  94942. * @param baseMatrix defines the base matrix
  94943. * @param index defines index of the bone in the hiearchy
  94944. */
  94945. constructor(
  94946. /**
  94947. * defines the bone name
  94948. */
  94949. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  94950. /**
  94951. * Gets the current object class name.
  94952. * @return the class name
  94953. */
  94954. getClassName(): string;
  94955. /**
  94956. * Gets the parent skeleton
  94957. * @returns a skeleton
  94958. */
  94959. getSkeleton(): Skeleton;
  94960. /**
  94961. * Gets parent bone
  94962. * @returns a bone or null if the bone is the root of the bone hierarchy
  94963. */
  94964. getParent(): Nullable<Bone>;
  94965. /**
  94966. * Returns an array containing the root bones
  94967. * @returns an array containing the root bones
  94968. */
  94969. getChildren(): Array<Bone>;
  94970. /**
  94971. * Gets the node index in matrix array generated for rendering
  94972. * @returns the node index
  94973. */
  94974. getIndex(): number;
  94975. /**
  94976. * Sets the parent bone
  94977. * @param parent defines the parent (can be null if the bone is the root)
  94978. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94979. */
  94980. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94981. /**
  94982. * Gets the local matrix
  94983. * @returns a matrix
  94984. */
  94985. getLocalMatrix(): Matrix;
  94986. /**
  94987. * Gets the base matrix (initial matrix which remains unchanged)
  94988. * @returns a matrix
  94989. */
  94990. getBaseMatrix(): Matrix;
  94991. /**
  94992. * Gets the rest pose matrix
  94993. * @returns a matrix
  94994. */
  94995. getRestPose(): Matrix;
  94996. /**
  94997. * Sets the rest pose matrix
  94998. * @param matrix the local-space rest pose to set for this bone
  94999. */
  95000. setRestPose(matrix: Matrix): void;
  95001. /**
  95002. * Gets the bind pose matrix
  95003. * @returns the bind pose matrix
  95004. */
  95005. getBindPose(): Matrix;
  95006. /**
  95007. * Sets the bind pose matrix
  95008. * @param matrix the local-space bind pose to set for this bone
  95009. */
  95010. setBindPose(matrix: Matrix): void;
  95011. /**
  95012. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95013. */
  95014. getWorldMatrix(): Matrix;
  95015. /**
  95016. * Sets the local matrix to rest pose matrix
  95017. */
  95018. returnToRest(): void;
  95019. /**
  95020. * Gets the inverse of the absolute transform matrix.
  95021. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95022. * @returns a matrix
  95023. */
  95024. getInvertedAbsoluteTransform(): Matrix;
  95025. /**
  95026. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95027. * @returns a matrix
  95028. */
  95029. getAbsoluteTransform(): Matrix;
  95030. /**
  95031. * Links with the given transform node.
  95032. * The local matrix of this bone is copied from the transform node every frame.
  95033. * @param transformNode defines the transform node to link to
  95034. */
  95035. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95036. /**
  95037. * Gets the node used to drive the bone's transformation
  95038. * @returns a transform node or null
  95039. */
  95040. getTransformNode(): Nullable<TransformNode>;
  95041. /** Gets or sets current position (in local space) */
  95042. get position(): Vector3;
  95043. set position(newPosition: Vector3);
  95044. /** Gets or sets current rotation (in local space) */
  95045. get rotation(): Vector3;
  95046. set rotation(newRotation: Vector3);
  95047. /** Gets or sets current rotation quaternion (in local space) */
  95048. get rotationQuaternion(): Quaternion;
  95049. set rotationQuaternion(newRotation: Quaternion);
  95050. /** Gets or sets current scaling (in local space) */
  95051. get scaling(): Vector3;
  95052. set scaling(newScaling: Vector3);
  95053. /**
  95054. * Gets the animation properties override
  95055. */
  95056. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95057. private _decompose;
  95058. private _compose;
  95059. /**
  95060. * Update the base and local matrices
  95061. * @param matrix defines the new base or local matrix
  95062. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95063. * @param updateLocalMatrix defines if the local matrix should be updated
  95064. */
  95065. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95066. /** @hidden */
  95067. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95068. /**
  95069. * Flag the bone as dirty (Forcing it to update everything)
  95070. */
  95071. markAsDirty(): void;
  95072. /** @hidden */
  95073. _markAsDirtyAndCompose(): void;
  95074. private _markAsDirtyAndDecompose;
  95075. /**
  95076. * Translate the bone in local or world space
  95077. * @param vec The amount to translate the bone
  95078. * @param space The space that the translation is in
  95079. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95080. */
  95081. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95082. /**
  95083. * Set the postion of the bone in local or world space
  95084. * @param position The position to set the bone
  95085. * @param space The space that the position is in
  95086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95087. */
  95088. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95089. /**
  95090. * Set the absolute position of the bone (world space)
  95091. * @param position The position to set the bone
  95092. * @param mesh The mesh that this bone is attached to
  95093. */
  95094. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95095. /**
  95096. * Scale the bone on the x, y and z axes (in local space)
  95097. * @param x The amount to scale the bone on the x axis
  95098. * @param y The amount to scale the bone on the y axis
  95099. * @param z The amount to scale the bone on the z axis
  95100. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95101. */
  95102. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95103. /**
  95104. * Set the bone scaling in local space
  95105. * @param scale defines the scaling vector
  95106. */
  95107. setScale(scale: Vector3): void;
  95108. /**
  95109. * Gets the current scaling in local space
  95110. * @returns the current scaling vector
  95111. */
  95112. getScale(): Vector3;
  95113. /**
  95114. * Gets the current scaling in local space and stores it in a target vector
  95115. * @param result defines the target vector
  95116. */
  95117. getScaleToRef(result: Vector3): void;
  95118. /**
  95119. * Set the yaw, pitch, and roll of the bone in local or world space
  95120. * @param yaw The rotation of the bone on the y axis
  95121. * @param pitch The rotation of the bone on the x axis
  95122. * @param roll The rotation of the bone on the z axis
  95123. * @param space The space that the axes of rotation are in
  95124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95125. */
  95126. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95127. /**
  95128. * Add a rotation to the bone on an axis in local or world space
  95129. * @param axis The axis to rotate the bone on
  95130. * @param amount The amount to rotate the bone
  95131. * @param space The space that the axis is in
  95132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95133. */
  95134. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95135. /**
  95136. * Set the rotation of the bone to a particular axis angle in local or world space
  95137. * @param axis The axis to rotate the bone on
  95138. * @param angle The angle that the bone should be rotated to
  95139. * @param space The space that the axis is in
  95140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95141. */
  95142. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95143. /**
  95144. * Set the euler rotation of the bone in local of world space
  95145. * @param rotation The euler rotation that the bone should be set to
  95146. * @param space The space that the rotation is in
  95147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95148. */
  95149. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95150. /**
  95151. * Set the quaternion rotation of the bone in local of world space
  95152. * @param quat The quaternion rotation that the bone should be set to
  95153. * @param space The space that the rotation is in
  95154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95155. */
  95156. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95157. /**
  95158. * Set the rotation matrix of the bone in local of world space
  95159. * @param rotMat The rotation matrix that the bone should be set to
  95160. * @param space The space that the rotation is in
  95161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95162. */
  95163. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95164. private _rotateWithMatrix;
  95165. private _getNegativeRotationToRef;
  95166. /**
  95167. * Get the position of the bone in local or world space
  95168. * @param space The space that the returned position is in
  95169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95170. * @returns The position of the bone
  95171. */
  95172. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95173. /**
  95174. * Copy the position of the bone to a vector3 in local or world space
  95175. * @param space The space that the returned position is in
  95176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95177. * @param result The vector3 to copy the position to
  95178. */
  95179. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95180. /**
  95181. * Get the absolute position of the bone (world space)
  95182. * @param mesh The mesh that this bone is attached to
  95183. * @returns The absolute position of the bone
  95184. */
  95185. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95186. /**
  95187. * Copy the absolute position of the bone (world space) to the result param
  95188. * @param mesh The mesh that this bone is attached to
  95189. * @param result The vector3 to copy the absolute position to
  95190. */
  95191. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95192. /**
  95193. * Compute the absolute transforms of this bone and its children
  95194. */
  95195. computeAbsoluteTransforms(): void;
  95196. /**
  95197. * Get the world direction from an axis that is in the local space of the bone
  95198. * @param localAxis The local direction that is used to compute the world direction
  95199. * @param mesh The mesh that this bone is attached to
  95200. * @returns The world direction
  95201. */
  95202. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95203. /**
  95204. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95205. * @param localAxis The local direction that is used to compute the world direction
  95206. * @param mesh The mesh that this bone is attached to
  95207. * @param result The vector3 that the world direction will be copied to
  95208. */
  95209. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95210. /**
  95211. * Get the euler rotation of the bone in local or world space
  95212. * @param space The space that the rotation should be in
  95213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95214. * @returns The euler rotation
  95215. */
  95216. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95217. /**
  95218. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95219. * @param space The space that the rotation should be in
  95220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95221. * @param result The vector3 that the rotation should be copied to
  95222. */
  95223. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95224. /**
  95225. * Get the quaternion rotation of the bone in either local or world space
  95226. * @param space The space that the rotation should be in
  95227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95228. * @returns The quaternion rotation
  95229. */
  95230. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95231. /**
  95232. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95233. * @param space The space that the rotation should be in
  95234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95235. * @param result The quaternion that the rotation should be copied to
  95236. */
  95237. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95238. /**
  95239. * Get the rotation matrix of the bone in local or world space
  95240. * @param space The space that the rotation should be in
  95241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95242. * @returns The rotation matrix
  95243. */
  95244. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95245. /**
  95246. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95247. * @param space The space that the rotation should be in
  95248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95249. * @param result The quaternion that the rotation should be copied to
  95250. */
  95251. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95252. /**
  95253. * Get the world position of a point that is in the local space of the bone
  95254. * @param position The local position
  95255. * @param mesh The mesh that this bone is attached to
  95256. * @returns The world position
  95257. */
  95258. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95259. /**
  95260. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95261. * @param position The local position
  95262. * @param mesh The mesh that this bone is attached to
  95263. * @param result The vector3 that the world position should be copied to
  95264. */
  95265. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95266. /**
  95267. * Get the local position of a point that is in world space
  95268. * @param position The world position
  95269. * @param mesh The mesh that this bone is attached to
  95270. * @returns The local position
  95271. */
  95272. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95273. /**
  95274. * Get the local position of a point that is in world space and copy it to the result param
  95275. * @param position The world position
  95276. * @param mesh The mesh that this bone is attached to
  95277. * @param result The vector3 that the local position should be copied to
  95278. */
  95279. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95280. }
  95281. }
  95282. declare module BABYLON {
  95283. /**
  95284. * Defines a runtime animation
  95285. */
  95286. export class RuntimeAnimation {
  95287. private _events;
  95288. /**
  95289. * The current frame of the runtime animation
  95290. */
  95291. private _currentFrame;
  95292. /**
  95293. * The animation used by the runtime animation
  95294. */
  95295. private _animation;
  95296. /**
  95297. * The target of the runtime animation
  95298. */
  95299. private _target;
  95300. /**
  95301. * The initiating animatable
  95302. */
  95303. private _host;
  95304. /**
  95305. * The original value of the runtime animation
  95306. */
  95307. private _originalValue;
  95308. /**
  95309. * The original blend value of the runtime animation
  95310. */
  95311. private _originalBlendValue;
  95312. /**
  95313. * The offsets cache of the runtime animation
  95314. */
  95315. private _offsetsCache;
  95316. /**
  95317. * The high limits cache of the runtime animation
  95318. */
  95319. private _highLimitsCache;
  95320. /**
  95321. * Specifies if the runtime animation has been stopped
  95322. */
  95323. private _stopped;
  95324. /**
  95325. * The blending factor of the runtime animation
  95326. */
  95327. private _blendingFactor;
  95328. /**
  95329. * The BabylonJS scene
  95330. */
  95331. private _scene;
  95332. /**
  95333. * The current value of the runtime animation
  95334. */
  95335. private _currentValue;
  95336. /** @hidden */
  95337. _animationState: _IAnimationState;
  95338. /**
  95339. * The active target of the runtime animation
  95340. */
  95341. private _activeTargets;
  95342. private _currentActiveTarget;
  95343. private _directTarget;
  95344. /**
  95345. * The target path of the runtime animation
  95346. */
  95347. private _targetPath;
  95348. /**
  95349. * The weight of the runtime animation
  95350. */
  95351. private _weight;
  95352. /**
  95353. * The ratio offset of the runtime animation
  95354. */
  95355. private _ratioOffset;
  95356. /**
  95357. * The previous delay of the runtime animation
  95358. */
  95359. private _previousDelay;
  95360. /**
  95361. * The previous ratio of the runtime animation
  95362. */
  95363. private _previousRatio;
  95364. private _enableBlending;
  95365. private _keys;
  95366. private _minFrame;
  95367. private _maxFrame;
  95368. private _minValue;
  95369. private _maxValue;
  95370. private _targetIsArray;
  95371. /**
  95372. * Gets the current frame of the runtime animation
  95373. */
  95374. get currentFrame(): number;
  95375. /**
  95376. * Gets the weight of the runtime animation
  95377. */
  95378. get weight(): number;
  95379. /**
  95380. * Gets the current value of the runtime animation
  95381. */
  95382. get currentValue(): any;
  95383. /**
  95384. * Gets the target path of the runtime animation
  95385. */
  95386. get targetPath(): string;
  95387. /**
  95388. * Gets the actual target of the runtime animation
  95389. */
  95390. get target(): any;
  95391. /**
  95392. * Gets the additive state of the runtime animation
  95393. */
  95394. get isAdditive(): boolean;
  95395. /** @hidden */
  95396. _onLoop: () => void;
  95397. /**
  95398. * Create a new RuntimeAnimation object
  95399. * @param target defines the target of the animation
  95400. * @param animation defines the source animation object
  95401. * @param scene defines the hosting scene
  95402. * @param host defines the initiating Animatable
  95403. */
  95404. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95405. private _preparePath;
  95406. /**
  95407. * Gets the animation from the runtime animation
  95408. */
  95409. get animation(): Animation;
  95410. /**
  95411. * Resets the runtime animation to the beginning
  95412. * @param restoreOriginal defines whether to restore the target property to the original value
  95413. */
  95414. reset(restoreOriginal?: boolean): void;
  95415. /**
  95416. * Specifies if the runtime animation is stopped
  95417. * @returns Boolean specifying if the runtime animation is stopped
  95418. */
  95419. isStopped(): boolean;
  95420. /**
  95421. * Disposes of the runtime animation
  95422. */
  95423. dispose(): void;
  95424. /**
  95425. * Apply the interpolated value to the target
  95426. * @param currentValue defines the value computed by the animation
  95427. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95428. */
  95429. setValue(currentValue: any, weight: number): void;
  95430. private _getOriginalValues;
  95431. private _setValue;
  95432. /**
  95433. * Gets the loop pmode of the runtime animation
  95434. * @returns Loop Mode
  95435. */
  95436. private _getCorrectLoopMode;
  95437. /**
  95438. * Move the current animation to a given frame
  95439. * @param frame defines the frame to move to
  95440. */
  95441. goToFrame(frame: number): void;
  95442. /**
  95443. * @hidden Internal use only
  95444. */
  95445. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95446. /**
  95447. * Execute the current animation
  95448. * @param delay defines the delay to add to the current frame
  95449. * @param from defines the lower bound of the animation range
  95450. * @param to defines the upper bound of the animation range
  95451. * @param loop defines if the current animation must loop
  95452. * @param speedRatio defines the current speed ratio
  95453. * @param weight defines the weight of the animation (default is -1 so no weight)
  95454. * @param onLoop optional callback called when animation loops
  95455. * @returns a boolean indicating if the animation is running
  95456. */
  95457. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95458. }
  95459. }
  95460. declare module BABYLON {
  95461. /**
  95462. * Class used to store an actual running animation
  95463. */
  95464. export class Animatable {
  95465. /** defines the target object */
  95466. target: any;
  95467. /** defines the starting frame number (default is 0) */
  95468. fromFrame: number;
  95469. /** defines the ending frame number (default is 100) */
  95470. toFrame: number;
  95471. /** defines if the animation must loop (default is false) */
  95472. loopAnimation: boolean;
  95473. /** defines a callback to call when animation ends if it is not looping */
  95474. onAnimationEnd?: (() => void) | null | undefined;
  95475. /** defines a callback to call when animation loops */
  95476. onAnimationLoop?: (() => void) | null | undefined;
  95477. /** defines whether the animation should be evaluated additively */
  95478. isAdditive: boolean;
  95479. private _localDelayOffset;
  95480. private _pausedDelay;
  95481. private _runtimeAnimations;
  95482. private _paused;
  95483. private _scene;
  95484. private _speedRatio;
  95485. private _weight;
  95486. private _syncRoot;
  95487. /**
  95488. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  95489. * This will only apply for non looping animation (default is true)
  95490. */
  95491. disposeOnEnd: boolean;
  95492. /**
  95493. * Gets a boolean indicating if the animation has started
  95494. */
  95495. animationStarted: boolean;
  95496. /**
  95497. * Observer raised when the animation ends
  95498. */
  95499. onAnimationEndObservable: Observable<Animatable>;
  95500. /**
  95501. * Observer raised when the animation loops
  95502. */
  95503. onAnimationLoopObservable: Observable<Animatable>;
  95504. /**
  95505. * Gets the root Animatable used to synchronize and normalize animations
  95506. */
  95507. get syncRoot(): Nullable<Animatable>;
  95508. /**
  95509. * Gets the current frame of the first RuntimeAnimation
  95510. * Used to synchronize Animatables
  95511. */
  95512. get masterFrame(): number;
  95513. /**
  95514. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95515. */
  95516. get weight(): number;
  95517. set weight(value: number);
  95518. /**
  95519. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95520. */
  95521. get speedRatio(): number;
  95522. set speedRatio(value: number);
  95523. /**
  95524. * Creates a new Animatable
  95525. * @param scene defines the hosting scene
  95526. * @param target defines the target object
  95527. * @param fromFrame defines the starting frame number (default is 0)
  95528. * @param toFrame defines the ending frame number (default is 100)
  95529. * @param loopAnimation defines if the animation must loop (default is false)
  95530. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95531. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95532. * @param animations defines a group of animation to add to the new Animatable
  95533. * @param onAnimationLoop defines a callback to call when animation loops
  95534. * @param isAdditive defines whether the animation should be evaluated additively
  95535. */
  95536. constructor(scene: Scene,
  95537. /** defines the target object */
  95538. target: any,
  95539. /** defines the starting frame number (default is 0) */
  95540. fromFrame?: number,
  95541. /** defines the ending frame number (default is 100) */
  95542. toFrame?: number,
  95543. /** defines if the animation must loop (default is false) */
  95544. loopAnimation?: boolean, speedRatio?: number,
  95545. /** defines a callback to call when animation ends if it is not looping */
  95546. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95547. /** defines a callback to call when animation loops */
  95548. onAnimationLoop?: (() => void) | null | undefined,
  95549. /** defines whether the animation should be evaluated additively */
  95550. isAdditive?: boolean);
  95551. /**
  95552. * Synchronize and normalize current Animatable with a source Animatable
  95553. * This is useful when using animation weights and when animations are not of the same length
  95554. * @param root defines the root Animatable to synchronize with
  95555. * @returns the current Animatable
  95556. */
  95557. syncWith(root: Animatable): Animatable;
  95558. /**
  95559. * Gets the list of runtime animations
  95560. * @returns an array of RuntimeAnimation
  95561. */
  95562. getAnimations(): RuntimeAnimation[];
  95563. /**
  95564. * Adds more animations to the current animatable
  95565. * @param target defines the target of the animations
  95566. * @param animations defines the new animations to add
  95567. */
  95568. appendAnimations(target: any, animations: Animation[]): void;
  95569. /**
  95570. * Gets the source animation for a specific property
  95571. * @param property defines the propertyu to look for
  95572. * @returns null or the source animation for the given property
  95573. */
  95574. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95575. /**
  95576. * Gets the runtime animation for a specific property
  95577. * @param property defines the propertyu to look for
  95578. * @returns null or the runtime animation for the given property
  95579. */
  95580. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95581. /**
  95582. * Resets the animatable to its original state
  95583. */
  95584. reset(): void;
  95585. /**
  95586. * Allows the animatable to blend with current running animations
  95587. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95588. * @param blendingSpeed defines the blending speed to use
  95589. */
  95590. enableBlending(blendingSpeed: number): void;
  95591. /**
  95592. * Disable animation blending
  95593. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95594. */
  95595. disableBlending(): void;
  95596. /**
  95597. * Jump directly to a given frame
  95598. * @param frame defines the frame to jump to
  95599. */
  95600. goToFrame(frame: number): void;
  95601. /**
  95602. * Pause the animation
  95603. */
  95604. pause(): void;
  95605. /**
  95606. * Restart the animation
  95607. */
  95608. restart(): void;
  95609. private _raiseOnAnimationEnd;
  95610. /**
  95611. * Stop and delete the current animation
  95612. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95613. * @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)
  95614. */
  95615. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95616. /**
  95617. * Wait asynchronously for the animation to end
  95618. * @returns a promise which will be fullfilled when the animation ends
  95619. */
  95620. waitAsync(): Promise<Animatable>;
  95621. /** @hidden */
  95622. _animate(delay: number): boolean;
  95623. }
  95624. interface Scene {
  95625. /** @hidden */
  95626. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95627. /** @hidden */
  95628. _processLateAnimationBindingsForMatrices(holder: {
  95629. totalWeight: number;
  95630. totalAdditiveWeight: number;
  95631. animations: RuntimeAnimation[];
  95632. additiveAnimations: RuntimeAnimation[];
  95633. originalValue: Matrix;
  95634. }): any;
  95635. /** @hidden */
  95636. _processLateAnimationBindingsForQuaternions(holder: {
  95637. totalWeight: number;
  95638. totalAdditiveWeight: number;
  95639. animations: RuntimeAnimation[];
  95640. additiveAnimations: RuntimeAnimation[];
  95641. originalValue: Quaternion;
  95642. }, refQuaternion: Quaternion): Quaternion;
  95643. /** @hidden */
  95644. _processLateAnimationBindings(): void;
  95645. /**
  95646. * Will start the animation sequence of a given target
  95647. * @param target defines the target
  95648. * @param from defines from which frame should animation start
  95649. * @param to defines until which frame should animation run.
  95650. * @param weight defines the weight to apply to the animation (1.0 by default)
  95651. * @param loop defines if the animation loops
  95652. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95653. * @param onAnimationEnd defines the function to be executed when the animation ends
  95654. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95655. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95656. * @param onAnimationLoop defines the callback to call when an animation loops
  95657. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95658. * @returns the animatable object created for this animation
  95659. */
  95660. 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;
  95661. /**
  95662. * Will start the animation sequence of a given target
  95663. * @param target defines the target
  95664. * @param from defines from which frame should animation start
  95665. * @param to defines until which frame should animation run.
  95666. * @param loop defines if the animation loops
  95667. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95668. * @param onAnimationEnd defines the function to be executed when the animation ends
  95669. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95670. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95671. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95672. * @param onAnimationLoop defines the callback to call when an animation loops
  95673. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95674. * @returns the animatable object created for this animation
  95675. */
  95676. 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;
  95677. /**
  95678. * Will start the animation sequence of a given target and its hierarchy
  95679. * @param target defines the target
  95680. * @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.
  95681. * @param from defines from which frame should animation start
  95682. * @param to defines until which frame should animation run.
  95683. * @param loop defines if the animation loops
  95684. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95685. * @param onAnimationEnd defines the function to be executed when the animation ends
  95686. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95687. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95688. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95689. * @param onAnimationLoop defines the callback to call when an animation loops
  95690. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95691. * @returns the list of created animatables
  95692. */
  95693. 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[];
  95694. /**
  95695. * Begin a new animation on a given node
  95696. * @param target defines the target where the animation will take place
  95697. * @param animations defines the list of animations to start
  95698. * @param from defines the initial value
  95699. * @param to defines the final value
  95700. * @param loop defines if you want animation to loop (off by default)
  95701. * @param speedRatio defines the speed ratio to apply to all animations
  95702. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95703. * @param onAnimationLoop defines the callback to call when an animation loops
  95704. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95705. * @returns the list of created animatables
  95706. */
  95707. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95708. /**
  95709. * Begin a new animation on a given node and its hierarchy
  95710. * @param target defines the root node where the animation will take place
  95711. * @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.
  95712. * @param animations defines the list of animations to start
  95713. * @param from defines the initial value
  95714. * @param to defines the final value
  95715. * @param loop defines if you want animation to loop (off by default)
  95716. * @param speedRatio defines the speed ratio to apply to all animations
  95717. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95718. * @param onAnimationLoop defines the callback to call when an animation loops
  95719. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95720. * @returns the list of animatables created for all nodes
  95721. */
  95722. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95723. /**
  95724. * Gets the animatable associated with a specific target
  95725. * @param target defines the target of the animatable
  95726. * @returns the required animatable if found
  95727. */
  95728. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95729. /**
  95730. * Gets all animatables associated with a given target
  95731. * @param target defines the target to look animatables for
  95732. * @returns an array of Animatables
  95733. */
  95734. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95735. /**
  95736. * Stops and removes all animations that have been applied to the scene
  95737. */
  95738. stopAllAnimations(): void;
  95739. /**
  95740. * Gets the current delta time used by animation engine
  95741. */
  95742. deltaTime: number;
  95743. }
  95744. interface Bone {
  95745. /**
  95746. * Copy an animation range from another bone
  95747. * @param source defines the source bone
  95748. * @param rangeName defines the range name to copy
  95749. * @param frameOffset defines the frame offset
  95750. * @param rescaleAsRequired defines if rescaling must be applied if required
  95751. * @param skelDimensionsRatio defines the scaling ratio
  95752. * @returns true if operation was successful
  95753. */
  95754. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95755. }
  95756. }
  95757. declare module BABYLON {
  95758. /**
  95759. * Class used to handle skinning animations
  95760. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95761. */
  95762. export class Skeleton implements IAnimatable {
  95763. /** defines the skeleton name */
  95764. name: string;
  95765. /** defines the skeleton Id */
  95766. id: string;
  95767. /**
  95768. * Defines the list of child bones
  95769. */
  95770. bones: Bone[];
  95771. /**
  95772. * Defines an estimate of the dimension of the skeleton at rest
  95773. */
  95774. dimensionsAtRest: Vector3;
  95775. /**
  95776. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95777. */
  95778. needInitialSkinMatrix: boolean;
  95779. /**
  95780. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95781. */
  95782. overrideMesh: Nullable<AbstractMesh>;
  95783. /**
  95784. * Gets the list of animations attached to this skeleton
  95785. */
  95786. animations: Array<Animation>;
  95787. private _scene;
  95788. private _isDirty;
  95789. private _transformMatrices;
  95790. private _transformMatrixTexture;
  95791. private _meshesWithPoseMatrix;
  95792. private _animatables;
  95793. private _identity;
  95794. private _synchronizedWithMesh;
  95795. private _ranges;
  95796. private _lastAbsoluteTransformsUpdateId;
  95797. private _canUseTextureForBones;
  95798. private _uniqueId;
  95799. /** @hidden */
  95800. _numBonesWithLinkedTransformNode: number;
  95801. /** @hidden */
  95802. _hasWaitingData: Nullable<boolean>;
  95803. /** @hidden */
  95804. _waitingOverrideMeshId: Nullable<string>;
  95805. /**
  95806. * Specifies if the skeleton should be serialized
  95807. */
  95808. doNotSerialize: boolean;
  95809. private _useTextureToStoreBoneMatrices;
  95810. /**
  95811. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95812. * Please note that this option is not available if the hardware does not support it
  95813. */
  95814. get useTextureToStoreBoneMatrices(): boolean;
  95815. set useTextureToStoreBoneMatrices(value: boolean);
  95816. private _animationPropertiesOverride;
  95817. /**
  95818. * Gets or sets the animation properties override
  95819. */
  95820. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95821. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95822. /**
  95823. * List of inspectable custom properties (used by the Inspector)
  95824. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95825. */
  95826. inspectableCustomProperties: IInspectable[];
  95827. /**
  95828. * An observable triggered before computing the skeleton's matrices
  95829. */
  95830. onBeforeComputeObservable: Observable<Skeleton>;
  95831. /**
  95832. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95833. */
  95834. get isUsingTextureForMatrices(): boolean;
  95835. /**
  95836. * Gets the unique ID of this skeleton
  95837. */
  95838. get uniqueId(): number;
  95839. /**
  95840. * Creates a new skeleton
  95841. * @param name defines the skeleton name
  95842. * @param id defines the skeleton Id
  95843. * @param scene defines the hosting scene
  95844. */
  95845. constructor(
  95846. /** defines the skeleton name */
  95847. name: string,
  95848. /** defines the skeleton Id */
  95849. id: string, scene: Scene);
  95850. /**
  95851. * Gets the current object class name.
  95852. * @return the class name
  95853. */
  95854. getClassName(): string;
  95855. /**
  95856. * Returns an array containing the root bones
  95857. * @returns an array containing the root bones
  95858. */
  95859. getChildren(): Array<Bone>;
  95860. /**
  95861. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95862. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95863. * @returns a Float32Array containing matrices data
  95864. */
  95865. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95866. /**
  95867. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95868. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95869. * @returns a raw texture containing the data
  95870. */
  95871. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95872. /**
  95873. * Gets the current hosting scene
  95874. * @returns a scene object
  95875. */
  95876. getScene(): Scene;
  95877. /**
  95878. * Gets a string representing the current skeleton data
  95879. * @param fullDetails defines a boolean indicating if we want a verbose version
  95880. * @returns a string representing the current skeleton data
  95881. */
  95882. toString(fullDetails?: boolean): string;
  95883. /**
  95884. * Get bone's index searching by name
  95885. * @param name defines bone's name to search for
  95886. * @return the indice of the bone. Returns -1 if not found
  95887. */
  95888. getBoneIndexByName(name: string): number;
  95889. /**
  95890. * Creater a new animation range
  95891. * @param name defines the name of the range
  95892. * @param from defines the start key
  95893. * @param to defines the end key
  95894. */
  95895. createAnimationRange(name: string, from: number, to: number): void;
  95896. /**
  95897. * Delete a specific animation range
  95898. * @param name defines the name of the range
  95899. * @param deleteFrames defines if frames must be removed as well
  95900. */
  95901. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95902. /**
  95903. * Gets a specific animation range
  95904. * @param name defines the name of the range to look for
  95905. * @returns the requested animation range or null if not found
  95906. */
  95907. getAnimationRange(name: string): Nullable<AnimationRange>;
  95908. /**
  95909. * Gets the list of all animation ranges defined on this skeleton
  95910. * @returns an array
  95911. */
  95912. getAnimationRanges(): Nullable<AnimationRange>[];
  95913. /**
  95914. * Copy animation range from a source skeleton.
  95915. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  95916. * @param source defines the source skeleton
  95917. * @param name defines the name of the range to copy
  95918. * @param rescaleAsRequired defines if rescaling must be applied if required
  95919. * @returns true if operation was successful
  95920. */
  95921. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  95922. /**
  95923. * Forces the skeleton to go to rest pose
  95924. */
  95925. returnToRest(): void;
  95926. private _getHighestAnimationFrame;
  95927. /**
  95928. * Begin a specific animation range
  95929. * @param name defines the name of the range to start
  95930. * @param loop defines if looping must be turned on (false by default)
  95931. * @param speedRatio defines the speed ratio to apply (1 by default)
  95932. * @param onAnimationEnd defines a callback which will be called when animation will end
  95933. * @returns a new animatable
  95934. */
  95935. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95936. /**
  95937. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  95938. * @param skeleton defines the Skeleton containing the animation range to convert
  95939. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  95940. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  95941. * @returns the original skeleton
  95942. */
  95943. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  95944. /** @hidden */
  95945. _markAsDirty(): void;
  95946. /** @hidden */
  95947. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95948. /** @hidden */
  95949. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95950. private _computeTransformMatrices;
  95951. /**
  95952. * Build all resources required to render a skeleton
  95953. */
  95954. prepare(): void;
  95955. /**
  95956. * Gets the list of animatables currently running for this skeleton
  95957. * @returns an array of animatables
  95958. */
  95959. getAnimatables(): IAnimatable[];
  95960. /**
  95961. * Clone the current skeleton
  95962. * @param name defines the name of the new skeleton
  95963. * @param id defines the id of the new skeleton
  95964. * @returns the new skeleton
  95965. */
  95966. clone(name: string, id?: string): Skeleton;
  95967. /**
  95968. * Enable animation blending for this skeleton
  95969. * @param blendingSpeed defines the blending speed to apply
  95970. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95971. */
  95972. enableBlending(blendingSpeed?: number): void;
  95973. /**
  95974. * Releases all resources associated with the current skeleton
  95975. */
  95976. dispose(): void;
  95977. /**
  95978. * Serialize the skeleton in a JSON object
  95979. * @returns a JSON object
  95980. */
  95981. serialize(): any;
  95982. /**
  95983. * Creates a new skeleton from serialized data
  95984. * @param parsedSkeleton defines the serialized data
  95985. * @param scene defines the hosting scene
  95986. * @returns a new skeleton
  95987. */
  95988. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  95989. /**
  95990. * Compute all node absolute transforms
  95991. * @param forceUpdate defines if computation must be done even if cache is up to date
  95992. */
  95993. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  95994. /**
  95995. * Gets the root pose matrix
  95996. * @returns a matrix
  95997. */
  95998. getPoseMatrix(): Nullable<Matrix>;
  95999. /**
  96000. * Sorts bones per internal index
  96001. */
  96002. sortBones(): void;
  96003. private _sortBones;
  96004. }
  96005. }
  96006. declare module BABYLON {
  96007. /**
  96008. * Creates an instance based on a source mesh.
  96009. */
  96010. export class InstancedMesh extends AbstractMesh {
  96011. private _sourceMesh;
  96012. private _currentLOD;
  96013. /** @hidden */
  96014. _indexInSourceMeshInstanceArray: number;
  96015. constructor(name: string, source: Mesh);
  96016. /**
  96017. * Returns the string "InstancedMesh".
  96018. */
  96019. getClassName(): string;
  96020. /** Gets the list of lights affecting that mesh */
  96021. get lightSources(): Light[];
  96022. _resyncLightSources(): void;
  96023. _resyncLightSource(light: Light): void;
  96024. _removeLightSource(light: Light, dispose: boolean): void;
  96025. /**
  96026. * If the source mesh receives shadows
  96027. */
  96028. get receiveShadows(): boolean;
  96029. /**
  96030. * The material of the source mesh
  96031. */
  96032. get material(): Nullable<Material>;
  96033. /**
  96034. * Visibility of the source mesh
  96035. */
  96036. get visibility(): number;
  96037. /**
  96038. * Skeleton of the source mesh
  96039. */
  96040. get skeleton(): Nullable<Skeleton>;
  96041. /**
  96042. * Rendering ground id of the source mesh
  96043. */
  96044. get renderingGroupId(): number;
  96045. set renderingGroupId(value: number);
  96046. /**
  96047. * Returns the total number of vertices (integer).
  96048. */
  96049. getTotalVertices(): number;
  96050. /**
  96051. * Returns a positive integer : the total number of indices in this mesh geometry.
  96052. * @returns the numner of indices or zero if the mesh has no geometry.
  96053. */
  96054. getTotalIndices(): number;
  96055. /**
  96056. * The source mesh of the instance
  96057. */
  96058. get sourceMesh(): Mesh;
  96059. /**
  96060. * Creates a new InstancedMesh object from the mesh model.
  96061. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96062. * @param name defines the name of the new instance
  96063. * @returns a new InstancedMesh
  96064. */
  96065. createInstance(name: string): InstancedMesh;
  96066. /**
  96067. * Is this node ready to be used/rendered
  96068. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96069. * @return {boolean} is it ready
  96070. */
  96071. isReady(completeCheck?: boolean): boolean;
  96072. /**
  96073. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96074. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96075. * @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.
  96076. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96077. */
  96078. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96079. /**
  96080. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96081. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96082. * The `data` are either a numeric array either a Float32Array.
  96083. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96084. * 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).
  96085. * Note that a new underlying VertexBuffer object is created each call.
  96086. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96087. *
  96088. * Possible `kind` values :
  96089. * - VertexBuffer.PositionKind
  96090. * - VertexBuffer.UVKind
  96091. * - VertexBuffer.UV2Kind
  96092. * - VertexBuffer.UV3Kind
  96093. * - VertexBuffer.UV4Kind
  96094. * - VertexBuffer.UV5Kind
  96095. * - VertexBuffer.UV6Kind
  96096. * - VertexBuffer.ColorKind
  96097. * - VertexBuffer.MatricesIndicesKind
  96098. * - VertexBuffer.MatricesIndicesExtraKind
  96099. * - VertexBuffer.MatricesWeightsKind
  96100. * - VertexBuffer.MatricesWeightsExtraKind
  96101. *
  96102. * Returns the Mesh.
  96103. */
  96104. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96105. /**
  96106. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96107. * If the mesh has no geometry, it is simply returned as it is.
  96108. * The `data` are either a numeric array either a Float32Array.
  96109. * No new underlying VertexBuffer object is created.
  96110. * 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.
  96111. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96112. *
  96113. * Possible `kind` values :
  96114. * - VertexBuffer.PositionKind
  96115. * - VertexBuffer.UVKind
  96116. * - VertexBuffer.UV2Kind
  96117. * - VertexBuffer.UV3Kind
  96118. * - VertexBuffer.UV4Kind
  96119. * - VertexBuffer.UV5Kind
  96120. * - VertexBuffer.UV6Kind
  96121. * - VertexBuffer.ColorKind
  96122. * - VertexBuffer.MatricesIndicesKind
  96123. * - VertexBuffer.MatricesIndicesExtraKind
  96124. * - VertexBuffer.MatricesWeightsKind
  96125. * - VertexBuffer.MatricesWeightsExtraKind
  96126. *
  96127. * Returns the Mesh.
  96128. */
  96129. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96130. /**
  96131. * Sets the mesh indices.
  96132. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96133. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96134. * This method creates a new index buffer each call.
  96135. * Returns the Mesh.
  96136. */
  96137. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96138. /**
  96139. * Boolean : True if the mesh owns the requested kind of data.
  96140. */
  96141. isVerticesDataPresent(kind: string): boolean;
  96142. /**
  96143. * Returns an array of indices (IndicesArray).
  96144. */
  96145. getIndices(): Nullable<IndicesArray>;
  96146. get _positions(): Nullable<Vector3[]>;
  96147. /**
  96148. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96149. * This means the mesh underlying bounding box and sphere are recomputed.
  96150. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96151. * @returns the current mesh
  96152. */
  96153. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96154. /** @hidden */
  96155. _preActivate(): InstancedMesh;
  96156. /** @hidden */
  96157. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96158. /** @hidden */
  96159. _postActivate(): void;
  96160. getWorldMatrix(): Matrix;
  96161. get isAnInstance(): boolean;
  96162. /**
  96163. * Returns the current associated LOD AbstractMesh.
  96164. */
  96165. getLOD(camera: Camera): AbstractMesh;
  96166. /** @hidden */
  96167. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96168. /** @hidden */
  96169. _syncSubMeshes(): InstancedMesh;
  96170. /** @hidden */
  96171. _generatePointsArray(): boolean;
  96172. /** @hidden */
  96173. _updateBoundingInfo(): AbstractMesh;
  96174. /**
  96175. * Creates a new InstancedMesh from the current mesh.
  96176. * - name (string) : the cloned mesh name
  96177. * - newParent (optional Node) : the optional Node to parent the clone to.
  96178. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96179. *
  96180. * Returns the clone.
  96181. */
  96182. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96183. /**
  96184. * Disposes the InstancedMesh.
  96185. * Returns nothing.
  96186. */
  96187. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96188. }
  96189. interface Mesh {
  96190. /**
  96191. * Register a custom buffer that will be instanced
  96192. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96193. * @param kind defines the buffer kind
  96194. * @param stride defines the stride in floats
  96195. */
  96196. registerInstancedBuffer(kind: string, stride: number): void;
  96197. /**
  96198. * true to use the edge renderer for all instances of this mesh
  96199. */
  96200. edgesShareWithInstances: boolean;
  96201. /** @hidden */
  96202. _userInstancedBuffersStorage: {
  96203. data: {
  96204. [key: string]: Float32Array;
  96205. };
  96206. sizes: {
  96207. [key: string]: number;
  96208. };
  96209. vertexBuffers: {
  96210. [key: string]: Nullable<VertexBuffer>;
  96211. };
  96212. strides: {
  96213. [key: string]: number;
  96214. };
  96215. };
  96216. }
  96217. interface AbstractMesh {
  96218. /**
  96219. * Object used to store instanced buffers defined by user
  96220. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96221. */
  96222. instancedBuffers: {
  96223. [key: string]: any;
  96224. };
  96225. }
  96226. }
  96227. declare module BABYLON {
  96228. /**
  96229. * Defines the options associated with the creation of a shader material.
  96230. */
  96231. export interface IShaderMaterialOptions {
  96232. /**
  96233. * Does the material work in alpha blend mode
  96234. */
  96235. needAlphaBlending: boolean;
  96236. /**
  96237. * Does the material work in alpha test mode
  96238. */
  96239. needAlphaTesting: boolean;
  96240. /**
  96241. * The list of attribute names used in the shader
  96242. */
  96243. attributes: string[];
  96244. /**
  96245. * The list of unifrom names used in the shader
  96246. */
  96247. uniforms: string[];
  96248. /**
  96249. * The list of UBO names used in the shader
  96250. */
  96251. uniformBuffers: string[];
  96252. /**
  96253. * The list of sampler names used in the shader
  96254. */
  96255. samplers: string[];
  96256. /**
  96257. * The list of defines used in the shader
  96258. */
  96259. defines: string[];
  96260. }
  96261. /**
  96262. * 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.
  96263. *
  96264. * This returned material effects how the mesh will look based on the code in the shaders.
  96265. *
  96266. * @see https://doc.babylonjs.com/how_to/shader_material
  96267. */
  96268. export class ShaderMaterial extends Material {
  96269. private _shaderPath;
  96270. private _options;
  96271. private _textures;
  96272. private _textureArrays;
  96273. private _floats;
  96274. private _ints;
  96275. private _floatsArrays;
  96276. private _colors3;
  96277. private _colors3Arrays;
  96278. private _colors4;
  96279. private _colors4Arrays;
  96280. private _vectors2;
  96281. private _vectors3;
  96282. private _vectors4;
  96283. private _matrices;
  96284. private _matrixArrays;
  96285. private _matrices3x3;
  96286. private _matrices2x2;
  96287. private _vectors2Arrays;
  96288. private _vectors3Arrays;
  96289. private _vectors4Arrays;
  96290. private _cachedWorldViewMatrix;
  96291. private _cachedWorldViewProjectionMatrix;
  96292. private _renderId;
  96293. private _multiview;
  96294. private _cachedDefines;
  96295. /** Define the Url to load snippets */
  96296. static SnippetUrl: string;
  96297. /** Snippet ID if the material was created from the snippet server */
  96298. snippetId: string;
  96299. /**
  96300. * Instantiate a new shader material.
  96301. * 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.
  96302. * This returned material effects how the mesh will look based on the code in the shaders.
  96303. * @see https://doc.babylonjs.com/how_to/shader_material
  96304. * @param name Define the name of the material in the scene
  96305. * @param scene Define the scene the material belongs to
  96306. * @param shaderPath Defines the route to the shader code in one of three ways:
  96307. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96308. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96309. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96310. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96311. * @param options Define the options used to create the shader
  96312. */
  96313. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96314. /**
  96315. * Gets the shader path used to define the shader code
  96316. * It can be modified to trigger a new compilation
  96317. */
  96318. get shaderPath(): any;
  96319. /**
  96320. * Sets the shader path used to define the shader code
  96321. * It can be modified to trigger a new compilation
  96322. */
  96323. set shaderPath(shaderPath: any);
  96324. /**
  96325. * Gets the options used to compile the shader.
  96326. * They can be modified to trigger a new compilation
  96327. */
  96328. get options(): IShaderMaterialOptions;
  96329. /**
  96330. * Gets the current class name of the material e.g. "ShaderMaterial"
  96331. * Mainly use in serialization.
  96332. * @returns the class name
  96333. */
  96334. getClassName(): string;
  96335. /**
  96336. * Specifies if the material will require alpha blending
  96337. * @returns a boolean specifying if alpha blending is needed
  96338. */
  96339. needAlphaBlending(): boolean;
  96340. /**
  96341. * Specifies if this material should be rendered in alpha test mode
  96342. * @returns a boolean specifying if an alpha test is needed.
  96343. */
  96344. needAlphaTesting(): boolean;
  96345. private _checkUniform;
  96346. /**
  96347. * Set a texture in the shader.
  96348. * @param name Define the name of the uniform samplers as defined in the shader
  96349. * @param texture Define the texture to bind to this sampler
  96350. * @return the material itself allowing "fluent" like uniform updates
  96351. */
  96352. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96353. /**
  96354. * Set a texture array in the shader.
  96355. * @param name Define the name of the uniform sampler array as defined in the shader
  96356. * @param textures Define the list of textures to bind to this sampler
  96357. * @return the material itself allowing "fluent" like uniform updates
  96358. */
  96359. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96360. /**
  96361. * Set a float in the shader.
  96362. * @param name Define the name of the uniform as defined in the shader
  96363. * @param value Define the value to give to the uniform
  96364. * @return the material itself allowing "fluent" like uniform updates
  96365. */
  96366. setFloat(name: string, value: number): ShaderMaterial;
  96367. /**
  96368. * Set a int in the shader.
  96369. * @param name Define the name of the uniform as defined in the shader
  96370. * @param value Define the value to give to the uniform
  96371. * @return the material itself allowing "fluent" like uniform updates
  96372. */
  96373. setInt(name: string, value: number): ShaderMaterial;
  96374. /**
  96375. * Set an array of floats in the shader.
  96376. * @param name Define the name of the uniform as defined in the shader
  96377. * @param value Define the value to give to the uniform
  96378. * @return the material itself allowing "fluent" like uniform updates
  96379. */
  96380. setFloats(name: string, value: number[]): ShaderMaterial;
  96381. /**
  96382. * Set a vec3 in the shader from a Color3.
  96383. * @param name Define the name of the uniform as defined in the shader
  96384. * @param value Define the value to give to the uniform
  96385. * @return the material itself allowing "fluent" like uniform updates
  96386. */
  96387. setColor3(name: string, value: Color3): ShaderMaterial;
  96388. /**
  96389. * Set a vec3 array in the shader from a Color3 array.
  96390. * @param name Define the name of the uniform as defined in the shader
  96391. * @param value Define the value to give to the uniform
  96392. * @return the material itself allowing "fluent" like uniform updates
  96393. */
  96394. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96395. /**
  96396. * Set a vec4 in the shader from a Color4.
  96397. * @param name Define the name of the uniform as defined in the shader
  96398. * @param value Define the value to give to the uniform
  96399. * @return the material itself allowing "fluent" like uniform updates
  96400. */
  96401. setColor4(name: string, value: Color4): ShaderMaterial;
  96402. /**
  96403. * Set a vec4 array in the shader from a Color4 array.
  96404. * @param name Define the name of the uniform as defined in the shader
  96405. * @param value Define the value to give to the uniform
  96406. * @return the material itself allowing "fluent" like uniform updates
  96407. */
  96408. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96409. /**
  96410. * Set a vec2 in the shader from a Vector2.
  96411. * @param name Define the name of the uniform as defined in the shader
  96412. * @param value Define the value to give to the uniform
  96413. * @return the material itself allowing "fluent" like uniform updates
  96414. */
  96415. setVector2(name: string, value: Vector2): ShaderMaterial;
  96416. /**
  96417. * Set a vec3 in the shader from a Vector3.
  96418. * @param name Define the name of the uniform as defined in the shader
  96419. * @param value Define the value to give to the uniform
  96420. * @return the material itself allowing "fluent" like uniform updates
  96421. */
  96422. setVector3(name: string, value: Vector3): ShaderMaterial;
  96423. /**
  96424. * Set a vec4 in the shader from a Vector4.
  96425. * @param name Define the name of the uniform as defined in the shader
  96426. * @param value Define the value to give to the uniform
  96427. * @return the material itself allowing "fluent" like uniform updates
  96428. */
  96429. setVector4(name: string, value: Vector4): ShaderMaterial;
  96430. /**
  96431. * Set a mat4 in the shader from a Matrix.
  96432. * @param name Define the name of the uniform as defined in the shader
  96433. * @param value Define the value to give to the uniform
  96434. * @return the material itself allowing "fluent" like uniform updates
  96435. */
  96436. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96437. /**
  96438. * Set a float32Array in the shader from a matrix array.
  96439. * @param name Define the name of the uniform as defined in the shader
  96440. * @param value Define the value to give to the uniform
  96441. * @return the material itself allowing "fluent" like uniform updates
  96442. */
  96443. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96444. /**
  96445. * Set a mat3 in the shader from a Float32Array.
  96446. * @param name Define the name of the uniform as defined in the shader
  96447. * @param value Define the value to give to the uniform
  96448. * @return the material itself allowing "fluent" like uniform updates
  96449. */
  96450. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96451. /**
  96452. * Set a mat2 in the shader from a Float32Array.
  96453. * @param name Define the name of the uniform as defined in the shader
  96454. * @param value Define the value to give to the uniform
  96455. * @return the material itself allowing "fluent" like uniform updates
  96456. */
  96457. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96458. /**
  96459. * Set a vec2 array in the shader from a number array.
  96460. * @param name Define the name of the uniform as defined in the shader
  96461. * @param value Define the value to give to the uniform
  96462. * @return the material itself allowing "fluent" like uniform updates
  96463. */
  96464. setArray2(name: string, value: number[]): ShaderMaterial;
  96465. /**
  96466. * Set a vec3 array in the shader from a number array.
  96467. * @param name Define the name of the uniform as defined in the shader
  96468. * @param value Define the value to give to the uniform
  96469. * @return the material itself allowing "fluent" like uniform updates
  96470. */
  96471. setArray3(name: string, value: number[]): ShaderMaterial;
  96472. /**
  96473. * Set a vec4 array in the shader from a number array.
  96474. * @param name Define the name of the uniform as defined in the shader
  96475. * @param value Define the value to give to the uniform
  96476. * @return the material itself allowing "fluent" like uniform updates
  96477. */
  96478. setArray4(name: string, value: number[]): ShaderMaterial;
  96479. private _checkCache;
  96480. /**
  96481. * Specifies that the submesh is ready to be used
  96482. * @param mesh defines the mesh to check
  96483. * @param subMesh defines which submesh to check
  96484. * @param useInstances specifies that instances should be used
  96485. * @returns a boolean indicating that the submesh is ready or not
  96486. */
  96487. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96488. /**
  96489. * Checks if the material is ready to render the requested mesh
  96490. * @param mesh Define the mesh to render
  96491. * @param useInstances Define whether or not the material is used with instances
  96492. * @returns true if ready, otherwise false
  96493. */
  96494. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96495. /**
  96496. * Binds the world matrix to the material
  96497. * @param world defines the world transformation matrix
  96498. * @param effectOverride - If provided, use this effect instead of internal effect
  96499. */
  96500. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  96501. /**
  96502. * Binds the submesh to this material by preparing the effect and shader to draw
  96503. * @param world defines the world transformation matrix
  96504. * @param mesh defines the mesh containing the submesh
  96505. * @param subMesh defines the submesh to bind the material to
  96506. */
  96507. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96508. /**
  96509. * Binds the material to the mesh
  96510. * @param world defines the world transformation matrix
  96511. * @param mesh defines the mesh to bind the material to
  96512. * @param effectOverride - If provided, use this effect instead of internal effect
  96513. */
  96514. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96515. protected _afterBind(mesh?: Mesh): void;
  96516. /**
  96517. * Gets the active textures from the material
  96518. * @returns an array of textures
  96519. */
  96520. getActiveTextures(): BaseTexture[];
  96521. /**
  96522. * Specifies if the material uses a texture
  96523. * @param texture defines the texture to check against the material
  96524. * @returns a boolean specifying if the material uses the texture
  96525. */
  96526. hasTexture(texture: BaseTexture): boolean;
  96527. /**
  96528. * Makes a duplicate of the material, and gives it a new name
  96529. * @param name defines the new name for the duplicated material
  96530. * @returns the cloned material
  96531. */
  96532. clone(name: string): ShaderMaterial;
  96533. /**
  96534. * Disposes the material
  96535. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96536. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96537. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96538. */
  96539. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96540. /**
  96541. * Serializes this material in a JSON representation
  96542. * @returns the serialized material object
  96543. */
  96544. serialize(): any;
  96545. /**
  96546. * Creates a shader material from parsed shader material data
  96547. * @param source defines the JSON represnetation of the material
  96548. * @param scene defines the hosting scene
  96549. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96550. * @returns a new material
  96551. */
  96552. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96553. /**
  96554. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96555. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96556. * @param url defines the url to load from
  96557. * @param scene defines the hosting scene
  96558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96559. * @returns a promise that will resolve to the new ShaderMaterial
  96560. */
  96561. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96562. /**
  96563. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96564. * @param snippetId defines the snippet to load
  96565. * @param scene defines the hosting scene
  96566. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96567. * @returns a promise that will resolve to the new ShaderMaterial
  96568. */
  96569. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96570. }
  96571. }
  96572. declare module BABYLON {
  96573. /** @hidden */
  96574. export var colorPixelShader: {
  96575. name: string;
  96576. shader: string;
  96577. };
  96578. }
  96579. declare module BABYLON {
  96580. /** @hidden */
  96581. export var colorVertexShader: {
  96582. name: string;
  96583. shader: string;
  96584. };
  96585. }
  96586. declare module BABYLON {
  96587. /**
  96588. * Line mesh
  96589. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96590. */
  96591. export class LinesMesh extends Mesh {
  96592. /**
  96593. * If vertex color should be applied to the mesh
  96594. */
  96595. readonly useVertexColor?: boolean | undefined;
  96596. /**
  96597. * If vertex alpha should be applied to the mesh
  96598. */
  96599. readonly useVertexAlpha?: boolean | undefined;
  96600. /**
  96601. * Color of the line (Default: White)
  96602. */
  96603. color: Color3;
  96604. /**
  96605. * Alpha of the line (Default: 1)
  96606. */
  96607. alpha: number;
  96608. /**
  96609. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96610. * This margin is expressed in world space coordinates, so its value may vary.
  96611. * Default value is 0.1
  96612. */
  96613. intersectionThreshold: number;
  96614. private _colorShader;
  96615. private color4;
  96616. /**
  96617. * Creates a new LinesMesh
  96618. * @param name defines the name
  96619. * @param scene defines the hosting scene
  96620. * @param parent defines the parent mesh if any
  96621. * @param source defines the optional source LinesMesh used to clone data from
  96622. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96623. * When false, achieved by calling a clone(), also passing False.
  96624. * This will make creation of children, recursive.
  96625. * @param useVertexColor defines if this LinesMesh supports vertex color
  96626. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96627. */
  96628. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96629. /**
  96630. * If vertex color should be applied to the mesh
  96631. */
  96632. useVertexColor?: boolean | undefined,
  96633. /**
  96634. * If vertex alpha should be applied to the mesh
  96635. */
  96636. useVertexAlpha?: boolean | undefined);
  96637. private _addClipPlaneDefine;
  96638. private _removeClipPlaneDefine;
  96639. isReady(): boolean;
  96640. /**
  96641. * Returns the string "LineMesh"
  96642. */
  96643. getClassName(): string;
  96644. /**
  96645. * @hidden
  96646. */
  96647. get material(): Material;
  96648. /**
  96649. * @hidden
  96650. */
  96651. set material(value: Material);
  96652. /**
  96653. * @hidden
  96654. */
  96655. get checkCollisions(): boolean;
  96656. /** @hidden */
  96657. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96658. /** @hidden */
  96659. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96660. /**
  96661. * Disposes of the line mesh
  96662. * @param doNotRecurse If children should be disposed
  96663. */
  96664. dispose(doNotRecurse?: boolean): void;
  96665. /**
  96666. * Returns a new LineMesh object cloned from the current one.
  96667. */
  96668. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96669. /**
  96670. * Creates a new InstancedLinesMesh object from the mesh model.
  96671. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96672. * @param name defines the name of the new instance
  96673. * @returns a new InstancedLinesMesh
  96674. */
  96675. createInstance(name: string): InstancedLinesMesh;
  96676. }
  96677. /**
  96678. * Creates an instance based on a source LinesMesh
  96679. */
  96680. export class InstancedLinesMesh extends InstancedMesh {
  96681. /**
  96682. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96683. * This margin is expressed in world space coordinates, so its value may vary.
  96684. * Initilized with the intersectionThreshold value of the source LinesMesh
  96685. */
  96686. intersectionThreshold: number;
  96687. constructor(name: string, source: LinesMesh);
  96688. /**
  96689. * Returns the string "InstancedLinesMesh".
  96690. */
  96691. getClassName(): string;
  96692. }
  96693. }
  96694. declare module BABYLON {
  96695. /** @hidden */
  96696. export var linePixelShader: {
  96697. name: string;
  96698. shader: string;
  96699. };
  96700. }
  96701. declare module BABYLON {
  96702. /** @hidden */
  96703. export var lineVertexShader: {
  96704. name: string;
  96705. shader: string;
  96706. };
  96707. }
  96708. declare module BABYLON {
  96709. interface Scene {
  96710. /** @hidden */
  96711. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96712. }
  96713. interface AbstractMesh {
  96714. /**
  96715. * Gets the edgesRenderer associated with the mesh
  96716. */
  96717. edgesRenderer: Nullable<EdgesRenderer>;
  96718. }
  96719. interface LinesMesh {
  96720. /**
  96721. * Enables the edge rendering mode on the mesh.
  96722. * This mode makes the mesh edges visible
  96723. * @param epsilon defines the maximal distance between two angles to detect a face
  96724. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96725. * @returns the currentAbstractMesh
  96726. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96727. */
  96728. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96729. }
  96730. interface InstancedLinesMesh {
  96731. /**
  96732. * Enables the edge rendering mode on the mesh.
  96733. * This mode makes the mesh edges visible
  96734. * @param epsilon defines the maximal distance between two angles to detect a face
  96735. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96736. * @returns the current InstancedLinesMesh
  96737. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96738. */
  96739. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96740. }
  96741. /**
  96742. * Defines the minimum contract an Edges renderer should follow.
  96743. */
  96744. export interface IEdgesRenderer extends IDisposable {
  96745. /**
  96746. * Gets or sets a boolean indicating if the edgesRenderer is active
  96747. */
  96748. isEnabled: boolean;
  96749. /**
  96750. * Renders the edges of the attached mesh,
  96751. */
  96752. render(): void;
  96753. /**
  96754. * Checks wether or not the edges renderer is ready to render.
  96755. * @return true if ready, otherwise false.
  96756. */
  96757. isReady(): boolean;
  96758. /**
  96759. * List of instances to render in case the source mesh has instances
  96760. */
  96761. customInstances: SmartArray<Matrix>;
  96762. }
  96763. /**
  96764. * Defines the additional options of the edges renderer
  96765. */
  96766. export interface IEdgesRendererOptions {
  96767. /**
  96768. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96769. * If not defined, the default value is true
  96770. */
  96771. useAlternateEdgeFinder?: boolean;
  96772. /**
  96773. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96774. * If not defined, the default value is true.
  96775. * 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)
  96776. * This option is used only if useAlternateEdgeFinder = true
  96777. */
  96778. useFastVertexMerger?: boolean;
  96779. /**
  96780. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96781. * The default value is 1e-6
  96782. * This option is used only if useAlternateEdgeFinder = true
  96783. */
  96784. epsilonVertexMerge?: number;
  96785. /**
  96786. * 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
  96787. * 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.
  96788. * This option is used only if useAlternateEdgeFinder = true
  96789. */
  96790. applyTessellation?: boolean;
  96791. /**
  96792. * 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
  96793. * The default value is 1e-6
  96794. * This option is used only if useAlternateEdgeFinder = true
  96795. */
  96796. epsilonVertexAligned?: number;
  96797. }
  96798. /**
  96799. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96800. */
  96801. export class EdgesRenderer implements IEdgesRenderer {
  96802. /**
  96803. * Define the size of the edges with an orthographic camera
  96804. */
  96805. edgesWidthScalerForOrthographic: number;
  96806. /**
  96807. * Define the size of the edges with a perspective camera
  96808. */
  96809. edgesWidthScalerForPerspective: number;
  96810. protected _source: AbstractMesh;
  96811. protected _linesPositions: number[];
  96812. protected _linesNormals: number[];
  96813. protected _linesIndices: number[];
  96814. protected _epsilon: number;
  96815. protected _indicesCount: number;
  96816. protected _lineShader: ShaderMaterial;
  96817. protected _ib: DataBuffer;
  96818. protected _buffers: {
  96819. [key: string]: Nullable<VertexBuffer>;
  96820. };
  96821. protected _buffersForInstances: {
  96822. [key: string]: Nullable<VertexBuffer>;
  96823. };
  96824. protected _checkVerticesInsteadOfIndices: boolean;
  96825. protected _options: Nullable<IEdgesRendererOptions>;
  96826. private _meshRebuildObserver;
  96827. private _meshDisposeObserver;
  96828. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96829. isEnabled: boolean;
  96830. /**
  96831. * List of instances to render in case the source mesh has instances
  96832. */
  96833. customInstances: SmartArray<Matrix>;
  96834. private static GetShader;
  96835. /**
  96836. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96837. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96838. * @param source Mesh used to create edges
  96839. * @param epsilon sum of angles in adjacency to check for edge
  96840. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96841. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96842. * @param options The options to apply when generating the edges
  96843. */
  96844. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96845. protected _prepareRessources(): void;
  96846. /** @hidden */
  96847. _rebuild(): void;
  96848. /**
  96849. * Releases the required resources for the edges renderer
  96850. */
  96851. dispose(): void;
  96852. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96853. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96854. /**
  96855. * Checks if the pair of p0 and p1 is en edge
  96856. * @param faceIndex
  96857. * @param edge
  96858. * @param faceNormals
  96859. * @param p0
  96860. * @param p1
  96861. * @private
  96862. */
  96863. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96864. /**
  96865. * push line into the position, normal and index buffer
  96866. * @protected
  96867. */
  96868. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96869. /**
  96870. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96871. */
  96872. private _tessellateTriangle;
  96873. private _generateEdgesLinesAlternate;
  96874. /**
  96875. * Generates lines edges from adjacencjes
  96876. * @private
  96877. */
  96878. _generateEdgesLines(): void;
  96879. /**
  96880. * Checks wether or not the edges renderer is ready to render.
  96881. * @return true if ready, otherwise false.
  96882. */
  96883. isReady(): boolean;
  96884. /**
  96885. * Renders the edges of the attached mesh,
  96886. */
  96887. render(): void;
  96888. }
  96889. /**
  96890. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  96891. */
  96892. export class LineEdgesRenderer extends EdgesRenderer {
  96893. /**
  96894. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  96895. * @param source LineMesh used to generate edges
  96896. * @param epsilon not important (specified angle for edge detection)
  96897. * @param checkVerticesInsteadOfIndices not important for LineMesh
  96898. */
  96899. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  96900. /**
  96901. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  96902. */
  96903. _generateEdgesLines(): void;
  96904. }
  96905. }
  96906. declare module BABYLON {
  96907. /**
  96908. * This represents the object necessary to create a rendering group.
  96909. * This is exclusively used and created by the rendering manager.
  96910. * To modify the behavior, you use the available helpers in your scene or meshes.
  96911. * @hidden
  96912. */
  96913. export class RenderingGroup {
  96914. index: number;
  96915. private static _zeroVector;
  96916. private _scene;
  96917. private _opaqueSubMeshes;
  96918. private _transparentSubMeshes;
  96919. private _alphaTestSubMeshes;
  96920. private _depthOnlySubMeshes;
  96921. private _particleSystems;
  96922. private _spriteManagers;
  96923. private _opaqueSortCompareFn;
  96924. private _alphaTestSortCompareFn;
  96925. private _transparentSortCompareFn;
  96926. private _renderOpaque;
  96927. private _renderAlphaTest;
  96928. private _renderTransparent;
  96929. /** @hidden */
  96930. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  96931. onBeforeTransparentRendering: () => void;
  96932. /**
  96933. * Set the opaque sort comparison function.
  96934. * If null the sub meshes will be render in the order they were created
  96935. */
  96936. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96937. /**
  96938. * Set the alpha test sort comparison function.
  96939. * If null the sub meshes will be render in the order they were created
  96940. */
  96941. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96942. /**
  96943. * Set the transparent sort comparison function.
  96944. * If null the sub meshes will be render in the order they were created
  96945. */
  96946. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96947. /**
  96948. * Creates a new rendering group.
  96949. * @param index The rendering group index
  96950. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  96951. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  96952. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  96953. */
  96954. 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>);
  96955. /**
  96956. * Render all the sub meshes contained in the group.
  96957. * @param customRenderFunction Used to override the default render behaviour of the group.
  96958. * @returns true if rendered some submeshes.
  96959. */
  96960. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  96961. /**
  96962. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  96963. * @param subMeshes The submeshes to render
  96964. */
  96965. private renderOpaqueSorted;
  96966. /**
  96967. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96968. * @param subMeshes The submeshes to render
  96969. */
  96970. private renderAlphaTestSorted;
  96971. /**
  96972. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96973. * @param subMeshes The submeshes to render
  96974. */
  96975. private renderTransparentSorted;
  96976. /**
  96977. * Renders the submeshes in a specified order.
  96978. * @param subMeshes The submeshes to sort before render
  96979. * @param sortCompareFn The comparison function use to sort
  96980. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96981. * @param transparent Specifies to activate blending if true
  96982. */
  96983. private static renderSorted;
  96984. /**
  96985. * Renders the submeshes in the order they were dispatched (no sort applied).
  96986. * @param subMeshes The submeshes to render
  96987. */
  96988. private static renderUnsorted;
  96989. /**
  96990. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96991. * are rendered back to front if in the same alpha index.
  96992. *
  96993. * @param a The first submesh
  96994. * @param b The second submesh
  96995. * @returns The result of the comparison
  96996. */
  96997. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  96998. /**
  96999. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97000. * are rendered back to front.
  97001. *
  97002. * @param a The first submesh
  97003. * @param b The second submesh
  97004. * @returns The result of the comparison
  97005. */
  97006. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97007. /**
  97008. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97009. * are rendered front to back (prevent overdraw).
  97010. *
  97011. * @param a The first submesh
  97012. * @param b The second submesh
  97013. * @returns The result of the comparison
  97014. */
  97015. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97016. /**
  97017. * Resets the different lists of submeshes to prepare a new frame.
  97018. */
  97019. prepare(): void;
  97020. dispose(): void;
  97021. /**
  97022. * Inserts the submesh in its correct queue depending on its material.
  97023. * @param subMesh The submesh to dispatch
  97024. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97025. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97026. */
  97027. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97028. dispatchSprites(spriteManager: ISpriteManager): void;
  97029. dispatchParticles(particleSystem: IParticleSystem): void;
  97030. private _renderParticles;
  97031. private _renderSprites;
  97032. }
  97033. }
  97034. declare module BABYLON {
  97035. /**
  97036. * Interface describing the different options available in the rendering manager
  97037. * regarding Auto Clear between groups.
  97038. */
  97039. export interface IRenderingManagerAutoClearSetup {
  97040. /**
  97041. * Defines whether or not autoclear is enable.
  97042. */
  97043. autoClear: boolean;
  97044. /**
  97045. * Defines whether or not to autoclear the depth buffer.
  97046. */
  97047. depth: boolean;
  97048. /**
  97049. * Defines whether or not to autoclear the stencil buffer.
  97050. */
  97051. stencil: boolean;
  97052. }
  97053. /**
  97054. * This class is used by the onRenderingGroupObservable
  97055. */
  97056. export class RenderingGroupInfo {
  97057. /**
  97058. * The Scene that being rendered
  97059. */
  97060. scene: Scene;
  97061. /**
  97062. * The camera currently used for the rendering pass
  97063. */
  97064. camera: Nullable<Camera>;
  97065. /**
  97066. * The ID of the renderingGroup being processed
  97067. */
  97068. renderingGroupId: number;
  97069. }
  97070. /**
  97071. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97072. * It is enable to manage the different groups as well as the different necessary sort functions.
  97073. * This should not be used directly aside of the few static configurations
  97074. */
  97075. export class RenderingManager {
  97076. /**
  97077. * The max id used for rendering groups (not included)
  97078. */
  97079. static MAX_RENDERINGGROUPS: number;
  97080. /**
  97081. * The min id used for rendering groups (included)
  97082. */
  97083. static MIN_RENDERINGGROUPS: number;
  97084. /**
  97085. * Used to globally prevent autoclearing scenes.
  97086. */
  97087. static AUTOCLEAR: boolean;
  97088. /**
  97089. * @hidden
  97090. */
  97091. _useSceneAutoClearSetup: boolean;
  97092. private _scene;
  97093. private _renderingGroups;
  97094. private _depthStencilBufferAlreadyCleaned;
  97095. private _autoClearDepthStencil;
  97096. private _customOpaqueSortCompareFn;
  97097. private _customAlphaTestSortCompareFn;
  97098. private _customTransparentSortCompareFn;
  97099. private _renderingGroupInfo;
  97100. /**
  97101. * Instantiates a new rendering group for a particular scene
  97102. * @param scene Defines the scene the groups belongs to
  97103. */
  97104. constructor(scene: Scene);
  97105. private _clearDepthStencilBuffer;
  97106. /**
  97107. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97108. * @hidden
  97109. */
  97110. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97111. /**
  97112. * Resets the different information of the group to prepare a new frame
  97113. * @hidden
  97114. */
  97115. reset(): void;
  97116. /**
  97117. * Dispose and release the group and its associated resources.
  97118. * @hidden
  97119. */
  97120. dispose(): void;
  97121. /**
  97122. * Clear the info related to rendering groups preventing retention points during dispose.
  97123. */
  97124. freeRenderingGroups(): void;
  97125. private _prepareRenderingGroup;
  97126. /**
  97127. * Add a sprite manager to the rendering manager in order to render it this frame.
  97128. * @param spriteManager Define the sprite manager to render
  97129. */
  97130. dispatchSprites(spriteManager: ISpriteManager): void;
  97131. /**
  97132. * Add a particle system to the rendering manager in order to render it this frame.
  97133. * @param particleSystem Define the particle system to render
  97134. */
  97135. dispatchParticles(particleSystem: IParticleSystem): void;
  97136. /**
  97137. * Add a submesh to the manager in order to render it this frame
  97138. * @param subMesh The submesh to dispatch
  97139. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97140. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97141. */
  97142. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97143. /**
  97144. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97145. * This allowed control for front to back rendering or reversly depending of the special needs.
  97146. *
  97147. * @param renderingGroupId The rendering group id corresponding to its index
  97148. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97149. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97150. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97151. */
  97152. 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;
  97153. /**
  97154. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97155. *
  97156. * @param renderingGroupId The rendering group id corresponding to its index
  97157. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97158. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97159. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97160. */
  97161. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97162. /**
  97163. * Gets the current auto clear configuration for one rendering group of the rendering
  97164. * manager.
  97165. * @param index the rendering group index to get the information for
  97166. * @returns The auto clear setup for the requested rendering group
  97167. */
  97168. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97169. }
  97170. }
  97171. declare module BABYLON {
  97172. /**
  97173. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97174. */
  97175. export interface ICustomShaderOptions {
  97176. /**
  97177. * Gets or sets the custom shader name to use
  97178. */
  97179. shaderName: string;
  97180. /**
  97181. * The list of attribute names used in the shader
  97182. */
  97183. attributes?: string[];
  97184. /**
  97185. * The list of unifrom names used in the shader
  97186. */
  97187. uniforms?: string[];
  97188. /**
  97189. * The list of sampler names used in the shader
  97190. */
  97191. samplers?: string[];
  97192. /**
  97193. * The list of defines used in the shader
  97194. */
  97195. defines?: string[];
  97196. }
  97197. /**
  97198. * Interface to implement to create a shadow generator compatible with BJS.
  97199. */
  97200. export interface IShadowGenerator {
  97201. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97202. id: string;
  97203. /**
  97204. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97205. * @returns The render target texture if present otherwise, null
  97206. */
  97207. getShadowMap(): Nullable<RenderTargetTexture>;
  97208. /**
  97209. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97210. * @param subMesh The submesh we want to render in the shadow map
  97211. * @param useInstances Defines wether will draw in the map using instances
  97212. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97213. * @returns true if ready otherwise, false
  97214. */
  97215. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97216. /**
  97217. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97218. * @param defines Defines of the material we want to update
  97219. * @param lightIndex Index of the light in the enabled light list of the material
  97220. */
  97221. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97222. /**
  97223. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97224. * defined in the generator but impacting the effect).
  97225. * It implies the unifroms available on the materials are the standard BJS ones.
  97226. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97227. * @param effect The effect we are binfing the information for
  97228. */
  97229. bindShadowLight(lightIndex: string, effect: Effect): void;
  97230. /**
  97231. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97232. * (eq to shadow prjection matrix * light transform matrix)
  97233. * @returns The transform matrix used to create the shadow map
  97234. */
  97235. getTransformMatrix(): Matrix;
  97236. /**
  97237. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97238. * Cube and 2D textures for instance.
  97239. */
  97240. recreateShadowMap(): void;
  97241. /**
  97242. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97243. * @param onCompiled Callback triggered at the and of the effects compilation
  97244. * @param options Sets of optional options forcing the compilation with different modes
  97245. */
  97246. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97247. useInstances: boolean;
  97248. }>): void;
  97249. /**
  97250. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97251. * @param options Sets of optional options forcing the compilation with different modes
  97252. * @returns A promise that resolves when the compilation completes
  97253. */
  97254. forceCompilationAsync(options?: Partial<{
  97255. useInstances: boolean;
  97256. }>): Promise<void>;
  97257. /**
  97258. * Serializes the shadow generator setup to a json object.
  97259. * @returns The serialized JSON object
  97260. */
  97261. serialize(): any;
  97262. /**
  97263. * Disposes the Shadow map and related Textures and effects.
  97264. */
  97265. dispose(): void;
  97266. }
  97267. /**
  97268. * Default implementation IShadowGenerator.
  97269. * This is the main object responsible of generating shadows in the framework.
  97270. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97271. */
  97272. export class ShadowGenerator implements IShadowGenerator {
  97273. /**
  97274. * Name of the shadow generator class
  97275. */
  97276. static CLASSNAME: string;
  97277. /**
  97278. * Shadow generator mode None: no filtering applied.
  97279. */
  97280. static readonly FILTER_NONE: number;
  97281. /**
  97282. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97283. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97284. */
  97285. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97286. /**
  97287. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97288. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97289. */
  97290. static readonly FILTER_POISSONSAMPLING: number;
  97291. /**
  97292. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97293. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97294. */
  97295. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97296. /**
  97297. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97298. * edge artifacts on steep falloff.
  97299. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97300. */
  97301. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97302. /**
  97303. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97304. * edge artifacts on steep falloff.
  97305. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97306. */
  97307. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97308. /**
  97309. * Shadow generator mode PCF: Percentage Closer Filtering
  97310. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97311. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97312. */
  97313. static readonly FILTER_PCF: number;
  97314. /**
  97315. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97316. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97317. * Contact Hardening
  97318. */
  97319. static readonly FILTER_PCSS: number;
  97320. /**
  97321. * Reserved for PCF and PCSS
  97322. * Highest Quality.
  97323. *
  97324. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97325. *
  97326. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97327. */
  97328. static readonly QUALITY_HIGH: number;
  97329. /**
  97330. * Reserved for PCF and PCSS
  97331. * Good tradeoff for quality/perf cross devices
  97332. *
  97333. * Execute PCF on a 3*3 kernel.
  97334. *
  97335. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97336. */
  97337. static readonly QUALITY_MEDIUM: number;
  97338. /**
  97339. * Reserved for PCF and PCSS
  97340. * The lowest quality but the fastest.
  97341. *
  97342. * Execute PCF on a 1*1 kernel.
  97343. *
  97344. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97345. */
  97346. static readonly QUALITY_LOW: number;
  97347. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97348. id: string;
  97349. /** Gets or sets the custom shader name to use */
  97350. customShaderOptions: ICustomShaderOptions;
  97351. /**
  97352. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97353. */
  97354. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97355. /**
  97356. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97357. */
  97358. onAfterShadowMapRenderObservable: Observable<Effect>;
  97359. /**
  97360. * Observable triggered before a mesh is rendered in the shadow map.
  97361. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97362. */
  97363. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97364. /**
  97365. * Observable triggered after a mesh is rendered in the shadow map.
  97366. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97367. */
  97368. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97369. protected _bias: number;
  97370. /**
  97371. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97372. */
  97373. get bias(): number;
  97374. /**
  97375. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97376. */
  97377. set bias(bias: number);
  97378. protected _normalBias: number;
  97379. /**
  97380. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97381. */
  97382. get normalBias(): number;
  97383. /**
  97384. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97385. */
  97386. set normalBias(normalBias: number);
  97387. protected _blurBoxOffset: number;
  97388. /**
  97389. * Gets the blur box offset: offset applied during the blur pass.
  97390. * Only useful if useKernelBlur = false
  97391. */
  97392. get blurBoxOffset(): number;
  97393. /**
  97394. * Sets the blur box offset: offset applied during the blur pass.
  97395. * Only useful if useKernelBlur = false
  97396. */
  97397. set blurBoxOffset(value: number);
  97398. protected _blurScale: number;
  97399. /**
  97400. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97401. * 2 means half of the size.
  97402. */
  97403. get blurScale(): number;
  97404. /**
  97405. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97406. * 2 means half of the size.
  97407. */
  97408. set blurScale(value: number);
  97409. protected _blurKernel: number;
  97410. /**
  97411. * Gets the blur kernel: kernel size of the blur pass.
  97412. * Only useful if useKernelBlur = true
  97413. */
  97414. get blurKernel(): number;
  97415. /**
  97416. * Sets the blur kernel: kernel size of the blur pass.
  97417. * Only useful if useKernelBlur = true
  97418. */
  97419. set blurKernel(value: number);
  97420. protected _useKernelBlur: boolean;
  97421. /**
  97422. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97423. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97424. */
  97425. get useKernelBlur(): boolean;
  97426. /**
  97427. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97428. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97429. */
  97430. set useKernelBlur(value: boolean);
  97431. protected _depthScale: number;
  97432. /**
  97433. * Gets the depth scale used in ESM mode.
  97434. */
  97435. get depthScale(): number;
  97436. /**
  97437. * Sets the depth scale used in ESM mode.
  97438. * This can override the scale stored on the light.
  97439. */
  97440. set depthScale(value: number);
  97441. protected _validateFilter(filter: number): number;
  97442. protected _filter: number;
  97443. /**
  97444. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97445. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97446. */
  97447. get filter(): number;
  97448. /**
  97449. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97450. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97451. */
  97452. set filter(value: number);
  97453. /**
  97454. * Gets if the current filter is set to Poisson Sampling.
  97455. */
  97456. get usePoissonSampling(): boolean;
  97457. /**
  97458. * Sets the current filter to Poisson Sampling.
  97459. */
  97460. set usePoissonSampling(value: boolean);
  97461. /**
  97462. * Gets if the current filter is set to ESM.
  97463. */
  97464. get useExponentialShadowMap(): boolean;
  97465. /**
  97466. * Sets the current filter is to ESM.
  97467. */
  97468. set useExponentialShadowMap(value: boolean);
  97469. /**
  97470. * Gets if the current filter is set to filtered ESM.
  97471. */
  97472. get useBlurExponentialShadowMap(): boolean;
  97473. /**
  97474. * Gets if the current filter is set to filtered ESM.
  97475. */
  97476. set useBlurExponentialShadowMap(value: boolean);
  97477. /**
  97478. * Gets if the current filter is set to "close ESM" (using the inverse of the
  97479. * exponential to prevent steep falloff artifacts).
  97480. */
  97481. get useCloseExponentialShadowMap(): boolean;
  97482. /**
  97483. * Sets the current filter to "close ESM" (using the inverse of the
  97484. * exponential to prevent steep falloff artifacts).
  97485. */
  97486. set useCloseExponentialShadowMap(value: boolean);
  97487. /**
  97488. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  97489. * exponential to prevent steep falloff artifacts).
  97490. */
  97491. get useBlurCloseExponentialShadowMap(): boolean;
  97492. /**
  97493. * Sets the current filter to filtered "close ESM" (using the inverse of the
  97494. * exponential to prevent steep falloff artifacts).
  97495. */
  97496. set useBlurCloseExponentialShadowMap(value: boolean);
  97497. /**
  97498. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  97499. */
  97500. get usePercentageCloserFiltering(): boolean;
  97501. /**
  97502. * Sets the current filter to "PCF" (percentage closer filtering).
  97503. */
  97504. set usePercentageCloserFiltering(value: boolean);
  97505. protected _filteringQuality: number;
  97506. /**
  97507. * Gets the PCF or PCSS Quality.
  97508. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97509. */
  97510. get filteringQuality(): number;
  97511. /**
  97512. * Sets the PCF or PCSS Quality.
  97513. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97514. */
  97515. set filteringQuality(filteringQuality: number);
  97516. /**
  97517. * Gets if the current filter is set to "PCSS" (contact hardening).
  97518. */
  97519. get useContactHardeningShadow(): boolean;
  97520. /**
  97521. * Sets the current filter to "PCSS" (contact hardening).
  97522. */
  97523. set useContactHardeningShadow(value: boolean);
  97524. protected _contactHardeningLightSizeUVRatio: number;
  97525. /**
  97526. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97527. * Using a ratio helps keeping shape stability independently of the map size.
  97528. *
  97529. * It does not account for the light projection as it was having too much
  97530. * instability during the light setup or during light position changes.
  97531. *
  97532. * Only valid if useContactHardeningShadow is true.
  97533. */
  97534. get contactHardeningLightSizeUVRatio(): number;
  97535. /**
  97536. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97537. * Using a ratio helps keeping shape stability independently of the map size.
  97538. *
  97539. * It does not account for the light projection as it was having too much
  97540. * instability during the light setup or during light position changes.
  97541. *
  97542. * Only valid if useContactHardeningShadow is true.
  97543. */
  97544. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97545. protected _darkness: number;
  97546. /** Gets or sets the actual darkness of a shadow */
  97547. get darkness(): number;
  97548. set darkness(value: number);
  97549. /**
  97550. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97551. * 0 means strongest and 1 would means no shadow.
  97552. * @returns the darkness.
  97553. */
  97554. getDarkness(): number;
  97555. /**
  97556. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97557. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97558. * @returns the shadow generator allowing fluent coding.
  97559. */
  97560. setDarkness(darkness: number): ShadowGenerator;
  97561. protected _transparencyShadow: boolean;
  97562. /** Gets or sets the ability to have transparent shadow */
  97563. get transparencyShadow(): boolean;
  97564. set transparencyShadow(value: boolean);
  97565. /**
  97566. * Sets the ability to have transparent shadow (boolean).
  97567. * @param transparent True if transparent else False
  97568. * @returns the shadow generator allowing fluent coding
  97569. */
  97570. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97571. /**
  97572. * Enables or disables shadows with varying strength based on the transparency
  97573. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97574. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97575. * mesh.visibility * alphaTexture.a
  97576. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97577. */
  97578. enableSoftTransparentShadow: boolean;
  97579. protected _shadowMap: Nullable<RenderTargetTexture>;
  97580. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97581. /**
  97582. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97583. * @returns The render target texture if present otherwise, null
  97584. */
  97585. getShadowMap(): Nullable<RenderTargetTexture>;
  97586. /**
  97587. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97588. * @returns The render target texture if the shadow map is present otherwise, null
  97589. */
  97590. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97591. /**
  97592. * Gets the class name of that object
  97593. * @returns "ShadowGenerator"
  97594. */
  97595. getClassName(): string;
  97596. /**
  97597. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97598. * @param mesh Mesh to add
  97599. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97600. * @returns the Shadow Generator itself
  97601. */
  97602. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97603. /**
  97604. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97605. * @param mesh Mesh to remove
  97606. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97607. * @returns the Shadow Generator itself
  97608. */
  97609. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97610. /**
  97611. * Controls the extent to which the shadows fade out at the edge of the frustum
  97612. */
  97613. frustumEdgeFalloff: number;
  97614. protected _light: IShadowLight;
  97615. /**
  97616. * Returns the associated light object.
  97617. * @returns the light generating the shadow
  97618. */
  97619. getLight(): IShadowLight;
  97620. /**
  97621. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97622. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97623. * It might on the other hand introduce peter panning.
  97624. */
  97625. forceBackFacesOnly: boolean;
  97626. protected _scene: Scene;
  97627. protected _lightDirection: Vector3;
  97628. protected _effect: Effect;
  97629. protected _viewMatrix: Matrix;
  97630. protected _projectionMatrix: Matrix;
  97631. protected _transformMatrix: Matrix;
  97632. protected _cachedPosition: Vector3;
  97633. protected _cachedDirection: Vector3;
  97634. protected _cachedDefines: string;
  97635. protected _currentRenderID: number;
  97636. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97637. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97638. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97639. protected _blurPostProcesses: PostProcess[];
  97640. protected _mapSize: number;
  97641. protected _currentFaceIndex: number;
  97642. protected _currentFaceIndexCache: number;
  97643. protected _textureType: number;
  97644. protected _defaultTextureMatrix: Matrix;
  97645. protected _storedUniqueId: Nullable<number>;
  97646. /** @hidden */
  97647. static _SceneComponentInitialization: (scene: Scene) => void;
  97648. /**
  97649. * Creates a ShadowGenerator object.
  97650. * A ShadowGenerator is the required tool to use the shadows.
  97651. * Each light casting shadows needs to use its own ShadowGenerator.
  97652. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97653. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97654. * @param light The light object generating the shadows.
  97655. * @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.
  97656. */
  97657. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97658. protected _initializeGenerator(): void;
  97659. protected _createTargetRenderTexture(): void;
  97660. protected _initializeShadowMap(): void;
  97661. protected _initializeBlurRTTAndPostProcesses(): void;
  97662. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97663. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97664. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97665. protected _applyFilterValues(): void;
  97666. /**
  97667. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97668. * @param onCompiled Callback triggered at the and of the effects compilation
  97669. * @param options Sets of optional options forcing the compilation with different modes
  97670. */
  97671. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97672. useInstances: boolean;
  97673. }>): void;
  97674. /**
  97675. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97676. * @param options Sets of optional options forcing the compilation with different modes
  97677. * @returns A promise that resolves when the compilation completes
  97678. */
  97679. forceCompilationAsync(options?: Partial<{
  97680. useInstances: boolean;
  97681. }>): Promise<void>;
  97682. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97683. private _prepareShadowDefines;
  97684. /**
  97685. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97686. * @param subMesh The submesh we want to render in the shadow map
  97687. * @param useInstances Defines wether will draw in the map using instances
  97688. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97689. * @returns true if ready otherwise, false
  97690. */
  97691. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97692. /**
  97693. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97694. * @param defines Defines of the material we want to update
  97695. * @param lightIndex Index of the light in the enabled light list of the material
  97696. */
  97697. prepareDefines(defines: any, lightIndex: number): void;
  97698. /**
  97699. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97700. * defined in the generator but impacting the effect).
  97701. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97702. * @param effect The effect we are binfing the information for
  97703. */
  97704. bindShadowLight(lightIndex: string, effect: Effect): void;
  97705. /**
  97706. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97707. * (eq to shadow prjection matrix * light transform matrix)
  97708. * @returns The transform matrix used to create the shadow map
  97709. */
  97710. getTransformMatrix(): Matrix;
  97711. /**
  97712. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97713. * Cube and 2D textures for instance.
  97714. */
  97715. recreateShadowMap(): void;
  97716. protected _disposeBlurPostProcesses(): void;
  97717. protected _disposeRTTandPostProcesses(): void;
  97718. /**
  97719. * Disposes the ShadowGenerator.
  97720. * Returns nothing.
  97721. */
  97722. dispose(): void;
  97723. /**
  97724. * Serializes the shadow generator setup to a json object.
  97725. * @returns The serialized JSON object
  97726. */
  97727. serialize(): any;
  97728. /**
  97729. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97730. * @param parsedShadowGenerator The JSON object to parse
  97731. * @param scene The scene to create the shadow map for
  97732. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97733. * @returns The parsed shadow generator
  97734. */
  97735. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97736. }
  97737. }
  97738. declare module BABYLON {
  97739. /**
  97740. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97741. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97742. * 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.
  97743. */
  97744. export abstract class Light extends Node {
  97745. /**
  97746. * Falloff Default: light is falling off following the material specification:
  97747. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97748. */
  97749. static readonly FALLOFF_DEFAULT: number;
  97750. /**
  97751. * Falloff Physical: light is falling off following the inverse squared distance law.
  97752. */
  97753. static readonly FALLOFF_PHYSICAL: number;
  97754. /**
  97755. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97756. * to enhance interoperability with other engines.
  97757. */
  97758. static readonly FALLOFF_GLTF: number;
  97759. /**
  97760. * Falloff Standard: light is falling off like in the standard material
  97761. * to enhance interoperability with other materials.
  97762. */
  97763. static readonly FALLOFF_STANDARD: number;
  97764. /**
  97765. * If every light affecting the material is in this lightmapMode,
  97766. * material.lightmapTexture adds or multiplies
  97767. * (depends on material.useLightmapAsShadowmap)
  97768. * after every other light calculations.
  97769. */
  97770. static readonly LIGHTMAP_DEFAULT: number;
  97771. /**
  97772. * material.lightmapTexture as only diffuse lighting from this light
  97773. * adds only specular lighting from this light
  97774. * adds dynamic shadows
  97775. */
  97776. static readonly LIGHTMAP_SPECULAR: number;
  97777. /**
  97778. * material.lightmapTexture as only lighting
  97779. * no light calculation from this light
  97780. * only adds dynamic shadows from this light
  97781. */
  97782. static readonly LIGHTMAP_SHADOWSONLY: number;
  97783. /**
  97784. * Each light type uses the default quantity according to its type:
  97785. * point/spot lights use luminous intensity
  97786. * directional lights use illuminance
  97787. */
  97788. static readonly INTENSITYMODE_AUTOMATIC: number;
  97789. /**
  97790. * lumen (lm)
  97791. */
  97792. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97793. /**
  97794. * candela (lm/sr)
  97795. */
  97796. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97797. /**
  97798. * lux (lm/m^2)
  97799. */
  97800. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97801. /**
  97802. * nit (cd/m^2)
  97803. */
  97804. static readonly INTENSITYMODE_LUMINANCE: number;
  97805. /**
  97806. * Light type const id of the point light.
  97807. */
  97808. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97809. /**
  97810. * Light type const id of the directional light.
  97811. */
  97812. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97813. /**
  97814. * Light type const id of the spot light.
  97815. */
  97816. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97817. /**
  97818. * Light type const id of the hemispheric light.
  97819. */
  97820. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97821. /**
  97822. * Diffuse gives the basic color to an object.
  97823. */
  97824. diffuse: Color3;
  97825. /**
  97826. * Specular produces a highlight color on an object.
  97827. * Note: This is note affecting PBR materials.
  97828. */
  97829. specular: Color3;
  97830. /**
  97831. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97832. * falling off base on range or angle.
  97833. * This can be set to any values in Light.FALLOFF_x.
  97834. *
  97835. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97836. * other types of materials.
  97837. */
  97838. falloffType: number;
  97839. /**
  97840. * Strength of the light.
  97841. * Note: By default it is define in the framework own unit.
  97842. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97843. */
  97844. intensity: number;
  97845. private _range;
  97846. protected _inverseSquaredRange: number;
  97847. /**
  97848. * Defines how far from the source the light is impacting in scene units.
  97849. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97850. */
  97851. get range(): number;
  97852. /**
  97853. * Defines how far from the source the light is impacting in scene units.
  97854. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97855. */
  97856. set range(value: number);
  97857. /**
  97858. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97859. * of light.
  97860. */
  97861. private _photometricScale;
  97862. private _intensityMode;
  97863. /**
  97864. * Gets the photometric scale used to interpret the intensity.
  97865. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97866. */
  97867. get intensityMode(): number;
  97868. /**
  97869. * Sets the photometric scale used to interpret the intensity.
  97870. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97871. */
  97872. set intensityMode(value: number);
  97873. private _radius;
  97874. /**
  97875. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97876. */
  97877. get radius(): number;
  97878. /**
  97879. * sets the light radius used by PBR Materials to simulate soft area lights.
  97880. */
  97881. set radius(value: number);
  97882. private _renderPriority;
  97883. /**
  97884. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  97885. * exceeding the number allowed of the materials.
  97886. */
  97887. renderPriority: number;
  97888. private _shadowEnabled;
  97889. /**
  97890. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97891. * the current shadow generator.
  97892. */
  97893. get shadowEnabled(): boolean;
  97894. /**
  97895. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97896. * the current shadow generator.
  97897. */
  97898. set shadowEnabled(value: boolean);
  97899. private _includedOnlyMeshes;
  97900. /**
  97901. * Gets the only meshes impacted by this light.
  97902. */
  97903. get includedOnlyMeshes(): AbstractMesh[];
  97904. /**
  97905. * Sets the only meshes impacted by this light.
  97906. */
  97907. set includedOnlyMeshes(value: AbstractMesh[]);
  97908. private _excludedMeshes;
  97909. /**
  97910. * Gets the meshes not impacted by this light.
  97911. */
  97912. get excludedMeshes(): AbstractMesh[];
  97913. /**
  97914. * Sets the meshes not impacted by this light.
  97915. */
  97916. set excludedMeshes(value: AbstractMesh[]);
  97917. private _excludeWithLayerMask;
  97918. /**
  97919. * Gets the layer id use to find what meshes are not impacted by the light.
  97920. * Inactive if 0
  97921. */
  97922. get excludeWithLayerMask(): number;
  97923. /**
  97924. * Sets the layer id use to find what meshes are not impacted by the light.
  97925. * Inactive if 0
  97926. */
  97927. set excludeWithLayerMask(value: number);
  97928. private _includeOnlyWithLayerMask;
  97929. /**
  97930. * Gets the layer id use to find what meshes are impacted by the light.
  97931. * Inactive if 0
  97932. */
  97933. get includeOnlyWithLayerMask(): number;
  97934. /**
  97935. * Sets the layer id use to find what meshes are impacted by the light.
  97936. * Inactive if 0
  97937. */
  97938. set includeOnlyWithLayerMask(value: number);
  97939. private _lightmapMode;
  97940. /**
  97941. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97942. */
  97943. get lightmapMode(): number;
  97944. /**
  97945. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97946. */
  97947. set lightmapMode(value: number);
  97948. /**
  97949. * Shadow generator associted to the light.
  97950. * @hidden Internal use only.
  97951. */
  97952. _shadowGenerator: Nullable<IShadowGenerator>;
  97953. /**
  97954. * @hidden Internal use only.
  97955. */
  97956. _excludedMeshesIds: string[];
  97957. /**
  97958. * @hidden Internal use only.
  97959. */
  97960. _includedOnlyMeshesIds: string[];
  97961. /**
  97962. * The current light unifom buffer.
  97963. * @hidden Internal use only.
  97964. */
  97965. _uniformBuffer: UniformBuffer;
  97966. /** @hidden */
  97967. _renderId: number;
  97968. /**
  97969. * Creates a Light object in the scene.
  97970. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97971. * @param name The firendly name of the light
  97972. * @param scene The scene the light belongs too
  97973. */
  97974. constructor(name: string, scene: Scene);
  97975. protected abstract _buildUniformLayout(): void;
  97976. /**
  97977. * Sets the passed Effect "effect" with the Light information.
  97978. * @param effect The effect to update
  97979. * @param lightIndex The index of the light in the effect to update
  97980. * @returns The light
  97981. */
  97982. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97983. /**
  97984. * Sets the passed Effect "effect" with the Light textures.
  97985. * @param effect The effect to update
  97986. * @param lightIndex The index of the light in the effect to update
  97987. * @returns The light
  97988. */
  97989. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  97990. /**
  97991. * Binds the lights information from the scene to the effect for the given mesh.
  97992. * @param lightIndex Light index
  97993. * @param scene The scene where the light belongs to
  97994. * @param effect The effect we are binding the data to
  97995. * @param useSpecular Defines if specular is supported
  97996. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97997. */
  97998. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97999. /**
  98000. * Sets the passed Effect "effect" with the Light information.
  98001. * @param effect The effect to update
  98002. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98003. * @returns The light
  98004. */
  98005. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98006. /**
  98007. * Returns the string "Light".
  98008. * @returns the class name
  98009. */
  98010. getClassName(): string;
  98011. /** @hidden */
  98012. readonly _isLight: boolean;
  98013. /**
  98014. * Converts the light information to a readable string for debug purpose.
  98015. * @param fullDetails Supports for multiple levels of logging within scene loading
  98016. * @returns the human readable light info
  98017. */
  98018. toString(fullDetails?: boolean): string;
  98019. /** @hidden */
  98020. protected _syncParentEnabledState(): void;
  98021. /**
  98022. * Set the enabled state of this node.
  98023. * @param value - the new enabled state
  98024. */
  98025. setEnabled(value: boolean): void;
  98026. /**
  98027. * Returns the Light associated shadow generator if any.
  98028. * @return the associated shadow generator.
  98029. */
  98030. getShadowGenerator(): Nullable<IShadowGenerator>;
  98031. /**
  98032. * Returns a Vector3, the absolute light position in the World.
  98033. * @returns the world space position of the light
  98034. */
  98035. getAbsolutePosition(): Vector3;
  98036. /**
  98037. * Specifies if the light will affect the passed mesh.
  98038. * @param mesh The mesh to test against the light
  98039. * @return true the mesh is affected otherwise, false.
  98040. */
  98041. canAffectMesh(mesh: AbstractMesh): boolean;
  98042. /**
  98043. * Sort function to order lights for rendering.
  98044. * @param a First Light object to compare to second.
  98045. * @param b Second Light object to compare first.
  98046. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98047. */
  98048. static CompareLightsPriority(a: Light, b: Light): number;
  98049. /**
  98050. * Releases resources associated with this node.
  98051. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98052. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98053. */
  98054. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98055. /**
  98056. * Returns the light type ID (integer).
  98057. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98058. */
  98059. getTypeID(): number;
  98060. /**
  98061. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98062. * @returns the scaled intensity in intensity mode unit
  98063. */
  98064. getScaledIntensity(): number;
  98065. /**
  98066. * Returns a new Light object, named "name", from the current one.
  98067. * @param name The name of the cloned light
  98068. * @param newParent The parent of this light, if it has one
  98069. * @returns the new created light
  98070. */
  98071. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98072. /**
  98073. * Serializes the current light into a Serialization object.
  98074. * @returns the serialized object.
  98075. */
  98076. serialize(): any;
  98077. /**
  98078. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98079. * This new light is named "name" and added to the passed scene.
  98080. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98081. * @param name The friendly name of the light
  98082. * @param scene The scene the new light will belong to
  98083. * @returns the constructor function
  98084. */
  98085. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98086. /**
  98087. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98088. * @param parsedLight The JSON representation of the light
  98089. * @param scene The scene to create the parsed light in
  98090. * @returns the created light after parsing
  98091. */
  98092. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98093. private _hookArrayForExcluded;
  98094. private _hookArrayForIncludedOnly;
  98095. private _resyncMeshes;
  98096. /**
  98097. * Forces the meshes to update their light related information in their rendering used effects
  98098. * @hidden Internal Use Only
  98099. */
  98100. _markMeshesAsLightDirty(): void;
  98101. /**
  98102. * Recomputes the cached photometric scale if needed.
  98103. */
  98104. private _computePhotometricScale;
  98105. /**
  98106. * Returns the Photometric Scale according to the light type and intensity mode.
  98107. */
  98108. private _getPhotometricScale;
  98109. /**
  98110. * Reorder the light in the scene according to their defined priority.
  98111. * @hidden Internal Use Only
  98112. */
  98113. _reorderLightsInScene(): void;
  98114. /**
  98115. * Prepares the list of defines specific to the light type.
  98116. * @param defines the list of defines
  98117. * @param lightIndex defines the index of the light for the effect
  98118. */
  98119. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98120. }
  98121. }
  98122. declare module BABYLON {
  98123. /**
  98124. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98125. * This is the base of the follow, arc rotate cameras and Free camera
  98126. * @see https://doc.babylonjs.com/features/cameras
  98127. */
  98128. export class TargetCamera extends Camera {
  98129. private static _RigCamTransformMatrix;
  98130. private static _TargetTransformMatrix;
  98131. private static _TargetFocalPoint;
  98132. private _tmpUpVector;
  98133. private _tmpTargetVector;
  98134. /**
  98135. * Define the current direction the camera is moving to
  98136. */
  98137. cameraDirection: Vector3;
  98138. /**
  98139. * Define the current rotation the camera is rotating to
  98140. */
  98141. cameraRotation: Vector2;
  98142. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98143. ignoreParentScaling: boolean;
  98144. /**
  98145. * When set, the up vector of the camera will be updated by the rotation of the camera
  98146. */
  98147. updateUpVectorFromRotation: boolean;
  98148. private _tmpQuaternion;
  98149. /**
  98150. * Define the current rotation of the camera
  98151. */
  98152. rotation: Vector3;
  98153. /**
  98154. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98155. */
  98156. rotationQuaternion: Quaternion;
  98157. /**
  98158. * Define the current speed of the camera
  98159. */
  98160. speed: number;
  98161. /**
  98162. * Add constraint to the camera to prevent it to move freely in all directions and
  98163. * around all axis.
  98164. */
  98165. noRotationConstraint: boolean;
  98166. /**
  98167. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98168. * panning
  98169. */
  98170. invertRotation: boolean;
  98171. /**
  98172. * Speed multiplier for inverse camera panning
  98173. */
  98174. inverseRotationSpeed: number;
  98175. /**
  98176. * Define the current target of the camera as an object or a position.
  98177. */
  98178. lockedTarget: any;
  98179. /** @hidden */
  98180. _currentTarget: Vector3;
  98181. /** @hidden */
  98182. _initialFocalDistance: number;
  98183. /** @hidden */
  98184. _viewMatrix: Matrix;
  98185. /** @hidden */
  98186. _camMatrix: Matrix;
  98187. /** @hidden */
  98188. _cameraTransformMatrix: Matrix;
  98189. /** @hidden */
  98190. _cameraRotationMatrix: Matrix;
  98191. /** @hidden */
  98192. _referencePoint: Vector3;
  98193. /** @hidden */
  98194. _transformedReferencePoint: Vector3;
  98195. /** @hidden */
  98196. _reset: () => void;
  98197. private _defaultUp;
  98198. /**
  98199. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98200. * This is the base of the follow, arc rotate cameras and Free camera
  98201. * @see https://doc.babylonjs.com/features/cameras
  98202. * @param name Defines the name of the camera in the scene
  98203. * @param position Defines the start position of the camera in the scene
  98204. * @param scene Defines the scene the camera belongs to
  98205. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98206. */
  98207. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98208. /**
  98209. * Gets the position in front of the camera at a given distance.
  98210. * @param distance The distance from the camera we want the position to be
  98211. * @returns the position
  98212. */
  98213. getFrontPosition(distance: number): Vector3;
  98214. /** @hidden */
  98215. _getLockedTargetPosition(): Nullable<Vector3>;
  98216. private _storedPosition;
  98217. private _storedRotation;
  98218. private _storedRotationQuaternion;
  98219. /**
  98220. * Store current camera state of the camera (fov, position, rotation, etc..)
  98221. * @returns the camera
  98222. */
  98223. storeState(): Camera;
  98224. /**
  98225. * Restored camera state. You must call storeState() first
  98226. * @returns whether it was successful or not
  98227. * @hidden
  98228. */
  98229. _restoreStateValues(): boolean;
  98230. /** @hidden */
  98231. _initCache(): void;
  98232. /** @hidden */
  98233. _updateCache(ignoreParentClass?: boolean): void;
  98234. /** @hidden */
  98235. _isSynchronizedViewMatrix(): boolean;
  98236. /** @hidden */
  98237. _computeLocalCameraSpeed(): number;
  98238. /**
  98239. * Defines the target the camera should look at.
  98240. * @param target Defines the new target as a Vector or a mesh
  98241. */
  98242. setTarget(target: Vector3): void;
  98243. /**
  98244. * Defines the target point of the camera.
  98245. * The camera looks towards it form the radius distance.
  98246. */
  98247. get target(): Vector3;
  98248. set target(value: Vector3);
  98249. /**
  98250. * Return the current target position of the camera. This value is expressed in local space.
  98251. * @returns the target position
  98252. */
  98253. getTarget(): Vector3;
  98254. /** @hidden */
  98255. _decideIfNeedsToMove(): boolean;
  98256. /** @hidden */
  98257. _updatePosition(): void;
  98258. /** @hidden */
  98259. _checkInputs(): void;
  98260. protected _updateCameraRotationMatrix(): void;
  98261. /**
  98262. * 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)
  98263. * @returns the current camera
  98264. */
  98265. private _rotateUpVectorWithCameraRotationMatrix;
  98266. private _cachedRotationZ;
  98267. private _cachedQuaternionRotationZ;
  98268. /** @hidden */
  98269. _getViewMatrix(): Matrix;
  98270. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98271. /**
  98272. * @hidden
  98273. */
  98274. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98275. /**
  98276. * @hidden
  98277. */
  98278. _updateRigCameras(): void;
  98279. private _getRigCamPositionAndTarget;
  98280. /**
  98281. * Gets the current object class name.
  98282. * @return the class name
  98283. */
  98284. getClassName(): string;
  98285. }
  98286. }
  98287. declare module BABYLON {
  98288. /**
  98289. * Gather the list of keyboard event types as constants.
  98290. */
  98291. export class KeyboardEventTypes {
  98292. /**
  98293. * The keydown event is fired when a key becomes active (pressed).
  98294. */
  98295. static readonly KEYDOWN: number;
  98296. /**
  98297. * The keyup event is fired when a key has been released.
  98298. */
  98299. static readonly KEYUP: number;
  98300. }
  98301. /**
  98302. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98303. */
  98304. export class KeyboardInfo {
  98305. /**
  98306. * Defines the type of event (KeyboardEventTypes)
  98307. */
  98308. type: number;
  98309. /**
  98310. * Defines the related dom event
  98311. */
  98312. event: KeyboardEvent;
  98313. /**
  98314. * Instantiates a new keyboard info.
  98315. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98316. * @param type Defines the type of event (KeyboardEventTypes)
  98317. * @param event Defines the related dom event
  98318. */
  98319. constructor(
  98320. /**
  98321. * Defines the type of event (KeyboardEventTypes)
  98322. */
  98323. type: number,
  98324. /**
  98325. * Defines the related dom event
  98326. */
  98327. event: KeyboardEvent);
  98328. }
  98329. /**
  98330. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98331. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98332. */
  98333. export class KeyboardInfoPre extends KeyboardInfo {
  98334. /**
  98335. * Defines the type of event (KeyboardEventTypes)
  98336. */
  98337. type: number;
  98338. /**
  98339. * Defines the related dom event
  98340. */
  98341. event: KeyboardEvent;
  98342. /**
  98343. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98344. */
  98345. skipOnPointerObservable: boolean;
  98346. /**
  98347. * Instantiates a new keyboard pre info.
  98348. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98349. * @param type Defines the type of event (KeyboardEventTypes)
  98350. * @param event Defines the related dom event
  98351. */
  98352. constructor(
  98353. /**
  98354. * Defines the type of event (KeyboardEventTypes)
  98355. */
  98356. type: number,
  98357. /**
  98358. * Defines the related dom event
  98359. */
  98360. event: KeyboardEvent);
  98361. }
  98362. }
  98363. declare module BABYLON {
  98364. /**
  98365. * Manage the keyboard inputs to control the movement of a free camera.
  98366. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98367. */
  98368. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98369. /**
  98370. * Defines the camera the input is attached to.
  98371. */
  98372. camera: FreeCamera;
  98373. /**
  98374. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98375. */
  98376. keysUp: number[];
  98377. /**
  98378. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98379. */
  98380. keysUpward: number[];
  98381. /**
  98382. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98383. */
  98384. keysDown: number[];
  98385. /**
  98386. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98387. */
  98388. keysDownward: number[];
  98389. /**
  98390. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98391. */
  98392. keysLeft: number[];
  98393. /**
  98394. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98395. */
  98396. keysRight: number[];
  98397. private _keys;
  98398. private _onCanvasBlurObserver;
  98399. private _onKeyboardObserver;
  98400. private _engine;
  98401. private _scene;
  98402. /**
  98403. * Attach the input controls to a specific dom element to get the input from.
  98404. * @param element Defines the element the controls should be listened from
  98405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98406. */
  98407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98408. /**
  98409. * Detach the current controls from the specified dom element.
  98410. * @param element Defines the element to stop listening the inputs from
  98411. */
  98412. detachControl(element: Nullable<HTMLElement>): void;
  98413. /**
  98414. * Update the current camera state depending on the inputs that have been used this frame.
  98415. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98416. */
  98417. checkInputs(): void;
  98418. /**
  98419. * Gets the class name of the current intput.
  98420. * @returns the class name
  98421. */
  98422. getClassName(): string;
  98423. /** @hidden */
  98424. _onLostFocus(): void;
  98425. /**
  98426. * Get the friendly name associated with the input class.
  98427. * @returns the input friendly name
  98428. */
  98429. getSimpleName(): string;
  98430. }
  98431. }
  98432. declare module BABYLON {
  98433. /**
  98434. * Gather the list of pointer event types as constants.
  98435. */
  98436. export class PointerEventTypes {
  98437. /**
  98438. * 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.
  98439. */
  98440. static readonly POINTERDOWN: number;
  98441. /**
  98442. * The pointerup event is fired when a pointer is no longer active.
  98443. */
  98444. static readonly POINTERUP: number;
  98445. /**
  98446. * The pointermove event is fired when a pointer changes coordinates.
  98447. */
  98448. static readonly POINTERMOVE: number;
  98449. /**
  98450. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98451. */
  98452. static readonly POINTERWHEEL: number;
  98453. /**
  98454. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98455. */
  98456. static readonly POINTERPICK: number;
  98457. /**
  98458. * The pointertap event is fired when a the object has been touched and released without drag.
  98459. */
  98460. static readonly POINTERTAP: number;
  98461. /**
  98462. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  98463. */
  98464. static readonly POINTERDOUBLETAP: number;
  98465. }
  98466. /**
  98467. * Base class of pointer info types.
  98468. */
  98469. export class PointerInfoBase {
  98470. /**
  98471. * Defines the type of event (PointerEventTypes)
  98472. */
  98473. type: number;
  98474. /**
  98475. * Defines the related dom event
  98476. */
  98477. event: PointerEvent | MouseWheelEvent;
  98478. /**
  98479. * Instantiates the base class of pointers info.
  98480. * @param type Defines the type of event (PointerEventTypes)
  98481. * @param event Defines the related dom event
  98482. */
  98483. constructor(
  98484. /**
  98485. * Defines the type of event (PointerEventTypes)
  98486. */
  98487. type: number,
  98488. /**
  98489. * Defines the related dom event
  98490. */
  98491. event: PointerEvent | MouseWheelEvent);
  98492. }
  98493. /**
  98494. * This class is used to store pointer related info for the onPrePointerObservable event.
  98495. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  98496. */
  98497. export class PointerInfoPre extends PointerInfoBase {
  98498. /**
  98499. * Ray from a pointer if availible (eg. 6dof controller)
  98500. */
  98501. ray: Nullable<Ray>;
  98502. /**
  98503. * Defines the local position of the pointer on the canvas.
  98504. */
  98505. localPosition: Vector2;
  98506. /**
  98507. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  98508. */
  98509. skipOnPointerObservable: boolean;
  98510. /**
  98511. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98512. * @param type Defines the type of event (PointerEventTypes)
  98513. * @param event Defines the related dom event
  98514. * @param localX Defines the local x coordinates of the pointer when the event occured
  98515. * @param localY Defines the local y coordinates of the pointer when the event occured
  98516. */
  98517. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98518. }
  98519. /**
  98520. * This type contains all the data related to a pointer event in Babylon.js.
  98521. * 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.
  98522. */
  98523. export class PointerInfo extends PointerInfoBase {
  98524. /**
  98525. * Defines the picking info associated to the info (if any)\
  98526. */
  98527. pickInfo: Nullable<PickingInfo>;
  98528. /**
  98529. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98530. * @param type Defines the type of event (PointerEventTypes)
  98531. * @param event Defines the related dom event
  98532. * @param pickInfo Defines the picking info associated to the info (if any)\
  98533. */
  98534. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98535. /**
  98536. * Defines the picking info associated to the info (if any)\
  98537. */
  98538. pickInfo: Nullable<PickingInfo>);
  98539. }
  98540. /**
  98541. * Data relating to a touch event on the screen.
  98542. */
  98543. export interface PointerTouch {
  98544. /**
  98545. * X coordinate of touch.
  98546. */
  98547. x: number;
  98548. /**
  98549. * Y coordinate of touch.
  98550. */
  98551. y: number;
  98552. /**
  98553. * Id of touch. Unique for each finger.
  98554. */
  98555. pointerId: number;
  98556. /**
  98557. * Event type passed from DOM.
  98558. */
  98559. type: any;
  98560. }
  98561. }
  98562. declare module BABYLON {
  98563. /**
  98564. * Manage the mouse inputs to control the movement of a free camera.
  98565. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98566. */
  98567. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98568. /**
  98569. * Define if touch is enabled in the mouse input
  98570. */
  98571. touchEnabled: boolean;
  98572. /**
  98573. * Defines the camera the input is attached to.
  98574. */
  98575. camera: FreeCamera;
  98576. /**
  98577. * Defines the buttons associated with the input to handle camera move.
  98578. */
  98579. buttons: number[];
  98580. /**
  98581. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98582. */
  98583. angularSensibility: number;
  98584. private _pointerInput;
  98585. private _onMouseMove;
  98586. private _observer;
  98587. private previousPosition;
  98588. /**
  98589. * Observable for when a pointer move event occurs containing the move offset
  98590. */
  98591. onPointerMovedObservable: Observable<{
  98592. offsetX: number;
  98593. offsetY: number;
  98594. }>;
  98595. /**
  98596. * @hidden
  98597. * If the camera should be rotated automatically based on pointer movement
  98598. */
  98599. _allowCameraRotation: boolean;
  98600. /**
  98601. * Manage the mouse inputs to control the movement of a free camera.
  98602. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98603. * @param touchEnabled Defines if touch is enabled or not
  98604. */
  98605. constructor(
  98606. /**
  98607. * Define if touch is enabled in the mouse input
  98608. */
  98609. touchEnabled?: boolean);
  98610. /**
  98611. * Attach the input controls to a specific dom element to get the input from.
  98612. * @param element Defines the element the controls should be listened from
  98613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98614. */
  98615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98616. /**
  98617. * Called on JS contextmenu event.
  98618. * Override this method to provide functionality.
  98619. */
  98620. protected onContextMenu(evt: PointerEvent): void;
  98621. /**
  98622. * Detach the current controls from the specified dom element.
  98623. * @param element Defines the element to stop listening the inputs from
  98624. */
  98625. detachControl(element: Nullable<HTMLElement>): void;
  98626. /**
  98627. * Gets the class name of the current intput.
  98628. * @returns the class name
  98629. */
  98630. getClassName(): string;
  98631. /**
  98632. * Get the friendly name associated with the input class.
  98633. * @returns the input friendly name
  98634. */
  98635. getSimpleName(): string;
  98636. }
  98637. }
  98638. declare module BABYLON {
  98639. /**
  98640. * Manage the touch inputs to control the movement of a free camera.
  98641. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98642. */
  98643. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98644. /**
  98645. * Define if mouse events can be treated as touch events
  98646. */
  98647. allowMouse: boolean;
  98648. /**
  98649. * Defines the camera the input is attached to.
  98650. */
  98651. camera: FreeCamera;
  98652. /**
  98653. * Defines the touch sensibility for rotation.
  98654. * The higher the faster.
  98655. */
  98656. touchAngularSensibility: number;
  98657. /**
  98658. * Defines the touch sensibility for move.
  98659. * The higher the faster.
  98660. */
  98661. touchMoveSensibility: number;
  98662. private _offsetX;
  98663. private _offsetY;
  98664. private _pointerPressed;
  98665. private _pointerInput;
  98666. private _observer;
  98667. private _onLostFocus;
  98668. /**
  98669. * Manage the touch inputs to control the movement of a free camera.
  98670. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98671. * @param allowMouse Defines if mouse events can be treated as touch events
  98672. */
  98673. constructor(
  98674. /**
  98675. * Define if mouse events can be treated as touch events
  98676. */
  98677. allowMouse?: boolean);
  98678. /**
  98679. * Attach the input controls to a specific dom element to get the input from.
  98680. * @param element Defines the element the controls should be listened from
  98681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98682. */
  98683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98684. /**
  98685. * Detach the current controls from the specified dom element.
  98686. * @param element Defines the element to stop listening the inputs from
  98687. */
  98688. detachControl(element: Nullable<HTMLElement>): void;
  98689. /**
  98690. * Update the current camera state depending on the inputs that have been used this frame.
  98691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98692. */
  98693. checkInputs(): void;
  98694. /**
  98695. * Gets the class name of the current intput.
  98696. * @returns the class name
  98697. */
  98698. getClassName(): string;
  98699. /**
  98700. * Get the friendly name associated with the input class.
  98701. * @returns the input friendly name
  98702. */
  98703. getSimpleName(): string;
  98704. }
  98705. }
  98706. declare module BABYLON {
  98707. /**
  98708. * Default Inputs manager for the FreeCamera.
  98709. * It groups all the default supported inputs for ease of use.
  98710. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98711. */
  98712. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98713. /**
  98714. * @hidden
  98715. */
  98716. _mouseInput: Nullable<FreeCameraMouseInput>;
  98717. /**
  98718. * Instantiates a new FreeCameraInputsManager.
  98719. * @param camera Defines the camera the inputs belong to
  98720. */
  98721. constructor(camera: FreeCamera);
  98722. /**
  98723. * Add keyboard input support to the input manager.
  98724. * @returns the current input manager
  98725. */
  98726. addKeyboard(): FreeCameraInputsManager;
  98727. /**
  98728. * Add mouse input support to the input manager.
  98729. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98730. * @returns the current input manager
  98731. */
  98732. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98733. /**
  98734. * Removes the mouse input support from the manager
  98735. * @returns the current input manager
  98736. */
  98737. removeMouse(): FreeCameraInputsManager;
  98738. /**
  98739. * Add touch input support to the input manager.
  98740. * @returns the current input manager
  98741. */
  98742. addTouch(): FreeCameraInputsManager;
  98743. /**
  98744. * Remove all attached input methods from a camera
  98745. */
  98746. clear(): void;
  98747. }
  98748. }
  98749. declare module BABYLON {
  98750. /**
  98751. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98752. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98753. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98754. */
  98755. export class FreeCamera extends TargetCamera {
  98756. /**
  98757. * Define the collision ellipsoid of the camera.
  98758. * This is helpful to simulate a camera body like the player body around the camera
  98759. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98760. */
  98761. ellipsoid: Vector3;
  98762. /**
  98763. * Define an offset for the position of the ellipsoid around the camera.
  98764. * This can be helpful to determine the center of the body near the gravity center of the body
  98765. * instead of its head.
  98766. */
  98767. ellipsoidOffset: Vector3;
  98768. /**
  98769. * Enable or disable collisions of the camera with the rest of the scene objects.
  98770. */
  98771. checkCollisions: boolean;
  98772. /**
  98773. * Enable or disable gravity on the camera.
  98774. */
  98775. applyGravity: boolean;
  98776. /**
  98777. * Define the input manager associated to the camera.
  98778. */
  98779. inputs: FreeCameraInputsManager;
  98780. /**
  98781. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98782. * Higher values reduce sensitivity.
  98783. */
  98784. get angularSensibility(): number;
  98785. /**
  98786. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98787. * Higher values reduce sensitivity.
  98788. */
  98789. set angularSensibility(value: number);
  98790. /**
  98791. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98792. */
  98793. get keysUp(): number[];
  98794. set keysUp(value: number[]);
  98795. /**
  98796. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98797. */
  98798. get keysUpward(): number[];
  98799. set keysUpward(value: number[]);
  98800. /**
  98801. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98802. */
  98803. get keysDown(): number[];
  98804. set keysDown(value: number[]);
  98805. /**
  98806. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98807. */
  98808. get keysDownward(): number[];
  98809. set keysDownward(value: number[]);
  98810. /**
  98811. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98812. */
  98813. get keysLeft(): number[];
  98814. set keysLeft(value: number[]);
  98815. /**
  98816. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98817. */
  98818. get keysRight(): number[];
  98819. set keysRight(value: number[]);
  98820. /**
  98821. * Event raised when the camera collide with a mesh in the scene.
  98822. */
  98823. onCollide: (collidedMesh: AbstractMesh) => void;
  98824. private _collider;
  98825. private _needMoveForGravity;
  98826. private _oldPosition;
  98827. private _diffPosition;
  98828. private _newPosition;
  98829. /** @hidden */
  98830. _localDirection: Vector3;
  98831. /** @hidden */
  98832. _transformedDirection: Vector3;
  98833. /**
  98834. * Instantiates a Free Camera.
  98835. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98836. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98837. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98838. * @param name Define the name of the camera in the scene
  98839. * @param position Define the start position of the camera in the scene
  98840. * @param scene Define the scene the camera belongs to
  98841. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98842. */
  98843. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98844. /**
  98845. * Attached controls to the current camera.
  98846. * @param element Defines the element the controls should be listened from
  98847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98848. */
  98849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98850. /**
  98851. * Detach the current controls from the camera.
  98852. * The camera will stop reacting to inputs.
  98853. * @param element Defines the element to stop listening the inputs from
  98854. */
  98855. detachControl(element: HTMLElement): void;
  98856. private _collisionMask;
  98857. /**
  98858. * Define a collision mask to limit the list of object the camera can collide with
  98859. */
  98860. get collisionMask(): number;
  98861. set collisionMask(mask: number);
  98862. /** @hidden */
  98863. _collideWithWorld(displacement: Vector3): void;
  98864. private _onCollisionPositionChange;
  98865. /** @hidden */
  98866. _checkInputs(): void;
  98867. /** @hidden */
  98868. _decideIfNeedsToMove(): boolean;
  98869. /** @hidden */
  98870. _updatePosition(): void;
  98871. /**
  98872. * Destroy the camera and release the current resources hold by it.
  98873. */
  98874. dispose(): void;
  98875. /**
  98876. * Gets the current object class name.
  98877. * @return the class name
  98878. */
  98879. getClassName(): string;
  98880. }
  98881. }
  98882. declare module BABYLON {
  98883. /**
  98884. * Represents a gamepad control stick position
  98885. */
  98886. export class StickValues {
  98887. /**
  98888. * The x component of the control stick
  98889. */
  98890. x: number;
  98891. /**
  98892. * The y component of the control stick
  98893. */
  98894. y: number;
  98895. /**
  98896. * Initializes the gamepad x and y control stick values
  98897. * @param x The x component of the gamepad control stick value
  98898. * @param y The y component of the gamepad control stick value
  98899. */
  98900. constructor(
  98901. /**
  98902. * The x component of the control stick
  98903. */
  98904. x: number,
  98905. /**
  98906. * The y component of the control stick
  98907. */
  98908. y: number);
  98909. }
  98910. /**
  98911. * An interface which manages callbacks for gamepad button changes
  98912. */
  98913. export interface GamepadButtonChanges {
  98914. /**
  98915. * Called when a gamepad has been changed
  98916. */
  98917. changed: boolean;
  98918. /**
  98919. * Called when a gamepad press event has been triggered
  98920. */
  98921. pressChanged: boolean;
  98922. /**
  98923. * Called when a touch event has been triggered
  98924. */
  98925. touchChanged: boolean;
  98926. /**
  98927. * Called when a value has changed
  98928. */
  98929. valueChanged: boolean;
  98930. }
  98931. /**
  98932. * Represents a gamepad
  98933. */
  98934. export class Gamepad {
  98935. /**
  98936. * The id of the gamepad
  98937. */
  98938. id: string;
  98939. /**
  98940. * The index of the gamepad
  98941. */
  98942. index: number;
  98943. /**
  98944. * The browser gamepad
  98945. */
  98946. browserGamepad: any;
  98947. /**
  98948. * Specifies what type of gamepad this represents
  98949. */
  98950. type: number;
  98951. private _leftStick;
  98952. private _rightStick;
  98953. /** @hidden */
  98954. _isConnected: boolean;
  98955. private _leftStickAxisX;
  98956. private _leftStickAxisY;
  98957. private _rightStickAxisX;
  98958. private _rightStickAxisY;
  98959. /**
  98960. * Triggered when the left control stick has been changed
  98961. */
  98962. private _onleftstickchanged;
  98963. /**
  98964. * Triggered when the right control stick has been changed
  98965. */
  98966. private _onrightstickchanged;
  98967. /**
  98968. * Represents a gamepad controller
  98969. */
  98970. static GAMEPAD: number;
  98971. /**
  98972. * Represents a generic controller
  98973. */
  98974. static GENERIC: number;
  98975. /**
  98976. * Represents an XBox controller
  98977. */
  98978. static XBOX: number;
  98979. /**
  98980. * Represents a pose-enabled controller
  98981. */
  98982. static POSE_ENABLED: number;
  98983. /**
  98984. * Represents an Dual Shock controller
  98985. */
  98986. static DUALSHOCK: number;
  98987. /**
  98988. * Specifies whether the left control stick should be Y-inverted
  98989. */
  98990. protected _invertLeftStickY: boolean;
  98991. /**
  98992. * Specifies if the gamepad has been connected
  98993. */
  98994. get isConnected(): boolean;
  98995. /**
  98996. * Initializes the gamepad
  98997. * @param id The id of the gamepad
  98998. * @param index The index of the gamepad
  98999. * @param browserGamepad The browser gamepad
  99000. * @param leftStickX The x component of the left joystick
  99001. * @param leftStickY The y component of the left joystick
  99002. * @param rightStickX The x component of the right joystick
  99003. * @param rightStickY The y component of the right joystick
  99004. */
  99005. constructor(
  99006. /**
  99007. * The id of the gamepad
  99008. */
  99009. id: string,
  99010. /**
  99011. * The index of the gamepad
  99012. */
  99013. index: number,
  99014. /**
  99015. * The browser gamepad
  99016. */
  99017. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99018. /**
  99019. * Callback triggered when the left joystick has changed
  99020. * @param callback
  99021. */
  99022. onleftstickchanged(callback: (values: StickValues) => void): void;
  99023. /**
  99024. * Callback triggered when the right joystick has changed
  99025. * @param callback
  99026. */
  99027. onrightstickchanged(callback: (values: StickValues) => void): void;
  99028. /**
  99029. * Gets the left joystick
  99030. */
  99031. get leftStick(): StickValues;
  99032. /**
  99033. * Sets the left joystick values
  99034. */
  99035. set leftStick(newValues: StickValues);
  99036. /**
  99037. * Gets the right joystick
  99038. */
  99039. get rightStick(): StickValues;
  99040. /**
  99041. * Sets the right joystick value
  99042. */
  99043. set rightStick(newValues: StickValues);
  99044. /**
  99045. * Updates the gamepad joystick positions
  99046. */
  99047. update(): void;
  99048. /**
  99049. * Disposes the gamepad
  99050. */
  99051. dispose(): void;
  99052. }
  99053. /**
  99054. * Represents a generic gamepad
  99055. */
  99056. export class GenericPad extends Gamepad {
  99057. private _buttons;
  99058. private _onbuttondown;
  99059. private _onbuttonup;
  99060. /**
  99061. * Observable triggered when a button has been pressed
  99062. */
  99063. onButtonDownObservable: Observable<number>;
  99064. /**
  99065. * Observable triggered when a button has been released
  99066. */
  99067. onButtonUpObservable: Observable<number>;
  99068. /**
  99069. * Callback triggered when a button has been pressed
  99070. * @param callback Called when a button has been pressed
  99071. */
  99072. onbuttondown(callback: (buttonPressed: number) => void): void;
  99073. /**
  99074. * Callback triggered when a button has been released
  99075. * @param callback Called when a button has been released
  99076. */
  99077. onbuttonup(callback: (buttonReleased: number) => void): void;
  99078. /**
  99079. * Initializes the generic gamepad
  99080. * @param id The id of the generic gamepad
  99081. * @param index The index of the generic gamepad
  99082. * @param browserGamepad The browser gamepad
  99083. */
  99084. constructor(id: string, index: number, browserGamepad: any);
  99085. private _setButtonValue;
  99086. /**
  99087. * Updates the generic gamepad
  99088. */
  99089. update(): void;
  99090. /**
  99091. * Disposes the generic gamepad
  99092. */
  99093. dispose(): void;
  99094. }
  99095. }
  99096. declare module BABYLON {
  99097. /**
  99098. * Defines the types of pose enabled controllers that are supported
  99099. */
  99100. export enum PoseEnabledControllerType {
  99101. /**
  99102. * HTC Vive
  99103. */
  99104. VIVE = 0,
  99105. /**
  99106. * Oculus Rift
  99107. */
  99108. OCULUS = 1,
  99109. /**
  99110. * Windows mixed reality
  99111. */
  99112. WINDOWS = 2,
  99113. /**
  99114. * Samsung gear VR
  99115. */
  99116. GEAR_VR = 3,
  99117. /**
  99118. * Google Daydream
  99119. */
  99120. DAYDREAM = 4,
  99121. /**
  99122. * Generic
  99123. */
  99124. GENERIC = 5
  99125. }
  99126. /**
  99127. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99128. */
  99129. export interface MutableGamepadButton {
  99130. /**
  99131. * Value of the button/trigger
  99132. */
  99133. value: number;
  99134. /**
  99135. * If the button/trigger is currently touched
  99136. */
  99137. touched: boolean;
  99138. /**
  99139. * If the button/trigger is currently pressed
  99140. */
  99141. pressed: boolean;
  99142. }
  99143. /**
  99144. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99145. * @hidden
  99146. */
  99147. export interface ExtendedGamepadButton extends GamepadButton {
  99148. /**
  99149. * If the button/trigger is currently pressed
  99150. */
  99151. readonly pressed: boolean;
  99152. /**
  99153. * If the button/trigger is currently touched
  99154. */
  99155. readonly touched: boolean;
  99156. /**
  99157. * Value of the button/trigger
  99158. */
  99159. readonly value: number;
  99160. }
  99161. /** @hidden */
  99162. export interface _GamePadFactory {
  99163. /**
  99164. * Returns whether or not the current gamepad can be created for this type of controller.
  99165. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99166. * @returns true if it can be created, otherwise false
  99167. */
  99168. canCreate(gamepadInfo: any): boolean;
  99169. /**
  99170. * Creates a new instance of the Gamepad.
  99171. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99172. * @returns the new gamepad instance
  99173. */
  99174. create(gamepadInfo: any): Gamepad;
  99175. }
  99176. /**
  99177. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99178. */
  99179. export class PoseEnabledControllerHelper {
  99180. /** @hidden */
  99181. static _ControllerFactories: _GamePadFactory[];
  99182. /** @hidden */
  99183. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99184. /**
  99185. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99186. * @param vrGamepad the gamepad to initialized
  99187. * @returns a vr controller of the type the gamepad identified as
  99188. */
  99189. static InitiateController(vrGamepad: any): Gamepad;
  99190. }
  99191. /**
  99192. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99193. */
  99194. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99195. /**
  99196. * If the controller is used in a webXR session
  99197. */
  99198. isXR: boolean;
  99199. private _deviceRoomPosition;
  99200. private _deviceRoomRotationQuaternion;
  99201. /**
  99202. * The device position in babylon space
  99203. */
  99204. devicePosition: Vector3;
  99205. /**
  99206. * The device rotation in babylon space
  99207. */
  99208. deviceRotationQuaternion: Quaternion;
  99209. /**
  99210. * The scale factor of the device in babylon space
  99211. */
  99212. deviceScaleFactor: number;
  99213. /**
  99214. * (Likely devicePosition should be used instead) The device position in its room space
  99215. */
  99216. position: Vector3;
  99217. /**
  99218. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99219. */
  99220. rotationQuaternion: Quaternion;
  99221. /**
  99222. * The type of controller (Eg. Windows mixed reality)
  99223. */
  99224. controllerType: PoseEnabledControllerType;
  99225. protected _calculatedPosition: Vector3;
  99226. private _calculatedRotation;
  99227. /**
  99228. * The raw pose from the device
  99229. */
  99230. rawPose: DevicePose;
  99231. private _trackPosition;
  99232. private _maxRotationDistFromHeadset;
  99233. private _draggedRoomRotation;
  99234. /**
  99235. * @hidden
  99236. */
  99237. _disableTrackPosition(fixedPosition: Vector3): void;
  99238. /**
  99239. * Internal, the mesh attached to the controller
  99240. * @hidden
  99241. */
  99242. _mesh: Nullable<AbstractMesh>;
  99243. private _poseControlledCamera;
  99244. private _leftHandSystemQuaternion;
  99245. /**
  99246. * Internal, matrix used to convert room space to babylon space
  99247. * @hidden
  99248. */
  99249. _deviceToWorld: Matrix;
  99250. /**
  99251. * Node to be used when casting a ray from the controller
  99252. * @hidden
  99253. */
  99254. _pointingPoseNode: Nullable<TransformNode>;
  99255. /**
  99256. * Name of the child mesh that can be used to cast a ray from the controller
  99257. */
  99258. static readonly POINTING_POSE: string;
  99259. /**
  99260. * Creates a new PoseEnabledController from a gamepad
  99261. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99262. */
  99263. constructor(browserGamepad: any);
  99264. private _workingMatrix;
  99265. /**
  99266. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99267. */
  99268. update(): void;
  99269. /**
  99270. * Updates only the pose device and mesh without doing any button event checking
  99271. */
  99272. protected _updatePoseAndMesh(): void;
  99273. /**
  99274. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99275. * @param poseData raw pose fromthe device
  99276. */
  99277. updateFromDevice(poseData: DevicePose): void;
  99278. /**
  99279. * @hidden
  99280. */
  99281. _meshAttachedObservable: Observable<AbstractMesh>;
  99282. /**
  99283. * Attaches a mesh to the controller
  99284. * @param mesh the mesh to be attached
  99285. */
  99286. attachToMesh(mesh: AbstractMesh): void;
  99287. /**
  99288. * Attaches the controllers mesh to a camera
  99289. * @param camera the camera the mesh should be attached to
  99290. */
  99291. attachToPoseControlledCamera(camera: TargetCamera): void;
  99292. /**
  99293. * Disposes of the controller
  99294. */
  99295. dispose(): void;
  99296. /**
  99297. * The mesh that is attached to the controller
  99298. */
  99299. get mesh(): Nullable<AbstractMesh>;
  99300. /**
  99301. * Gets the ray of the controller in the direction the controller is pointing
  99302. * @param length the length the resulting ray should be
  99303. * @returns a ray in the direction the controller is pointing
  99304. */
  99305. getForwardRay(length?: number): Ray;
  99306. }
  99307. }
  99308. declare module BABYLON {
  99309. /**
  99310. * Defines the WebVRController object that represents controllers tracked in 3D space
  99311. */
  99312. export abstract class WebVRController extends PoseEnabledController {
  99313. /**
  99314. * Internal, the default controller model for the controller
  99315. */
  99316. protected _defaultModel: Nullable<AbstractMesh>;
  99317. /**
  99318. * Fired when the trigger state has changed
  99319. */
  99320. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99321. /**
  99322. * Fired when the main button state has changed
  99323. */
  99324. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99325. /**
  99326. * Fired when the secondary button state has changed
  99327. */
  99328. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99329. /**
  99330. * Fired when the pad state has changed
  99331. */
  99332. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99333. /**
  99334. * Fired when controllers stick values have changed
  99335. */
  99336. onPadValuesChangedObservable: Observable<StickValues>;
  99337. /**
  99338. * Array of button availible on the controller
  99339. */
  99340. protected _buttons: Array<MutableGamepadButton>;
  99341. private _onButtonStateChange;
  99342. /**
  99343. * Fired when a controller button's state has changed
  99344. * @param callback the callback containing the button that was modified
  99345. */
  99346. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99347. /**
  99348. * X and Y axis corresponding to the controllers joystick
  99349. */
  99350. pad: StickValues;
  99351. /**
  99352. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99353. */
  99354. hand: string;
  99355. /**
  99356. * The default controller model for the controller
  99357. */
  99358. get defaultModel(): Nullable<AbstractMesh>;
  99359. /**
  99360. * Creates a new WebVRController from a gamepad
  99361. * @param vrGamepad the gamepad that the WebVRController should be created from
  99362. */
  99363. constructor(vrGamepad: any);
  99364. /**
  99365. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99366. */
  99367. update(): void;
  99368. /**
  99369. * Function to be called when a button is modified
  99370. */
  99371. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99372. /**
  99373. * Loads a mesh and attaches it to the controller
  99374. * @param scene the scene the mesh should be added to
  99375. * @param meshLoaded callback for when the mesh has been loaded
  99376. */
  99377. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99378. private _setButtonValue;
  99379. private _changes;
  99380. private _checkChanges;
  99381. /**
  99382. * Disposes of th webVRCOntroller
  99383. */
  99384. dispose(): void;
  99385. }
  99386. }
  99387. declare module BABYLON {
  99388. /**
  99389. * The HemisphericLight simulates the ambient environment light,
  99390. * so the passed direction is the light reflection direction, not the incoming direction.
  99391. */
  99392. export class HemisphericLight extends Light {
  99393. /**
  99394. * The groundColor is the light in the opposite direction to the one specified during creation.
  99395. * 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.
  99396. */
  99397. groundColor: Color3;
  99398. /**
  99399. * The light reflection direction, not the incoming direction.
  99400. */
  99401. direction: Vector3;
  99402. /**
  99403. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99404. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99405. * The HemisphericLight can't cast shadows.
  99406. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99407. * @param name The friendly name of the light
  99408. * @param direction The direction of the light reflection
  99409. * @param scene The scene the light belongs to
  99410. */
  99411. constructor(name: string, direction: Vector3, scene: Scene);
  99412. protected _buildUniformLayout(): void;
  99413. /**
  99414. * Returns the string "HemisphericLight".
  99415. * @return The class name
  99416. */
  99417. getClassName(): string;
  99418. /**
  99419. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99420. * Returns the updated direction.
  99421. * @param target The target the direction should point to
  99422. * @return The computed direction
  99423. */
  99424. setDirectionToTarget(target: Vector3): Vector3;
  99425. /**
  99426. * Returns the shadow generator associated to the light.
  99427. * @returns Always null for hemispheric lights because it does not support shadows.
  99428. */
  99429. getShadowGenerator(): Nullable<IShadowGenerator>;
  99430. /**
  99431. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99432. * @param effect The effect to update
  99433. * @param lightIndex The index of the light in the effect to update
  99434. * @returns The hemispheric light
  99435. */
  99436. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99437. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99438. /**
  99439. * Computes the world matrix of the node
  99440. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99441. * @param useWasUpdatedFlag defines a reserved property
  99442. * @returns the world matrix
  99443. */
  99444. computeWorldMatrix(): Matrix;
  99445. /**
  99446. * Returns the integer 3.
  99447. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99448. */
  99449. getTypeID(): number;
  99450. /**
  99451. * Prepares the list of defines specific to the light type.
  99452. * @param defines the list of defines
  99453. * @param lightIndex defines the index of the light for the effect
  99454. */
  99455. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99456. }
  99457. }
  99458. declare module BABYLON {
  99459. /** @hidden */
  99460. export var vrMultiviewToSingleviewPixelShader: {
  99461. name: string;
  99462. shader: string;
  99463. };
  99464. }
  99465. declare module BABYLON {
  99466. /**
  99467. * Renders to multiple views with a single draw call
  99468. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  99469. */
  99470. export class MultiviewRenderTarget extends RenderTargetTexture {
  99471. /**
  99472. * Creates a multiview render target
  99473. * @param scene scene used with the render target
  99474. * @param size the size of the render target (used for each view)
  99475. */
  99476. constructor(scene: Scene, size?: number | {
  99477. width: number;
  99478. height: number;
  99479. } | {
  99480. ratio: number;
  99481. });
  99482. /**
  99483. * @hidden
  99484. * @param faceIndex the face index, if its a cube texture
  99485. */
  99486. _bindFrameBuffer(faceIndex?: number): void;
  99487. /**
  99488. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  99489. * @returns the view count
  99490. */
  99491. getViewCount(): number;
  99492. }
  99493. }
  99494. declare module BABYLON {
  99495. interface Engine {
  99496. /**
  99497. * Creates a new multiview render target
  99498. * @param width defines the width of the texture
  99499. * @param height defines the height of the texture
  99500. * @returns the created multiview texture
  99501. */
  99502. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  99503. /**
  99504. * Binds a multiview framebuffer to be drawn to
  99505. * @param multiviewTexture texture to bind
  99506. */
  99507. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  99508. }
  99509. interface Camera {
  99510. /**
  99511. * @hidden
  99512. * 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)
  99513. */
  99514. _useMultiviewToSingleView: boolean;
  99515. /**
  99516. * @hidden
  99517. * 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)
  99518. */
  99519. _multiviewTexture: Nullable<RenderTargetTexture>;
  99520. /**
  99521. * @hidden
  99522. * ensures the multiview texture of the camera exists and has the specified width/height
  99523. * @param width height to set on the multiview texture
  99524. * @param height width to set on the multiview texture
  99525. */
  99526. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99527. }
  99528. interface Scene {
  99529. /** @hidden */
  99530. _transformMatrixR: Matrix;
  99531. /** @hidden */
  99532. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99533. /** @hidden */
  99534. _createMultiviewUbo(): void;
  99535. /** @hidden */
  99536. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99537. /** @hidden */
  99538. _renderMultiviewToSingleView(camera: Camera): void;
  99539. }
  99540. }
  99541. declare module BABYLON {
  99542. /**
  99543. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99544. * This will not be used for webXR as it supports displaying texture arrays directly
  99545. */
  99546. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99547. /**
  99548. * Gets a string identifying the name of the class
  99549. * @returns "VRMultiviewToSingleviewPostProcess" string
  99550. */
  99551. getClassName(): string;
  99552. /**
  99553. * Initializes a VRMultiviewToSingleview
  99554. * @param name name of the post process
  99555. * @param camera camera to be applied to
  99556. * @param scaleFactor scaling factor to the size of the output texture
  99557. */
  99558. constructor(name: string, camera: Camera, scaleFactor: number);
  99559. }
  99560. }
  99561. declare module BABYLON {
  99562. /**
  99563. * Interface used to define additional presentation attributes
  99564. */
  99565. export interface IVRPresentationAttributes {
  99566. /**
  99567. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99568. */
  99569. highRefreshRate: boolean;
  99570. /**
  99571. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99572. */
  99573. foveationLevel: number;
  99574. }
  99575. interface Engine {
  99576. /** @hidden */
  99577. _vrDisplay: any;
  99578. /** @hidden */
  99579. _vrSupported: boolean;
  99580. /** @hidden */
  99581. _oldSize: Size;
  99582. /** @hidden */
  99583. _oldHardwareScaleFactor: number;
  99584. /** @hidden */
  99585. _vrExclusivePointerMode: boolean;
  99586. /** @hidden */
  99587. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99588. /** @hidden */
  99589. _onVRDisplayPointerRestricted: () => void;
  99590. /** @hidden */
  99591. _onVRDisplayPointerUnrestricted: () => void;
  99592. /** @hidden */
  99593. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99594. /** @hidden */
  99595. _onVrDisplayDisconnect: Nullable<() => void>;
  99596. /** @hidden */
  99597. _onVrDisplayPresentChange: Nullable<() => void>;
  99598. /**
  99599. * Observable signaled when VR display mode changes
  99600. */
  99601. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99602. /**
  99603. * Observable signaled when VR request present is complete
  99604. */
  99605. onVRRequestPresentComplete: Observable<boolean>;
  99606. /**
  99607. * Observable signaled when VR request present starts
  99608. */
  99609. onVRRequestPresentStart: Observable<Engine>;
  99610. /**
  99611. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99612. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99613. */
  99614. isInVRExclusivePointerMode: boolean;
  99615. /**
  99616. * Gets a boolean indicating if a webVR device was detected
  99617. * @returns true if a webVR device was detected
  99618. */
  99619. isVRDevicePresent(): boolean;
  99620. /**
  99621. * Gets the current webVR device
  99622. * @returns the current webVR device (or null)
  99623. */
  99624. getVRDevice(): any;
  99625. /**
  99626. * Initializes a webVR display and starts listening to display change events
  99627. * The onVRDisplayChangedObservable will be notified upon these changes
  99628. * @returns A promise containing a VRDisplay and if vr is supported
  99629. */
  99630. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99631. /** @hidden */
  99632. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99633. /**
  99634. * Gets or sets the presentation attributes used to configure VR rendering
  99635. */
  99636. vrPresentationAttributes?: IVRPresentationAttributes;
  99637. /**
  99638. * Call this function to switch to webVR mode
  99639. * Will do nothing if webVR is not supported or if there is no webVR device
  99640. * @param options the webvr options provided to the camera. mainly used for multiview
  99641. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99642. */
  99643. enableVR(options: WebVROptions): void;
  99644. /** @hidden */
  99645. _onVRFullScreenTriggered(): void;
  99646. }
  99647. }
  99648. declare module BABYLON {
  99649. /**
  99650. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99651. * IMPORTANT!! The data is right-hand data.
  99652. * @export
  99653. * @interface DevicePose
  99654. */
  99655. export interface DevicePose {
  99656. /**
  99657. * The position of the device, values in array are [x,y,z].
  99658. */
  99659. readonly position: Nullable<Float32Array>;
  99660. /**
  99661. * The linearVelocity of the device, values in array are [x,y,z].
  99662. */
  99663. readonly linearVelocity: Nullable<Float32Array>;
  99664. /**
  99665. * The linearAcceleration of the device, values in array are [x,y,z].
  99666. */
  99667. readonly linearAcceleration: Nullable<Float32Array>;
  99668. /**
  99669. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99670. */
  99671. readonly orientation: Nullable<Float32Array>;
  99672. /**
  99673. * The angularVelocity of the device, values in array are [x,y,z].
  99674. */
  99675. readonly angularVelocity: Nullable<Float32Array>;
  99676. /**
  99677. * The angularAcceleration of the device, values in array are [x,y,z].
  99678. */
  99679. readonly angularAcceleration: Nullable<Float32Array>;
  99680. }
  99681. /**
  99682. * Interface representing a pose controlled object in Babylon.
  99683. * A pose controlled object has both regular pose values as well as pose values
  99684. * from an external device such as a VR head mounted display
  99685. */
  99686. export interface PoseControlled {
  99687. /**
  99688. * The position of the object in babylon space.
  99689. */
  99690. position: Vector3;
  99691. /**
  99692. * The rotation quaternion of the object in babylon space.
  99693. */
  99694. rotationQuaternion: Quaternion;
  99695. /**
  99696. * The position of the device in babylon space.
  99697. */
  99698. devicePosition?: Vector3;
  99699. /**
  99700. * The rotation quaternion of the device in babylon space.
  99701. */
  99702. deviceRotationQuaternion: Quaternion;
  99703. /**
  99704. * The raw pose coming from the device.
  99705. */
  99706. rawPose: Nullable<DevicePose>;
  99707. /**
  99708. * The scale of the device to be used when translating from device space to babylon space.
  99709. */
  99710. deviceScaleFactor: number;
  99711. /**
  99712. * Updates the poseControlled values based on the input device pose.
  99713. * @param poseData the pose data to update the object with
  99714. */
  99715. updateFromDevice(poseData: DevicePose): void;
  99716. }
  99717. /**
  99718. * Set of options to customize the webVRCamera
  99719. */
  99720. export interface WebVROptions {
  99721. /**
  99722. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99723. */
  99724. trackPosition?: boolean;
  99725. /**
  99726. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99727. */
  99728. positionScale?: number;
  99729. /**
  99730. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99731. */
  99732. displayName?: string;
  99733. /**
  99734. * Should the native controller meshes be initialized. (default: true)
  99735. */
  99736. controllerMeshes?: boolean;
  99737. /**
  99738. * Creating a default HemiLight only on controllers. (default: true)
  99739. */
  99740. defaultLightingOnControllers?: boolean;
  99741. /**
  99742. * If you don't want to use the default VR button of the helper. (default: false)
  99743. */
  99744. useCustomVRButton?: boolean;
  99745. /**
  99746. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99747. */
  99748. customVRButton?: HTMLButtonElement;
  99749. /**
  99750. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99751. */
  99752. rayLength?: number;
  99753. /**
  99754. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99755. */
  99756. defaultHeight?: number;
  99757. /**
  99758. * If multiview should be used if availible (default: false)
  99759. */
  99760. useMultiview?: boolean;
  99761. }
  99762. /**
  99763. * This represents a WebVR camera.
  99764. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99765. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99766. */
  99767. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99768. private webVROptions;
  99769. /**
  99770. * @hidden
  99771. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99772. */
  99773. _vrDevice: any;
  99774. /**
  99775. * The rawPose of the vrDevice.
  99776. */
  99777. rawPose: Nullable<DevicePose>;
  99778. private _onVREnabled;
  99779. private _specsVersion;
  99780. private _attached;
  99781. private _frameData;
  99782. protected _descendants: Array<Node>;
  99783. private _deviceRoomPosition;
  99784. /** @hidden */
  99785. _deviceRoomRotationQuaternion: Quaternion;
  99786. private _standingMatrix;
  99787. /**
  99788. * Represents device position in babylon space.
  99789. */
  99790. devicePosition: Vector3;
  99791. /**
  99792. * Represents device rotation in babylon space.
  99793. */
  99794. deviceRotationQuaternion: Quaternion;
  99795. /**
  99796. * The scale of the device to be used when translating from device space to babylon space.
  99797. */
  99798. deviceScaleFactor: number;
  99799. private _deviceToWorld;
  99800. private _worldToDevice;
  99801. /**
  99802. * References to the webVR controllers for the vrDevice.
  99803. */
  99804. controllers: Array<WebVRController>;
  99805. /**
  99806. * Emits an event when a controller is attached.
  99807. */
  99808. onControllersAttachedObservable: Observable<WebVRController[]>;
  99809. /**
  99810. * Emits an event when a controller's mesh has been loaded;
  99811. */
  99812. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99813. /**
  99814. * Emits an event when the HMD's pose has been updated.
  99815. */
  99816. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99817. private _poseSet;
  99818. /**
  99819. * If the rig cameras be used as parent instead of this camera.
  99820. */
  99821. rigParenting: boolean;
  99822. private _lightOnControllers;
  99823. private _defaultHeight?;
  99824. /**
  99825. * Instantiates a WebVRFreeCamera.
  99826. * @param name The name of the WebVRFreeCamera
  99827. * @param position The starting anchor position for the camera
  99828. * @param scene The scene the camera belongs to
  99829. * @param webVROptions a set of customizable options for the webVRCamera
  99830. */
  99831. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99832. /**
  99833. * Gets the device distance from the ground in meters.
  99834. * @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.
  99835. */
  99836. deviceDistanceToRoomGround(): number;
  99837. /**
  99838. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99839. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99840. */
  99841. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99842. /**
  99843. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99844. * @returns A promise with a boolean set to if the standing matrix is supported.
  99845. */
  99846. useStandingMatrixAsync(): Promise<boolean>;
  99847. /**
  99848. * Disposes the camera
  99849. */
  99850. dispose(): void;
  99851. /**
  99852. * Gets a vrController by name.
  99853. * @param name The name of the controller to retreive
  99854. * @returns the controller matching the name specified or null if not found
  99855. */
  99856. getControllerByName(name: string): Nullable<WebVRController>;
  99857. private _leftController;
  99858. /**
  99859. * The controller corresponding to the users left hand.
  99860. */
  99861. get leftController(): Nullable<WebVRController>;
  99862. private _rightController;
  99863. /**
  99864. * The controller corresponding to the users right hand.
  99865. */
  99866. get rightController(): Nullable<WebVRController>;
  99867. /**
  99868. * Casts a ray forward from the vrCamera's gaze.
  99869. * @param length Length of the ray (default: 100)
  99870. * @returns the ray corresponding to the gaze
  99871. */
  99872. getForwardRay(length?: number): Ray;
  99873. /**
  99874. * @hidden
  99875. * Updates the camera based on device's frame data
  99876. */
  99877. _checkInputs(): void;
  99878. /**
  99879. * Updates the poseControlled values based on the input device pose.
  99880. * @param poseData Pose coming from the device
  99881. */
  99882. updateFromDevice(poseData: DevicePose): void;
  99883. private _htmlElementAttached;
  99884. private _detachIfAttached;
  99885. /**
  99886. * WebVR's attach control will start broadcasting frames to the device.
  99887. * Note that in certain browsers (chrome for example) this function must be called
  99888. * within a user-interaction callback. Example:
  99889. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  99890. *
  99891. * @param element html element to attach the vrDevice to
  99892. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  99893. */
  99894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99895. /**
  99896. * Detaches the camera from the html element and disables VR
  99897. *
  99898. * @param element html element to detach from
  99899. */
  99900. detachControl(element: HTMLElement): void;
  99901. /**
  99902. * @returns the name of this class
  99903. */
  99904. getClassName(): string;
  99905. /**
  99906. * Calls resetPose on the vrDisplay
  99907. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  99908. */
  99909. resetToCurrentRotation(): void;
  99910. /**
  99911. * @hidden
  99912. * Updates the rig cameras (left and right eye)
  99913. */
  99914. _updateRigCameras(): void;
  99915. private _workingVector;
  99916. private _oneVector;
  99917. private _workingMatrix;
  99918. private updateCacheCalled;
  99919. private _correctPositionIfNotTrackPosition;
  99920. /**
  99921. * @hidden
  99922. * Updates the cached values of the camera
  99923. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  99924. */
  99925. _updateCache(ignoreParentClass?: boolean): void;
  99926. /**
  99927. * @hidden
  99928. * Get current device position in babylon world
  99929. */
  99930. _computeDevicePosition(): void;
  99931. /**
  99932. * Updates the current device position and rotation in the babylon world
  99933. */
  99934. update(): void;
  99935. /**
  99936. * @hidden
  99937. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  99938. * @returns an identity matrix
  99939. */
  99940. _getViewMatrix(): Matrix;
  99941. private _tmpMatrix;
  99942. /**
  99943. * This function is called by the two RIG cameras.
  99944. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  99945. * @hidden
  99946. */
  99947. _getWebVRViewMatrix(): Matrix;
  99948. /** @hidden */
  99949. _getWebVRProjectionMatrix(): Matrix;
  99950. private _onGamepadConnectedObserver;
  99951. private _onGamepadDisconnectedObserver;
  99952. private _updateCacheWhenTrackingDisabledObserver;
  99953. /**
  99954. * Initializes the controllers and their meshes
  99955. */
  99956. initControllers(): void;
  99957. }
  99958. }
  99959. declare module BABYLON {
  99960. /**
  99961. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  99962. *
  99963. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  99964. *
  99965. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99966. */
  99967. export class MaterialHelper {
  99968. /**
  99969. * Bind the current view position to an effect.
  99970. * @param effect The effect to be bound
  99971. * @param scene The scene the eyes position is used from
  99972. * @param variableName name of the shader variable that will hold the eye position
  99973. */
  99974. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  99975. /**
  99976. * Helps preparing the defines values about the UVs in used in the effect.
  99977. * UVs are shared as much as we can accross channels in the shaders.
  99978. * @param texture The texture we are preparing the UVs for
  99979. * @param defines The defines to update
  99980. * @param key The channel key "diffuse", "specular"... used in the shader
  99981. */
  99982. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99983. /**
  99984. * Binds a texture matrix value to its corrsponding uniform
  99985. * @param texture The texture to bind the matrix for
  99986. * @param uniformBuffer The uniform buffer receivin the data
  99987. * @param key The channel key "diffuse", "specular"... used in the shader
  99988. */
  99989. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  99990. /**
  99991. * Gets the current status of the fog (should it be enabled?)
  99992. * @param mesh defines the mesh to evaluate for fog support
  99993. * @param scene defines the hosting scene
  99994. * @returns true if fog must be enabled
  99995. */
  99996. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  99997. /**
  99998. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  99999. * @param mesh defines the current mesh
  100000. * @param scene defines the current scene
  100001. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100002. * @param pointsCloud defines if point cloud rendering has to be turned on
  100003. * @param fogEnabled defines if fog has to be turned on
  100004. * @param alphaTest defines if alpha testing has to be turned on
  100005. * @param defines defines the current list of defines
  100006. */
  100007. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100008. /**
  100009. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100010. * @param scene defines the current scene
  100011. * @param engine defines the current engine
  100012. * @param defines specifies the list of active defines
  100013. * @param useInstances defines if instances have to be turned on
  100014. * @param useClipPlane defines if clip plane have to be turned on
  100015. * @param useInstances defines if instances have to be turned on
  100016. * @param useThinInstances defines if thin instances have to be turned on
  100017. */
  100018. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100019. /**
  100020. * Prepares the defines for bones
  100021. * @param mesh The mesh containing the geometry data we will draw
  100022. * @param defines The defines to update
  100023. */
  100024. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100025. /**
  100026. * Prepares the defines for morph targets
  100027. * @param mesh The mesh containing the geometry data we will draw
  100028. * @param defines The defines to update
  100029. */
  100030. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100031. /**
  100032. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100033. * @param mesh The mesh containing the geometry data we will draw
  100034. * @param defines The defines to update
  100035. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100036. * @param useBones Precise whether bones should be used or not (override mesh info)
  100037. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100038. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100039. * @returns false if defines are considered not dirty and have not been checked
  100040. */
  100041. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100042. /**
  100043. * Prepares the defines related to multiview
  100044. * @param scene The scene we are intending to draw
  100045. * @param defines The defines to update
  100046. */
  100047. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100048. /**
  100049. * Prepares the defines related to the prepass
  100050. * @param scene The scene we are intending to draw
  100051. * @param defines The defines to update
  100052. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100053. */
  100054. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100055. /**
  100056. * Prepares the defines related to the light information passed in parameter
  100057. * @param scene The scene we are intending to draw
  100058. * @param mesh The mesh the effect is compiling for
  100059. * @param light The light the effect is compiling for
  100060. * @param lightIndex The index of the light
  100061. * @param defines The defines to update
  100062. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100063. * @param state Defines the current state regarding what is needed (normals, etc...)
  100064. */
  100065. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100066. needNormals: boolean;
  100067. needRebuild: boolean;
  100068. shadowEnabled: boolean;
  100069. specularEnabled: boolean;
  100070. lightmapMode: boolean;
  100071. }): void;
  100072. /**
  100073. * Prepares the defines related to the light information passed in parameter
  100074. * @param scene The scene we are intending to draw
  100075. * @param mesh The mesh the effect is compiling for
  100076. * @param defines The defines to update
  100077. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100078. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100079. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100080. * @returns true if normals will be required for the rest of the effect
  100081. */
  100082. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100083. /**
  100084. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100085. * @param lightIndex defines the light index
  100086. * @param uniformsList The uniform list
  100087. * @param samplersList The sampler list
  100088. * @param projectedLightTexture defines if projected texture must be used
  100089. * @param uniformBuffersList defines an optional list of uniform buffers
  100090. */
  100091. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100092. /**
  100093. * Prepares the uniforms and samplers list to be used in the effect
  100094. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100095. * @param samplersList The sampler list
  100096. * @param defines The defines helping in the list generation
  100097. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100098. */
  100099. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100100. /**
  100101. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100102. * @param defines The defines to update while falling back
  100103. * @param fallbacks The authorized effect fallbacks
  100104. * @param maxSimultaneousLights The maximum number of lights allowed
  100105. * @param rank the current rank of the Effect
  100106. * @returns The newly affected rank
  100107. */
  100108. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100109. private static _TmpMorphInfluencers;
  100110. /**
  100111. * Prepares the list of attributes required for morph targets according to the effect defines.
  100112. * @param attribs The current list of supported attribs
  100113. * @param mesh The mesh to prepare the morph targets attributes for
  100114. * @param influencers The number of influencers
  100115. */
  100116. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100117. /**
  100118. * Prepares the list of attributes required for morph targets according to the effect defines.
  100119. * @param attribs The current list of supported attribs
  100120. * @param mesh The mesh to prepare the morph targets attributes for
  100121. * @param defines The current Defines of the effect
  100122. */
  100123. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100124. /**
  100125. * Prepares the list of attributes required for bones according to the effect defines.
  100126. * @param attribs The current list of supported attribs
  100127. * @param mesh The mesh to prepare the bones attributes for
  100128. * @param defines The current Defines of the effect
  100129. * @param fallbacks The current efffect fallback strategy
  100130. */
  100131. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100132. /**
  100133. * Check and prepare the list of attributes required for instances according to the effect defines.
  100134. * @param attribs The current list of supported attribs
  100135. * @param defines The current MaterialDefines of the effect
  100136. */
  100137. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100138. /**
  100139. * Add the list of attributes required for instances to the attribs array.
  100140. * @param attribs The current list of supported attribs
  100141. */
  100142. static PushAttributesForInstances(attribs: string[]): void;
  100143. /**
  100144. * Binds the light information to the effect.
  100145. * @param light The light containing the generator
  100146. * @param effect The effect we are binding the data to
  100147. * @param lightIndex The light index in the effect used to render
  100148. */
  100149. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100150. /**
  100151. * Binds the lights information from the scene to the effect for the given mesh.
  100152. * @param light Light to bind
  100153. * @param lightIndex Light index
  100154. * @param scene The scene where the light belongs to
  100155. * @param effect The effect we are binding the data to
  100156. * @param useSpecular Defines if specular is supported
  100157. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100158. */
  100159. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100160. /**
  100161. * Binds the lights information from the scene to the effect for the given mesh.
  100162. * @param scene The scene the lights belongs to
  100163. * @param mesh The mesh we are binding the information to render
  100164. * @param effect The effect we are binding the data to
  100165. * @param defines The generated defines for the effect
  100166. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100167. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100168. */
  100169. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100170. private static _tempFogColor;
  100171. /**
  100172. * Binds the fog information from the scene to the effect for the given mesh.
  100173. * @param scene The scene the lights belongs to
  100174. * @param mesh The mesh we are binding the information to render
  100175. * @param effect The effect we are binding the data to
  100176. * @param linearSpace Defines if the fog effect is applied in linear space
  100177. */
  100178. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100179. /**
  100180. * Binds the bones information from the mesh to the effect.
  100181. * @param mesh The mesh we are binding the information to render
  100182. * @param effect The effect we are binding the data to
  100183. */
  100184. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100185. /**
  100186. * Binds the morph targets information from the mesh to the effect.
  100187. * @param abstractMesh The mesh we are binding the information to render
  100188. * @param effect The effect we are binding the data to
  100189. */
  100190. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100191. /**
  100192. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100193. * @param defines The generated defines used in the effect
  100194. * @param effect The effect we are binding the data to
  100195. * @param scene The scene we are willing to render with logarithmic scale for
  100196. */
  100197. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100198. /**
  100199. * Binds the clip plane information from the scene to the effect.
  100200. * @param scene The scene the clip plane information are extracted from
  100201. * @param effect The effect we are binding the data to
  100202. */
  100203. static BindClipPlane(effect: Effect, scene: Scene): void;
  100204. }
  100205. }
  100206. declare module BABYLON {
  100207. /**
  100208. * Block used to expose an input value
  100209. */
  100210. export class InputBlock extends NodeMaterialBlock {
  100211. private _mode;
  100212. private _associatedVariableName;
  100213. private _storedValue;
  100214. private _valueCallback;
  100215. private _type;
  100216. private _animationType;
  100217. /** Gets or set a value used to limit the range of float values */
  100218. min: number;
  100219. /** Gets or set a value used to limit the range of float values */
  100220. max: number;
  100221. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100222. isBoolean: boolean;
  100223. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100224. matrixMode: number;
  100225. /** @hidden */
  100226. _systemValue: Nullable<NodeMaterialSystemValues>;
  100227. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  100228. visibleInInspector: boolean;
  100229. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100230. isConstant: boolean;
  100231. /** Gets or sets the group to use to display this block in the Inspector */
  100232. groupInInspector: string;
  100233. /** Gets an observable raised when the value is changed */
  100234. onValueChangedObservable: Observable<InputBlock>;
  100235. /**
  100236. * Gets or sets the connection point type (default is float)
  100237. */
  100238. get type(): NodeMaterialBlockConnectionPointTypes;
  100239. /**
  100240. * Creates a new InputBlock
  100241. * @param name defines the block name
  100242. * @param target defines the target of that block (Vertex by default)
  100243. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100244. */
  100245. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100246. /**
  100247. * Validates if a name is a reserve word.
  100248. * @param newName the new name to be given to the node.
  100249. * @returns false if the name is a reserve word, else true.
  100250. */
  100251. validateBlockName(newName: string): boolean;
  100252. /**
  100253. * Gets the output component
  100254. */
  100255. get output(): NodeMaterialConnectionPoint;
  100256. /**
  100257. * Set the source of this connection point to a vertex attribute
  100258. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100259. * @returns the current connection point
  100260. */
  100261. setAsAttribute(attributeName?: string): InputBlock;
  100262. /**
  100263. * Set the source of this connection point to a system value
  100264. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100265. * @returns the current connection point
  100266. */
  100267. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100268. /**
  100269. * Gets or sets the value of that point.
  100270. * Please note that this value will be ignored if valueCallback is defined
  100271. */
  100272. get value(): any;
  100273. set value(value: any);
  100274. /**
  100275. * Gets or sets a callback used to get the value of that point.
  100276. * Please note that setting this value will force the connection point to ignore the value property
  100277. */
  100278. get valueCallback(): () => any;
  100279. set valueCallback(value: () => any);
  100280. /**
  100281. * Gets or sets the associated variable name in the shader
  100282. */
  100283. get associatedVariableName(): string;
  100284. set associatedVariableName(value: string);
  100285. /** Gets or sets the type of animation applied to the input */
  100286. get animationType(): AnimatedInputBlockTypes;
  100287. set animationType(value: AnimatedInputBlockTypes);
  100288. /**
  100289. * Gets a boolean indicating that this connection point not defined yet
  100290. */
  100291. get isUndefined(): boolean;
  100292. /**
  100293. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100294. * In this case the connection point name must be the name of the uniform to use.
  100295. * Can only be set on inputs
  100296. */
  100297. get isUniform(): boolean;
  100298. set isUniform(value: boolean);
  100299. /**
  100300. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100301. * In this case the connection point name must be the name of the attribute to use
  100302. * Can only be set on inputs
  100303. */
  100304. get isAttribute(): boolean;
  100305. set isAttribute(value: boolean);
  100306. /**
  100307. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100308. * Can only be set on exit points
  100309. */
  100310. get isVarying(): boolean;
  100311. set isVarying(value: boolean);
  100312. /**
  100313. * Gets a boolean indicating that the current connection point is a system value
  100314. */
  100315. get isSystemValue(): boolean;
  100316. /**
  100317. * Gets or sets the current well known value or null if not defined as a system value
  100318. */
  100319. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100320. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100321. /**
  100322. * Gets the current class name
  100323. * @returns the class name
  100324. */
  100325. getClassName(): string;
  100326. /**
  100327. * Animate the input if animationType !== None
  100328. * @param scene defines the rendering scene
  100329. */
  100330. animate(scene: Scene): void;
  100331. private _emitDefine;
  100332. initialize(state: NodeMaterialBuildState): void;
  100333. /**
  100334. * Set the input block to its default value (based on its type)
  100335. */
  100336. setDefaultValue(): void;
  100337. private _emitConstant;
  100338. /** @hidden */
  100339. get _noContextSwitch(): boolean;
  100340. private _emit;
  100341. /** @hidden */
  100342. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100343. /** @hidden */
  100344. _transmit(effect: Effect, scene: Scene): void;
  100345. protected _buildBlock(state: NodeMaterialBuildState): void;
  100346. protected _dumpPropertiesCode(): string;
  100347. dispose(): void;
  100348. serialize(): any;
  100349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100350. }
  100351. }
  100352. declare module BABYLON {
  100353. /**
  100354. * Enum used to define the compatibility state between two connection points
  100355. */
  100356. export enum NodeMaterialConnectionPointCompatibilityStates {
  100357. /** Points are compatibles */
  100358. Compatible = 0,
  100359. /** Points are incompatible because of their types */
  100360. TypeIncompatible = 1,
  100361. /** Points are incompatible because of their targets (vertex vs fragment) */
  100362. TargetIncompatible = 2
  100363. }
  100364. /**
  100365. * Defines the direction of a connection point
  100366. */
  100367. export enum NodeMaterialConnectionPointDirection {
  100368. /** Input */
  100369. Input = 0,
  100370. /** Output */
  100371. Output = 1
  100372. }
  100373. /**
  100374. * Defines a connection point for a block
  100375. */
  100376. export class NodeMaterialConnectionPoint {
  100377. /** @hidden */
  100378. _ownerBlock: NodeMaterialBlock;
  100379. /** @hidden */
  100380. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100381. private _endpoints;
  100382. private _associatedVariableName;
  100383. private _direction;
  100384. /** @hidden */
  100385. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100386. /** @hidden */
  100387. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100388. private _type;
  100389. /** @hidden */
  100390. _enforceAssociatedVariableName: boolean;
  100391. /** Gets the direction of the point */
  100392. get direction(): NodeMaterialConnectionPointDirection;
  100393. /** Indicates that this connection point needs dual validation before being connected to another point */
  100394. needDualDirectionValidation: boolean;
  100395. /**
  100396. * Gets or sets the additional types supported by this connection point
  100397. */
  100398. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100399. /**
  100400. * Gets or sets the additional types excluded by this connection point
  100401. */
  100402. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100403. /**
  100404. * Observable triggered when this point is connected
  100405. */
  100406. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100407. /**
  100408. * Gets or sets the associated variable name in the shader
  100409. */
  100410. get associatedVariableName(): string;
  100411. set associatedVariableName(value: string);
  100412. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100413. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100414. /**
  100415. * Gets or sets the connection point type (default is float)
  100416. */
  100417. get type(): NodeMaterialBlockConnectionPointTypes;
  100418. set type(value: NodeMaterialBlockConnectionPointTypes);
  100419. /**
  100420. * Gets or sets the connection point name
  100421. */
  100422. name: string;
  100423. /**
  100424. * Gets or sets the connection point name
  100425. */
  100426. displayName: string;
  100427. /**
  100428. * Gets or sets a boolean indicating that this connection point can be omitted
  100429. */
  100430. isOptional: boolean;
  100431. /**
  100432. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100433. */
  100434. isExposedOnFrame: boolean;
  100435. /**
  100436. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100437. */
  100438. define: string;
  100439. /** @hidden */
  100440. _prioritizeVertex: boolean;
  100441. private _target;
  100442. /** Gets or sets the target of that connection point */
  100443. get target(): NodeMaterialBlockTargets;
  100444. set target(value: NodeMaterialBlockTargets);
  100445. /**
  100446. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100447. */
  100448. get isConnected(): boolean;
  100449. /**
  100450. * Gets a boolean indicating that the current point is connected to an input block
  100451. */
  100452. get isConnectedToInputBlock(): boolean;
  100453. /**
  100454. * Gets a the connected input block (if any)
  100455. */
  100456. get connectInputBlock(): Nullable<InputBlock>;
  100457. /** Get the other side of the connection (if any) */
  100458. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100459. /** Get the block that owns this connection point */
  100460. get ownerBlock(): NodeMaterialBlock;
  100461. /** Get the block connected on the other side of this connection (if any) */
  100462. get sourceBlock(): Nullable<NodeMaterialBlock>;
  100463. /** Get the block connected on the endpoints of this connection (if any) */
  100464. get connectedBlocks(): Array<NodeMaterialBlock>;
  100465. /** Gets the list of connected endpoints */
  100466. get endpoints(): NodeMaterialConnectionPoint[];
  100467. /** Gets a boolean indicating if that output point is connected to at least one input */
  100468. get hasEndpoints(): boolean;
  100469. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  100470. get isConnectedInVertexShader(): boolean;
  100471. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  100472. get isConnectedInFragmentShader(): boolean;
  100473. /**
  100474. * Creates a block suitable to be used as an input for this input point.
  100475. * If null is returned, a block based on the point type will be created.
  100476. * @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
  100477. */
  100478. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100479. /**
  100480. * Creates a new connection point
  100481. * @param name defines the connection point name
  100482. * @param ownerBlock defines the block hosting this connection point
  100483. * @param direction defines the direction of the connection point
  100484. */
  100485. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  100486. /**
  100487. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  100488. * @returns the class name
  100489. */
  100490. getClassName(): string;
  100491. /**
  100492. * Gets a boolean indicating if the current point can be connected to another point
  100493. * @param connectionPoint defines the other connection point
  100494. * @returns a boolean
  100495. */
  100496. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  100497. /**
  100498. * Gets a number indicating if the current point can be connected to another point
  100499. * @param connectionPoint defines the other connection point
  100500. * @returns a number defining the compatibility state
  100501. */
  100502. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100503. /**
  100504. * Connect this point to another connection point
  100505. * @param connectionPoint defines the other connection point
  100506. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  100507. * @returns the current connection point
  100508. */
  100509. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  100510. /**
  100511. * Disconnect this point from one of his endpoint
  100512. * @param endpoint defines the other connection point
  100513. * @returns the current connection point
  100514. */
  100515. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  100516. /**
  100517. * Serializes this point in a JSON representation
  100518. * @param isInput defines if the connection point is an input (default is true)
  100519. * @returns the serialized point object
  100520. */
  100521. serialize(isInput?: boolean): any;
  100522. /**
  100523. * Release resources
  100524. */
  100525. dispose(): void;
  100526. }
  100527. }
  100528. declare module BABYLON {
  100529. /**
  100530. * Enum used to define the material modes
  100531. */
  100532. export enum NodeMaterialModes {
  100533. /** Regular material */
  100534. Material = 0,
  100535. /** For post process */
  100536. PostProcess = 1,
  100537. /** For particle system */
  100538. Particle = 2
  100539. }
  100540. }
  100541. declare module BABYLON {
  100542. /**
  100543. * Block used to read a texture from a sampler
  100544. */
  100545. export class TextureBlock extends NodeMaterialBlock {
  100546. private _defineName;
  100547. private _linearDefineName;
  100548. private _gammaDefineName;
  100549. private _tempTextureRead;
  100550. private _samplerName;
  100551. private _transformedUVName;
  100552. private _textureTransformName;
  100553. private _textureInfoName;
  100554. private _mainUVName;
  100555. private _mainUVDefineName;
  100556. private _fragmentOnly;
  100557. /**
  100558. * Gets or sets the texture associated with the node
  100559. */
  100560. texture: Nullable<Texture>;
  100561. /**
  100562. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100563. */
  100564. convertToGammaSpace: boolean;
  100565. /**
  100566. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100567. */
  100568. convertToLinearSpace: boolean;
  100569. /**
  100570. * Create a new TextureBlock
  100571. * @param name defines the block name
  100572. */
  100573. constructor(name: string, fragmentOnly?: boolean);
  100574. /**
  100575. * Gets the current class name
  100576. * @returns the class name
  100577. */
  100578. getClassName(): string;
  100579. /**
  100580. * Gets the uv input component
  100581. */
  100582. get uv(): NodeMaterialConnectionPoint;
  100583. /**
  100584. * Gets the rgba output component
  100585. */
  100586. get rgba(): NodeMaterialConnectionPoint;
  100587. /**
  100588. * Gets the rgb output component
  100589. */
  100590. get rgb(): NodeMaterialConnectionPoint;
  100591. /**
  100592. * Gets the r output component
  100593. */
  100594. get r(): NodeMaterialConnectionPoint;
  100595. /**
  100596. * Gets the g output component
  100597. */
  100598. get g(): NodeMaterialConnectionPoint;
  100599. /**
  100600. * Gets the b output component
  100601. */
  100602. get b(): NodeMaterialConnectionPoint;
  100603. /**
  100604. * Gets the a output component
  100605. */
  100606. get a(): NodeMaterialConnectionPoint;
  100607. get target(): NodeMaterialBlockTargets;
  100608. autoConfigure(material: NodeMaterial): void;
  100609. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100611. isReady(): boolean;
  100612. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100613. private get _isMixed();
  100614. private _injectVertexCode;
  100615. private _writeTextureRead;
  100616. private _writeOutput;
  100617. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100618. protected _dumpPropertiesCode(): string;
  100619. serialize(): any;
  100620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100621. }
  100622. }
  100623. declare module BABYLON {
  100624. /** @hidden */
  100625. export var reflectionFunction: {
  100626. name: string;
  100627. shader: string;
  100628. };
  100629. }
  100630. declare module BABYLON {
  100631. /**
  100632. * Base block used to read a reflection texture from a sampler
  100633. */
  100634. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100635. /** @hidden */
  100636. _define3DName: string;
  100637. /** @hidden */
  100638. _defineCubicName: string;
  100639. /** @hidden */
  100640. _defineExplicitName: string;
  100641. /** @hidden */
  100642. _defineProjectionName: string;
  100643. /** @hidden */
  100644. _defineLocalCubicName: string;
  100645. /** @hidden */
  100646. _defineSphericalName: string;
  100647. /** @hidden */
  100648. _definePlanarName: string;
  100649. /** @hidden */
  100650. _defineEquirectangularName: string;
  100651. /** @hidden */
  100652. _defineMirroredEquirectangularFixedName: string;
  100653. /** @hidden */
  100654. _defineEquirectangularFixedName: string;
  100655. /** @hidden */
  100656. _defineSkyboxName: string;
  100657. /** @hidden */
  100658. _defineOppositeZ: string;
  100659. /** @hidden */
  100660. _cubeSamplerName: string;
  100661. /** @hidden */
  100662. _2DSamplerName: string;
  100663. protected _positionUVWName: string;
  100664. protected _directionWName: string;
  100665. protected _reflectionVectorName: string;
  100666. /** @hidden */
  100667. _reflectionCoordsName: string;
  100668. /** @hidden */
  100669. _reflectionMatrixName: string;
  100670. protected _reflectionColorName: string;
  100671. /**
  100672. * Gets or sets the texture associated with the node
  100673. */
  100674. texture: Nullable<BaseTexture>;
  100675. /**
  100676. * Create a new ReflectionTextureBaseBlock
  100677. * @param name defines the block name
  100678. */
  100679. constructor(name: string);
  100680. /**
  100681. * Gets the current class name
  100682. * @returns the class name
  100683. */
  100684. getClassName(): string;
  100685. /**
  100686. * Gets the world position input component
  100687. */
  100688. abstract get position(): NodeMaterialConnectionPoint;
  100689. /**
  100690. * Gets the world position input component
  100691. */
  100692. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100693. /**
  100694. * Gets the world normal input component
  100695. */
  100696. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100697. /**
  100698. * Gets the world input component
  100699. */
  100700. abstract get world(): NodeMaterialConnectionPoint;
  100701. /**
  100702. * Gets the camera (or eye) position component
  100703. */
  100704. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100705. /**
  100706. * Gets the view input component
  100707. */
  100708. abstract get view(): NodeMaterialConnectionPoint;
  100709. protected _getTexture(): Nullable<BaseTexture>;
  100710. autoConfigure(material: NodeMaterial): void;
  100711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100712. isReady(): boolean;
  100713. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100714. /**
  100715. * Gets the code to inject in the vertex shader
  100716. * @param state current state of the node material building
  100717. * @returns the shader code
  100718. */
  100719. handleVertexSide(state: NodeMaterialBuildState): string;
  100720. /**
  100721. * Handles the inits for the fragment code path
  100722. * @param state node material build state
  100723. */
  100724. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100725. /**
  100726. * Generates the reflection coords code for the fragment code path
  100727. * @param worldNormalVarName name of the world normal variable
  100728. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100729. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100730. * @returns the shader code
  100731. */
  100732. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100733. /**
  100734. * Generates the reflection color code for the fragment code path
  100735. * @param lodVarName name of the lod variable
  100736. * @param swizzleLookupTexture swizzle to use for the final color variable
  100737. * @returns the shader code
  100738. */
  100739. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100740. /**
  100741. * Generates the code corresponding to the connected output points
  100742. * @param state node material build state
  100743. * @param varName name of the variable to output
  100744. * @returns the shader code
  100745. */
  100746. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100747. protected _buildBlock(state: NodeMaterialBuildState): this;
  100748. protected _dumpPropertiesCode(): string;
  100749. serialize(): any;
  100750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100751. }
  100752. }
  100753. declare module BABYLON {
  100754. /**
  100755. * Defines a connection point to be used for points with a custom object type
  100756. */
  100757. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100758. private _blockType;
  100759. private _blockName;
  100760. private _nameForCheking?;
  100761. /**
  100762. * Creates a new connection point
  100763. * @param name defines the connection point name
  100764. * @param ownerBlock defines the block hosting this connection point
  100765. * @param direction defines the direction of the connection point
  100766. */
  100767. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100768. /**
  100769. * Gets a number indicating if the current point can be connected to another point
  100770. * @param connectionPoint defines the other connection point
  100771. * @returns a number defining the compatibility state
  100772. */
  100773. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100774. /**
  100775. * Creates a block suitable to be used as an input for this input point.
  100776. * If null is returned, a block based on the point type will be created.
  100777. * @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
  100778. */
  100779. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100780. }
  100781. }
  100782. declare module BABYLON {
  100783. /**
  100784. * Enum defining the type of properties that can be edited in the property pages in the NME
  100785. */
  100786. export enum PropertyTypeForEdition {
  100787. /** property is a boolean */
  100788. Boolean = 0,
  100789. /** property is a float */
  100790. Float = 1,
  100791. /** property is a Vector2 */
  100792. Vector2 = 2,
  100793. /** property is a list of values */
  100794. List = 3
  100795. }
  100796. /**
  100797. * Interface that defines an option in a variable of type list
  100798. */
  100799. export interface IEditablePropertyListOption {
  100800. /** label of the option */
  100801. "label": string;
  100802. /** value of the option */
  100803. "value": number;
  100804. }
  100805. /**
  100806. * Interface that defines the options available for an editable property
  100807. */
  100808. export interface IEditablePropertyOption {
  100809. /** min value */
  100810. "min"?: number;
  100811. /** max value */
  100812. "max"?: number;
  100813. /** notifiers: indicates which actions to take when the property is changed */
  100814. "notifiers"?: {
  100815. /** the material should be rebuilt */
  100816. "rebuild"?: boolean;
  100817. /** the preview should be updated */
  100818. "update"?: boolean;
  100819. };
  100820. /** list of the options for a variable of type list */
  100821. "options"?: IEditablePropertyListOption[];
  100822. }
  100823. /**
  100824. * Interface that describes an editable property
  100825. */
  100826. export interface IPropertyDescriptionForEdition {
  100827. /** name of the property */
  100828. "propertyName": string;
  100829. /** display name of the property */
  100830. "displayName": string;
  100831. /** type of the property */
  100832. "type": PropertyTypeForEdition;
  100833. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100834. "groupName": string;
  100835. /** options for the property */
  100836. "options": IEditablePropertyOption;
  100837. }
  100838. /**
  100839. * Decorator that flags a property in a node material block as being editable
  100840. */
  100841. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100842. }
  100843. declare module BABYLON {
  100844. /**
  100845. * Block used to implement the refraction part of the sub surface module of the PBR material
  100846. */
  100847. export class RefractionBlock extends NodeMaterialBlock {
  100848. /** @hidden */
  100849. _define3DName: string;
  100850. /** @hidden */
  100851. _refractionMatrixName: string;
  100852. /** @hidden */
  100853. _defineLODRefractionAlpha: string;
  100854. /** @hidden */
  100855. _defineLinearSpecularRefraction: string;
  100856. /** @hidden */
  100857. _defineOppositeZ: string;
  100858. /** @hidden */
  100859. _cubeSamplerName: string;
  100860. /** @hidden */
  100861. _2DSamplerName: string;
  100862. /** @hidden */
  100863. _vRefractionMicrosurfaceInfosName: string;
  100864. /** @hidden */
  100865. _vRefractionInfosName: string;
  100866. private _scene;
  100867. /**
  100868. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100869. * Materials half opaque for instance using refraction could benefit from this control.
  100870. */
  100871. linkRefractionWithTransparency: boolean;
  100872. /**
  100873. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100874. */
  100875. invertRefractionY: boolean;
  100876. /**
  100877. * Gets or sets the texture associated with the node
  100878. */
  100879. texture: Nullable<BaseTexture>;
  100880. /**
  100881. * Create a new RefractionBlock
  100882. * @param name defines the block name
  100883. */
  100884. constructor(name: string);
  100885. /**
  100886. * Gets the current class name
  100887. * @returns the class name
  100888. */
  100889. getClassName(): string;
  100890. /**
  100891. * Gets the intensity input component
  100892. */
  100893. get intensity(): NodeMaterialConnectionPoint;
  100894. /**
  100895. * Gets the index of refraction input component
  100896. */
  100897. get indexOfRefraction(): NodeMaterialConnectionPoint;
  100898. /**
  100899. * Gets the tint at distance input component
  100900. */
  100901. get tintAtDistance(): NodeMaterialConnectionPoint;
  100902. /**
  100903. * Gets the view input component
  100904. */
  100905. get view(): NodeMaterialConnectionPoint;
  100906. /**
  100907. * Gets the refraction object output component
  100908. */
  100909. get refraction(): NodeMaterialConnectionPoint;
  100910. /**
  100911. * Returns true if the block has a texture
  100912. */
  100913. get hasTexture(): boolean;
  100914. protected _getTexture(): Nullable<BaseTexture>;
  100915. autoConfigure(material: NodeMaterial): void;
  100916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100917. isReady(): boolean;
  100918. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100919. /**
  100920. * Gets the main code of the block (fragment side)
  100921. * @param state current state of the node material building
  100922. * @returns the shader code
  100923. */
  100924. getCode(state: NodeMaterialBuildState): string;
  100925. protected _buildBlock(state: NodeMaterialBuildState): this;
  100926. protected _dumpPropertiesCode(): string;
  100927. serialize(): any;
  100928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100929. }
  100930. }
  100931. declare module BABYLON {
  100932. /**
  100933. * Base block used as input for post process
  100934. */
  100935. export class CurrentScreenBlock extends NodeMaterialBlock {
  100936. private _samplerName;
  100937. private _linearDefineName;
  100938. private _gammaDefineName;
  100939. private _mainUVName;
  100940. private _tempTextureRead;
  100941. /**
  100942. * Gets or sets the texture associated with the node
  100943. */
  100944. texture: Nullable<BaseTexture>;
  100945. /**
  100946. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100947. */
  100948. convertToGammaSpace: boolean;
  100949. /**
  100950. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100951. */
  100952. convertToLinearSpace: boolean;
  100953. /**
  100954. * Create a new CurrentScreenBlock
  100955. * @param name defines the block name
  100956. */
  100957. constructor(name: string);
  100958. /**
  100959. * Gets the current class name
  100960. * @returns the class name
  100961. */
  100962. getClassName(): string;
  100963. /**
  100964. * Gets the uv input component
  100965. */
  100966. get uv(): NodeMaterialConnectionPoint;
  100967. /**
  100968. * Gets the rgba output component
  100969. */
  100970. get rgba(): NodeMaterialConnectionPoint;
  100971. /**
  100972. * Gets the rgb output component
  100973. */
  100974. get rgb(): NodeMaterialConnectionPoint;
  100975. /**
  100976. * Gets the r output component
  100977. */
  100978. get r(): NodeMaterialConnectionPoint;
  100979. /**
  100980. * Gets the g output component
  100981. */
  100982. get g(): NodeMaterialConnectionPoint;
  100983. /**
  100984. * Gets the b output component
  100985. */
  100986. get b(): NodeMaterialConnectionPoint;
  100987. /**
  100988. * Gets the a output component
  100989. */
  100990. get a(): NodeMaterialConnectionPoint;
  100991. /**
  100992. * Initialize the block and prepare the context for build
  100993. * @param state defines the state that will be used for the build
  100994. */
  100995. initialize(state: NodeMaterialBuildState): void;
  100996. get target(): NodeMaterialBlockTargets;
  100997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100998. isReady(): boolean;
  100999. private _injectVertexCode;
  101000. private _writeTextureRead;
  101001. private _writeOutput;
  101002. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101003. serialize(): any;
  101004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101005. }
  101006. }
  101007. declare module BABYLON {
  101008. /**
  101009. * Base block used for the particle texture
  101010. */
  101011. export class ParticleTextureBlock extends NodeMaterialBlock {
  101012. private _samplerName;
  101013. private _linearDefineName;
  101014. private _gammaDefineName;
  101015. private _tempTextureRead;
  101016. /**
  101017. * Gets or sets the texture associated with the node
  101018. */
  101019. texture: Nullable<BaseTexture>;
  101020. /**
  101021. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101022. */
  101023. convertToGammaSpace: boolean;
  101024. /**
  101025. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101026. */
  101027. convertToLinearSpace: boolean;
  101028. /**
  101029. * Create a new ParticleTextureBlock
  101030. * @param name defines the block name
  101031. */
  101032. constructor(name: string);
  101033. /**
  101034. * Gets the current class name
  101035. * @returns the class name
  101036. */
  101037. getClassName(): string;
  101038. /**
  101039. * Gets the uv input component
  101040. */
  101041. get uv(): NodeMaterialConnectionPoint;
  101042. /**
  101043. * Gets the rgba output component
  101044. */
  101045. get rgba(): NodeMaterialConnectionPoint;
  101046. /**
  101047. * Gets the rgb output component
  101048. */
  101049. get rgb(): NodeMaterialConnectionPoint;
  101050. /**
  101051. * Gets the r output component
  101052. */
  101053. get r(): NodeMaterialConnectionPoint;
  101054. /**
  101055. * Gets the g output component
  101056. */
  101057. get g(): NodeMaterialConnectionPoint;
  101058. /**
  101059. * Gets the b output component
  101060. */
  101061. get b(): NodeMaterialConnectionPoint;
  101062. /**
  101063. * Gets the a output component
  101064. */
  101065. get a(): NodeMaterialConnectionPoint;
  101066. /**
  101067. * Initialize the block and prepare the context for build
  101068. * @param state defines the state that will be used for the build
  101069. */
  101070. initialize(state: NodeMaterialBuildState): void;
  101071. autoConfigure(material: NodeMaterial): void;
  101072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101073. isReady(): boolean;
  101074. private _writeOutput;
  101075. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101076. serialize(): any;
  101077. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101078. }
  101079. }
  101080. declare module BABYLON {
  101081. /**
  101082. * Class used to store shared data between 2 NodeMaterialBuildState
  101083. */
  101084. export class NodeMaterialBuildStateSharedData {
  101085. /**
  101086. * Gets the list of emitted varyings
  101087. */
  101088. temps: string[];
  101089. /**
  101090. * Gets the list of emitted varyings
  101091. */
  101092. varyings: string[];
  101093. /**
  101094. * Gets the varying declaration string
  101095. */
  101096. varyingDeclaration: string;
  101097. /**
  101098. * Input blocks
  101099. */
  101100. inputBlocks: InputBlock[];
  101101. /**
  101102. * Input blocks
  101103. */
  101104. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101105. /**
  101106. * Bindable blocks (Blocks that need to set data to the effect)
  101107. */
  101108. bindableBlocks: NodeMaterialBlock[];
  101109. /**
  101110. * List of blocks that can provide a compilation fallback
  101111. */
  101112. blocksWithFallbacks: NodeMaterialBlock[];
  101113. /**
  101114. * List of blocks that can provide a define update
  101115. */
  101116. blocksWithDefines: NodeMaterialBlock[];
  101117. /**
  101118. * List of blocks that can provide a repeatable content
  101119. */
  101120. repeatableContentBlocks: NodeMaterialBlock[];
  101121. /**
  101122. * List of blocks that can provide a dynamic list of uniforms
  101123. */
  101124. dynamicUniformBlocks: NodeMaterialBlock[];
  101125. /**
  101126. * List of blocks that can block the isReady function for the material
  101127. */
  101128. blockingBlocks: NodeMaterialBlock[];
  101129. /**
  101130. * Gets the list of animated inputs
  101131. */
  101132. animatedInputs: InputBlock[];
  101133. /**
  101134. * Build Id used to avoid multiple recompilations
  101135. */
  101136. buildId: number;
  101137. /** List of emitted variables */
  101138. variableNames: {
  101139. [key: string]: number;
  101140. };
  101141. /** List of emitted defines */
  101142. defineNames: {
  101143. [key: string]: number;
  101144. };
  101145. /** Should emit comments? */
  101146. emitComments: boolean;
  101147. /** Emit build activity */
  101148. verbose: boolean;
  101149. /** Gets or sets the hosting scene */
  101150. scene: Scene;
  101151. /**
  101152. * Gets the compilation hints emitted at compilation time
  101153. */
  101154. hints: {
  101155. needWorldViewMatrix: boolean;
  101156. needWorldViewProjectionMatrix: boolean;
  101157. needAlphaBlending: boolean;
  101158. needAlphaTesting: boolean;
  101159. };
  101160. /**
  101161. * List of compilation checks
  101162. */
  101163. checks: {
  101164. emitVertex: boolean;
  101165. emitFragment: boolean;
  101166. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101167. };
  101168. /**
  101169. * Is vertex program allowed to be empty?
  101170. */
  101171. allowEmptyVertexProgram: boolean;
  101172. /** Creates a new shared data */
  101173. constructor();
  101174. /**
  101175. * Emits console errors and exceptions if there is a failing check
  101176. */
  101177. emitErrors(): void;
  101178. }
  101179. }
  101180. declare module BABYLON {
  101181. /**
  101182. * Class used to store node based material build state
  101183. */
  101184. export class NodeMaterialBuildState {
  101185. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101186. supportUniformBuffers: boolean;
  101187. /**
  101188. * Gets the list of emitted attributes
  101189. */
  101190. attributes: string[];
  101191. /**
  101192. * Gets the list of emitted uniforms
  101193. */
  101194. uniforms: string[];
  101195. /**
  101196. * Gets the list of emitted constants
  101197. */
  101198. constants: string[];
  101199. /**
  101200. * Gets the list of emitted samplers
  101201. */
  101202. samplers: string[];
  101203. /**
  101204. * Gets the list of emitted functions
  101205. */
  101206. functions: {
  101207. [key: string]: string;
  101208. };
  101209. /**
  101210. * Gets the list of emitted extensions
  101211. */
  101212. extensions: {
  101213. [key: string]: string;
  101214. };
  101215. /**
  101216. * Gets the target of the compilation state
  101217. */
  101218. target: NodeMaterialBlockTargets;
  101219. /**
  101220. * Gets the list of emitted counters
  101221. */
  101222. counters: {
  101223. [key: string]: number;
  101224. };
  101225. /**
  101226. * Shared data between multiple NodeMaterialBuildState instances
  101227. */
  101228. sharedData: NodeMaterialBuildStateSharedData;
  101229. /** @hidden */
  101230. _vertexState: NodeMaterialBuildState;
  101231. /** @hidden */
  101232. _attributeDeclaration: string;
  101233. /** @hidden */
  101234. _uniformDeclaration: string;
  101235. /** @hidden */
  101236. _constantDeclaration: string;
  101237. /** @hidden */
  101238. _samplerDeclaration: string;
  101239. /** @hidden */
  101240. _varyingTransfer: string;
  101241. /** @hidden */
  101242. _injectAtEnd: string;
  101243. private _repeatableContentAnchorIndex;
  101244. /** @hidden */
  101245. _builtCompilationString: string;
  101246. /**
  101247. * Gets the emitted compilation strings
  101248. */
  101249. compilationString: string;
  101250. /**
  101251. * Finalize the compilation strings
  101252. * @param state defines the current compilation state
  101253. */
  101254. finalize(state: NodeMaterialBuildState): void;
  101255. /** @hidden */
  101256. get _repeatableContentAnchor(): string;
  101257. /** @hidden */
  101258. _getFreeVariableName(prefix: string): string;
  101259. /** @hidden */
  101260. _getFreeDefineName(prefix: string): string;
  101261. /** @hidden */
  101262. _excludeVariableName(name: string): void;
  101263. /** @hidden */
  101264. _emit2DSampler(name: string): void;
  101265. /** @hidden */
  101266. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101267. /** @hidden */
  101268. _emitExtension(name: string, extension: string, define?: string): void;
  101269. /** @hidden */
  101270. _emitFunction(name: string, code: string, comments: string): void;
  101271. /** @hidden */
  101272. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101273. replaceStrings?: {
  101274. search: RegExp;
  101275. replace: string;
  101276. }[];
  101277. repeatKey?: string;
  101278. }): string;
  101279. /** @hidden */
  101280. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101281. repeatKey?: string;
  101282. removeAttributes?: boolean;
  101283. removeUniforms?: boolean;
  101284. removeVaryings?: boolean;
  101285. removeIfDef?: boolean;
  101286. replaceStrings?: {
  101287. search: RegExp;
  101288. replace: string;
  101289. }[];
  101290. }, storeKey?: string): void;
  101291. /** @hidden */
  101292. _registerTempVariable(name: string): boolean;
  101293. /** @hidden */
  101294. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101295. /** @hidden */
  101296. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101297. /** @hidden */
  101298. _emitFloat(value: number): string;
  101299. }
  101300. }
  101301. declare module BABYLON {
  101302. /**
  101303. * Helper class used to generate session unique ID
  101304. */
  101305. export class UniqueIdGenerator {
  101306. private static _UniqueIdCounter;
  101307. /**
  101308. * Gets an unique (relatively to the current scene) Id
  101309. */
  101310. static get UniqueId(): number;
  101311. }
  101312. }
  101313. declare module BABYLON {
  101314. /**
  101315. * Defines a block that can be used inside a node based material
  101316. */
  101317. export class NodeMaterialBlock {
  101318. private _buildId;
  101319. private _buildTarget;
  101320. private _target;
  101321. private _isFinalMerger;
  101322. private _isInput;
  101323. private _name;
  101324. protected _isUnique: boolean;
  101325. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101326. inputsAreExclusive: boolean;
  101327. /** @hidden */
  101328. _codeVariableName: string;
  101329. /** @hidden */
  101330. _inputs: NodeMaterialConnectionPoint[];
  101331. /** @hidden */
  101332. _outputs: NodeMaterialConnectionPoint[];
  101333. /** @hidden */
  101334. _preparationId: number;
  101335. /**
  101336. * Gets the name of the block
  101337. */
  101338. get name(): string;
  101339. /**
  101340. * Sets the name of the block. Will check if the name is valid.
  101341. */
  101342. set name(newName: string);
  101343. /**
  101344. * Gets or sets the unique id of the node
  101345. */
  101346. uniqueId: number;
  101347. /**
  101348. * Gets or sets the comments associated with this block
  101349. */
  101350. comments: string;
  101351. /**
  101352. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101353. */
  101354. get isUnique(): boolean;
  101355. /**
  101356. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101357. */
  101358. get isFinalMerger(): boolean;
  101359. /**
  101360. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101361. */
  101362. get isInput(): boolean;
  101363. /**
  101364. * Gets or sets the build Id
  101365. */
  101366. get buildId(): number;
  101367. set buildId(value: number);
  101368. /**
  101369. * Gets or sets the target of the block
  101370. */
  101371. get target(): NodeMaterialBlockTargets;
  101372. set target(value: NodeMaterialBlockTargets);
  101373. /**
  101374. * Gets the list of input points
  101375. */
  101376. get inputs(): NodeMaterialConnectionPoint[];
  101377. /** Gets the list of output points */
  101378. get outputs(): NodeMaterialConnectionPoint[];
  101379. /**
  101380. * Find an input by its name
  101381. * @param name defines the name of the input to look for
  101382. * @returns the input or null if not found
  101383. */
  101384. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101385. /**
  101386. * Find an output by its name
  101387. * @param name defines the name of the outputto look for
  101388. * @returns the output or null if not found
  101389. */
  101390. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101391. /**
  101392. * Creates a new NodeMaterialBlock
  101393. * @param name defines the block name
  101394. * @param target defines the target of that block (Vertex by default)
  101395. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101396. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101397. */
  101398. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101399. /**
  101400. * Initialize the block and prepare the context for build
  101401. * @param state defines the state that will be used for the build
  101402. */
  101403. initialize(state: NodeMaterialBuildState): void;
  101404. /**
  101405. * Bind data to effect. Will only be called for blocks with isBindable === true
  101406. * @param effect defines the effect to bind data to
  101407. * @param nodeMaterial defines the hosting NodeMaterial
  101408. * @param mesh defines the mesh that will be rendered
  101409. * @param subMesh defines the submesh that will be rendered
  101410. */
  101411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101412. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101413. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101414. protected _writeFloat(value: number): string;
  101415. /**
  101416. * Gets the current class name e.g. "NodeMaterialBlock"
  101417. * @returns the class name
  101418. */
  101419. getClassName(): string;
  101420. /**
  101421. * Register a new input. Must be called inside a block constructor
  101422. * @param name defines the connection point name
  101423. * @param type defines the connection point type
  101424. * @param isOptional defines a boolean indicating that this input can be omitted
  101425. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101426. * @param point an already created connection point. If not provided, create a new one
  101427. * @returns the current block
  101428. */
  101429. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101430. /**
  101431. * Register a new output. Must be called inside a block constructor
  101432. * @param name defines the connection point name
  101433. * @param type defines the connection point type
  101434. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101435. * @param point an already created connection point. If not provided, create a new one
  101436. * @returns the current block
  101437. */
  101438. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101439. /**
  101440. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101441. * @param forOutput defines an optional connection point to check compatibility with
  101442. * @returns the first available input or null
  101443. */
  101444. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101445. /**
  101446. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101447. * @param forBlock defines an optional block to check compatibility with
  101448. * @returns the first available input or null
  101449. */
  101450. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101451. /**
  101452. * Gets the sibling of the given output
  101453. * @param current defines the current output
  101454. * @returns the next output in the list or null
  101455. */
  101456. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  101457. /**
  101458. * Connect current block with another block
  101459. * @param other defines the block to connect with
  101460. * @param options define the various options to help pick the right connections
  101461. * @returns the current block
  101462. */
  101463. connectTo(other: NodeMaterialBlock, options?: {
  101464. input?: string;
  101465. output?: string;
  101466. outputSwizzle?: string;
  101467. }): this | undefined;
  101468. protected _buildBlock(state: NodeMaterialBuildState): void;
  101469. /**
  101470. * Add uniforms, samplers and uniform buffers at compilation time
  101471. * @param state defines the state to update
  101472. * @param nodeMaterial defines the node material requesting the update
  101473. * @param defines defines the material defines to update
  101474. * @param uniformBuffers defines the list of uniform buffer names
  101475. */
  101476. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  101477. /**
  101478. * Add potential fallbacks if shader compilation fails
  101479. * @param mesh defines the mesh to be rendered
  101480. * @param fallbacks defines the current prioritized list of fallbacks
  101481. */
  101482. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  101483. /**
  101484. * Initialize defines for shader compilation
  101485. * @param mesh defines the mesh to be rendered
  101486. * @param nodeMaterial defines the node material requesting the update
  101487. * @param defines defines the material defines to update
  101488. * @param useInstances specifies that instances should be used
  101489. */
  101490. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101491. /**
  101492. * Update defines for shader compilation
  101493. * @param mesh defines the mesh to be rendered
  101494. * @param nodeMaterial defines the node material requesting the update
  101495. * @param defines defines the material defines to update
  101496. * @param useInstances specifies that instances should be used
  101497. * @param subMesh defines which submesh to render
  101498. */
  101499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101500. /**
  101501. * Lets the block try to connect some inputs automatically
  101502. * @param material defines the hosting NodeMaterial
  101503. */
  101504. autoConfigure(material: NodeMaterial): void;
  101505. /**
  101506. * Function called when a block is declared as repeatable content generator
  101507. * @param vertexShaderState defines the current compilation state for the vertex shader
  101508. * @param fragmentShaderState defines the current compilation state for the fragment shader
  101509. * @param mesh defines the mesh to be rendered
  101510. * @param defines defines the material defines to update
  101511. */
  101512. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  101513. /**
  101514. * Checks if the block is ready
  101515. * @param mesh defines the mesh to be rendered
  101516. * @param nodeMaterial defines the node material requesting the update
  101517. * @param defines defines the material defines to update
  101518. * @param useInstances specifies that instances should be used
  101519. * @returns true if the block is ready
  101520. */
  101521. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  101522. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  101523. private _processBuild;
  101524. /**
  101525. * Validates the new name for the block node.
  101526. * @param newName the new name to be given to the node.
  101527. * @returns false if the name is a reserve word, else true.
  101528. */
  101529. validateBlockName(newName: string): boolean;
  101530. /**
  101531. * Compile the current node and generate the shader code
  101532. * @param state defines the current compilation state (uniforms, samplers, current string)
  101533. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101534. * @returns true if already built
  101535. */
  101536. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101537. protected _inputRename(name: string): string;
  101538. protected _outputRename(name: string): string;
  101539. protected _dumpPropertiesCode(): string;
  101540. /** @hidden */
  101541. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101542. /** @hidden */
  101543. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101544. /**
  101545. * Clone the current block to a new identical block
  101546. * @param scene defines the hosting scene
  101547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101548. * @returns a copy of the current block
  101549. */
  101550. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101551. /**
  101552. * Serializes this block in a JSON representation
  101553. * @returns the serialized block object
  101554. */
  101555. serialize(): any;
  101556. /** @hidden */
  101557. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101558. private _deserializePortDisplayNamesAndExposedOnFrame;
  101559. /**
  101560. * Release resources
  101561. */
  101562. dispose(): void;
  101563. }
  101564. }
  101565. declare module BABYLON {
  101566. /**
  101567. * Base class of materials working in push mode in babylon JS
  101568. * @hidden
  101569. */
  101570. export class PushMaterial extends Material {
  101571. protected _activeEffect: Effect;
  101572. protected _normalMatrix: Matrix;
  101573. constructor(name: string, scene: Scene);
  101574. getEffect(): Effect;
  101575. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101576. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101577. /**
  101578. * Binds the given world matrix to the active effect
  101579. *
  101580. * @param world the matrix to bind
  101581. */
  101582. bindOnlyWorldMatrix(world: Matrix): void;
  101583. /**
  101584. * Binds the given normal matrix to the active effect
  101585. *
  101586. * @param normalMatrix the matrix to bind
  101587. */
  101588. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101589. bind(world: Matrix, mesh?: Mesh): void;
  101590. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101591. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101592. }
  101593. }
  101594. declare module BABYLON {
  101595. /**
  101596. * Root class for all node material optimizers
  101597. */
  101598. export class NodeMaterialOptimizer {
  101599. /**
  101600. * Function used to optimize a NodeMaterial graph
  101601. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101602. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101603. */
  101604. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101605. }
  101606. }
  101607. declare module BABYLON {
  101608. /**
  101609. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101610. */
  101611. export class TransformBlock extends NodeMaterialBlock {
  101612. /**
  101613. * Defines the value to use to complement W value to transform it to a Vector4
  101614. */
  101615. complementW: number;
  101616. /**
  101617. * Defines the value to use to complement z value to transform it to a Vector4
  101618. */
  101619. complementZ: number;
  101620. /**
  101621. * Creates a new TransformBlock
  101622. * @param name defines the block name
  101623. */
  101624. constructor(name: string);
  101625. /**
  101626. * Gets the current class name
  101627. * @returns the class name
  101628. */
  101629. getClassName(): string;
  101630. /**
  101631. * Gets the vector input
  101632. */
  101633. get vector(): NodeMaterialConnectionPoint;
  101634. /**
  101635. * Gets the output component
  101636. */
  101637. get output(): NodeMaterialConnectionPoint;
  101638. /**
  101639. * Gets the xyz output component
  101640. */
  101641. get xyz(): NodeMaterialConnectionPoint;
  101642. /**
  101643. * Gets the matrix transform input
  101644. */
  101645. get transform(): NodeMaterialConnectionPoint;
  101646. protected _buildBlock(state: NodeMaterialBuildState): this;
  101647. /**
  101648. * Update defines for shader compilation
  101649. * @param mesh defines the mesh to be rendered
  101650. * @param nodeMaterial defines the node material requesting the update
  101651. * @param defines defines the material defines to update
  101652. * @param useInstances specifies that instances should be used
  101653. * @param subMesh defines which submesh to render
  101654. */
  101655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101656. serialize(): any;
  101657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101658. protected _dumpPropertiesCode(): string;
  101659. }
  101660. }
  101661. declare module BABYLON {
  101662. /**
  101663. * Block used to output the vertex position
  101664. */
  101665. export class VertexOutputBlock extends NodeMaterialBlock {
  101666. /**
  101667. * Creates a new VertexOutputBlock
  101668. * @param name defines the block name
  101669. */
  101670. constructor(name: string);
  101671. /**
  101672. * Gets the current class name
  101673. * @returns the class name
  101674. */
  101675. getClassName(): string;
  101676. /**
  101677. * Gets the vector input component
  101678. */
  101679. get vector(): NodeMaterialConnectionPoint;
  101680. protected _buildBlock(state: NodeMaterialBuildState): this;
  101681. }
  101682. }
  101683. declare module BABYLON {
  101684. /**
  101685. * Block used to output the final color
  101686. */
  101687. export class FragmentOutputBlock extends NodeMaterialBlock {
  101688. /**
  101689. * Create a new FragmentOutputBlock
  101690. * @param name defines the block name
  101691. */
  101692. constructor(name: string);
  101693. /**
  101694. * Gets the current class name
  101695. * @returns the class name
  101696. */
  101697. getClassName(): string;
  101698. /**
  101699. * Gets the rgba input component
  101700. */
  101701. get rgba(): NodeMaterialConnectionPoint;
  101702. /**
  101703. * Gets the rgb input component
  101704. */
  101705. get rgb(): NodeMaterialConnectionPoint;
  101706. /**
  101707. * Gets the a input component
  101708. */
  101709. get a(): NodeMaterialConnectionPoint;
  101710. protected _buildBlock(state: NodeMaterialBuildState): this;
  101711. }
  101712. }
  101713. declare module BABYLON {
  101714. /**
  101715. * Block used for the particle ramp gradient section
  101716. */
  101717. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101718. /**
  101719. * Create a new ParticleRampGradientBlock
  101720. * @param name defines the block name
  101721. */
  101722. constructor(name: string);
  101723. /**
  101724. * Gets the current class name
  101725. * @returns the class name
  101726. */
  101727. getClassName(): string;
  101728. /**
  101729. * Gets the color input component
  101730. */
  101731. get color(): NodeMaterialConnectionPoint;
  101732. /**
  101733. * Gets the rampColor output component
  101734. */
  101735. get rampColor(): NodeMaterialConnectionPoint;
  101736. /**
  101737. * Initialize the block and prepare the context for build
  101738. * @param state defines the state that will be used for the build
  101739. */
  101740. initialize(state: NodeMaterialBuildState): void;
  101741. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101742. }
  101743. }
  101744. declare module BABYLON {
  101745. /**
  101746. * Block used for the particle blend multiply section
  101747. */
  101748. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101749. /**
  101750. * Create a new ParticleBlendMultiplyBlock
  101751. * @param name defines the block name
  101752. */
  101753. constructor(name: string);
  101754. /**
  101755. * Gets the current class name
  101756. * @returns the class name
  101757. */
  101758. getClassName(): string;
  101759. /**
  101760. * Gets the color input component
  101761. */
  101762. get color(): NodeMaterialConnectionPoint;
  101763. /**
  101764. * Gets the alphaTexture input component
  101765. */
  101766. get alphaTexture(): NodeMaterialConnectionPoint;
  101767. /**
  101768. * Gets the alphaColor input component
  101769. */
  101770. get alphaColor(): NodeMaterialConnectionPoint;
  101771. /**
  101772. * Gets the blendColor output component
  101773. */
  101774. get blendColor(): NodeMaterialConnectionPoint;
  101775. /**
  101776. * Initialize the block and prepare the context for build
  101777. * @param state defines the state that will be used for the build
  101778. */
  101779. initialize(state: NodeMaterialBuildState): void;
  101780. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101781. }
  101782. }
  101783. declare module BABYLON {
  101784. /**
  101785. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101786. */
  101787. export class VectorMergerBlock extends NodeMaterialBlock {
  101788. /**
  101789. * Create a new VectorMergerBlock
  101790. * @param name defines the block name
  101791. */
  101792. constructor(name: string);
  101793. /**
  101794. * Gets the current class name
  101795. * @returns the class name
  101796. */
  101797. getClassName(): string;
  101798. /**
  101799. * Gets the xyz component (input)
  101800. */
  101801. get xyzIn(): NodeMaterialConnectionPoint;
  101802. /**
  101803. * Gets the xy component (input)
  101804. */
  101805. get xyIn(): NodeMaterialConnectionPoint;
  101806. /**
  101807. * Gets the x component (input)
  101808. */
  101809. get x(): NodeMaterialConnectionPoint;
  101810. /**
  101811. * Gets the y component (input)
  101812. */
  101813. get y(): NodeMaterialConnectionPoint;
  101814. /**
  101815. * Gets the z component (input)
  101816. */
  101817. get z(): NodeMaterialConnectionPoint;
  101818. /**
  101819. * Gets the w component (input)
  101820. */
  101821. get w(): NodeMaterialConnectionPoint;
  101822. /**
  101823. * Gets the xyzw component (output)
  101824. */
  101825. get xyzw(): NodeMaterialConnectionPoint;
  101826. /**
  101827. * Gets the xyz component (output)
  101828. */
  101829. get xyzOut(): NodeMaterialConnectionPoint;
  101830. /**
  101831. * Gets the xy component (output)
  101832. */
  101833. get xyOut(): NodeMaterialConnectionPoint;
  101834. /**
  101835. * Gets the xy component (output)
  101836. * @deprecated Please use xyOut instead.
  101837. */
  101838. get xy(): NodeMaterialConnectionPoint;
  101839. /**
  101840. * Gets the xyz component (output)
  101841. * @deprecated Please use xyzOut instead.
  101842. */
  101843. get xyz(): NodeMaterialConnectionPoint;
  101844. protected _buildBlock(state: NodeMaterialBuildState): this;
  101845. }
  101846. }
  101847. declare module BABYLON {
  101848. /**
  101849. * Block used to remap a float from a range to a new one
  101850. */
  101851. export class RemapBlock extends NodeMaterialBlock {
  101852. /**
  101853. * Gets or sets the source range
  101854. */
  101855. sourceRange: Vector2;
  101856. /**
  101857. * Gets or sets the target range
  101858. */
  101859. targetRange: Vector2;
  101860. /**
  101861. * Creates a new RemapBlock
  101862. * @param name defines the block name
  101863. */
  101864. constructor(name: string);
  101865. /**
  101866. * Gets the current class name
  101867. * @returns the class name
  101868. */
  101869. getClassName(): string;
  101870. /**
  101871. * Gets the input component
  101872. */
  101873. get input(): NodeMaterialConnectionPoint;
  101874. /**
  101875. * Gets the source min input component
  101876. */
  101877. get sourceMin(): NodeMaterialConnectionPoint;
  101878. /**
  101879. * Gets the source max input component
  101880. */
  101881. get sourceMax(): NodeMaterialConnectionPoint;
  101882. /**
  101883. * Gets the target min input component
  101884. */
  101885. get targetMin(): NodeMaterialConnectionPoint;
  101886. /**
  101887. * Gets the target max input component
  101888. */
  101889. get targetMax(): NodeMaterialConnectionPoint;
  101890. /**
  101891. * Gets the output component
  101892. */
  101893. get output(): NodeMaterialConnectionPoint;
  101894. protected _buildBlock(state: NodeMaterialBuildState): this;
  101895. protected _dumpPropertiesCode(): string;
  101896. serialize(): any;
  101897. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101898. }
  101899. }
  101900. declare module BABYLON {
  101901. /**
  101902. * Block used to multiply 2 values
  101903. */
  101904. export class MultiplyBlock extends NodeMaterialBlock {
  101905. /**
  101906. * Creates a new MultiplyBlock
  101907. * @param name defines the block name
  101908. */
  101909. constructor(name: string);
  101910. /**
  101911. * Gets the current class name
  101912. * @returns the class name
  101913. */
  101914. getClassName(): string;
  101915. /**
  101916. * Gets the left operand input component
  101917. */
  101918. get left(): NodeMaterialConnectionPoint;
  101919. /**
  101920. * Gets the right operand input component
  101921. */
  101922. get right(): NodeMaterialConnectionPoint;
  101923. /**
  101924. * Gets the output component
  101925. */
  101926. get output(): NodeMaterialConnectionPoint;
  101927. protected _buildBlock(state: NodeMaterialBuildState): this;
  101928. }
  101929. }
  101930. declare module BABYLON {
  101931. /**
  101932. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  101933. */
  101934. export class ColorSplitterBlock extends NodeMaterialBlock {
  101935. /**
  101936. * Create a new ColorSplitterBlock
  101937. * @param name defines the block name
  101938. */
  101939. constructor(name: string);
  101940. /**
  101941. * Gets the current class name
  101942. * @returns the class name
  101943. */
  101944. getClassName(): string;
  101945. /**
  101946. * Gets the rgba component (input)
  101947. */
  101948. get rgba(): NodeMaterialConnectionPoint;
  101949. /**
  101950. * Gets the rgb component (input)
  101951. */
  101952. get rgbIn(): NodeMaterialConnectionPoint;
  101953. /**
  101954. * Gets the rgb component (output)
  101955. */
  101956. get rgbOut(): NodeMaterialConnectionPoint;
  101957. /**
  101958. * Gets the r component (output)
  101959. */
  101960. get r(): NodeMaterialConnectionPoint;
  101961. /**
  101962. * Gets the g component (output)
  101963. */
  101964. get g(): NodeMaterialConnectionPoint;
  101965. /**
  101966. * Gets the b component (output)
  101967. */
  101968. get b(): NodeMaterialConnectionPoint;
  101969. /**
  101970. * Gets the a component (output)
  101971. */
  101972. get a(): NodeMaterialConnectionPoint;
  101973. protected _inputRename(name: string): string;
  101974. protected _outputRename(name: string): string;
  101975. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101976. }
  101977. }
  101978. declare module BABYLON {
  101979. /**
  101980. * Interface used to configure the node material editor
  101981. */
  101982. export interface INodeMaterialEditorOptions {
  101983. /** Define the URl to load node editor script */
  101984. editorURL?: string;
  101985. }
  101986. /** @hidden */
  101987. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101988. NORMAL: boolean;
  101989. TANGENT: boolean;
  101990. UV1: boolean;
  101991. /** BONES */
  101992. NUM_BONE_INFLUENCERS: number;
  101993. BonesPerMesh: number;
  101994. BONETEXTURE: boolean;
  101995. /** MORPH TARGETS */
  101996. MORPHTARGETS: boolean;
  101997. MORPHTARGETS_NORMAL: boolean;
  101998. MORPHTARGETS_TANGENT: boolean;
  101999. MORPHTARGETS_UV: boolean;
  102000. NUM_MORPH_INFLUENCERS: number;
  102001. /** IMAGE PROCESSING */
  102002. IMAGEPROCESSING: boolean;
  102003. VIGNETTE: boolean;
  102004. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102005. VIGNETTEBLENDMODEOPAQUE: boolean;
  102006. TONEMAPPING: boolean;
  102007. TONEMAPPING_ACES: boolean;
  102008. CONTRAST: boolean;
  102009. EXPOSURE: boolean;
  102010. COLORCURVES: boolean;
  102011. COLORGRADING: boolean;
  102012. COLORGRADING3D: boolean;
  102013. SAMPLER3DGREENDEPTH: boolean;
  102014. SAMPLER3DBGRMAP: boolean;
  102015. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102016. /** MISC. */
  102017. BUMPDIRECTUV: number;
  102018. constructor();
  102019. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102020. }
  102021. /**
  102022. * Class used to configure NodeMaterial
  102023. */
  102024. export interface INodeMaterialOptions {
  102025. /**
  102026. * Defines if blocks should emit comments
  102027. */
  102028. emitComments: boolean;
  102029. }
  102030. /**
  102031. * Class used to create a node based material built by assembling shader blocks
  102032. */
  102033. export class NodeMaterial extends PushMaterial {
  102034. private static _BuildIdGenerator;
  102035. private _options;
  102036. private _vertexCompilationState;
  102037. private _fragmentCompilationState;
  102038. private _sharedData;
  102039. private _buildId;
  102040. private _buildWasSuccessful;
  102041. private _cachedWorldViewMatrix;
  102042. private _cachedWorldViewProjectionMatrix;
  102043. private _optimizers;
  102044. private _animationFrame;
  102045. /** Define the Url to load node editor script */
  102046. static EditorURL: string;
  102047. /** Define the Url to load snippets */
  102048. static SnippetUrl: string;
  102049. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102050. static IgnoreTexturesAtLoadTime: boolean;
  102051. private BJSNODEMATERIALEDITOR;
  102052. /** Get the inspector from bundle or global */
  102053. private _getGlobalNodeMaterialEditor;
  102054. /**
  102055. * Snippet ID if the material was created from the snippet server
  102056. */
  102057. snippetId: string;
  102058. /**
  102059. * Gets or sets data used by visual editor
  102060. * @see https://nme.babylonjs.com
  102061. */
  102062. editorData: any;
  102063. /**
  102064. * 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)
  102065. */
  102066. ignoreAlpha: boolean;
  102067. /**
  102068. * Defines the maximum number of lights that can be used in the material
  102069. */
  102070. maxSimultaneousLights: number;
  102071. /**
  102072. * Observable raised when the material is built
  102073. */
  102074. onBuildObservable: Observable<NodeMaterial>;
  102075. /**
  102076. * Gets or sets the root nodes of the material vertex shader
  102077. */
  102078. _vertexOutputNodes: NodeMaterialBlock[];
  102079. /**
  102080. * Gets or sets the root nodes of the material fragment (pixel) shader
  102081. */
  102082. _fragmentOutputNodes: NodeMaterialBlock[];
  102083. /** Gets or sets options to control the node material overall behavior */
  102084. get options(): INodeMaterialOptions;
  102085. set options(options: INodeMaterialOptions);
  102086. /**
  102087. * Default configuration related to image processing available in the standard Material.
  102088. */
  102089. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102090. /**
  102091. * Gets the image processing configuration used either in this material.
  102092. */
  102093. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102094. /**
  102095. * Sets the Default image processing configuration used either in the this material.
  102096. *
  102097. * If sets to null, the scene one is in use.
  102098. */
  102099. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102100. /**
  102101. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102102. */
  102103. attachedBlocks: NodeMaterialBlock[];
  102104. /**
  102105. * Specifies the mode of the node material
  102106. * @hidden
  102107. */
  102108. _mode: NodeMaterialModes;
  102109. /**
  102110. * Gets the mode property
  102111. */
  102112. get mode(): NodeMaterialModes;
  102113. /**
  102114. * Create a new node based material
  102115. * @param name defines the material name
  102116. * @param scene defines the hosting scene
  102117. * @param options defines creation option
  102118. */
  102119. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102120. /**
  102121. * Gets the current class name of the material e.g. "NodeMaterial"
  102122. * @returns the class name
  102123. */
  102124. getClassName(): string;
  102125. /**
  102126. * Keep track of the image processing observer to allow dispose and replace.
  102127. */
  102128. private _imageProcessingObserver;
  102129. /**
  102130. * Attaches a new image processing configuration to the Standard Material.
  102131. * @param configuration
  102132. */
  102133. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102134. /**
  102135. * Get a block by its name
  102136. * @param name defines the name of the block to retrieve
  102137. * @returns the required block or null if not found
  102138. */
  102139. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102140. /**
  102141. * Get a block by its name
  102142. * @param predicate defines the predicate used to find the good candidate
  102143. * @returns the required block or null if not found
  102144. */
  102145. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102146. /**
  102147. * Get an input block by its name
  102148. * @param predicate defines the predicate used to find the good candidate
  102149. * @returns the required input block or null if not found
  102150. */
  102151. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102152. /**
  102153. * Gets the list of input blocks attached to this material
  102154. * @returns an array of InputBlocks
  102155. */
  102156. getInputBlocks(): InputBlock[];
  102157. /**
  102158. * Adds a new optimizer to the list of optimizers
  102159. * @param optimizer defines the optimizers to add
  102160. * @returns the current material
  102161. */
  102162. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102163. /**
  102164. * Remove an optimizer from the list of optimizers
  102165. * @param optimizer defines the optimizers to remove
  102166. * @returns the current material
  102167. */
  102168. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102169. /**
  102170. * Add a new block to the list of output nodes
  102171. * @param node defines the node to add
  102172. * @returns the current material
  102173. */
  102174. addOutputNode(node: NodeMaterialBlock): this;
  102175. /**
  102176. * Remove a block from the list of root nodes
  102177. * @param node defines the node to remove
  102178. * @returns the current material
  102179. */
  102180. removeOutputNode(node: NodeMaterialBlock): this;
  102181. private _addVertexOutputNode;
  102182. private _removeVertexOutputNode;
  102183. private _addFragmentOutputNode;
  102184. private _removeFragmentOutputNode;
  102185. /**
  102186. * Specifies if the material will require alpha blending
  102187. * @returns a boolean specifying if alpha blending is needed
  102188. */
  102189. needAlphaBlending(): boolean;
  102190. /**
  102191. * Specifies if this material should be rendered in alpha test mode
  102192. * @returns a boolean specifying if an alpha test is needed.
  102193. */
  102194. needAlphaTesting(): boolean;
  102195. private _initializeBlock;
  102196. private _resetDualBlocks;
  102197. /**
  102198. * Remove a block from the current node material
  102199. * @param block defines the block to remove
  102200. */
  102201. removeBlock(block: NodeMaterialBlock): void;
  102202. /**
  102203. * Build the material and generates the inner effect
  102204. * @param verbose defines if the build should log activity
  102205. */
  102206. build(verbose?: boolean): void;
  102207. /**
  102208. * Runs an otpimization phase to try to improve the shader code
  102209. */
  102210. optimize(): void;
  102211. private _prepareDefinesForAttributes;
  102212. /**
  102213. * Create a post process from the material
  102214. * @param camera The camera to apply the render pass to.
  102215. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102217. * @param engine The engine which the post process will be applied. (default: current engine)
  102218. * @param reusable If the post process can be reused on the same frame. (default: false)
  102219. * @param textureType Type of textures used when performing the post process. (default: 0)
  102220. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102221. * @returns the post process created
  102222. */
  102223. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  102224. /**
  102225. * Create the post process effect from the material
  102226. * @param postProcess The post process to create the effect for
  102227. */
  102228. createEffectForPostProcess(postProcess: PostProcess): void;
  102229. private _createEffectOrPostProcess;
  102230. private _createEffectForParticles;
  102231. /**
  102232. * Create the effect to be used as the custom effect for a particle system
  102233. * @param particleSystem Particle system to create the effect for
  102234. * @param onCompiled defines a function to call when the effect creation is successful
  102235. * @param onError defines a function to call when the effect creation has failed
  102236. */
  102237. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102238. private _processDefines;
  102239. /**
  102240. * Get if the submesh is ready to be used and all its information available.
  102241. * Child classes can use it to update shaders
  102242. * @param mesh defines the mesh to check
  102243. * @param subMesh defines which submesh to check
  102244. * @param useInstances specifies that instances should be used
  102245. * @returns a boolean indicating that the submesh is ready or not
  102246. */
  102247. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102248. /**
  102249. * Get a string representing the shaders built by the current node graph
  102250. */
  102251. get compiledShaders(): string;
  102252. /**
  102253. * Binds the world matrix to the material
  102254. * @param world defines the world transformation matrix
  102255. */
  102256. bindOnlyWorldMatrix(world: Matrix): void;
  102257. /**
  102258. * Binds the submesh to this material by preparing the effect and shader to draw
  102259. * @param world defines the world transformation matrix
  102260. * @param mesh defines the mesh containing the submesh
  102261. * @param subMesh defines the submesh to bind the material to
  102262. */
  102263. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102264. /**
  102265. * Gets the active textures from the material
  102266. * @returns an array of textures
  102267. */
  102268. getActiveTextures(): BaseTexture[];
  102269. /**
  102270. * Gets the list of texture blocks
  102271. * @returns an array of texture blocks
  102272. */
  102273. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102274. /**
  102275. * Specifies if the material uses a texture
  102276. * @param texture defines the texture to check against the material
  102277. * @returns a boolean specifying if the material uses the texture
  102278. */
  102279. hasTexture(texture: BaseTexture): boolean;
  102280. /**
  102281. * Disposes the material
  102282. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102283. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102284. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102285. */
  102286. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102287. /** Creates the node editor window. */
  102288. private _createNodeEditor;
  102289. /**
  102290. * Launch the node material editor
  102291. * @param config Define the configuration of the editor
  102292. * @return a promise fulfilled when the node editor is visible
  102293. */
  102294. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102295. /**
  102296. * Clear the current material
  102297. */
  102298. clear(): void;
  102299. /**
  102300. * Clear the current material and set it to a default state
  102301. */
  102302. setToDefault(): void;
  102303. /**
  102304. * Clear the current material and set it to a default state for post process
  102305. */
  102306. setToDefaultPostProcess(): void;
  102307. /**
  102308. * Clear the current material and set it to a default state for particle
  102309. */
  102310. setToDefaultParticle(): void;
  102311. /**
  102312. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102313. * @param url defines the url to load from
  102314. * @returns a promise that will fullfil when the material is fully loaded
  102315. */
  102316. loadAsync(url: string): Promise<void>;
  102317. private _gatherBlocks;
  102318. /**
  102319. * Generate a string containing the code declaration required to create an equivalent of this material
  102320. * @returns a string
  102321. */
  102322. generateCode(): string;
  102323. /**
  102324. * Serializes this material in a JSON representation
  102325. * @returns the serialized material object
  102326. */
  102327. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102328. private _restoreConnections;
  102329. /**
  102330. * Clear the current graph and load a new one from a serialization object
  102331. * @param source defines the JSON representation of the material
  102332. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102333. * @param merge defines whether or not the source must be merged or replace the current content
  102334. */
  102335. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102336. /**
  102337. * Makes a duplicate of the current material.
  102338. * @param name - name to use for the new material.
  102339. */
  102340. clone(name: string): NodeMaterial;
  102341. /**
  102342. * Creates a node material from parsed material data
  102343. * @param source defines the JSON representation of the material
  102344. * @param scene defines the hosting scene
  102345. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102346. * @returns a new node material
  102347. */
  102348. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102349. /**
  102350. * Creates a node material from a snippet saved in a remote file
  102351. * @param name defines the name of the material to create
  102352. * @param url defines the url to load from
  102353. * @param scene defines the hosting scene
  102354. * @returns a promise that will resolve to the new node material
  102355. */
  102356. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102357. /**
  102358. * Creates a node material from a snippet saved by the node material editor
  102359. * @param snippetId defines the snippet to load
  102360. * @param scene defines the hosting scene
  102361. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102362. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102363. * @returns a promise that will resolve to the new node material
  102364. */
  102365. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102366. /**
  102367. * Creates a new node material set to default basic configuration
  102368. * @param name defines the name of the material
  102369. * @param scene defines the hosting scene
  102370. * @returns a new NodeMaterial
  102371. */
  102372. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102373. }
  102374. }
  102375. declare module BABYLON {
  102376. /**
  102377. * Size options for a post process
  102378. */
  102379. export type PostProcessOptions = {
  102380. width: number;
  102381. height: number;
  102382. };
  102383. /**
  102384. * PostProcess can be used to apply a shader to a texture after it has been rendered
  102385. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102386. */
  102387. export class PostProcess {
  102388. /**
  102389. * Gets or sets the unique id of the post process
  102390. */
  102391. uniqueId: number;
  102392. /** Name of the PostProcess. */
  102393. name: string;
  102394. /**
  102395. * Width of the texture to apply the post process on
  102396. */
  102397. width: number;
  102398. /**
  102399. * Height of the texture to apply the post process on
  102400. */
  102401. height: number;
  102402. /**
  102403. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  102404. */
  102405. nodeMaterialSource: Nullable<NodeMaterial>;
  102406. /**
  102407. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  102408. * @hidden
  102409. */
  102410. _outputTexture: Nullable<InternalTexture>;
  102411. /**
  102412. * Sampling mode used by the shader
  102413. * See https://doc.babylonjs.com/classes/3.1/texture
  102414. */
  102415. renderTargetSamplingMode: number;
  102416. /**
  102417. * Clear color to use when screen clearing
  102418. */
  102419. clearColor: Color4;
  102420. /**
  102421. * If the buffer needs to be cleared before applying the post process. (default: true)
  102422. * Should be set to false if shader will overwrite all previous pixels.
  102423. */
  102424. autoClear: boolean;
  102425. /**
  102426. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  102427. */
  102428. alphaMode: number;
  102429. /**
  102430. * Sets the setAlphaBlendConstants of the babylon engine
  102431. */
  102432. alphaConstants: Color4;
  102433. /**
  102434. * Animations to be used for the post processing
  102435. */
  102436. animations: Animation[];
  102437. /**
  102438. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  102439. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  102440. */
  102441. enablePixelPerfectMode: boolean;
  102442. /**
  102443. * Force the postprocess to be applied without taking in account viewport
  102444. */
  102445. forceFullscreenViewport: boolean;
  102446. /**
  102447. * List of inspectable custom properties (used by the Inspector)
  102448. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102449. */
  102450. inspectableCustomProperties: IInspectable[];
  102451. /**
  102452. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  102453. *
  102454. * | Value | Type | Description |
  102455. * | ----- | ----------------------------------- | ----------- |
  102456. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  102457. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  102458. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  102459. *
  102460. */
  102461. scaleMode: number;
  102462. /**
  102463. * Force textures to be a power of two (default: false)
  102464. */
  102465. alwaysForcePOT: boolean;
  102466. private _samples;
  102467. /**
  102468. * Number of sample textures (default: 1)
  102469. */
  102470. get samples(): number;
  102471. set samples(n: number);
  102472. /**
  102473. * Modify the scale of the post process to be the same as the viewport (default: false)
  102474. */
  102475. adaptScaleToCurrentViewport: boolean;
  102476. private _camera;
  102477. protected _scene: Scene;
  102478. private _engine;
  102479. private _options;
  102480. private _reusable;
  102481. private _textureType;
  102482. private _textureFormat;
  102483. /**
  102484. * Smart array of input and output textures for the post process.
  102485. * @hidden
  102486. */
  102487. _textures: SmartArray<InternalTexture>;
  102488. /**
  102489. * The index in _textures that corresponds to the output texture.
  102490. * @hidden
  102491. */
  102492. _currentRenderTextureInd: number;
  102493. private _effect;
  102494. private _samplers;
  102495. private _fragmentUrl;
  102496. private _vertexUrl;
  102497. private _parameters;
  102498. private _scaleRatio;
  102499. protected _indexParameters: any;
  102500. private _shareOutputWithPostProcess;
  102501. private _texelSize;
  102502. private _forcedOutputTexture;
  102503. /**
  102504. * Returns the fragment url or shader name used in the post process.
  102505. * @returns the fragment url or name in the shader store.
  102506. */
  102507. getEffectName(): string;
  102508. /**
  102509. * An event triggered when the postprocess is activated.
  102510. */
  102511. onActivateObservable: Observable<Camera>;
  102512. private _onActivateObserver;
  102513. /**
  102514. * A function that is added to the onActivateObservable
  102515. */
  102516. set onActivate(callback: Nullable<(camera: Camera) => void>);
  102517. /**
  102518. * An event triggered when the postprocess changes its size.
  102519. */
  102520. onSizeChangedObservable: Observable<PostProcess>;
  102521. private _onSizeChangedObserver;
  102522. /**
  102523. * A function that is added to the onSizeChangedObservable
  102524. */
  102525. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102526. /**
  102527. * An event triggered when the postprocess applies its effect.
  102528. */
  102529. onApplyObservable: Observable<Effect>;
  102530. private _onApplyObserver;
  102531. /**
  102532. * A function that is added to the onApplyObservable
  102533. */
  102534. set onApply(callback: (effect: Effect) => void);
  102535. /**
  102536. * An event triggered before rendering the postprocess
  102537. */
  102538. onBeforeRenderObservable: Observable<Effect>;
  102539. private _onBeforeRenderObserver;
  102540. /**
  102541. * A function that is added to the onBeforeRenderObservable
  102542. */
  102543. set onBeforeRender(callback: (effect: Effect) => void);
  102544. /**
  102545. * An event triggered after rendering the postprocess
  102546. */
  102547. onAfterRenderObservable: Observable<Effect>;
  102548. private _onAfterRenderObserver;
  102549. /**
  102550. * A function that is added to the onAfterRenderObservable
  102551. */
  102552. set onAfterRender(callback: (efect: Effect) => void);
  102553. /**
  102554. * 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
  102555. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102556. */
  102557. get inputTexture(): InternalTexture;
  102558. set inputTexture(value: InternalTexture);
  102559. /**
  102560. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102561. * the only way to unset it is to use this function to restore its internal state
  102562. */
  102563. restoreDefaultInputTexture(): void;
  102564. /**
  102565. * Gets the camera which post process is applied to.
  102566. * @returns The camera the post process is applied to.
  102567. */
  102568. getCamera(): Camera;
  102569. /**
  102570. * Gets the texel size of the postprocess.
  102571. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102572. */
  102573. get texelSize(): Vector2;
  102574. /**
  102575. * Creates a new instance PostProcess
  102576. * @param name The name of the PostProcess.
  102577. * @param fragmentUrl The url of the fragment shader to be used.
  102578. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102579. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102580. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102581. * @param camera The camera to apply the render pass to.
  102582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102583. * @param engine The engine which the post process will be applied. (default: current engine)
  102584. * @param reusable If the post process can be reused on the same frame. (default: false)
  102585. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102586. * @param textureType Type of textures used when performing the post process. (default: 0)
  102587. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102588. * @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
  102589. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  102590. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102591. */
  102592. 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);
  102593. /**
  102594. * Gets a string identifying the name of the class
  102595. * @returns "PostProcess" string
  102596. */
  102597. getClassName(): string;
  102598. /**
  102599. * Gets the engine which this post process belongs to.
  102600. * @returns The engine the post process was enabled with.
  102601. */
  102602. getEngine(): Engine;
  102603. /**
  102604. * The effect that is created when initializing the post process.
  102605. * @returns The created effect corresponding the the postprocess.
  102606. */
  102607. getEffect(): Effect;
  102608. /**
  102609. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102610. * @param postProcess The post process to share the output with.
  102611. * @returns This post process.
  102612. */
  102613. shareOutputWith(postProcess: PostProcess): PostProcess;
  102614. /**
  102615. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102616. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102617. */
  102618. useOwnOutput(): void;
  102619. /**
  102620. * Updates the effect with the current post process compile time values and recompiles the shader.
  102621. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102622. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102623. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102624. * @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
  102625. * @param onCompiled Called when the shader has been compiled.
  102626. * @param onError Called if there is an error when compiling a shader.
  102627. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102628. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102629. */
  102630. 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;
  102631. /**
  102632. * The post process is reusable if it can be used multiple times within one frame.
  102633. * @returns If the post process is reusable
  102634. */
  102635. isReusable(): boolean;
  102636. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102637. markTextureDirty(): void;
  102638. /**
  102639. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102640. * 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.
  102641. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102642. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102643. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102644. * @returns The target texture that was bound to be written to.
  102645. */
  102646. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102647. /**
  102648. * If the post process is supported.
  102649. */
  102650. get isSupported(): boolean;
  102651. /**
  102652. * The aspect ratio of the output texture.
  102653. */
  102654. get aspectRatio(): number;
  102655. /**
  102656. * Get a value indicating if the post-process is ready to be used
  102657. * @returns true if the post-process is ready (shader is compiled)
  102658. */
  102659. isReady(): boolean;
  102660. /**
  102661. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102662. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102663. */
  102664. apply(): Nullable<Effect>;
  102665. private _disposeTextures;
  102666. /**
  102667. * Disposes the post process.
  102668. * @param camera The camera to dispose the post process on.
  102669. */
  102670. dispose(camera?: Camera): void;
  102671. /**
  102672. * Serializes the particle system to a JSON object
  102673. * @returns the JSON object
  102674. */
  102675. serialize(): any;
  102676. /**
  102677. * Creates a material from parsed material data
  102678. * @param parsedPostProcess defines parsed post process data
  102679. * @param scene defines the hosting scene
  102680. * @param rootUrl defines the root URL to use to load textures
  102681. * @returns a new post process
  102682. */
  102683. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102684. }
  102685. }
  102686. declare module BABYLON {
  102687. /** @hidden */
  102688. export var kernelBlurVaryingDeclaration: {
  102689. name: string;
  102690. shader: string;
  102691. };
  102692. }
  102693. declare module BABYLON {
  102694. /** @hidden */
  102695. export var kernelBlurFragment: {
  102696. name: string;
  102697. shader: string;
  102698. };
  102699. }
  102700. declare module BABYLON {
  102701. /** @hidden */
  102702. export var kernelBlurFragment2: {
  102703. name: string;
  102704. shader: string;
  102705. };
  102706. }
  102707. declare module BABYLON {
  102708. /** @hidden */
  102709. export var kernelBlurPixelShader: {
  102710. name: string;
  102711. shader: string;
  102712. };
  102713. }
  102714. declare module BABYLON {
  102715. /** @hidden */
  102716. export var kernelBlurVertex: {
  102717. name: string;
  102718. shader: string;
  102719. };
  102720. }
  102721. declare module BABYLON {
  102722. /** @hidden */
  102723. export var kernelBlurVertexShader: {
  102724. name: string;
  102725. shader: string;
  102726. };
  102727. }
  102728. declare module BABYLON {
  102729. /**
  102730. * The Blur Post Process which blurs an image based on a kernel and direction.
  102731. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102732. */
  102733. export class BlurPostProcess extends PostProcess {
  102734. private blockCompilation;
  102735. protected _kernel: number;
  102736. protected _idealKernel: number;
  102737. protected _packedFloat: boolean;
  102738. private _staticDefines;
  102739. /** The direction in which to blur the image. */
  102740. direction: Vector2;
  102741. /**
  102742. * Sets the length in pixels of the blur sample region
  102743. */
  102744. set kernel(v: number);
  102745. /**
  102746. * Gets the length in pixels of the blur sample region
  102747. */
  102748. get kernel(): number;
  102749. /**
  102750. * Sets wether or not the blur needs to unpack/repack floats
  102751. */
  102752. set packedFloat(v: boolean);
  102753. /**
  102754. * Gets wether or not the blur is unpacking/repacking floats
  102755. */
  102756. get packedFloat(): boolean;
  102757. /**
  102758. * Gets a string identifying the name of the class
  102759. * @returns "BlurPostProcess" string
  102760. */
  102761. getClassName(): string;
  102762. /**
  102763. * Creates a new instance BlurPostProcess
  102764. * @param name The name of the effect.
  102765. * @param direction The direction in which to blur the image.
  102766. * @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.
  102767. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102768. * @param camera The camera to apply the render pass to.
  102769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102770. * @param engine The engine which the post process will be applied. (default: current engine)
  102771. * @param reusable If the post process can be reused on the same frame. (default: false)
  102772. * @param textureType Type of textures used when performing the post process. (default: 0)
  102773. * @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)
  102774. */
  102775. 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);
  102776. /**
  102777. * Updates the effect with the current post process compile time values and recompiles the shader.
  102778. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102779. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102780. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102781. * @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
  102782. * @param onCompiled Called when the shader has been compiled.
  102783. * @param onError Called if there is an error when compiling a shader.
  102784. */
  102785. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102786. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102787. /**
  102788. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  102789. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  102790. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  102791. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  102792. * The gaps between physical kernels are compensated for in the weighting of the samples
  102793. * @param idealKernel Ideal blur kernel.
  102794. * @return Nearest best kernel.
  102795. */
  102796. protected _nearestBestKernel(idealKernel: number): number;
  102797. /**
  102798. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  102799. * @param x The point on the Gaussian distribution to sample.
  102800. * @return the value of the Gaussian function at x.
  102801. */
  102802. protected _gaussianWeight(x: number): number;
  102803. /**
  102804. * Generates a string that can be used as a floating point number in GLSL.
  102805. * @param x Value to print.
  102806. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  102807. * @return GLSL float string.
  102808. */
  102809. protected _glslFloat(x: number, decimalFigures?: number): string;
  102810. /** @hidden */
  102811. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  102812. }
  102813. }
  102814. declare module BABYLON {
  102815. /**
  102816. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102817. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102818. * You can then easily use it as a reflectionTexture on a flat surface.
  102819. * In case the surface is not a plane, please consider relying on reflection probes.
  102820. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102821. */
  102822. export class MirrorTexture extends RenderTargetTexture {
  102823. private scene;
  102824. /**
  102825. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  102826. * 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.
  102827. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102828. */
  102829. mirrorPlane: Plane;
  102830. /**
  102831. * Define the blur ratio used to blur the reflection if needed.
  102832. */
  102833. set blurRatio(value: number);
  102834. get blurRatio(): number;
  102835. /**
  102836. * Define the adaptive blur kernel used to blur the reflection if needed.
  102837. * This will autocompute the closest best match for the `blurKernel`
  102838. */
  102839. set adaptiveBlurKernel(value: number);
  102840. /**
  102841. * Define the blur kernel used to blur the reflection if needed.
  102842. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102843. */
  102844. set blurKernel(value: number);
  102845. /**
  102846. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  102847. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102848. */
  102849. set blurKernelX(value: number);
  102850. get blurKernelX(): number;
  102851. /**
  102852. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  102853. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102854. */
  102855. set blurKernelY(value: number);
  102856. get blurKernelY(): number;
  102857. private _autoComputeBlurKernel;
  102858. protected _onRatioRescale(): void;
  102859. private _updateGammaSpace;
  102860. private _imageProcessingConfigChangeObserver;
  102861. private _transformMatrix;
  102862. private _mirrorMatrix;
  102863. private _savedViewMatrix;
  102864. private _blurX;
  102865. private _blurY;
  102866. private _adaptiveBlurKernel;
  102867. private _blurKernelX;
  102868. private _blurKernelY;
  102869. private _blurRatio;
  102870. /**
  102871. * Instantiates a Mirror Texture.
  102872. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102873. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102874. * You can then easily use it as a reflectionTexture on a flat surface.
  102875. * In case the surface is not a plane, please consider relying on reflection probes.
  102876. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102877. * @param name
  102878. * @param size
  102879. * @param scene
  102880. * @param generateMipMaps
  102881. * @param type
  102882. * @param samplingMode
  102883. * @param generateDepthBuffer
  102884. */
  102885. constructor(name: string, size: number | {
  102886. width: number;
  102887. height: number;
  102888. } | {
  102889. ratio: number;
  102890. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  102891. private _preparePostProcesses;
  102892. /**
  102893. * Clone the mirror texture.
  102894. * @returns the cloned texture
  102895. */
  102896. clone(): MirrorTexture;
  102897. /**
  102898. * Serialize the texture to a JSON representation you could use in Parse later on
  102899. * @returns the serialized JSON representation
  102900. */
  102901. serialize(): any;
  102902. /**
  102903. * Dispose the texture and release its associated resources.
  102904. */
  102905. dispose(): void;
  102906. }
  102907. }
  102908. declare module BABYLON {
  102909. /**
  102910. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102911. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102912. */
  102913. export class Texture extends BaseTexture {
  102914. /**
  102915. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  102916. */
  102917. static SerializeBuffers: boolean;
  102918. /** @hidden */
  102919. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  102920. /** @hidden */
  102921. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  102922. /** @hidden */
  102923. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  102924. /** nearest is mag = nearest and min = nearest and mip = linear */
  102925. static readonly NEAREST_SAMPLINGMODE: number;
  102926. /** nearest is mag = nearest and min = nearest and mip = linear */
  102927. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  102928. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102929. static readonly BILINEAR_SAMPLINGMODE: number;
  102930. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102931. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  102932. /** Trilinear is mag = linear and min = linear and mip = linear */
  102933. static readonly TRILINEAR_SAMPLINGMODE: number;
  102934. /** Trilinear is mag = linear and min = linear and mip = linear */
  102935. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  102936. /** mag = nearest and min = nearest and mip = nearest */
  102937. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  102938. /** mag = nearest and min = linear and mip = nearest */
  102939. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  102940. /** mag = nearest and min = linear and mip = linear */
  102941. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  102942. /** mag = nearest and min = linear and mip = none */
  102943. static readonly NEAREST_LINEAR: number;
  102944. /** mag = nearest and min = nearest and mip = none */
  102945. static readonly NEAREST_NEAREST: number;
  102946. /** mag = linear and min = nearest and mip = nearest */
  102947. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  102948. /** mag = linear and min = nearest and mip = linear */
  102949. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  102950. /** mag = linear and min = linear and mip = none */
  102951. static readonly LINEAR_LINEAR: number;
  102952. /** mag = linear and min = nearest and mip = none */
  102953. static readonly LINEAR_NEAREST: number;
  102954. /** Explicit coordinates mode */
  102955. static readonly EXPLICIT_MODE: number;
  102956. /** Spherical coordinates mode */
  102957. static readonly SPHERICAL_MODE: number;
  102958. /** Planar coordinates mode */
  102959. static readonly PLANAR_MODE: number;
  102960. /** Cubic coordinates mode */
  102961. static readonly CUBIC_MODE: number;
  102962. /** Projection coordinates mode */
  102963. static readonly PROJECTION_MODE: number;
  102964. /** Inverse Cubic coordinates mode */
  102965. static readonly SKYBOX_MODE: number;
  102966. /** Inverse Cubic coordinates mode */
  102967. static readonly INVCUBIC_MODE: number;
  102968. /** Equirectangular coordinates mode */
  102969. static readonly EQUIRECTANGULAR_MODE: number;
  102970. /** Equirectangular Fixed coordinates mode */
  102971. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  102972. /** Equirectangular Fixed Mirrored coordinates mode */
  102973. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102974. /** Texture is not repeating outside of 0..1 UVs */
  102975. static readonly CLAMP_ADDRESSMODE: number;
  102976. /** Texture is repeating outside of 0..1 UVs */
  102977. static readonly WRAP_ADDRESSMODE: number;
  102978. /** Texture is repeating and mirrored */
  102979. static readonly MIRROR_ADDRESSMODE: number;
  102980. /**
  102981. * 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
  102982. */
  102983. static UseSerializedUrlIfAny: boolean;
  102984. /**
  102985. * Define the url of the texture.
  102986. */
  102987. url: Nullable<string>;
  102988. /**
  102989. * Define an offset on the texture to offset the u coordinates of the UVs
  102990. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102991. */
  102992. uOffset: number;
  102993. /**
  102994. * Define an offset on the texture to offset the v coordinates of the UVs
  102995. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102996. */
  102997. vOffset: number;
  102998. /**
  102999. * Define an offset on the texture to scale the u coordinates of the UVs
  103000. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103001. */
  103002. uScale: number;
  103003. /**
  103004. * Define an offset on the texture to scale the v coordinates of the UVs
  103005. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103006. */
  103007. vScale: number;
  103008. /**
  103009. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103010. * @see https://doc.babylonjs.com/how_to/more_materials
  103011. */
  103012. uAng: number;
  103013. /**
  103014. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103015. * @see https://doc.babylonjs.com/how_to/more_materials
  103016. */
  103017. vAng: number;
  103018. /**
  103019. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103020. * @see https://doc.babylonjs.com/how_to/more_materials
  103021. */
  103022. wAng: number;
  103023. /**
  103024. * Defines the center of rotation (U)
  103025. */
  103026. uRotationCenter: number;
  103027. /**
  103028. * Defines the center of rotation (V)
  103029. */
  103030. vRotationCenter: number;
  103031. /**
  103032. * Defines the center of rotation (W)
  103033. */
  103034. wRotationCenter: number;
  103035. /**
  103036. * Are mip maps generated for this texture or not.
  103037. */
  103038. get noMipmap(): boolean;
  103039. /**
  103040. * List of inspectable custom properties (used by the Inspector)
  103041. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103042. */
  103043. inspectableCustomProperties: Nullable<IInspectable[]>;
  103044. private _noMipmap;
  103045. /** @hidden */
  103046. _invertY: boolean;
  103047. private _rowGenerationMatrix;
  103048. private _cachedTextureMatrix;
  103049. private _projectionModeMatrix;
  103050. private _t0;
  103051. private _t1;
  103052. private _t2;
  103053. private _cachedUOffset;
  103054. private _cachedVOffset;
  103055. private _cachedUScale;
  103056. private _cachedVScale;
  103057. private _cachedUAng;
  103058. private _cachedVAng;
  103059. private _cachedWAng;
  103060. private _cachedProjectionMatrixId;
  103061. private _cachedCoordinatesMode;
  103062. /** @hidden */
  103063. protected _initialSamplingMode: number;
  103064. /** @hidden */
  103065. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103066. private _deleteBuffer;
  103067. protected _format: Nullable<number>;
  103068. private _delayedOnLoad;
  103069. private _delayedOnError;
  103070. private _mimeType?;
  103071. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103072. get mimeType(): string | undefined;
  103073. /**
  103074. * Observable triggered once the texture has been loaded.
  103075. */
  103076. onLoadObservable: Observable<Texture>;
  103077. protected _isBlocking: boolean;
  103078. /**
  103079. * Is the texture preventing material to render while loading.
  103080. * If false, a default texture will be used instead of the loading one during the preparation step.
  103081. */
  103082. set isBlocking(value: boolean);
  103083. get isBlocking(): boolean;
  103084. /**
  103085. * Get the current sampling mode associated with the texture.
  103086. */
  103087. get samplingMode(): number;
  103088. /**
  103089. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103090. */
  103091. get invertY(): boolean;
  103092. /**
  103093. * Instantiates a new texture.
  103094. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103095. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103096. * @param url defines the url of the picture to load as a texture
  103097. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103098. * @param noMipmap defines if the texture will require mip maps or not
  103099. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103100. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103101. * @param onLoad defines a callback triggered when the texture has been loaded
  103102. * @param onError defines a callback triggered when an error occurred during the loading session
  103103. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103104. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103105. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103106. * @param mimeType defines an optional mime type information
  103107. */
  103108. 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);
  103109. /**
  103110. * Update the url (and optional buffer) of this texture if url was null during construction.
  103111. * @param url the url of the texture
  103112. * @param buffer the buffer of the texture (defaults to null)
  103113. * @param onLoad callback called when the texture is loaded (defaults to null)
  103114. */
  103115. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103116. /**
  103117. * Finish the loading sequence of a texture flagged as delayed load.
  103118. * @hidden
  103119. */
  103120. delayLoad(): void;
  103121. private _prepareRowForTextureGeneration;
  103122. /**
  103123. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103124. * @returns the transform matrix of the texture.
  103125. */
  103126. getTextureMatrix(uBase?: number): Matrix;
  103127. /**
  103128. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103129. * @returns The reflection texture transform
  103130. */
  103131. getReflectionTextureMatrix(): Matrix;
  103132. /**
  103133. * Clones the texture.
  103134. * @returns the cloned texture
  103135. */
  103136. clone(): Texture;
  103137. /**
  103138. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103139. * @returns The JSON representation of the texture
  103140. */
  103141. serialize(): any;
  103142. /**
  103143. * Get the current class name of the texture useful for serialization or dynamic coding.
  103144. * @returns "Texture"
  103145. */
  103146. getClassName(): string;
  103147. /**
  103148. * Dispose the texture and release its associated resources.
  103149. */
  103150. dispose(): void;
  103151. /**
  103152. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103153. * @param parsedTexture Define the JSON representation of the texture
  103154. * @param scene Define the scene the parsed texture should be instantiated in
  103155. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103156. * @returns The parsed texture if successful
  103157. */
  103158. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103159. /**
  103160. * Creates a texture from its base 64 representation.
  103161. * @param data Define the base64 payload without the data: prefix
  103162. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103163. * @param scene Define the scene the texture should belong to
  103164. * @param noMipmap Forces the texture to not create mip map information if true
  103165. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103166. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103167. * @param onLoad define a callback triggered when the texture has been loaded
  103168. * @param onError define a callback triggered when an error occurred during the loading session
  103169. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103170. * @returns the created texture
  103171. */
  103172. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103173. /**
  103174. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103175. * @param data Define the base64 payload without the data: prefix
  103176. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103177. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103178. * @param scene Define the scene the texture should belong to
  103179. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103180. * @param noMipmap Forces the texture to not create mip map information if true
  103181. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103182. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103183. * @param onLoad define a callback triggered when the texture has been loaded
  103184. * @param onError define a callback triggered when an error occurred during the loading session
  103185. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103186. * @returns the created texture
  103187. */
  103188. 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;
  103189. }
  103190. }
  103191. declare module BABYLON {
  103192. /**
  103193. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103194. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103195. */
  103196. export class PostProcessManager {
  103197. private _scene;
  103198. private _indexBuffer;
  103199. private _vertexBuffers;
  103200. /**
  103201. * Creates a new instance PostProcess
  103202. * @param scene The scene that the post process is associated with.
  103203. */
  103204. constructor(scene: Scene);
  103205. private _prepareBuffers;
  103206. private _buildIndexBuffer;
  103207. /**
  103208. * Rebuilds the vertex buffers of the manager.
  103209. * @hidden
  103210. */
  103211. _rebuild(): void;
  103212. /**
  103213. * Prepares a frame to be run through a post process.
  103214. * @param sourceTexture The input texture to the post procesess. (default: null)
  103215. * @param postProcesses An array of post processes to be run. (default: null)
  103216. * @returns True if the post processes were able to be run.
  103217. * @hidden
  103218. */
  103219. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103220. /**
  103221. * Manually render a set of post processes to a texture.
  103222. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103223. * @param postProcesses An array of post processes to be run.
  103224. * @param targetTexture The target texture to render to.
  103225. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103226. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103227. * @param lodLevel defines which lod of the texture to render to
  103228. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103229. */
  103230. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103231. /**
  103232. * Finalize the result of the output of the postprocesses.
  103233. * @param doNotPresent If true the result will not be displayed to the screen.
  103234. * @param targetTexture The target texture to render to.
  103235. * @param faceIndex The index of the face to bind the target texture to.
  103236. * @param postProcesses The array of post processes to render.
  103237. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103238. * @hidden
  103239. */
  103240. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103241. /**
  103242. * Disposes of the post process manager.
  103243. */
  103244. dispose(): void;
  103245. }
  103246. }
  103247. declare module BABYLON {
  103248. /**
  103249. * This Helps creating a texture that will be created from a camera in your scene.
  103250. * It is basically a dynamic texture that could be used to create special effects for instance.
  103251. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103252. */
  103253. export class RenderTargetTexture extends Texture {
  103254. /**
  103255. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103256. */
  103257. static readonly REFRESHRATE_RENDER_ONCE: number;
  103258. /**
  103259. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103260. */
  103261. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103262. /**
  103263. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103264. * the central point of your effect and can save a lot of performances.
  103265. */
  103266. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103267. /**
  103268. * Use this predicate to dynamically define the list of mesh you want to render.
  103269. * If set, the renderList property will be overwritten.
  103270. */
  103271. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103272. private _renderList;
  103273. /**
  103274. * Use this list to define the list of mesh you want to render.
  103275. */
  103276. get renderList(): Nullable<Array<AbstractMesh>>;
  103277. set renderList(value: Nullable<Array<AbstractMesh>>);
  103278. /**
  103279. * Use this function to overload the renderList array at rendering time.
  103280. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103281. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103282. * the cube (if the RTT is a cube, else layerOrFace=0).
  103283. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103284. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103285. * hold dummy elements!
  103286. */
  103287. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103288. private _hookArray;
  103289. /**
  103290. * Define if particles should be rendered in your texture.
  103291. */
  103292. renderParticles: boolean;
  103293. /**
  103294. * Define if sprites should be rendered in your texture.
  103295. */
  103296. renderSprites: boolean;
  103297. /**
  103298. * Define the camera used to render the texture.
  103299. */
  103300. activeCamera: Nullable<Camera>;
  103301. /**
  103302. * Override the mesh isReady function with your own one.
  103303. */
  103304. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103305. /**
  103306. * Override the render function of the texture with your own one.
  103307. */
  103308. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103309. /**
  103310. * Define if camera post processes should be use while rendering the texture.
  103311. */
  103312. useCameraPostProcesses: boolean;
  103313. /**
  103314. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103315. */
  103316. ignoreCameraViewport: boolean;
  103317. private _postProcessManager;
  103318. private _postProcesses;
  103319. private _resizeObserver;
  103320. /**
  103321. * An event triggered when the texture is unbind.
  103322. */
  103323. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103324. /**
  103325. * An event triggered when the texture is unbind.
  103326. */
  103327. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103328. private _onAfterUnbindObserver;
  103329. /**
  103330. * Set a after unbind callback in the texture.
  103331. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103332. */
  103333. set onAfterUnbind(callback: () => void);
  103334. /**
  103335. * An event triggered before rendering the texture
  103336. */
  103337. onBeforeRenderObservable: Observable<number>;
  103338. private _onBeforeRenderObserver;
  103339. /**
  103340. * Set a before render callback in the texture.
  103341. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103342. */
  103343. set onBeforeRender(callback: (faceIndex: number) => void);
  103344. /**
  103345. * An event triggered after rendering the texture
  103346. */
  103347. onAfterRenderObservable: Observable<number>;
  103348. private _onAfterRenderObserver;
  103349. /**
  103350. * Set a after render callback in the texture.
  103351. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103352. */
  103353. set onAfterRender(callback: (faceIndex: number) => void);
  103354. /**
  103355. * An event triggered after the texture clear
  103356. */
  103357. onClearObservable: Observable<Engine>;
  103358. private _onClearObserver;
  103359. /**
  103360. * Set a clear callback in the texture.
  103361. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103362. */
  103363. set onClear(callback: (Engine: Engine) => void);
  103364. /**
  103365. * An event triggered when the texture is resized.
  103366. */
  103367. onResizeObservable: Observable<RenderTargetTexture>;
  103368. /**
  103369. * Define the clear color of the Render Target if it should be different from the scene.
  103370. */
  103371. clearColor: Color4;
  103372. protected _size: number | {
  103373. width: number;
  103374. height: number;
  103375. layers?: number;
  103376. };
  103377. protected _initialSizeParameter: number | {
  103378. width: number;
  103379. height: number;
  103380. } | {
  103381. ratio: number;
  103382. };
  103383. protected _sizeRatio: Nullable<number>;
  103384. /** @hidden */
  103385. _generateMipMaps: boolean;
  103386. protected _renderingManager: RenderingManager;
  103387. /** @hidden */
  103388. _waitingRenderList?: string[];
  103389. protected _doNotChangeAspectRatio: boolean;
  103390. protected _currentRefreshId: number;
  103391. protected _refreshRate: number;
  103392. protected _textureMatrix: Matrix;
  103393. protected _samples: number;
  103394. protected _renderTargetOptions: RenderTargetCreationOptions;
  103395. /**
  103396. * Gets render target creation options that were used.
  103397. */
  103398. get renderTargetOptions(): RenderTargetCreationOptions;
  103399. protected _onRatioRescale(): void;
  103400. /**
  103401. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  103402. * It must define where the camera used to render the texture is set
  103403. */
  103404. boundingBoxPosition: Vector3;
  103405. private _boundingBoxSize;
  103406. /**
  103407. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  103408. * When defined, the cubemap will switch to local mode
  103409. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103410. * @example https://www.babylonjs-playground.com/#RNASML
  103411. */
  103412. set boundingBoxSize(value: Vector3);
  103413. get boundingBoxSize(): Vector3;
  103414. /**
  103415. * In case the RTT has been created with a depth texture, get the associated
  103416. * depth texture.
  103417. * Otherwise, return null.
  103418. */
  103419. get depthStencilTexture(): Nullable<InternalTexture>;
  103420. /**
  103421. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  103422. * or used a shadow, depth texture...
  103423. * @param name The friendly name of the texture
  103424. * @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)
  103425. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  103426. * @param generateMipMaps True if mip maps need to be generated after render.
  103427. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  103428. * @param type The type of the buffer in the RTT (int, half float, float...)
  103429. * @param isCube True if a cube texture needs to be created
  103430. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  103431. * @param generateDepthBuffer True to generate a depth buffer
  103432. * @param generateStencilBuffer True to generate a stencil buffer
  103433. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  103434. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  103435. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103436. */
  103437. constructor(name: string, size: number | {
  103438. width: number;
  103439. height: number;
  103440. layers?: number;
  103441. } | {
  103442. ratio: number;
  103443. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  103444. /**
  103445. * Creates a depth stencil texture.
  103446. * This is only available in WebGL 2 or with the depth texture extension available.
  103447. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  103448. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  103449. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  103450. */
  103451. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  103452. private _processSizeParameter;
  103453. /**
  103454. * Define the number of samples to use in case of MSAA.
  103455. * It defaults to one meaning no MSAA has been enabled.
  103456. */
  103457. get samples(): number;
  103458. set samples(value: number);
  103459. /**
  103460. * Resets the refresh counter of the texture and start bak from scratch.
  103461. * Could be useful to regenerate the texture if it is setup to render only once.
  103462. */
  103463. resetRefreshCounter(): void;
  103464. /**
  103465. * Define the refresh rate of the texture or the rendering frequency.
  103466. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  103467. */
  103468. get refreshRate(): number;
  103469. set refreshRate(value: number);
  103470. /**
  103471. * Adds a post process to the render target rendering passes.
  103472. * @param postProcess define the post process to add
  103473. */
  103474. addPostProcess(postProcess: PostProcess): void;
  103475. /**
  103476. * Clear all the post processes attached to the render target
  103477. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  103478. */
  103479. clearPostProcesses(dispose?: boolean): void;
  103480. /**
  103481. * Remove one of the post process from the list of attached post processes to the texture
  103482. * @param postProcess define the post process to remove from the list
  103483. */
  103484. removePostProcess(postProcess: PostProcess): void;
  103485. /** @hidden */
  103486. _shouldRender(): boolean;
  103487. /**
  103488. * Gets the actual render size of the texture.
  103489. * @returns the width of the render size
  103490. */
  103491. getRenderSize(): number;
  103492. /**
  103493. * Gets the actual render width of the texture.
  103494. * @returns the width of the render size
  103495. */
  103496. getRenderWidth(): number;
  103497. /**
  103498. * Gets the actual render height of the texture.
  103499. * @returns the height of the render size
  103500. */
  103501. getRenderHeight(): number;
  103502. /**
  103503. * Gets the actual number of layers of the texture.
  103504. * @returns the number of layers
  103505. */
  103506. getRenderLayers(): number;
  103507. /**
  103508. * Get if the texture can be rescaled or not.
  103509. */
  103510. get canRescale(): boolean;
  103511. /**
  103512. * Resize the texture using a ratio.
  103513. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  103514. */
  103515. scale(ratio: number): void;
  103516. /**
  103517. * Get the texture reflection matrix used to rotate/transform the reflection.
  103518. * @returns the reflection matrix
  103519. */
  103520. getReflectionTextureMatrix(): Matrix;
  103521. /**
  103522. * Resize the texture to a new desired size.
  103523. * Be carrefull as it will recreate all the data in the new texture.
  103524. * @param size Define the new size. It can be:
  103525. * - a number for squared texture,
  103526. * - an object containing { width: number, height: number }
  103527. * - or an object containing a ratio { ratio: number }
  103528. */
  103529. resize(size: number | {
  103530. width: number;
  103531. height: number;
  103532. } | {
  103533. ratio: number;
  103534. }): void;
  103535. private _defaultRenderListPrepared;
  103536. /**
  103537. * Renders all the objects from the render list into the texture.
  103538. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103539. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103540. */
  103541. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103542. private _bestReflectionRenderTargetDimension;
  103543. private _prepareRenderingManager;
  103544. /**
  103545. * @hidden
  103546. * @param faceIndex face index to bind to if this is a cubetexture
  103547. * @param layer defines the index of the texture to bind in the array
  103548. */
  103549. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103550. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103551. private renderToTarget;
  103552. /**
  103553. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103554. * This allowed control for front to back rendering or reversly depending of the special needs.
  103555. *
  103556. * @param renderingGroupId The rendering group id corresponding to its index
  103557. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103558. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103559. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103560. */
  103561. 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;
  103562. /**
  103563. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103564. *
  103565. * @param renderingGroupId The rendering group id corresponding to its index
  103566. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103567. */
  103568. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103569. /**
  103570. * Clones the texture.
  103571. * @returns the cloned texture
  103572. */
  103573. clone(): RenderTargetTexture;
  103574. /**
  103575. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103576. * @returns The JSON representation of the texture
  103577. */
  103578. serialize(): any;
  103579. /**
  103580. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103581. */
  103582. disposeFramebufferObjects(): void;
  103583. /**
  103584. * Dispose the texture and release its associated resources.
  103585. */
  103586. dispose(): void;
  103587. /** @hidden */
  103588. _rebuild(): void;
  103589. /**
  103590. * Clear the info related to rendering groups preventing retention point in material dispose.
  103591. */
  103592. freeRenderingGroups(): void;
  103593. /**
  103594. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103595. * @returns the view count
  103596. */
  103597. getViewCount(): number;
  103598. }
  103599. }
  103600. declare module BABYLON {
  103601. /**
  103602. * Class used to manipulate GUIDs
  103603. */
  103604. export class GUID {
  103605. /**
  103606. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103607. * Be aware Math.random() could cause collisions, but:
  103608. * "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"
  103609. * @returns a pseudo random id
  103610. */
  103611. static RandomId(): string;
  103612. }
  103613. }
  103614. declare module BABYLON {
  103615. /**
  103616. * Options to be used when creating a shadow depth material
  103617. */
  103618. export interface IIOptionShadowDepthMaterial {
  103619. /** Variables in the vertex shader code that need to have their names remapped.
  103620. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103621. * "var_name" should be either: worldPos or vNormalW
  103622. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103623. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103624. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103625. */
  103626. remappedVariables?: string[];
  103627. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103628. standalone?: boolean;
  103629. }
  103630. /**
  103631. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103632. */
  103633. export class ShadowDepthWrapper {
  103634. private _scene;
  103635. private _options?;
  103636. private _baseMaterial;
  103637. private _onEffectCreatedObserver;
  103638. private _subMeshToEffect;
  103639. private _subMeshToDepthEffect;
  103640. private _meshes;
  103641. /** @hidden */
  103642. _matriceNames: any;
  103643. /** Gets the standalone status of the wrapper */
  103644. get standalone(): boolean;
  103645. /** Gets the base material the wrapper is built upon */
  103646. get baseMaterial(): Material;
  103647. /**
  103648. * Instantiate a new shadow depth wrapper.
  103649. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103650. * generate the shadow depth map. For more information, please refer to the documentation:
  103651. * https://doc.babylonjs.com/babylon101/shadows
  103652. * @param baseMaterial Material to wrap
  103653. * @param scene Define the scene the material belongs to
  103654. * @param options Options used to create the wrapper
  103655. */
  103656. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103657. /**
  103658. * Gets the effect to use to generate the depth map
  103659. * @param subMesh subMesh to get the effect for
  103660. * @param shadowGenerator shadow generator to get the effect for
  103661. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103662. */
  103663. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103664. /**
  103665. * Specifies that the submesh is ready to be used for depth rendering
  103666. * @param subMesh submesh to check
  103667. * @param defines the list of defines to take into account when checking the effect
  103668. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103669. * @param useInstances specifies that instances should be used
  103670. * @returns a boolean indicating that the submesh is ready or not
  103671. */
  103672. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103673. /**
  103674. * Disposes the resources
  103675. */
  103676. dispose(): void;
  103677. private _makeEffect;
  103678. }
  103679. }
  103680. declare module BABYLON {
  103681. interface ThinEngine {
  103682. /**
  103683. * Unbind a list of render target textures from the webGL context
  103684. * This is used only when drawBuffer extension or webGL2 are active
  103685. * @param textures defines the render target textures to unbind
  103686. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103687. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103688. */
  103689. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103690. /**
  103691. * Create a multi render target texture
  103692. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103693. * @param size defines the size of the texture
  103694. * @param options defines the creation options
  103695. * @returns the cube texture as an InternalTexture
  103696. */
  103697. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103698. /**
  103699. * Update the sample count for a given multiple render target texture
  103700. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103701. * @param textures defines the textures to update
  103702. * @param samples defines the sample count to set
  103703. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103704. */
  103705. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103706. /**
  103707. * Select a subsets of attachments to draw to.
  103708. * @param attachments gl attachments
  103709. */
  103710. bindAttachments(attachments: number[]): void;
  103711. }
  103712. }
  103713. declare module BABYLON {
  103714. /**
  103715. * Creation options of the multi render target texture.
  103716. */
  103717. export interface IMultiRenderTargetOptions {
  103718. /**
  103719. * Define if the texture needs to create mip maps after render.
  103720. */
  103721. generateMipMaps?: boolean;
  103722. /**
  103723. * Define the types of all the draw buffers we want to create
  103724. */
  103725. types?: number[];
  103726. /**
  103727. * Define the sampling modes of all the draw buffers we want to create
  103728. */
  103729. samplingModes?: number[];
  103730. /**
  103731. * Define if a depth buffer is required
  103732. */
  103733. generateDepthBuffer?: boolean;
  103734. /**
  103735. * Define if a stencil buffer is required
  103736. */
  103737. generateStencilBuffer?: boolean;
  103738. /**
  103739. * Define if a depth texture is required instead of a depth buffer
  103740. */
  103741. generateDepthTexture?: boolean;
  103742. /**
  103743. * Define the number of desired draw buffers
  103744. */
  103745. textureCount?: number;
  103746. /**
  103747. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103748. */
  103749. doNotChangeAspectRatio?: boolean;
  103750. /**
  103751. * Define the default type of the buffers we are creating
  103752. */
  103753. defaultType?: number;
  103754. }
  103755. /**
  103756. * A multi render target, like a render target provides the ability to render to a texture.
  103757. * Unlike the render target, it can render to several draw buffers in one draw.
  103758. * This is specially interesting in deferred rendering or for any effects requiring more than
  103759. * just one color from a single pass.
  103760. */
  103761. export class MultiRenderTarget extends RenderTargetTexture {
  103762. private _internalTextures;
  103763. private _textures;
  103764. private _multiRenderTargetOptions;
  103765. private _count;
  103766. /**
  103767. * Get if draw buffers are currently supported by the used hardware and browser.
  103768. */
  103769. get isSupported(): boolean;
  103770. /**
  103771. * Get the list of textures generated by the multi render target.
  103772. */
  103773. get textures(): Texture[];
  103774. /**
  103775. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103776. */
  103777. get count(): number;
  103778. /**
  103779. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103780. */
  103781. get depthTexture(): Texture;
  103782. /**
  103783. * Set the wrapping mode on U of all the textures we are rendering to.
  103784. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103785. */
  103786. set wrapU(wrap: number);
  103787. /**
  103788. * Set the wrapping mode on V of all the textures we are rendering to.
  103789. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103790. */
  103791. set wrapV(wrap: number);
  103792. /**
  103793. * Instantiate a new multi render target texture.
  103794. * A multi render target, like a render target provides the ability to render to a texture.
  103795. * Unlike the render target, it can render to several draw buffers in one draw.
  103796. * This is specially interesting in deferred rendering or for any effects requiring more than
  103797. * just one color from a single pass.
  103798. * @param name Define the name of the texture
  103799. * @param size Define the size of the buffers to render to
  103800. * @param count Define the number of target we are rendering into
  103801. * @param scene Define the scene the texture belongs to
  103802. * @param options Define the options used to create the multi render target
  103803. */
  103804. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103805. /** @hidden */
  103806. _rebuild(): void;
  103807. private _createInternalTextures;
  103808. private _createTextures;
  103809. /**
  103810. * Define the number of samples used if MSAA is enabled.
  103811. */
  103812. get samples(): number;
  103813. set samples(value: number);
  103814. /**
  103815. * Resize all the textures in the multi render target.
  103816. * Be carrefull as it will recreate all the data in the new texture.
  103817. * @param size Define the new size
  103818. */
  103819. resize(size: any): void;
  103820. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103821. /**
  103822. * Dispose the render targets and their associated resources
  103823. */
  103824. dispose(): void;
  103825. /**
  103826. * Release all the underlying texture used as draw buffers.
  103827. */
  103828. releaseInternalTextures(): void;
  103829. }
  103830. }
  103831. declare module BABYLON {
  103832. /** @hidden */
  103833. export var imageProcessingPixelShader: {
  103834. name: string;
  103835. shader: string;
  103836. };
  103837. }
  103838. declare module BABYLON {
  103839. /**
  103840. * ImageProcessingPostProcess
  103841. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103842. */
  103843. export class ImageProcessingPostProcess extends PostProcess {
  103844. /**
  103845. * Default configuration related to image processing available in the PBR Material.
  103846. */
  103847. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103848. /**
  103849. * Gets the image processing configuration used either in this material.
  103850. */
  103851. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103852. /**
  103853. * Sets the Default image processing configuration used either in the this material.
  103854. *
  103855. * If sets to null, the scene one is in use.
  103856. */
  103857. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103858. /**
  103859. * Keep track of the image processing observer to allow dispose and replace.
  103860. */
  103861. private _imageProcessingObserver;
  103862. /**
  103863. * Attaches a new image processing configuration to the PBR Material.
  103864. * @param configuration
  103865. */
  103866. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103867. /**
  103868. * If the post process is supported.
  103869. */
  103870. get isSupported(): boolean;
  103871. /**
  103872. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103873. */
  103874. get colorCurves(): Nullable<ColorCurves>;
  103875. /**
  103876. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103877. */
  103878. set colorCurves(value: Nullable<ColorCurves>);
  103879. /**
  103880. * Gets wether the color curves effect is enabled.
  103881. */
  103882. get colorCurvesEnabled(): boolean;
  103883. /**
  103884. * Sets wether the color curves effect is enabled.
  103885. */
  103886. set colorCurvesEnabled(value: boolean);
  103887. /**
  103888. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103889. */
  103890. get colorGradingTexture(): Nullable<BaseTexture>;
  103891. /**
  103892. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103893. */
  103894. set colorGradingTexture(value: Nullable<BaseTexture>);
  103895. /**
  103896. * Gets wether the color grading effect is enabled.
  103897. */
  103898. get colorGradingEnabled(): boolean;
  103899. /**
  103900. * Gets wether the color grading effect is enabled.
  103901. */
  103902. set colorGradingEnabled(value: boolean);
  103903. /**
  103904. * Gets exposure used in the effect.
  103905. */
  103906. get exposure(): number;
  103907. /**
  103908. * Sets exposure used in the effect.
  103909. */
  103910. set exposure(value: number);
  103911. /**
  103912. * Gets wether tonemapping is enabled or not.
  103913. */
  103914. get toneMappingEnabled(): boolean;
  103915. /**
  103916. * Sets wether tonemapping is enabled or not
  103917. */
  103918. set toneMappingEnabled(value: boolean);
  103919. /**
  103920. * Gets the type of tone mapping effect.
  103921. */
  103922. get toneMappingType(): number;
  103923. /**
  103924. * Sets the type of tone mapping effect.
  103925. */
  103926. set toneMappingType(value: number);
  103927. /**
  103928. * Gets contrast used in the effect.
  103929. */
  103930. get contrast(): number;
  103931. /**
  103932. * Sets contrast used in the effect.
  103933. */
  103934. set contrast(value: number);
  103935. /**
  103936. * Gets Vignette stretch size.
  103937. */
  103938. get vignetteStretch(): number;
  103939. /**
  103940. * Sets Vignette stretch size.
  103941. */
  103942. set vignetteStretch(value: number);
  103943. /**
  103944. * Gets Vignette centre X Offset.
  103945. */
  103946. get vignetteCentreX(): number;
  103947. /**
  103948. * Sets Vignette centre X Offset.
  103949. */
  103950. set vignetteCentreX(value: number);
  103951. /**
  103952. * Gets Vignette centre Y Offset.
  103953. */
  103954. get vignetteCentreY(): number;
  103955. /**
  103956. * Sets Vignette centre Y Offset.
  103957. */
  103958. set vignetteCentreY(value: number);
  103959. /**
  103960. * Gets Vignette weight or intensity of the vignette effect.
  103961. */
  103962. get vignetteWeight(): number;
  103963. /**
  103964. * Sets Vignette weight or intensity of the vignette effect.
  103965. */
  103966. set vignetteWeight(value: number);
  103967. /**
  103968. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103969. * if vignetteEnabled is set to true.
  103970. */
  103971. get vignetteColor(): Color4;
  103972. /**
  103973. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103974. * if vignetteEnabled is set to true.
  103975. */
  103976. set vignetteColor(value: Color4);
  103977. /**
  103978. * Gets Camera field of view used by the Vignette effect.
  103979. */
  103980. get vignetteCameraFov(): number;
  103981. /**
  103982. * Sets Camera field of view used by the Vignette effect.
  103983. */
  103984. set vignetteCameraFov(value: number);
  103985. /**
  103986. * Gets the vignette blend mode allowing different kind of effect.
  103987. */
  103988. get vignetteBlendMode(): number;
  103989. /**
  103990. * Sets the vignette blend mode allowing different kind of effect.
  103991. */
  103992. set vignetteBlendMode(value: number);
  103993. /**
  103994. * Gets wether the vignette effect is enabled.
  103995. */
  103996. get vignetteEnabled(): boolean;
  103997. /**
  103998. * Sets wether the vignette effect is enabled.
  103999. */
  104000. set vignetteEnabled(value: boolean);
  104001. private _fromLinearSpace;
  104002. /**
  104003. * Gets wether the input of the processing is in Gamma or Linear Space.
  104004. */
  104005. get fromLinearSpace(): boolean;
  104006. /**
  104007. * Sets wether the input of the processing is in Gamma or Linear Space.
  104008. */
  104009. set fromLinearSpace(value: boolean);
  104010. /**
  104011. * Defines cache preventing GC.
  104012. */
  104013. private _defines;
  104014. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104015. /**
  104016. * "ImageProcessingPostProcess"
  104017. * @returns "ImageProcessingPostProcess"
  104018. */
  104019. getClassName(): string;
  104020. /**
  104021. * @hidden
  104022. */
  104023. _updateParameters(): void;
  104024. dispose(camera?: Camera): void;
  104025. }
  104026. }
  104027. declare module BABYLON {
  104028. /** @hidden */
  104029. export var fibonacci: {
  104030. name: string;
  104031. shader: string;
  104032. };
  104033. }
  104034. declare module BABYLON {
  104035. /** @hidden */
  104036. export var subSurfaceScatteringFunctions: {
  104037. name: string;
  104038. shader: string;
  104039. };
  104040. }
  104041. declare module BABYLON {
  104042. /** @hidden */
  104043. export var diffusionProfile: {
  104044. name: string;
  104045. shader: string;
  104046. };
  104047. }
  104048. declare module BABYLON {
  104049. /** @hidden */
  104050. export var subSurfaceScatteringPixelShader: {
  104051. name: string;
  104052. shader: string;
  104053. };
  104054. }
  104055. declare module BABYLON {
  104056. /**
  104057. * Sub surface scattering post process
  104058. */
  104059. export class SubSurfaceScatteringPostProcess extends PostProcess {
  104060. /**
  104061. * Gets a string identifying the name of the class
  104062. * @returns "SubSurfaceScatteringPostProcess" string
  104063. */
  104064. getClassName(): string;
  104065. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  104066. }
  104067. }
  104068. declare module BABYLON {
  104069. /**
  104070. * Interface for defining prepass effects in the prepass post-process pipeline
  104071. */
  104072. export interface PrePassEffectConfiguration {
  104073. /**
  104074. * Post process to attach for this effect
  104075. */
  104076. postProcess: PostProcess;
  104077. /**
  104078. * Is the effect enabled
  104079. */
  104080. enabled: boolean;
  104081. /**
  104082. * Disposes the effect configuration
  104083. */
  104084. dispose(): void;
  104085. /**
  104086. * Disposes the effect configuration
  104087. */
  104088. createPostProcess: () => PostProcess;
  104089. }
  104090. }
  104091. declare module BABYLON {
  104092. /**
  104093. * Contains all parameters needed for the prepass to perform
  104094. * screen space subsurface scattering
  104095. */
  104096. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  104097. private _ssDiffusionS;
  104098. private _ssFilterRadii;
  104099. private _ssDiffusionD;
  104100. /**
  104101. * Post process to attach for screen space subsurface scattering
  104102. */
  104103. postProcess: SubSurfaceScatteringPostProcess;
  104104. /**
  104105. * Diffusion profile color for subsurface scattering
  104106. */
  104107. get ssDiffusionS(): number[];
  104108. /**
  104109. * Diffusion profile max color channel value for subsurface scattering
  104110. */
  104111. get ssDiffusionD(): number[];
  104112. /**
  104113. * Diffusion profile filter radius for subsurface scattering
  104114. */
  104115. get ssFilterRadii(): number[];
  104116. /**
  104117. * Is subsurface enabled
  104118. */
  104119. enabled: boolean;
  104120. /**
  104121. * Diffusion profile colors for subsurface scattering
  104122. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  104123. * See ...
  104124. * Note that you can only store up to 5 of them
  104125. */
  104126. ssDiffusionProfileColors: Color3[];
  104127. /**
  104128. * Defines the ratio real world => scene units.
  104129. * Used for subsurface scattering
  104130. */
  104131. metersPerUnit: number;
  104132. private _scene;
  104133. /**
  104134. * Builds a subsurface configuration object
  104135. * @param scene The scene
  104136. */
  104137. constructor(scene: Scene);
  104138. /**
  104139. * Adds a new diffusion profile.
  104140. * Useful for more realistic subsurface scattering on diverse materials.
  104141. * @param color The color of the diffusion profile. Should be the average color of the material.
  104142. * @return The index of the diffusion profile for the material subsurface configuration
  104143. */
  104144. addDiffusionProfile(color: Color3): number;
  104145. /**
  104146. * Creates the sss post process
  104147. * @return The created post process
  104148. */
  104149. createPostProcess(): SubSurfaceScatteringPostProcess;
  104150. /**
  104151. * Deletes all diffusion profiles.
  104152. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  104153. */
  104154. clearAllDiffusionProfiles(): void;
  104155. /**
  104156. * Disposes this object
  104157. */
  104158. dispose(): void;
  104159. /**
  104160. * @hidden
  104161. * https://zero-radiance.github.io/post/sampling-diffusion/
  104162. *
  104163. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  104164. * ------------------------------------------------------------------------------------
  104165. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  104166. * PDF[r, phi, s] = r * R[r, phi, s]
  104167. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  104168. * ------------------------------------------------------------------------------------
  104169. * We importance sample the color channel with the widest scattering distance.
  104170. */
  104171. getDiffusionProfileParameters(color: Color3): number;
  104172. /**
  104173. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  104174. * 'u' is the random number (the value of the CDF): [0, 1).
  104175. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  104176. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  104177. */
  104178. private _sampleBurleyDiffusionProfile;
  104179. }
  104180. }
  104181. declare module BABYLON {
  104182. /**
  104183. * Renders a pre pass of the scene
  104184. * This means every mesh in the scene will be rendered to a render target texture
  104185. * And then this texture will be composited to the rendering canvas with post processes
  104186. * It is necessary for effects like subsurface scattering or deferred shading
  104187. */
  104188. export class PrePassRenderer {
  104189. /** @hidden */
  104190. static _SceneComponentInitialization: (scene: Scene) => void;
  104191. private _scene;
  104192. private _engine;
  104193. private _isDirty;
  104194. /**
  104195. * Number of textures in the multi render target texture where the scene is directly rendered
  104196. */
  104197. readonly mrtCount: number;
  104198. /**
  104199. * The render target where the scene is directly rendered
  104200. */
  104201. prePassRT: MultiRenderTarget;
  104202. private _mrtTypes;
  104203. private _multiRenderAttachments;
  104204. private _defaultAttachments;
  104205. private _clearAttachments;
  104206. private _postProcesses;
  104207. private readonly _clearColor;
  104208. /**
  104209. * Image processing post process for composition
  104210. */
  104211. imageProcessingPostProcess: ImageProcessingPostProcess;
  104212. /**
  104213. * Configuration for sub surface scattering post process
  104214. */
  104215. subSurfaceConfiguration: SubSurfaceConfiguration;
  104216. /**
  104217. * Should materials render their geometry on the MRT
  104218. */
  104219. materialsShouldRenderGeometry: boolean;
  104220. /**
  104221. * Should materials render the irradiance information on the MRT
  104222. */
  104223. materialsShouldRenderIrradiance: boolean;
  104224. private _enabled;
  104225. /**
  104226. * Indicates if the prepass is enabled
  104227. */
  104228. get enabled(): boolean;
  104229. /**
  104230. * How many samples are used for MSAA of the scene render target
  104231. */
  104232. get samples(): number;
  104233. set samples(n: number);
  104234. /**
  104235. * Instanciates a prepass renderer
  104236. * @param scene The scene
  104237. */
  104238. constructor(scene: Scene);
  104239. private _initializeAttachments;
  104240. private _createCompositionEffect;
  104241. /**
  104242. * Indicates if rendering a prepass is supported
  104243. */
  104244. get isSupported(): boolean;
  104245. /**
  104246. * Sets the proper output textures to draw in the engine.
  104247. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104248. */
  104249. bindAttachmentsForEffect(effect: Effect): void;
  104250. /**
  104251. * @hidden
  104252. */
  104253. _beforeCameraDraw(): void;
  104254. /**
  104255. * @hidden
  104256. */
  104257. _afterCameraDraw(): void;
  104258. private _checkRTSize;
  104259. private _bindFrameBuffer;
  104260. /**
  104261. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104262. */
  104263. clear(): void;
  104264. private _setState;
  104265. private _enable;
  104266. private _disable;
  104267. private _resetPostProcessChain;
  104268. private _bindPostProcessChain;
  104269. /**
  104270. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104271. */
  104272. markAsDirty(): void;
  104273. private _update;
  104274. /**
  104275. * Disposes the prepass renderer.
  104276. */
  104277. dispose(): void;
  104278. }
  104279. }
  104280. declare module BABYLON {
  104281. /**
  104282. * Options for compiling materials.
  104283. */
  104284. export interface IMaterialCompilationOptions {
  104285. /**
  104286. * Defines whether clip planes are enabled.
  104287. */
  104288. clipPlane: boolean;
  104289. /**
  104290. * Defines whether instances are enabled.
  104291. */
  104292. useInstances: boolean;
  104293. }
  104294. /**
  104295. * Options passed when calling customShaderNameResolve
  104296. */
  104297. export interface ICustomShaderNameResolveOptions {
  104298. /**
  104299. * 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
  104300. */
  104301. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104302. }
  104303. /**
  104304. * Base class for the main features of a material in Babylon.js
  104305. */
  104306. export class Material implements IAnimatable {
  104307. /**
  104308. * Returns the triangle fill mode
  104309. */
  104310. static readonly TriangleFillMode: number;
  104311. /**
  104312. * Returns the wireframe mode
  104313. */
  104314. static readonly WireFrameFillMode: number;
  104315. /**
  104316. * Returns the point fill mode
  104317. */
  104318. static readonly PointFillMode: number;
  104319. /**
  104320. * Returns the point list draw mode
  104321. */
  104322. static readonly PointListDrawMode: number;
  104323. /**
  104324. * Returns the line list draw mode
  104325. */
  104326. static readonly LineListDrawMode: number;
  104327. /**
  104328. * Returns the line loop draw mode
  104329. */
  104330. static readonly LineLoopDrawMode: number;
  104331. /**
  104332. * Returns the line strip draw mode
  104333. */
  104334. static readonly LineStripDrawMode: number;
  104335. /**
  104336. * Returns the triangle strip draw mode
  104337. */
  104338. static readonly TriangleStripDrawMode: number;
  104339. /**
  104340. * Returns the triangle fan draw mode
  104341. */
  104342. static readonly TriangleFanDrawMode: number;
  104343. /**
  104344. * Stores the clock-wise side orientation
  104345. */
  104346. static readonly ClockWiseSideOrientation: number;
  104347. /**
  104348. * Stores the counter clock-wise side orientation
  104349. */
  104350. static readonly CounterClockWiseSideOrientation: number;
  104351. /**
  104352. * The dirty texture flag value
  104353. */
  104354. static readonly TextureDirtyFlag: number;
  104355. /**
  104356. * The dirty light flag value
  104357. */
  104358. static readonly LightDirtyFlag: number;
  104359. /**
  104360. * The dirty fresnel flag value
  104361. */
  104362. static readonly FresnelDirtyFlag: number;
  104363. /**
  104364. * The dirty attribute flag value
  104365. */
  104366. static readonly AttributesDirtyFlag: number;
  104367. /**
  104368. * The dirty misc flag value
  104369. */
  104370. static readonly MiscDirtyFlag: number;
  104371. /**
  104372. * The all dirty flag value
  104373. */
  104374. static readonly AllDirtyFlag: number;
  104375. /**
  104376. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104377. */
  104378. static readonly MATERIAL_OPAQUE: number;
  104379. /**
  104380. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104381. */
  104382. static readonly MATERIAL_ALPHATEST: number;
  104383. /**
  104384. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104385. */
  104386. static readonly MATERIAL_ALPHABLEND: number;
  104387. /**
  104388. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104389. * They are also discarded below the alpha cutoff threshold to improve performances.
  104390. */
  104391. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104392. /**
  104393. * The Whiteout method is used to blend normals.
  104394. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104395. */
  104396. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104397. /**
  104398. * The Reoriented Normal Mapping method is used to blend normals.
  104399. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104400. */
  104401. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104402. /**
  104403. * Custom callback helping to override the default shader used in the material.
  104404. */
  104405. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104406. /**
  104407. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104408. */
  104409. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104410. /**
  104411. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104412. * This means that the material can keep using a previous shader while a new one is being compiled.
  104413. * This is mostly used when shader parallel compilation is supported (true by default)
  104414. */
  104415. allowShaderHotSwapping: boolean;
  104416. /**
  104417. * The ID of the material
  104418. */
  104419. id: string;
  104420. /**
  104421. * Gets or sets the unique id of the material
  104422. */
  104423. uniqueId: number;
  104424. /**
  104425. * The name of the material
  104426. */
  104427. name: string;
  104428. /**
  104429. * Gets or sets user defined metadata
  104430. */
  104431. metadata: any;
  104432. /**
  104433. * For internal use only. Please do not use.
  104434. */
  104435. reservedDataStore: any;
  104436. /**
  104437. * Specifies if the ready state should be checked on each call
  104438. */
  104439. checkReadyOnEveryCall: boolean;
  104440. /**
  104441. * Specifies if the ready state should be checked once
  104442. */
  104443. checkReadyOnlyOnce: boolean;
  104444. /**
  104445. * The state of the material
  104446. */
  104447. state: string;
  104448. /**
  104449. * If the material can be rendered to several textures with MRT extension
  104450. */
  104451. get canRenderToMRT(): boolean;
  104452. /**
  104453. * The alpha value of the material
  104454. */
  104455. protected _alpha: number;
  104456. /**
  104457. * List of inspectable custom properties (used by the Inspector)
  104458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104459. */
  104460. inspectableCustomProperties: IInspectable[];
  104461. /**
  104462. * Sets the alpha value of the material
  104463. */
  104464. set alpha(value: number);
  104465. /**
  104466. * Gets the alpha value of the material
  104467. */
  104468. get alpha(): number;
  104469. /**
  104470. * Specifies if back face culling is enabled
  104471. */
  104472. protected _backFaceCulling: boolean;
  104473. /**
  104474. * Sets the back-face culling state
  104475. */
  104476. set backFaceCulling(value: boolean);
  104477. /**
  104478. * Gets the back-face culling state
  104479. */
  104480. get backFaceCulling(): boolean;
  104481. /**
  104482. * Stores the value for side orientation
  104483. */
  104484. sideOrientation: number;
  104485. /**
  104486. * Callback triggered when the material is compiled
  104487. */
  104488. onCompiled: Nullable<(effect: Effect) => void>;
  104489. /**
  104490. * Callback triggered when an error occurs
  104491. */
  104492. onError: Nullable<(effect: Effect, errors: string) => void>;
  104493. /**
  104494. * Callback triggered to get the render target textures
  104495. */
  104496. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  104497. /**
  104498. * Gets a boolean indicating that current material needs to register RTT
  104499. */
  104500. get hasRenderTargetTextures(): boolean;
  104501. /**
  104502. * Specifies if the material should be serialized
  104503. */
  104504. doNotSerialize: boolean;
  104505. /**
  104506. * @hidden
  104507. */
  104508. _storeEffectOnSubMeshes: boolean;
  104509. /**
  104510. * Stores the animations for the material
  104511. */
  104512. animations: Nullable<Array<Animation>>;
  104513. /**
  104514. * An event triggered when the material is disposed
  104515. */
  104516. onDisposeObservable: Observable<Material>;
  104517. /**
  104518. * An observer which watches for dispose events
  104519. */
  104520. private _onDisposeObserver;
  104521. private _onUnBindObservable;
  104522. /**
  104523. * Called during a dispose event
  104524. */
  104525. set onDispose(callback: () => void);
  104526. private _onBindObservable;
  104527. /**
  104528. * An event triggered when the material is bound
  104529. */
  104530. get onBindObservable(): Observable<AbstractMesh>;
  104531. /**
  104532. * An observer which watches for bind events
  104533. */
  104534. private _onBindObserver;
  104535. /**
  104536. * Called during a bind event
  104537. */
  104538. set onBind(callback: (Mesh: AbstractMesh) => void);
  104539. /**
  104540. * An event triggered when the material is unbound
  104541. */
  104542. get onUnBindObservable(): Observable<Material>;
  104543. protected _onEffectCreatedObservable: Nullable<Observable<{
  104544. effect: Effect;
  104545. subMesh: Nullable<SubMesh>;
  104546. }>>;
  104547. /**
  104548. * An event triggered when the effect is (re)created
  104549. */
  104550. get onEffectCreatedObservable(): Observable<{
  104551. effect: Effect;
  104552. subMesh: Nullable<SubMesh>;
  104553. }>;
  104554. /**
  104555. * Stores the value of the alpha mode
  104556. */
  104557. private _alphaMode;
  104558. /**
  104559. * Sets the value of the alpha mode.
  104560. *
  104561. * | Value | Type | Description |
  104562. * | --- | --- | --- |
  104563. * | 0 | ALPHA_DISABLE | |
  104564. * | 1 | ALPHA_ADD | |
  104565. * | 2 | ALPHA_COMBINE | |
  104566. * | 3 | ALPHA_SUBTRACT | |
  104567. * | 4 | ALPHA_MULTIPLY | |
  104568. * | 5 | ALPHA_MAXIMIZED | |
  104569. * | 6 | ALPHA_ONEONE | |
  104570. * | 7 | ALPHA_PREMULTIPLIED | |
  104571. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104572. * | 9 | ALPHA_INTERPOLATE | |
  104573. * | 10 | ALPHA_SCREENMODE | |
  104574. *
  104575. */
  104576. set alphaMode(value: number);
  104577. /**
  104578. * Gets the value of the alpha mode
  104579. */
  104580. get alphaMode(): number;
  104581. /**
  104582. * Stores the state of the need depth pre-pass value
  104583. */
  104584. private _needDepthPrePass;
  104585. /**
  104586. * Sets the need depth pre-pass value
  104587. */
  104588. set needDepthPrePass(value: boolean);
  104589. /**
  104590. * Gets the depth pre-pass value
  104591. */
  104592. get needDepthPrePass(): boolean;
  104593. /**
  104594. * Specifies if depth writing should be disabled
  104595. */
  104596. disableDepthWrite: boolean;
  104597. /**
  104598. * Specifies if color writing should be disabled
  104599. */
  104600. disableColorWrite: boolean;
  104601. /**
  104602. * Specifies if depth writing should be forced
  104603. */
  104604. forceDepthWrite: boolean;
  104605. /**
  104606. * Specifies the depth function that should be used. 0 means the default engine function
  104607. */
  104608. depthFunction: number;
  104609. /**
  104610. * Specifies if there should be a separate pass for culling
  104611. */
  104612. separateCullingPass: boolean;
  104613. /**
  104614. * Stores the state specifing if fog should be enabled
  104615. */
  104616. private _fogEnabled;
  104617. /**
  104618. * Sets the state for enabling fog
  104619. */
  104620. set fogEnabled(value: boolean);
  104621. /**
  104622. * Gets the value of the fog enabled state
  104623. */
  104624. get fogEnabled(): boolean;
  104625. /**
  104626. * Stores the size of points
  104627. */
  104628. pointSize: number;
  104629. /**
  104630. * Stores the z offset value
  104631. */
  104632. zOffset: number;
  104633. get wireframe(): boolean;
  104634. /**
  104635. * Sets the state of wireframe mode
  104636. */
  104637. set wireframe(value: boolean);
  104638. /**
  104639. * Gets the value specifying if point clouds are enabled
  104640. */
  104641. get pointsCloud(): boolean;
  104642. /**
  104643. * Sets the state of point cloud mode
  104644. */
  104645. set pointsCloud(value: boolean);
  104646. /**
  104647. * Gets the material fill mode
  104648. */
  104649. get fillMode(): number;
  104650. /**
  104651. * Sets the material fill mode
  104652. */
  104653. set fillMode(value: number);
  104654. /**
  104655. * @hidden
  104656. * Stores the effects for the material
  104657. */
  104658. _effect: Nullable<Effect>;
  104659. /**
  104660. * Specifies if uniform buffers should be used
  104661. */
  104662. private _useUBO;
  104663. /**
  104664. * Stores a reference to the scene
  104665. */
  104666. private _scene;
  104667. /**
  104668. * Stores the fill mode state
  104669. */
  104670. private _fillMode;
  104671. /**
  104672. * Specifies if the depth write state should be cached
  104673. */
  104674. private _cachedDepthWriteState;
  104675. /**
  104676. * Specifies if the color write state should be cached
  104677. */
  104678. private _cachedColorWriteState;
  104679. /**
  104680. * Specifies if the depth function state should be cached
  104681. */
  104682. private _cachedDepthFunctionState;
  104683. /**
  104684. * Stores the uniform buffer
  104685. */
  104686. protected _uniformBuffer: UniformBuffer;
  104687. /** @hidden */
  104688. _indexInSceneMaterialArray: number;
  104689. /** @hidden */
  104690. meshMap: Nullable<{
  104691. [id: string]: AbstractMesh | undefined;
  104692. }>;
  104693. /**
  104694. * Creates a material instance
  104695. * @param name defines the name of the material
  104696. * @param scene defines the scene to reference
  104697. * @param doNotAdd specifies if the material should be added to the scene
  104698. */
  104699. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104700. /**
  104701. * Returns a string representation of the current material
  104702. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104703. * @returns a string with material information
  104704. */
  104705. toString(fullDetails?: boolean): string;
  104706. /**
  104707. * Gets the class name of the material
  104708. * @returns a string with the class name of the material
  104709. */
  104710. getClassName(): string;
  104711. /**
  104712. * Specifies if updates for the material been locked
  104713. */
  104714. get isFrozen(): boolean;
  104715. /**
  104716. * Locks updates for the material
  104717. */
  104718. freeze(): void;
  104719. /**
  104720. * Unlocks updates for the material
  104721. */
  104722. unfreeze(): void;
  104723. /**
  104724. * Specifies if the material is ready to be used
  104725. * @param mesh defines the mesh to check
  104726. * @param useInstances specifies if instances should be used
  104727. * @returns a boolean indicating if the material is ready to be used
  104728. */
  104729. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104730. /**
  104731. * Specifies that the submesh is ready to be used
  104732. * @param mesh defines the mesh to check
  104733. * @param subMesh defines which submesh to check
  104734. * @param useInstances specifies that instances should be used
  104735. * @returns a boolean indicating that the submesh is ready or not
  104736. */
  104737. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104738. /**
  104739. * Returns the material effect
  104740. * @returns the effect associated with the material
  104741. */
  104742. getEffect(): Nullable<Effect>;
  104743. /**
  104744. * Returns the current scene
  104745. * @returns a Scene
  104746. */
  104747. getScene(): Scene;
  104748. /**
  104749. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104750. */
  104751. protected _forceAlphaTest: boolean;
  104752. /**
  104753. * The transparency mode of the material.
  104754. */
  104755. protected _transparencyMode: Nullable<number>;
  104756. /**
  104757. * Gets the current transparency mode.
  104758. */
  104759. get transparencyMode(): Nullable<number>;
  104760. /**
  104761. * Sets the transparency mode of the material.
  104762. *
  104763. * | Value | Type | Description |
  104764. * | ----- | ----------------------------------- | ----------- |
  104765. * | 0 | OPAQUE | |
  104766. * | 1 | ALPHATEST | |
  104767. * | 2 | ALPHABLEND | |
  104768. * | 3 | ALPHATESTANDBLEND | |
  104769. *
  104770. */
  104771. set transparencyMode(value: Nullable<number>);
  104772. /**
  104773. * Returns true if alpha blending should be disabled.
  104774. */
  104775. protected get _disableAlphaBlending(): boolean;
  104776. /**
  104777. * Specifies whether or not this material should be rendered in alpha blend mode.
  104778. * @returns a boolean specifying if alpha blending is needed
  104779. */
  104780. needAlphaBlending(): boolean;
  104781. /**
  104782. * Specifies if the mesh will require alpha blending
  104783. * @param mesh defines the mesh to check
  104784. * @returns a boolean specifying if alpha blending is needed for the mesh
  104785. */
  104786. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104787. /**
  104788. * Specifies whether or not this material should be rendered in alpha test mode.
  104789. * @returns a boolean specifying if an alpha test is needed.
  104790. */
  104791. needAlphaTesting(): boolean;
  104792. /**
  104793. * Specifies if material alpha testing should be turned on for the mesh
  104794. * @param mesh defines the mesh to check
  104795. */
  104796. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  104797. /**
  104798. * Gets the texture used for the alpha test
  104799. * @returns the texture to use for alpha testing
  104800. */
  104801. getAlphaTestTexture(): Nullable<BaseTexture>;
  104802. /**
  104803. * Marks the material to indicate that it needs to be re-calculated
  104804. */
  104805. markDirty(): void;
  104806. /** @hidden */
  104807. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  104808. /**
  104809. * Binds the material to the mesh
  104810. * @param world defines the world transformation matrix
  104811. * @param mesh defines the mesh to bind the material to
  104812. */
  104813. bind(world: Matrix, mesh?: Mesh): void;
  104814. /**
  104815. * Binds the submesh to the material
  104816. * @param world defines the world transformation matrix
  104817. * @param mesh defines the mesh containing the submesh
  104818. * @param subMesh defines the submesh to bind the material to
  104819. */
  104820. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104821. /**
  104822. * Binds the world matrix to the material
  104823. * @param world defines the world transformation matrix
  104824. */
  104825. bindOnlyWorldMatrix(world: Matrix): void;
  104826. /**
  104827. * Binds the scene's uniform buffer to the effect.
  104828. * @param effect defines the effect to bind to the scene uniform buffer
  104829. * @param sceneUbo defines the uniform buffer storing scene data
  104830. */
  104831. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  104832. /**
  104833. * Binds the view matrix to the effect
  104834. * @param effect defines the effect to bind the view matrix to
  104835. */
  104836. bindView(effect: Effect): void;
  104837. /**
  104838. * Binds the view projection matrix to the effect
  104839. * @param effect defines the effect to bind the view projection matrix to
  104840. */
  104841. bindViewProjection(effect: Effect): void;
  104842. /**
  104843. * Processes to execute after binding the material to a mesh
  104844. * @param mesh defines the rendered mesh
  104845. */
  104846. protected _afterBind(mesh?: Mesh): void;
  104847. /**
  104848. * Unbinds the material from the mesh
  104849. */
  104850. unbind(): void;
  104851. /**
  104852. * Gets the active textures from the material
  104853. * @returns an array of textures
  104854. */
  104855. getActiveTextures(): BaseTexture[];
  104856. /**
  104857. * Specifies if the material uses a texture
  104858. * @param texture defines the texture to check against the material
  104859. * @returns a boolean specifying if the material uses the texture
  104860. */
  104861. hasTexture(texture: BaseTexture): boolean;
  104862. /**
  104863. * Makes a duplicate of the material, and gives it a new name
  104864. * @param name defines the new name for the duplicated material
  104865. * @returns the cloned material
  104866. */
  104867. clone(name: string): Nullable<Material>;
  104868. /**
  104869. * Gets the meshes bound to the material
  104870. * @returns an array of meshes bound to the material
  104871. */
  104872. getBindedMeshes(): AbstractMesh[];
  104873. /**
  104874. * Force shader compilation
  104875. * @param mesh defines the mesh associated with this material
  104876. * @param onCompiled defines a function to execute once the material is compiled
  104877. * @param options defines the options to configure the compilation
  104878. * @param onError defines a function to execute if the material fails compiling
  104879. */
  104880. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  104881. /**
  104882. * Force shader compilation
  104883. * @param mesh defines the mesh that will use this material
  104884. * @param options defines additional options for compiling the shaders
  104885. * @returns a promise that resolves when the compilation completes
  104886. */
  104887. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  104888. private static readonly _AllDirtyCallBack;
  104889. private static readonly _ImageProcessingDirtyCallBack;
  104890. private static readonly _TextureDirtyCallBack;
  104891. private static readonly _FresnelDirtyCallBack;
  104892. private static readonly _MiscDirtyCallBack;
  104893. private static readonly _LightsDirtyCallBack;
  104894. private static readonly _AttributeDirtyCallBack;
  104895. private static _FresnelAndMiscDirtyCallBack;
  104896. private static _TextureAndMiscDirtyCallBack;
  104897. private static readonly _DirtyCallbackArray;
  104898. private static readonly _RunDirtyCallBacks;
  104899. /**
  104900. * Marks a define in the material to indicate that it needs to be re-computed
  104901. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  104902. */
  104903. markAsDirty(flag: number): void;
  104904. /**
  104905. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  104906. * @param func defines a function which checks material defines against the submeshes
  104907. */
  104908. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  104909. /**
  104910. * Indicates that the scene should check if the rendering now needs a prepass
  104911. */
  104912. protected _markScenePrePassDirty(): void;
  104913. /**
  104914. * Indicates that we need to re-calculated for all submeshes
  104915. */
  104916. protected _markAllSubMeshesAsAllDirty(): void;
  104917. /**
  104918. * Indicates that image processing needs to be re-calculated for all submeshes
  104919. */
  104920. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  104921. /**
  104922. * Indicates that textures need to be re-calculated for all submeshes
  104923. */
  104924. protected _markAllSubMeshesAsTexturesDirty(): void;
  104925. /**
  104926. * Indicates that fresnel needs to be re-calculated for all submeshes
  104927. */
  104928. protected _markAllSubMeshesAsFresnelDirty(): void;
  104929. /**
  104930. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  104931. */
  104932. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  104933. /**
  104934. * Indicates that lights need to be re-calculated for all submeshes
  104935. */
  104936. protected _markAllSubMeshesAsLightsDirty(): void;
  104937. /**
  104938. * Indicates that attributes need to be re-calculated for all submeshes
  104939. */
  104940. protected _markAllSubMeshesAsAttributesDirty(): void;
  104941. /**
  104942. * Indicates that misc needs to be re-calculated for all submeshes
  104943. */
  104944. protected _markAllSubMeshesAsMiscDirty(): void;
  104945. /**
  104946. * Indicates that textures and misc need to be re-calculated for all submeshes
  104947. */
  104948. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  104949. /**
  104950. * Sets the required values to the prepass renderer.
  104951. * @param prePassRenderer defines the prepass renderer to setup.
  104952. * @returns true if the pre pass is needed.
  104953. */
  104954. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104955. /**
  104956. * Disposes the material
  104957. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104958. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104959. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104960. */
  104961. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104962. /** @hidden */
  104963. private releaseVertexArrayObject;
  104964. /**
  104965. * Serializes this material
  104966. * @returns the serialized material object
  104967. */
  104968. serialize(): any;
  104969. /**
  104970. * Creates a material from parsed material data
  104971. * @param parsedMaterial defines parsed material data
  104972. * @param scene defines the hosting scene
  104973. * @param rootUrl defines the root URL to use to load textures
  104974. * @returns a new material
  104975. */
  104976. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  104977. }
  104978. }
  104979. declare module BABYLON {
  104980. /**
  104981. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104982. * separate meshes. This can be use to improve performances.
  104983. * @see https://doc.babylonjs.com/how_to/multi_materials
  104984. */
  104985. export class MultiMaterial extends Material {
  104986. private _subMaterials;
  104987. /**
  104988. * Gets or Sets the list of Materials used within the multi material.
  104989. * They need to be ordered according to the submeshes order in the associated mesh
  104990. */
  104991. get subMaterials(): Nullable<Material>[];
  104992. set subMaterials(value: Nullable<Material>[]);
  104993. /**
  104994. * Function used to align with Node.getChildren()
  104995. * @returns the list of Materials used within the multi material
  104996. */
  104997. getChildren(): Nullable<Material>[];
  104998. /**
  104999. * Instantiates a new Multi Material
  105000. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105001. * separate meshes. This can be use to improve performances.
  105002. * @see https://doc.babylonjs.com/how_to/multi_materials
  105003. * @param name Define the name in the scene
  105004. * @param scene Define the scene the material belongs to
  105005. */
  105006. constructor(name: string, scene: Scene);
  105007. private _hookArray;
  105008. /**
  105009. * Get one of the submaterial by its index in the submaterials array
  105010. * @param index The index to look the sub material at
  105011. * @returns The Material if the index has been defined
  105012. */
  105013. getSubMaterial(index: number): Nullable<Material>;
  105014. /**
  105015. * Get the list of active textures for the whole sub materials list.
  105016. * @returns All the textures that will be used during the rendering
  105017. */
  105018. getActiveTextures(): BaseTexture[];
  105019. /**
  105020. * Gets the current class name of the material e.g. "MultiMaterial"
  105021. * Mainly use in serialization.
  105022. * @returns the class name
  105023. */
  105024. getClassName(): string;
  105025. /**
  105026. * Checks if the material is ready to render the requested sub mesh
  105027. * @param mesh Define the mesh the submesh belongs to
  105028. * @param subMesh Define the sub mesh to look readyness for
  105029. * @param useInstances Define whether or not the material is used with instances
  105030. * @returns true if ready, otherwise false
  105031. */
  105032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105033. /**
  105034. * Clones the current material and its related sub materials
  105035. * @param name Define the name of the newly cloned material
  105036. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105037. * @returns the cloned material
  105038. */
  105039. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105040. /**
  105041. * Serializes the materials into a JSON representation.
  105042. * @returns the JSON representation
  105043. */
  105044. serialize(): any;
  105045. /**
  105046. * Dispose the material and release its associated resources
  105047. * @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)
  105048. * @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)
  105049. * @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)
  105050. */
  105051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105052. /**
  105053. * Creates a MultiMaterial from parsed MultiMaterial data.
  105054. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105055. * @param scene defines the hosting scene
  105056. * @returns a new MultiMaterial
  105057. */
  105058. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105059. }
  105060. }
  105061. declare module BABYLON {
  105062. /**
  105063. * Defines a subdivision inside a mesh
  105064. */
  105065. export class SubMesh implements ICullable {
  105066. /** the material index to use */
  105067. materialIndex: number;
  105068. /** vertex index start */
  105069. verticesStart: number;
  105070. /** vertices count */
  105071. verticesCount: number;
  105072. /** index start */
  105073. indexStart: number;
  105074. /** indices count */
  105075. indexCount: number;
  105076. /** @hidden */
  105077. _materialDefines: Nullable<MaterialDefines>;
  105078. /** @hidden */
  105079. _materialEffect: Nullable<Effect>;
  105080. /** @hidden */
  105081. _effectOverride: Nullable<Effect>;
  105082. /**
  105083. * Gets material defines used by the effect associated to the sub mesh
  105084. */
  105085. get materialDefines(): Nullable<MaterialDefines>;
  105086. /**
  105087. * Sets material defines used by the effect associated to the sub mesh
  105088. */
  105089. set materialDefines(defines: Nullable<MaterialDefines>);
  105090. /**
  105091. * Gets associated effect
  105092. */
  105093. get effect(): Nullable<Effect>;
  105094. /**
  105095. * Sets associated effect (effect used to render this submesh)
  105096. * @param effect defines the effect to associate with
  105097. * @param defines defines the set of defines used to compile this effect
  105098. */
  105099. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105100. /** @hidden */
  105101. _linesIndexCount: number;
  105102. private _mesh;
  105103. private _renderingMesh;
  105104. private _boundingInfo;
  105105. private _linesIndexBuffer;
  105106. /** @hidden */
  105107. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105108. /** @hidden */
  105109. _trianglePlanes: Plane[];
  105110. /** @hidden */
  105111. _lastColliderTransformMatrix: Nullable<Matrix>;
  105112. /** @hidden */
  105113. _renderId: number;
  105114. /** @hidden */
  105115. _alphaIndex: number;
  105116. /** @hidden */
  105117. _distanceToCamera: number;
  105118. /** @hidden */
  105119. _id: number;
  105120. private _currentMaterial;
  105121. /**
  105122. * Add a new submesh to a mesh
  105123. * @param materialIndex defines the material index to use
  105124. * @param verticesStart defines vertex index start
  105125. * @param verticesCount defines vertices count
  105126. * @param indexStart defines index start
  105127. * @param indexCount defines indices count
  105128. * @param mesh defines the parent mesh
  105129. * @param renderingMesh defines an optional rendering mesh
  105130. * @param createBoundingBox defines if bounding box should be created for this submesh
  105131. * @returns the new submesh
  105132. */
  105133. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105134. /**
  105135. * Creates a new submesh
  105136. * @param materialIndex defines the material index to use
  105137. * @param verticesStart defines vertex index start
  105138. * @param verticesCount defines vertices count
  105139. * @param indexStart defines index start
  105140. * @param indexCount defines indices count
  105141. * @param mesh defines the parent mesh
  105142. * @param renderingMesh defines an optional rendering mesh
  105143. * @param createBoundingBox defines if bounding box should be created for this submesh
  105144. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105145. */
  105146. constructor(
  105147. /** the material index to use */
  105148. materialIndex: number,
  105149. /** vertex index start */
  105150. verticesStart: number,
  105151. /** vertices count */
  105152. verticesCount: number,
  105153. /** index start */
  105154. indexStart: number,
  105155. /** indices count */
  105156. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105157. /**
  105158. * Returns true if this submesh covers the entire parent mesh
  105159. * @ignorenaming
  105160. */
  105161. get IsGlobal(): boolean;
  105162. /**
  105163. * Returns the submesh BoudingInfo object
  105164. * @returns current bounding info (or mesh's one if the submesh is global)
  105165. */
  105166. getBoundingInfo(): BoundingInfo;
  105167. /**
  105168. * Sets the submesh BoundingInfo
  105169. * @param boundingInfo defines the new bounding info to use
  105170. * @returns the SubMesh
  105171. */
  105172. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105173. /**
  105174. * Returns the mesh of the current submesh
  105175. * @return the parent mesh
  105176. */
  105177. getMesh(): AbstractMesh;
  105178. /**
  105179. * Returns the rendering mesh of the submesh
  105180. * @returns the rendering mesh (could be different from parent mesh)
  105181. */
  105182. getRenderingMesh(): Mesh;
  105183. /**
  105184. * Returns the replacement mesh of the submesh
  105185. * @returns the replacement mesh (could be different from parent mesh)
  105186. */
  105187. getReplacementMesh(): Nullable<AbstractMesh>;
  105188. /**
  105189. * Returns the effective mesh of the submesh
  105190. * @returns the effective mesh (could be different from parent mesh)
  105191. */
  105192. getEffectiveMesh(): AbstractMesh;
  105193. /**
  105194. * Returns the submesh material
  105195. * @returns null or the current material
  105196. */
  105197. getMaterial(): Nullable<Material>;
  105198. private _IsMultiMaterial;
  105199. /**
  105200. * Sets a new updated BoundingInfo object to the submesh
  105201. * @param data defines an optional position array to use to determine the bounding info
  105202. * @returns the SubMesh
  105203. */
  105204. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105205. /** @hidden */
  105206. _checkCollision(collider: Collider): boolean;
  105207. /**
  105208. * Updates the submesh BoundingInfo
  105209. * @param world defines the world matrix to use to update the bounding info
  105210. * @returns the submesh
  105211. */
  105212. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105213. /**
  105214. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105215. * @param frustumPlanes defines the frustum planes
  105216. * @returns true if the submesh is intersecting with the frustum
  105217. */
  105218. isInFrustum(frustumPlanes: Plane[]): boolean;
  105219. /**
  105220. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105221. * @param frustumPlanes defines the frustum planes
  105222. * @returns true if the submesh is inside the frustum
  105223. */
  105224. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105225. /**
  105226. * Renders the submesh
  105227. * @param enableAlphaMode defines if alpha needs to be used
  105228. * @returns the submesh
  105229. */
  105230. render(enableAlphaMode: boolean): SubMesh;
  105231. /**
  105232. * @hidden
  105233. */
  105234. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105235. /**
  105236. * Checks if the submesh intersects with a ray
  105237. * @param ray defines the ray to test
  105238. * @returns true is the passed ray intersects the submesh bounding box
  105239. */
  105240. canIntersects(ray: Ray): boolean;
  105241. /**
  105242. * Intersects current submesh with a ray
  105243. * @param ray defines the ray to test
  105244. * @param positions defines mesh's positions array
  105245. * @param indices defines mesh's indices array
  105246. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105248. * @returns intersection info or null if no intersection
  105249. */
  105250. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105251. /** @hidden */
  105252. private _intersectLines;
  105253. /** @hidden */
  105254. private _intersectUnIndexedLines;
  105255. /** @hidden */
  105256. private _intersectTriangles;
  105257. /** @hidden */
  105258. private _intersectUnIndexedTriangles;
  105259. /** @hidden */
  105260. _rebuild(): void;
  105261. /**
  105262. * Creates a new submesh from the passed mesh
  105263. * @param newMesh defines the new hosting mesh
  105264. * @param newRenderingMesh defines an optional rendering mesh
  105265. * @returns the new submesh
  105266. */
  105267. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105268. /**
  105269. * Release associated resources
  105270. */
  105271. dispose(): void;
  105272. /**
  105273. * Gets the class name
  105274. * @returns the string "SubMesh".
  105275. */
  105276. getClassName(): string;
  105277. /**
  105278. * Creates a new submesh from indices data
  105279. * @param materialIndex the index of the main mesh material
  105280. * @param startIndex the index where to start the copy in the mesh indices array
  105281. * @param indexCount the number of indices to copy then from the startIndex
  105282. * @param mesh the main mesh to create the submesh from
  105283. * @param renderingMesh the optional rendering mesh
  105284. * @returns a new submesh
  105285. */
  105286. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105287. }
  105288. }
  105289. declare module BABYLON {
  105290. /**
  105291. * Class used to represent data loading progression
  105292. */
  105293. export class SceneLoaderFlags {
  105294. private static _ForceFullSceneLoadingForIncremental;
  105295. private static _ShowLoadingScreen;
  105296. private static _CleanBoneMatrixWeights;
  105297. private static _loggingLevel;
  105298. /**
  105299. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105300. */
  105301. static get ForceFullSceneLoadingForIncremental(): boolean;
  105302. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105303. /**
  105304. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105305. */
  105306. static get ShowLoadingScreen(): boolean;
  105307. static set ShowLoadingScreen(value: boolean);
  105308. /**
  105309. * Defines the current logging level (while loading the scene)
  105310. * @ignorenaming
  105311. */
  105312. static get loggingLevel(): number;
  105313. static set loggingLevel(value: number);
  105314. /**
  105315. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105316. */
  105317. static get CleanBoneMatrixWeights(): boolean;
  105318. static set CleanBoneMatrixWeights(value: boolean);
  105319. }
  105320. }
  105321. declare module BABYLON {
  105322. /**
  105323. * Class used to store geometry data (vertex buffers + index buffer)
  105324. */
  105325. export class Geometry implements IGetSetVerticesData {
  105326. /**
  105327. * Gets or sets the ID of the geometry
  105328. */
  105329. id: string;
  105330. /**
  105331. * Gets or sets the unique ID of the geometry
  105332. */
  105333. uniqueId: number;
  105334. /**
  105335. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105336. */
  105337. delayLoadState: number;
  105338. /**
  105339. * Gets the file containing the data to load when running in delay load state
  105340. */
  105341. delayLoadingFile: Nullable<string>;
  105342. /**
  105343. * Callback called when the geometry is updated
  105344. */
  105345. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105346. private _scene;
  105347. private _engine;
  105348. private _meshes;
  105349. private _totalVertices;
  105350. /** @hidden */
  105351. _indices: IndicesArray;
  105352. /** @hidden */
  105353. _vertexBuffers: {
  105354. [key: string]: VertexBuffer;
  105355. };
  105356. private _isDisposed;
  105357. private _extend;
  105358. private _boundingBias;
  105359. /** @hidden */
  105360. _delayInfo: Array<string>;
  105361. private _indexBuffer;
  105362. private _indexBufferIsUpdatable;
  105363. /** @hidden */
  105364. _boundingInfo: Nullable<BoundingInfo>;
  105365. /** @hidden */
  105366. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105367. /** @hidden */
  105368. _softwareSkinningFrameId: number;
  105369. private _vertexArrayObjects;
  105370. private _updatable;
  105371. /** @hidden */
  105372. _positions: Nullable<Vector3[]>;
  105373. /**
  105374. * 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
  105375. */
  105376. get boundingBias(): Vector2;
  105377. /**
  105378. * 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
  105379. */
  105380. set boundingBias(value: Vector2);
  105381. /**
  105382. * Static function used to attach a new empty geometry to a mesh
  105383. * @param mesh defines the mesh to attach the geometry to
  105384. * @returns the new Geometry
  105385. */
  105386. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105387. /** Get the list of meshes using this geometry */
  105388. get meshes(): Mesh[];
  105389. /**
  105390. * 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
  105391. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105392. */
  105393. useBoundingInfoFromGeometry: boolean;
  105394. /**
  105395. * Creates a new geometry
  105396. * @param id defines the unique ID
  105397. * @param scene defines the hosting scene
  105398. * @param vertexData defines the VertexData used to get geometry data
  105399. * @param updatable defines if geometry must be updatable (false by default)
  105400. * @param mesh defines the mesh that will be associated with the geometry
  105401. */
  105402. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105403. /**
  105404. * Gets the current extend of the geometry
  105405. */
  105406. get extend(): {
  105407. minimum: Vector3;
  105408. maximum: Vector3;
  105409. };
  105410. /**
  105411. * Gets the hosting scene
  105412. * @returns the hosting Scene
  105413. */
  105414. getScene(): Scene;
  105415. /**
  105416. * Gets the hosting engine
  105417. * @returns the hosting Engine
  105418. */
  105419. getEngine(): Engine;
  105420. /**
  105421. * Defines if the geometry is ready to use
  105422. * @returns true if the geometry is ready to be used
  105423. */
  105424. isReady(): boolean;
  105425. /**
  105426. * Gets a value indicating that the geometry should not be serialized
  105427. */
  105428. get doNotSerialize(): boolean;
  105429. /** @hidden */
  105430. _rebuild(): void;
  105431. /**
  105432. * Affects all geometry data in one call
  105433. * @param vertexData defines the geometry data
  105434. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105435. */
  105436. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105437. /**
  105438. * Set specific vertex data
  105439. * @param kind defines the data kind (Position, normal, etc...)
  105440. * @param data defines the vertex data to use
  105441. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105442. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105443. */
  105444. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105445. /**
  105446. * Removes a specific vertex data
  105447. * @param kind defines the data kind (Position, normal, etc...)
  105448. */
  105449. removeVerticesData(kind: string): void;
  105450. /**
  105451. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105452. * @param buffer defines the vertex buffer to use
  105453. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105454. */
  105455. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105456. /**
  105457. * Update a specific vertex buffer
  105458. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  105459. * It will do nothing if the buffer is not updatable
  105460. * @param kind defines the data kind (Position, normal, etc...)
  105461. * @param data defines the data to use
  105462. * @param offset defines the offset in the target buffer where to store the data
  105463. * @param useBytes set to true if the offset is in bytes
  105464. */
  105465. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  105466. /**
  105467. * Update a specific vertex buffer
  105468. * This function will create a new buffer if the current one is not updatable
  105469. * @param kind defines the data kind (Position, normal, etc...)
  105470. * @param data defines the data to use
  105471. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  105472. */
  105473. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  105474. private _updateBoundingInfo;
  105475. /** @hidden */
  105476. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  105477. /**
  105478. * Gets total number of vertices
  105479. * @returns the total number of vertices
  105480. */
  105481. getTotalVertices(): number;
  105482. /**
  105483. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105484. * @param kind defines the data kind (Position, normal, etc...)
  105485. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105486. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105487. * @returns a float array containing vertex data
  105488. */
  105489. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105490. /**
  105491. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  105492. * @param kind defines the data kind (Position, normal, etc...)
  105493. * @returns true if the vertex buffer with the specified kind is updatable
  105494. */
  105495. isVertexBufferUpdatable(kind: string): boolean;
  105496. /**
  105497. * Gets a specific vertex buffer
  105498. * @param kind defines the data kind (Position, normal, etc...)
  105499. * @returns a VertexBuffer
  105500. */
  105501. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105502. /**
  105503. * Returns all vertex buffers
  105504. * @return an object holding all vertex buffers indexed by kind
  105505. */
  105506. getVertexBuffers(): Nullable<{
  105507. [key: string]: VertexBuffer;
  105508. }>;
  105509. /**
  105510. * Gets a boolean indicating if specific vertex buffer is present
  105511. * @param kind defines the data kind (Position, normal, etc...)
  105512. * @returns true if data is present
  105513. */
  105514. isVerticesDataPresent(kind: string): boolean;
  105515. /**
  105516. * Gets a list of all attached data kinds (Position, normal, etc...)
  105517. * @returns a list of string containing all kinds
  105518. */
  105519. getVerticesDataKinds(): string[];
  105520. /**
  105521. * Update index buffer
  105522. * @param indices defines the indices to store in the index buffer
  105523. * @param offset defines the offset in the target buffer where to store the data
  105524. * @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)
  105525. */
  105526. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105527. /**
  105528. * Creates a new index buffer
  105529. * @param indices defines the indices to store in the index buffer
  105530. * @param totalVertices defines the total number of vertices (could be null)
  105531. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105532. */
  105533. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105534. /**
  105535. * Return the total number of indices
  105536. * @returns the total number of indices
  105537. */
  105538. getTotalIndices(): number;
  105539. /**
  105540. * Gets the index buffer array
  105541. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105542. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105543. * @returns the index buffer array
  105544. */
  105545. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105546. /**
  105547. * Gets the index buffer
  105548. * @return the index buffer
  105549. */
  105550. getIndexBuffer(): Nullable<DataBuffer>;
  105551. /** @hidden */
  105552. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105553. /**
  105554. * Release the associated resources for a specific mesh
  105555. * @param mesh defines the source mesh
  105556. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105557. */
  105558. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105559. /**
  105560. * Apply current geometry to a given mesh
  105561. * @param mesh defines the mesh to apply geometry to
  105562. */
  105563. applyToMesh(mesh: Mesh): void;
  105564. private _updateExtend;
  105565. private _applyToMesh;
  105566. private notifyUpdate;
  105567. /**
  105568. * Load the geometry if it was flagged as delay loaded
  105569. * @param scene defines the hosting scene
  105570. * @param onLoaded defines a callback called when the geometry is loaded
  105571. */
  105572. load(scene: Scene, onLoaded?: () => void): void;
  105573. private _queueLoad;
  105574. /**
  105575. * Invert the geometry to move from a right handed system to a left handed one.
  105576. */
  105577. toLeftHanded(): void;
  105578. /** @hidden */
  105579. _resetPointsArrayCache(): void;
  105580. /** @hidden */
  105581. _generatePointsArray(): boolean;
  105582. /**
  105583. * Gets a value indicating if the geometry is disposed
  105584. * @returns true if the geometry was disposed
  105585. */
  105586. isDisposed(): boolean;
  105587. private _disposeVertexArrayObjects;
  105588. /**
  105589. * Free all associated resources
  105590. */
  105591. dispose(): void;
  105592. /**
  105593. * Clone the current geometry into a new geometry
  105594. * @param id defines the unique ID of the new geometry
  105595. * @returns a new geometry object
  105596. */
  105597. copy(id: string): Geometry;
  105598. /**
  105599. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105600. * @return a JSON representation of the current geometry data (without the vertices data)
  105601. */
  105602. serialize(): any;
  105603. private toNumberArray;
  105604. /**
  105605. * Serialize all vertices data into a JSON oject
  105606. * @returns a JSON representation of the current geometry data
  105607. */
  105608. serializeVerticeData(): any;
  105609. /**
  105610. * Extracts a clone of a mesh geometry
  105611. * @param mesh defines the source mesh
  105612. * @param id defines the unique ID of the new geometry object
  105613. * @returns the new geometry object
  105614. */
  105615. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105616. /**
  105617. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105618. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105619. * Be aware Math.random() could cause collisions, but:
  105620. * "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"
  105621. * @returns a string containing a new GUID
  105622. */
  105623. static RandomId(): string;
  105624. /** @hidden */
  105625. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105626. private static _CleanMatricesWeights;
  105627. /**
  105628. * Create a new geometry from persisted data (Using .babylon file format)
  105629. * @param parsedVertexData defines the persisted data
  105630. * @param scene defines the hosting scene
  105631. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105632. * @returns the new geometry object
  105633. */
  105634. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105635. }
  105636. }
  105637. declare module BABYLON {
  105638. /**
  105639. * Define an interface for all classes that will get and set the data on vertices
  105640. */
  105641. export interface IGetSetVerticesData {
  105642. /**
  105643. * Gets a boolean indicating if specific vertex data is present
  105644. * @param kind defines the vertex data kind to use
  105645. * @returns true is data kind is present
  105646. */
  105647. isVerticesDataPresent(kind: string): boolean;
  105648. /**
  105649. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105650. * @param kind defines the data kind (Position, normal, etc...)
  105651. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105652. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105653. * @returns a float array containing vertex data
  105654. */
  105655. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105656. /**
  105657. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105658. * @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.
  105659. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105660. * @returns the indices array or an empty array if the mesh has no geometry
  105661. */
  105662. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105663. /**
  105664. * Set specific vertex data
  105665. * @param kind defines the data kind (Position, normal, etc...)
  105666. * @param data defines the vertex data to use
  105667. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105668. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105669. */
  105670. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105671. /**
  105672. * Update a specific associated vertex buffer
  105673. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105674. * - VertexBuffer.PositionKind
  105675. * - VertexBuffer.UVKind
  105676. * - VertexBuffer.UV2Kind
  105677. * - VertexBuffer.UV3Kind
  105678. * - VertexBuffer.UV4Kind
  105679. * - VertexBuffer.UV5Kind
  105680. * - VertexBuffer.UV6Kind
  105681. * - VertexBuffer.ColorKind
  105682. * - VertexBuffer.MatricesIndicesKind
  105683. * - VertexBuffer.MatricesIndicesExtraKind
  105684. * - VertexBuffer.MatricesWeightsKind
  105685. * - VertexBuffer.MatricesWeightsExtraKind
  105686. * @param data defines the data source
  105687. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105688. * @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)
  105689. */
  105690. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105691. /**
  105692. * Creates a new index buffer
  105693. * @param indices defines the indices to store in the index buffer
  105694. * @param totalVertices defines the total number of vertices (could be null)
  105695. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105696. */
  105697. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105698. }
  105699. /**
  105700. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105701. */
  105702. export class VertexData {
  105703. /**
  105704. * Mesh side orientation : usually the external or front surface
  105705. */
  105706. static readonly FRONTSIDE: number;
  105707. /**
  105708. * Mesh side orientation : usually the internal or back surface
  105709. */
  105710. static readonly BACKSIDE: number;
  105711. /**
  105712. * Mesh side orientation : both internal and external or front and back surfaces
  105713. */
  105714. static readonly DOUBLESIDE: number;
  105715. /**
  105716. * Mesh side orientation : by default, `FRONTSIDE`
  105717. */
  105718. static readonly DEFAULTSIDE: number;
  105719. /**
  105720. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105721. */
  105722. positions: Nullable<FloatArray>;
  105723. /**
  105724. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105725. */
  105726. normals: Nullable<FloatArray>;
  105727. /**
  105728. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105729. */
  105730. tangents: Nullable<FloatArray>;
  105731. /**
  105732. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105733. */
  105734. uvs: Nullable<FloatArray>;
  105735. /**
  105736. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105737. */
  105738. uvs2: Nullable<FloatArray>;
  105739. /**
  105740. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105741. */
  105742. uvs3: Nullable<FloatArray>;
  105743. /**
  105744. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105745. */
  105746. uvs4: Nullable<FloatArray>;
  105747. /**
  105748. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105749. */
  105750. uvs5: Nullable<FloatArray>;
  105751. /**
  105752. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105753. */
  105754. uvs6: Nullable<FloatArray>;
  105755. /**
  105756. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  105757. */
  105758. colors: Nullable<FloatArray>;
  105759. /**
  105760. * 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).
  105761. */
  105762. matricesIndices: Nullable<FloatArray>;
  105763. /**
  105764. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  105765. */
  105766. matricesWeights: Nullable<FloatArray>;
  105767. /**
  105768. * An array extending the number of possible indices
  105769. */
  105770. matricesIndicesExtra: Nullable<FloatArray>;
  105771. /**
  105772. * An array extending the number of possible weights when the number of indices is extended
  105773. */
  105774. matricesWeightsExtra: Nullable<FloatArray>;
  105775. /**
  105776. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  105777. */
  105778. indices: Nullable<IndicesArray>;
  105779. /**
  105780. * Uses the passed data array to set the set the values for the specified kind of data
  105781. * @param data a linear array of floating numbers
  105782. * @param kind the type of data that is being set, eg positions, colors etc
  105783. */
  105784. set(data: FloatArray, kind: string): void;
  105785. /**
  105786. * Associates the vertexData to the passed Mesh.
  105787. * Sets it as updatable or not (default `false`)
  105788. * @param mesh the mesh the vertexData is applied to
  105789. * @param updatable when used and having the value true allows new data to update the vertexData
  105790. * @returns the VertexData
  105791. */
  105792. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  105793. /**
  105794. * Associates the vertexData to the passed Geometry.
  105795. * Sets it as updatable or not (default `false`)
  105796. * @param geometry the geometry the vertexData is applied to
  105797. * @param updatable when used and having the value true allows new data to update the vertexData
  105798. * @returns VertexData
  105799. */
  105800. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  105801. /**
  105802. * Updates the associated mesh
  105803. * @param mesh the mesh to be updated
  105804. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105805. * @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
  105806. * @returns VertexData
  105807. */
  105808. updateMesh(mesh: Mesh): VertexData;
  105809. /**
  105810. * Updates the associated geometry
  105811. * @param geometry the geometry to be updated
  105812. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105813. * @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
  105814. * @returns VertexData.
  105815. */
  105816. updateGeometry(geometry: Geometry): VertexData;
  105817. private _applyTo;
  105818. private _update;
  105819. /**
  105820. * Transforms each position and each normal of the vertexData according to the passed Matrix
  105821. * @param matrix the transforming matrix
  105822. * @returns the VertexData
  105823. */
  105824. transform(matrix: Matrix): VertexData;
  105825. /**
  105826. * Merges the passed VertexData into the current one
  105827. * @param other the VertexData to be merged into the current one
  105828. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  105829. * @returns the modified VertexData
  105830. */
  105831. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  105832. private _mergeElement;
  105833. private _validate;
  105834. /**
  105835. * Serializes the VertexData
  105836. * @returns a serialized object
  105837. */
  105838. serialize(): any;
  105839. /**
  105840. * Extracts the vertexData from a mesh
  105841. * @param mesh the mesh from which to extract the VertexData
  105842. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  105843. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105844. * @returns the object VertexData associated to the passed mesh
  105845. */
  105846. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105847. /**
  105848. * Extracts the vertexData from the geometry
  105849. * @param geometry the geometry from which to extract the VertexData
  105850. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  105851. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105852. * @returns the object VertexData associated to the passed mesh
  105853. */
  105854. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105855. private static _ExtractFrom;
  105856. /**
  105857. * Creates the VertexData for a Ribbon
  105858. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  105859. * * pathArray array of paths, each of which an array of successive Vector3
  105860. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  105861. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  105862. * * 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
  105863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105864. * * 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)
  105865. * * 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)
  105866. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  105867. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  105868. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  105869. * @returns the VertexData of the ribbon
  105870. */
  105871. static CreateRibbon(options: {
  105872. pathArray: Vector3[][];
  105873. closeArray?: boolean;
  105874. closePath?: boolean;
  105875. offset?: number;
  105876. sideOrientation?: number;
  105877. frontUVs?: Vector4;
  105878. backUVs?: Vector4;
  105879. invertUV?: boolean;
  105880. uvs?: Vector2[];
  105881. colors?: Color4[];
  105882. }): VertexData;
  105883. /**
  105884. * Creates the VertexData for a box
  105885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105886. * * size sets the width, height and depth of the box to the value of size, optional default 1
  105887. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  105888. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  105889. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  105890. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105891. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105892. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105893. * * 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)
  105894. * * 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)
  105895. * @returns the VertexData of the box
  105896. */
  105897. static CreateBox(options: {
  105898. size?: number;
  105899. width?: number;
  105900. height?: number;
  105901. depth?: number;
  105902. faceUV?: Vector4[];
  105903. faceColors?: Color4[];
  105904. sideOrientation?: number;
  105905. frontUVs?: Vector4;
  105906. backUVs?: Vector4;
  105907. }): VertexData;
  105908. /**
  105909. * Creates the VertexData for a tiled box
  105910. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105911. * * faceTiles sets the pattern, tile size and number of tiles for a face
  105912. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105913. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105915. * @returns the VertexData of the box
  105916. */
  105917. static CreateTiledBox(options: {
  105918. pattern?: number;
  105919. width?: number;
  105920. height?: number;
  105921. depth?: number;
  105922. tileSize?: number;
  105923. tileWidth?: number;
  105924. tileHeight?: number;
  105925. alignHorizontal?: number;
  105926. alignVertical?: number;
  105927. faceUV?: Vector4[];
  105928. faceColors?: Color4[];
  105929. sideOrientation?: number;
  105930. }): VertexData;
  105931. /**
  105932. * Creates the VertexData for a tiled plane
  105933. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105934. * * pattern a limited pattern arrangement depending on the number
  105935. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  105936. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  105937. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  105938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105939. * * 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)
  105940. * * 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)
  105941. * @returns the VertexData of the tiled plane
  105942. */
  105943. static CreateTiledPlane(options: {
  105944. pattern?: number;
  105945. tileSize?: number;
  105946. tileWidth?: number;
  105947. tileHeight?: number;
  105948. size?: number;
  105949. width?: number;
  105950. height?: number;
  105951. alignHorizontal?: number;
  105952. alignVertical?: number;
  105953. sideOrientation?: number;
  105954. frontUVs?: Vector4;
  105955. backUVs?: Vector4;
  105956. }): VertexData;
  105957. /**
  105958. * Creates the VertexData for an ellipsoid, defaults to a sphere
  105959. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105960. * * segments sets the number of horizontal strips optional, default 32
  105961. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  105962. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  105963. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  105964. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  105965. * * 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
  105966. * * 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
  105967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105968. * * 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)
  105969. * * 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)
  105970. * @returns the VertexData of the ellipsoid
  105971. */
  105972. static CreateSphere(options: {
  105973. segments?: number;
  105974. diameter?: number;
  105975. diameterX?: number;
  105976. diameterY?: number;
  105977. diameterZ?: number;
  105978. arc?: number;
  105979. slice?: number;
  105980. sideOrientation?: number;
  105981. frontUVs?: Vector4;
  105982. backUVs?: Vector4;
  105983. }): VertexData;
  105984. /**
  105985. * Creates the VertexData for a cylinder, cone or prism
  105986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105987. * * height sets the height (y direction) of the cylinder, optional, default 2
  105988. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  105989. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  105990. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  105991. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105992. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  105993. * * 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
  105994. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105995. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105996. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  105997. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  105998. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105999. * * 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)
  106000. * * 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)
  106001. * @returns the VertexData of the cylinder, cone or prism
  106002. */
  106003. static CreateCylinder(options: {
  106004. height?: number;
  106005. diameterTop?: number;
  106006. diameterBottom?: number;
  106007. diameter?: number;
  106008. tessellation?: number;
  106009. subdivisions?: number;
  106010. arc?: number;
  106011. faceColors?: Color4[];
  106012. faceUV?: Vector4[];
  106013. hasRings?: boolean;
  106014. enclose?: boolean;
  106015. sideOrientation?: number;
  106016. frontUVs?: Vector4;
  106017. backUVs?: Vector4;
  106018. }): VertexData;
  106019. /**
  106020. * Creates the VertexData for a torus
  106021. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106022. * * diameter the diameter of the torus, optional default 1
  106023. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106024. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106025. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106026. * * 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)
  106027. * * 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)
  106028. * @returns the VertexData of the torus
  106029. */
  106030. static CreateTorus(options: {
  106031. diameter?: number;
  106032. thickness?: number;
  106033. tessellation?: number;
  106034. sideOrientation?: number;
  106035. frontUVs?: Vector4;
  106036. backUVs?: Vector4;
  106037. }): VertexData;
  106038. /**
  106039. * Creates the VertexData of the LineSystem
  106040. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106041. * - lines an array of lines, each line being an array of successive Vector3
  106042. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106043. * @returns the VertexData of the LineSystem
  106044. */
  106045. static CreateLineSystem(options: {
  106046. lines: Vector3[][];
  106047. colors?: Nullable<Color4[][]>;
  106048. }): VertexData;
  106049. /**
  106050. * Create the VertexData for a DashedLines
  106051. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106052. * - points an array successive Vector3
  106053. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106054. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106055. * - dashNb the intended total number of dashes, optional, default 200
  106056. * @returns the VertexData for the DashedLines
  106057. */
  106058. static CreateDashedLines(options: {
  106059. points: Vector3[];
  106060. dashSize?: number;
  106061. gapSize?: number;
  106062. dashNb?: number;
  106063. }): VertexData;
  106064. /**
  106065. * Creates the VertexData for a Ground
  106066. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106067. * - width the width (x direction) of the ground, optional, default 1
  106068. * - height the height (z direction) of the ground, optional, default 1
  106069. * - subdivisions the number of subdivisions per side, optional, default 1
  106070. * @returns the VertexData of the Ground
  106071. */
  106072. static CreateGround(options: {
  106073. width?: number;
  106074. height?: number;
  106075. subdivisions?: number;
  106076. subdivisionsX?: number;
  106077. subdivisionsY?: number;
  106078. }): VertexData;
  106079. /**
  106080. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106081. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106082. * * xmin the ground minimum X coordinate, optional, default -1
  106083. * * zmin the ground minimum Z coordinate, optional, default -1
  106084. * * xmax the ground maximum X coordinate, optional, default 1
  106085. * * zmax the ground maximum Z coordinate, optional, default 1
  106086. * * 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}
  106087. * * 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}
  106088. * @returns the VertexData of the TiledGround
  106089. */
  106090. static CreateTiledGround(options: {
  106091. xmin: number;
  106092. zmin: number;
  106093. xmax: number;
  106094. zmax: number;
  106095. subdivisions?: {
  106096. w: number;
  106097. h: number;
  106098. };
  106099. precision?: {
  106100. w: number;
  106101. h: number;
  106102. };
  106103. }): VertexData;
  106104. /**
  106105. * Creates the VertexData of the Ground designed from a heightmap
  106106. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106107. * * width the width (x direction) of the ground
  106108. * * height the height (z direction) of the ground
  106109. * * subdivisions the number of subdivisions per side
  106110. * * minHeight the minimum altitude on the ground, optional, default 0
  106111. * * maxHeight the maximum altitude on the ground, optional default 1
  106112. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106113. * * buffer the array holding the image color data
  106114. * * bufferWidth the width of image
  106115. * * bufferHeight the height of image
  106116. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106117. * @returns the VertexData of the Ground designed from a heightmap
  106118. */
  106119. static CreateGroundFromHeightMap(options: {
  106120. width: number;
  106121. height: number;
  106122. subdivisions: number;
  106123. minHeight: number;
  106124. maxHeight: number;
  106125. colorFilter: Color3;
  106126. buffer: Uint8Array;
  106127. bufferWidth: number;
  106128. bufferHeight: number;
  106129. alphaFilter: number;
  106130. }): VertexData;
  106131. /**
  106132. * Creates the VertexData for a Plane
  106133. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106134. * * size sets the width and height of the plane to the value of size, optional default 1
  106135. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106136. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106138. * * 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)
  106139. * * 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)
  106140. * @returns the VertexData of the box
  106141. */
  106142. static CreatePlane(options: {
  106143. size?: number;
  106144. width?: number;
  106145. height?: number;
  106146. sideOrientation?: number;
  106147. frontUVs?: Vector4;
  106148. backUVs?: Vector4;
  106149. }): VertexData;
  106150. /**
  106151. * Creates the VertexData of the Disc or regular Polygon
  106152. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106153. * * radius the radius of the disc, optional default 0.5
  106154. * * tessellation the number of polygon sides, optional, default 64
  106155. * * 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
  106156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106157. * * 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)
  106158. * * 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)
  106159. * @returns the VertexData of the box
  106160. */
  106161. static CreateDisc(options: {
  106162. radius?: number;
  106163. tessellation?: number;
  106164. arc?: number;
  106165. sideOrientation?: number;
  106166. frontUVs?: Vector4;
  106167. backUVs?: Vector4;
  106168. }): VertexData;
  106169. /**
  106170. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106171. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106172. * @param polygon a mesh built from polygonTriangulation.build()
  106173. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106174. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106175. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106176. * @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)
  106177. * @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)
  106178. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106179. * @returns the VertexData of the Polygon
  106180. */
  106181. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106182. /**
  106183. * Creates the VertexData of the IcoSphere
  106184. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106185. * * radius the radius of the IcoSphere, optional default 1
  106186. * * radiusX allows stretching in the x direction, optional, default radius
  106187. * * radiusY allows stretching in the y direction, optional, default radius
  106188. * * radiusZ allows stretching in the z direction, optional, default radius
  106189. * * flat when true creates a flat shaded mesh, optional, default true
  106190. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106191. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106192. * * 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)
  106193. * * 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)
  106194. * @returns the VertexData of the IcoSphere
  106195. */
  106196. static CreateIcoSphere(options: {
  106197. radius?: number;
  106198. radiusX?: number;
  106199. radiusY?: number;
  106200. radiusZ?: number;
  106201. flat?: boolean;
  106202. subdivisions?: number;
  106203. sideOrientation?: number;
  106204. frontUVs?: Vector4;
  106205. backUVs?: Vector4;
  106206. }): VertexData;
  106207. /**
  106208. * Creates the VertexData for a Polyhedron
  106209. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106210. * * type provided types are:
  106211. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106212. * * 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)
  106213. * * size the size of the IcoSphere, optional default 1
  106214. * * sizeX allows stretching in the x direction, optional, default size
  106215. * * sizeY allows stretching in the y direction, optional, default size
  106216. * * sizeZ allows stretching in the z direction, optional, default size
  106217. * * 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
  106218. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106219. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106220. * * flat when true creates a flat shaded mesh, optional, default true
  106221. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106223. * * 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)
  106224. * * 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)
  106225. * @returns the VertexData of the Polyhedron
  106226. */
  106227. static CreatePolyhedron(options: {
  106228. type?: number;
  106229. size?: number;
  106230. sizeX?: number;
  106231. sizeY?: number;
  106232. sizeZ?: number;
  106233. custom?: any;
  106234. faceUV?: Vector4[];
  106235. faceColors?: Color4[];
  106236. flat?: boolean;
  106237. sideOrientation?: number;
  106238. frontUVs?: Vector4;
  106239. backUVs?: Vector4;
  106240. }): VertexData;
  106241. /**
  106242. * Creates the VertexData for a TorusKnot
  106243. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106244. * * radius the radius of the torus knot, optional, default 2
  106245. * * tube the thickness of the tube, optional, default 0.5
  106246. * * radialSegments the number of sides on each tube segments, optional, default 32
  106247. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106248. * * p the number of windings around the z axis, optional, default 2
  106249. * * q the number of windings around the x axis, optional, default 3
  106250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106251. * * 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)
  106252. * * 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)
  106253. * @returns the VertexData of the Torus Knot
  106254. */
  106255. static CreateTorusKnot(options: {
  106256. radius?: number;
  106257. tube?: number;
  106258. radialSegments?: number;
  106259. tubularSegments?: number;
  106260. p?: number;
  106261. q?: number;
  106262. sideOrientation?: number;
  106263. frontUVs?: Vector4;
  106264. backUVs?: Vector4;
  106265. }): VertexData;
  106266. /**
  106267. * Compute normals for given positions and indices
  106268. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106269. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106270. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106271. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106272. * * facetNormals : optional array of facet normals (vector3)
  106273. * * facetPositions : optional array of facet positions (vector3)
  106274. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106275. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106276. * * bInfo : optional bounding info, required for facetPartitioning computation
  106277. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106278. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106279. * * useRightHandedSystem: optional boolean to for right handed system computation
  106280. * * depthSort : optional boolean to enable the facet depth sort computation
  106281. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106282. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106283. */
  106284. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106285. facetNormals?: any;
  106286. facetPositions?: any;
  106287. facetPartitioning?: any;
  106288. ratio?: number;
  106289. bInfo?: any;
  106290. bbSize?: Vector3;
  106291. subDiv?: any;
  106292. useRightHandedSystem?: boolean;
  106293. depthSort?: boolean;
  106294. distanceTo?: Vector3;
  106295. depthSortedFacets?: any;
  106296. }): void;
  106297. /** @hidden */
  106298. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106299. /**
  106300. * Applies VertexData created from the imported parameters to the geometry
  106301. * @param parsedVertexData the parsed data from an imported file
  106302. * @param geometry the geometry to apply the VertexData to
  106303. */
  106304. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106305. }
  106306. }
  106307. declare module BABYLON {
  106308. /**
  106309. * Defines a target to use with MorphTargetManager
  106310. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106311. */
  106312. export class MorphTarget implements IAnimatable {
  106313. /** defines the name of the target */
  106314. name: string;
  106315. /**
  106316. * Gets or sets the list of animations
  106317. */
  106318. animations: Animation[];
  106319. private _scene;
  106320. private _positions;
  106321. private _normals;
  106322. private _tangents;
  106323. private _uvs;
  106324. private _influence;
  106325. private _uniqueId;
  106326. /**
  106327. * Observable raised when the influence changes
  106328. */
  106329. onInfluenceChanged: Observable<boolean>;
  106330. /** @hidden */
  106331. _onDataLayoutChanged: Observable<void>;
  106332. /**
  106333. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106334. */
  106335. get influence(): number;
  106336. set influence(influence: number);
  106337. /**
  106338. * Gets or sets the id of the morph Target
  106339. */
  106340. id: string;
  106341. private _animationPropertiesOverride;
  106342. /**
  106343. * Gets or sets the animation properties override
  106344. */
  106345. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106346. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106347. /**
  106348. * Creates a new MorphTarget
  106349. * @param name defines the name of the target
  106350. * @param influence defines the influence to use
  106351. * @param scene defines the scene the morphtarget belongs to
  106352. */
  106353. constructor(
  106354. /** defines the name of the target */
  106355. name: string, influence?: number, scene?: Nullable<Scene>);
  106356. /**
  106357. * Gets the unique ID of this manager
  106358. */
  106359. get uniqueId(): number;
  106360. /**
  106361. * Gets a boolean defining if the target contains position data
  106362. */
  106363. get hasPositions(): boolean;
  106364. /**
  106365. * Gets a boolean defining if the target contains normal data
  106366. */
  106367. get hasNormals(): boolean;
  106368. /**
  106369. * Gets a boolean defining if the target contains tangent data
  106370. */
  106371. get hasTangents(): boolean;
  106372. /**
  106373. * Gets a boolean defining if the target contains texture coordinates data
  106374. */
  106375. get hasUVs(): boolean;
  106376. /**
  106377. * Affects position data to this target
  106378. * @param data defines the position data to use
  106379. */
  106380. setPositions(data: Nullable<FloatArray>): void;
  106381. /**
  106382. * Gets the position data stored in this target
  106383. * @returns a FloatArray containing the position data (or null if not present)
  106384. */
  106385. getPositions(): Nullable<FloatArray>;
  106386. /**
  106387. * Affects normal data to this target
  106388. * @param data defines the normal data to use
  106389. */
  106390. setNormals(data: Nullable<FloatArray>): void;
  106391. /**
  106392. * Gets the normal data stored in this target
  106393. * @returns a FloatArray containing the normal data (or null if not present)
  106394. */
  106395. getNormals(): Nullable<FloatArray>;
  106396. /**
  106397. * Affects tangent data to this target
  106398. * @param data defines the tangent data to use
  106399. */
  106400. setTangents(data: Nullable<FloatArray>): void;
  106401. /**
  106402. * Gets the tangent data stored in this target
  106403. * @returns a FloatArray containing the tangent data (or null if not present)
  106404. */
  106405. getTangents(): Nullable<FloatArray>;
  106406. /**
  106407. * Affects texture coordinates data to this target
  106408. * @param data defines the texture coordinates data to use
  106409. */
  106410. setUVs(data: Nullable<FloatArray>): void;
  106411. /**
  106412. * Gets the texture coordinates data stored in this target
  106413. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106414. */
  106415. getUVs(): Nullable<FloatArray>;
  106416. /**
  106417. * Clone the current target
  106418. * @returns a new MorphTarget
  106419. */
  106420. clone(): MorphTarget;
  106421. /**
  106422. * Serializes the current target into a Serialization object
  106423. * @returns the serialized object
  106424. */
  106425. serialize(): any;
  106426. /**
  106427. * Returns the string "MorphTarget"
  106428. * @returns "MorphTarget"
  106429. */
  106430. getClassName(): string;
  106431. /**
  106432. * Creates a new target from serialized data
  106433. * @param serializationObject defines the serialized data to use
  106434. * @returns a new MorphTarget
  106435. */
  106436. static Parse(serializationObject: any): MorphTarget;
  106437. /**
  106438. * Creates a MorphTarget from mesh data
  106439. * @param mesh defines the source mesh
  106440. * @param name defines the name to use for the new target
  106441. * @param influence defines the influence to attach to the target
  106442. * @returns a new MorphTarget
  106443. */
  106444. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106445. }
  106446. }
  106447. declare module BABYLON {
  106448. /**
  106449. * This class is used to deform meshes using morphing between different targets
  106450. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106451. */
  106452. export class MorphTargetManager {
  106453. private _targets;
  106454. private _targetInfluenceChangedObservers;
  106455. private _targetDataLayoutChangedObservers;
  106456. private _activeTargets;
  106457. private _scene;
  106458. private _influences;
  106459. private _supportsNormals;
  106460. private _supportsTangents;
  106461. private _supportsUVs;
  106462. private _vertexCount;
  106463. private _uniqueId;
  106464. private _tempInfluences;
  106465. /**
  106466. * Gets or sets a boolean indicating if normals must be morphed
  106467. */
  106468. enableNormalMorphing: boolean;
  106469. /**
  106470. * Gets or sets a boolean indicating if tangents must be morphed
  106471. */
  106472. enableTangentMorphing: boolean;
  106473. /**
  106474. * Gets or sets a boolean indicating if UV must be morphed
  106475. */
  106476. enableUVMorphing: boolean;
  106477. /**
  106478. * Creates a new MorphTargetManager
  106479. * @param scene defines the current scene
  106480. */
  106481. constructor(scene?: Nullable<Scene>);
  106482. /**
  106483. * Gets the unique ID of this manager
  106484. */
  106485. get uniqueId(): number;
  106486. /**
  106487. * Gets the number of vertices handled by this manager
  106488. */
  106489. get vertexCount(): number;
  106490. /**
  106491. * Gets a boolean indicating if this manager supports morphing of normals
  106492. */
  106493. get supportsNormals(): boolean;
  106494. /**
  106495. * Gets a boolean indicating if this manager supports morphing of tangents
  106496. */
  106497. get supportsTangents(): boolean;
  106498. /**
  106499. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  106500. */
  106501. get supportsUVs(): boolean;
  106502. /**
  106503. * Gets the number of targets stored in this manager
  106504. */
  106505. get numTargets(): number;
  106506. /**
  106507. * Gets the number of influencers (ie. the number of targets with influences > 0)
  106508. */
  106509. get numInfluencers(): number;
  106510. /**
  106511. * Gets the list of influences (one per target)
  106512. */
  106513. get influences(): Float32Array;
  106514. /**
  106515. * Gets the active target at specified index. An active target is a target with an influence > 0
  106516. * @param index defines the index to check
  106517. * @returns the requested target
  106518. */
  106519. getActiveTarget(index: number): MorphTarget;
  106520. /**
  106521. * Gets the target at specified index
  106522. * @param index defines the index to check
  106523. * @returns the requested target
  106524. */
  106525. getTarget(index: number): MorphTarget;
  106526. /**
  106527. * Add a new target to this manager
  106528. * @param target defines the target to add
  106529. */
  106530. addTarget(target: MorphTarget): void;
  106531. /**
  106532. * Removes a target from the manager
  106533. * @param target defines the target to remove
  106534. */
  106535. removeTarget(target: MorphTarget): void;
  106536. /**
  106537. * Clone the current manager
  106538. * @returns a new MorphTargetManager
  106539. */
  106540. clone(): MorphTargetManager;
  106541. /**
  106542. * Serializes the current manager into a Serialization object
  106543. * @returns the serialized object
  106544. */
  106545. serialize(): any;
  106546. private _syncActiveTargets;
  106547. /**
  106548. * Syncrhonize the targets with all the meshes using this morph target manager
  106549. */
  106550. synchronize(): void;
  106551. /**
  106552. * Creates a new MorphTargetManager from serialized data
  106553. * @param serializationObject defines the serialized data
  106554. * @param scene defines the hosting scene
  106555. * @returns the new MorphTargetManager
  106556. */
  106557. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106558. }
  106559. }
  106560. declare module BABYLON {
  106561. /**
  106562. * Class used to represent a specific level of detail of a mesh
  106563. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106564. */
  106565. export class MeshLODLevel {
  106566. /** Defines the distance where this level should start being displayed */
  106567. distance: number;
  106568. /** Defines the mesh to use to render this level */
  106569. mesh: Nullable<Mesh>;
  106570. /**
  106571. * Creates a new LOD level
  106572. * @param distance defines the distance where this level should star being displayed
  106573. * @param mesh defines the mesh to use to render this level
  106574. */
  106575. constructor(
  106576. /** Defines the distance where this level should start being displayed */
  106577. distance: number,
  106578. /** Defines the mesh to use to render this level */
  106579. mesh: Nullable<Mesh>);
  106580. }
  106581. }
  106582. declare module BABYLON {
  106583. /**
  106584. * Helper class used to generate a canvas to manipulate images
  106585. */
  106586. export class CanvasGenerator {
  106587. /**
  106588. * Create a new canvas (or offscreen canvas depending on the context)
  106589. * @param width defines the expected width
  106590. * @param height defines the expected height
  106591. * @return a new canvas or offscreen canvas
  106592. */
  106593. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106594. }
  106595. }
  106596. declare module BABYLON {
  106597. /**
  106598. * Mesh representing the gorund
  106599. */
  106600. export class GroundMesh extends Mesh {
  106601. /** If octree should be generated */
  106602. generateOctree: boolean;
  106603. private _heightQuads;
  106604. /** @hidden */
  106605. _subdivisionsX: number;
  106606. /** @hidden */
  106607. _subdivisionsY: number;
  106608. /** @hidden */
  106609. _width: number;
  106610. /** @hidden */
  106611. _height: number;
  106612. /** @hidden */
  106613. _minX: number;
  106614. /** @hidden */
  106615. _maxX: number;
  106616. /** @hidden */
  106617. _minZ: number;
  106618. /** @hidden */
  106619. _maxZ: number;
  106620. constructor(name: string, scene: Scene);
  106621. /**
  106622. * "GroundMesh"
  106623. * @returns "GroundMesh"
  106624. */
  106625. getClassName(): string;
  106626. /**
  106627. * The minimum of x and y subdivisions
  106628. */
  106629. get subdivisions(): number;
  106630. /**
  106631. * X subdivisions
  106632. */
  106633. get subdivisionsX(): number;
  106634. /**
  106635. * Y subdivisions
  106636. */
  106637. get subdivisionsY(): number;
  106638. /**
  106639. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106640. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106641. * @param chunksCount the number of subdivisions for x and y
  106642. * @param octreeBlocksSize (Default: 32)
  106643. */
  106644. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106645. /**
  106646. * Returns a height (y) value in the Worl system :
  106647. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106648. * @param x x coordinate
  106649. * @param z z coordinate
  106650. * @returns the ground y position if (x, z) are outside the ground surface.
  106651. */
  106652. getHeightAtCoordinates(x: number, z: number): number;
  106653. /**
  106654. * Returns a normalized vector (Vector3) orthogonal to the ground
  106655. * at the ground coordinates (x, z) expressed in the World system.
  106656. * @param x x coordinate
  106657. * @param z z coordinate
  106658. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106659. */
  106660. getNormalAtCoordinates(x: number, z: number): Vector3;
  106661. /**
  106662. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106663. * at the ground coordinates (x, z) expressed in the World system.
  106664. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106665. * @param x x coordinate
  106666. * @param z z coordinate
  106667. * @param ref vector to store the result
  106668. * @returns the GroundMesh.
  106669. */
  106670. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106671. /**
  106672. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106673. * if the ground has been updated.
  106674. * This can be used in the render loop.
  106675. * @returns the GroundMesh.
  106676. */
  106677. updateCoordinateHeights(): GroundMesh;
  106678. private _getFacetAt;
  106679. private _initHeightQuads;
  106680. private _computeHeightQuads;
  106681. /**
  106682. * Serializes this ground mesh
  106683. * @param serializationObject object to write serialization to
  106684. */
  106685. serialize(serializationObject: any): void;
  106686. /**
  106687. * Parses a serialized ground mesh
  106688. * @param parsedMesh the serialized mesh
  106689. * @param scene the scene to create the ground mesh in
  106690. * @returns the created ground mesh
  106691. */
  106692. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106693. }
  106694. }
  106695. declare module BABYLON {
  106696. /**
  106697. * Interface for Physics-Joint data
  106698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106699. */
  106700. export interface PhysicsJointData {
  106701. /**
  106702. * The main pivot of the joint
  106703. */
  106704. mainPivot?: Vector3;
  106705. /**
  106706. * The connected pivot of the joint
  106707. */
  106708. connectedPivot?: Vector3;
  106709. /**
  106710. * The main axis of the joint
  106711. */
  106712. mainAxis?: Vector3;
  106713. /**
  106714. * The connected axis of the joint
  106715. */
  106716. connectedAxis?: Vector3;
  106717. /**
  106718. * The collision of the joint
  106719. */
  106720. collision?: boolean;
  106721. /**
  106722. * Native Oimo/Cannon/Energy data
  106723. */
  106724. nativeParams?: any;
  106725. }
  106726. /**
  106727. * This is a holder class for the physics joint created by the physics plugin
  106728. * It holds a set of functions to control the underlying joint
  106729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106730. */
  106731. export class PhysicsJoint {
  106732. /**
  106733. * The type of the physics joint
  106734. */
  106735. type: number;
  106736. /**
  106737. * The data for the physics joint
  106738. */
  106739. jointData: PhysicsJointData;
  106740. private _physicsJoint;
  106741. protected _physicsPlugin: IPhysicsEnginePlugin;
  106742. /**
  106743. * Initializes the physics joint
  106744. * @param type The type of the physics joint
  106745. * @param jointData The data for the physics joint
  106746. */
  106747. constructor(
  106748. /**
  106749. * The type of the physics joint
  106750. */
  106751. type: number,
  106752. /**
  106753. * The data for the physics joint
  106754. */
  106755. jointData: PhysicsJointData);
  106756. /**
  106757. * Gets the physics joint
  106758. */
  106759. get physicsJoint(): any;
  106760. /**
  106761. * Sets the physics joint
  106762. */
  106763. set physicsJoint(newJoint: any);
  106764. /**
  106765. * Sets the physics plugin
  106766. */
  106767. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  106768. /**
  106769. * Execute a function that is physics-plugin specific.
  106770. * @param {Function} func the function that will be executed.
  106771. * It accepts two parameters: the physics world and the physics joint
  106772. */
  106773. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  106774. /**
  106775. * Distance-Joint type
  106776. */
  106777. static DistanceJoint: number;
  106778. /**
  106779. * Hinge-Joint type
  106780. */
  106781. static HingeJoint: number;
  106782. /**
  106783. * Ball-and-Socket joint type
  106784. */
  106785. static BallAndSocketJoint: number;
  106786. /**
  106787. * Wheel-Joint type
  106788. */
  106789. static WheelJoint: number;
  106790. /**
  106791. * Slider-Joint type
  106792. */
  106793. static SliderJoint: number;
  106794. /**
  106795. * Prismatic-Joint type
  106796. */
  106797. static PrismaticJoint: number;
  106798. /**
  106799. * Universal-Joint type
  106800. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  106801. */
  106802. static UniversalJoint: number;
  106803. /**
  106804. * Hinge-Joint 2 type
  106805. */
  106806. static Hinge2Joint: number;
  106807. /**
  106808. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  106809. */
  106810. static PointToPointJoint: number;
  106811. /**
  106812. * Spring-Joint type
  106813. */
  106814. static SpringJoint: number;
  106815. /**
  106816. * Lock-Joint type
  106817. */
  106818. static LockJoint: number;
  106819. }
  106820. /**
  106821. * A class representing a physics distance joint
  106822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106823. */
  106824. export class DistanceJoint extends PhysicsJoint {
  106825. /**
  106826. *
  106827. * @param jointData The data for the Distance-Joint
  106828. */
  106829. constructor(jointData: DistanceJointData);
  106830. /**
  106831. * Update the predefined distance.
  106832. * @param maxDistance The maximum preferred distance
  106833. * @param minDistance The minimum preferred distance
  106834. */
  106835. updateDistance(maxDistance: number, minDistance?: number): void;
  106836. }
  106837. /**
  106838. * Represents a Motor-Enabled Joint
  106839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106840. */
  106841. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  106842. /**
  106843. * Initializes the Motor-Enabled Joint
  106844. * @param type The type of the joint
  106845. * @param jointData The physica joint data for the joint
  106846. */
  106847. constructor(type: number, jointData: PhysicsJointData);
  106848. /**
  106849. * Set the motor values.
  106850. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106851. * @param force the force to apply
  106852. * @param maxForce max force for this motor.
  106853. */
  106854. setMotor(force?: number, maxForce?: number): void;
  106855. /**
  106856. * Set the motor's limits.
  106857. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106858. * @param upperLimit The upper limit of the motor
  106859. * @param lowerLimit The lower limit of the motor
  106860. */
  106861. setLimit(upperLimit: number, lowerLimit?: number): void;
  106862. }
  106863. /**
  106864. * This class represents a single physics Hinge-Joint
  106865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106866. */
  106867. export class HingeJoint extends MotorEnabledJoint {
  106868. /**
  106869. * Initializes the Hinge-Joint
  106870. * @param jointData The joint data for the Hinge-Joint
  106871. */
  106872. constructor(jointData: PhysicsJointData);
  106873. /**
  106874. * Set the motor values.
  106875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106876. * @param {number} force the force to apply
  106877. * @param {number} maxForce max force for this motor.
  106878. */
  106879. setMotor(force?: number, maxForce?: number): void;
  106880. /**
  106881. * Set the motor's limits.
  106882. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106883. * @param upperLimit The upper limit of the motor
  106884. * @param lowerLimit The lower limit of the motor
  106885. */
  106886. setLimit(upperLimit: number, lowerLimit?: number): void;
  106887. }
  106888. /**
  106889. * This class represents a dual hinge physics joint (same as wheel joint)
  106890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106891. */
  106892. export class Hinge2Joint extends MotorEnabledJoint {
  106893. /**
  106894. * Initializes the Hinge2-Joint
  106895. * @param jointData The joint data for the Hinge2-Joint
  106896. */
  106897. constructor(jointData: PhysicsJointData);
  106898. /**
  106899. * Set the motor values.
  106900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106901. * @param {number} targetSpeed the speed the motor is to reach
  106902. * @param {number} maxForce max force for this motor.
  106903. * @param {motorIndex} the motor's index, 0 or 1.
  106904. */
  106905. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  106906. /**
  106907. * Set the motor limits.
  106908. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106909. * @param {number} upperLimit the upper limit
  106910. * @param {number} lowerLimit lower limit
  106911. * @param {motorIndex} the motor's index, 0 or 1.
  106912. */
  106913. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106914. }
  106915. /**
  106916. * Interface for a motor enabled joint
  106917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106918. */
  106919. export interface IMotorEnabledJoint {
  106920. /**
  106921. * Physics joint
  106922. */
  106923. physicsJoint: any;
  106924. /**
  106925. * Sets the motor of the motor-enabled joint
  106926. * @param force The force of the motor
  106927. * @param maxForce The maximum force of the motor
  106928. * @param motorIndex The index of the motor
  106929. */
  106930. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  106931. /**
  106932. * Sets the limit of the motor
  106933. * @param upperLimit The upper limit of the motor
  106934. * @param lowerLimit The lower limit of the motor
  106935. * @param motorIndex The index of the motor
  106936. */
  106937. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106938. }
  106939. /**
  106940. * Joint data for a Distance-Joint
  106941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106942. */
  106943. export interface DistanceJointData extends PhysicsJointData {
  106944. /**
  106945. * Max distance the 2 joint objects can be apart
  106946. */
  106947. maxDistance: number;
  106948. }
  106949. /**
  106950. * Joint data from a spring joint
  106951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106952. */
  106953. export interface SpringJointData extends PhysicsJointData {
  106954. /**
  106955. * Length of the spring
  106956. */
  106957. length: number;
  106958. /**
  106959. * Stiffness of the spring
  106960. */
  106961. stiffness: number;
  106962. /**
  106963. * Damping of the spring
  106964. */
  106965. damping: number;
  106966. /** this callback will be called when applying the force to the impostors. */
  106967. forceApplicationCallback: () => void;
  106968. }
  106969. }
  106970. declare module BABYLON {
  106971. /**
  106972. * Holds the data for the raycast result
  106973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106974. */
  106975. export class PhysicsRaycastResult {
  106976. private _hasHit;
  106977. private _hitDistance;
  106978. private _hitNormalWorld;
  106979. private _hitPointWorld;
  106980. private _rayFromWorld;
  106981. private _rayToWorld;
  106982. /**
  106983. * Gets if there was a hit
  106984. */
  106985. get hasHit(): boolean;
  106986. /**
  106987. * Gets the distance from the hit
  106988. */
  106989. get hitDistance(): number;
  106990. /**
  106991. * Gets the hit normal/direction in the world
  106992. */
  106993. get hitNormalWorld(): Vector3;
  106994. /**
  106995. * Gets the hit point in the world
  106996. */
  106997. get hitPointWorld(): Vector3;
  106998. /**
  106999. * Gets the ray "start point" of the ray in the world
  107000. */
  107001. get rayFromWorld(): Vector3;
  107002. /**
  107003. * Gets the ray "end point" of the ray in the world
  107004. */
  107005. get rayToWorld(): Vector3;
  107006. /**
  107007. * Sets the hit data (normal & point in world space)
  107008. * @param hitNormalWorld defines the normal in world space
  107009. * @param hitPointWorld defines the point in world space
  107010. */
  107011. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107012. /**
  107013. * Sets the distance from the start point to the hit point
  107014. * @param distance
  107015. */
  107016. setHitDistance(distance: number): void;
  107017. /**
  107018. * Calculates the distance manually
  107019. */
  107020. calculateHitDistance(): void;
  107021. /**
  107022. * Resets all the values to default
  107023. * @param from The from point on world space
  107024. * @param to The to point on world space
  107025. */
  107026. reset(from?: Vector3, to?: Vector3): void;
  107027. }
  107028. /**
  107029. * Interface for the size containing width and height
  107030. */
  107031. interface IXYZ {
  107032. /**
  107033. * X
  107034. */
  107035. x: number;
  107036. /**
  107037. * Y
  107038. */
  107039. y: number;
  107040. /**
  107041. * Z
  107042. */
  107043. z: number;
  107044. }
  107045. }
  107046. declare module BABYLON {
  107047. /**
  107048. * Interface used to describe a physics joint
  107049. */
  107050. export interface PhysicsImpostorJoint {
  107051. /** Defines the main impostor to which the joint is linked */
  107052. mainImpostor: PhysicsImpostor;
  107053. /** Defines the impostor that is connected to the main impostor using this joint */
  107054. connectedImpostor: PhysicsImpostor;
  107055. /** Defines the joint itself */
  107056. joint: PhysicsJoint;
  107057. }
  107058. /** @hidden */
  107059. export interface IPhysicsEnginePlugin {
  107060. world: any;
  107061. name: string;
  107062. setGravity(gravity: Vector3): void;
  107063. setTimeStep(timeStep: number): void;
  107064. getTimeStep(): number;
  107065. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107066. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107067. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107068. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107069. removePhysicsBody(impostor: PhysicsImpostor): void;
  107070. generateJoint(joint: PhysicsImpostorJoint): void;
  107071. removeJoint(joint: PhysicsImpostorJoint): void;
  107072. isSupported(): boolean;
  107073. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107074. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107075. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107076. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107077. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107078. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107079. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107080. getBodyMass(impostor: PhysicsImpostor): number;
  107081. getBodyFriction(impostor: PhysicsImpostor): number;
  107082. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107083. getBodyRestitution(impostor: PhysicsImpostor): number;
  107084. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107085. getBodyPressure?(impostor: PhysicsImpostor): number;
  107086. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107087. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107088. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107089. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107090. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107091. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107092. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107093. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107094. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107095. sleepBody(impostor: PhysicsImpostor): void;
  107096. wakeUpBody(impostor: PhysicsImpostor): void;
  107097. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107098. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107099. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107100. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107101. getRadius(impostor: PhysicsImpostor): number;
  107102. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107103. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107104. dispose(): void;
  107105. }
  107106. /**
  107107. * Interface used to define a physics engine
  107108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107109. */
  107110. export interface IPhysicsEngine {
  107111. /**
  107112. * Gets the gravity vector used by the simulation
  107113. */
  107114. gravity: Vector3;
  107115. /**
  107116. * Sets the gravity vector used by the simulation
  107117. * @param gravity defines the gravity vector to use
  107118. */
  107119. setGravity(gravity: Vector3): void;
  107120. /**
  107121. * Set the time step of the physics engine.
  107122. * Default is 1/60.
  107123. * To slow it down, enter 1/600 for example.
  107124. * To speed it up, 1/30
  107125. * @param newTimeStep the new timestep to apply to this world.
  107126. */
  107127. setTimeStep(newTimeStep: number): void;
  107128. /**
  107129. * Get the time step of the physics engine.
  107130. * @returns the current time step
  107131. */
  107132. getTimeStep(): number;
  107133. /**
  107134. * Set the sub time step of the physics engine.
  107135. * Default is 0 meaning there is no sub steps
  107136. * To increase physics resolution precision, set a small value (like 1 ms)
  107137. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107138. */
  107139. setSubTimeStep(subTimeStep: number): void;
  107140. /**
  107141. * Get the sub time step of the physics engine.
  107142. * @returns the current sub time step
  107143. */
  107144. getSubTimeStep(): number;
  107145. /**
  107146. * Release all resources
  107147. */
  107148. dispose(): void;
  107149. /**
  107150. * Gets the name of the current physics plugin
  107151. * @returns the name of the plugin
  107152. */
  107153. getPhysicsPluginName(): string;
  107154. /**
  107155. * Adding a new impostor for the impostor tracking.
  107156. * This will be done by the impostor itself.
  107157. * @param impostor the impostor to add
  107158. */
  107159. addImpostor(impostor: PhysicsImpostor): void;
  107160. /**
  107161. * Remove an impostor from the engine.
  107162. * This impostor and its mesh will not longer be updated by the physics engine.
  107163. * @param impostor the impostor to remove
  107164. */
  107165. removeImpostor(impostor: PhysicsImpostor): void;
  107166. /**
  107167. * Add a joint to the physics engine
  107168. * @param mainImpostor defines the main impostor to which the joint is added.
  107169. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107170. * @param joint defines the joint that will connect both impostors.
  107171. */
  107172. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107173. /**
  107174. * Removes a joint from the simulation
  107175. * @param mainImpostor defines the impostor used with the joint
  107176. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107177. * @param joint defines the joint to remove
  107178. */
  107179. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107180. /**
  107181. * Gets the current plugin used to run the simulation
  107182. * @returns current plugin
  107183. */
  107184. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107185. /**
  107186. * Gets the list of physic impostors
  107187. * @returns an array of PhysicsImpostor
  107188. */
  107189. getImpostors(): Array<PhysicsImpostor>;
  107190. /**
  107191. * Gets the impostor for a physics enabled object
  107192. * @param object defines the object impersonated by the impostor
  107193. * @returns the PhysicsImpostor or null if not found
  107194. */
  107195. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107196. /**
  107197. * Gets the impostor for a physics body object
  107198. * @param body defines physics body used by the impostor
  107199. * @returns the PhysicsImpostor or null if not found
  107200. */
  107201. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107202. /**
  107203. * Does a raycast in the physics world
  107204. * @param from when should the ray start?
  107205. * @param to when should the ray end?
  107206. * @returns PhysicsRaycastResult
  107207. */
  107208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107209. /**
  107210. * Called by the scene. No need to call it.
  107211. * @param delta defines the timespam between frames
  107212. */
  107213. _step(delta: number): void;
  107214. }
  107215. }
  107216. declare module BABYLON {
  107217. /**
  107218. * The interface for the physics imposter parameters
  107219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107220. */
  107221. export interface PhysicsImpostorParameters {
  107222. /**
  107223. * The mass of the physics imposter
  107224. */
  107225. mass: number;
  107226. /**
  107227. * The friction of the physics imposter
  107228. */
  107229. friction?: number;
  107230. /**
  107231. * The coefficient of restitution of the physics imposter
  107232. */
  107233. restitution?: number;
  107234. /**
  107235. * The native options of the physics imposter
  107236. */
  107237. nativeOptions?: any;
  107238. /**
  107239. * Specifies if the parent should be ignored
  107240. */
  107241. ignoreParent?: boolean;
  107242. /**
  107243. * Specifies if bi-directional transformations should be disabled
  107244. */
  107245. disableBidirectionalTransformation?: boolean;
  107246. /**
  107247. * The pressure inside the physics imposter, soft object only
  107248. */
  107249. pressure?: number;
  107250. /**
  107251. * The stiffness the physics imposter, soft object only
  107252. */
  107253. stiffness?: number;
  107254. /**
  107255. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107256. */
  107257. velocityIterations?: number;
  107258. /**
  107259. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107260. */
  107261. positionIterations?: number;
  107262. /**
  107263. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107264. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107265. * Add to fix multiple points
  107266. */
  107267. fixedPoints?: number;
  107268. /**
  107269. * The collision margin around a soft object
  107270. */
  107271. margin?: number;
  107272. /**
  107273. * The collision margin around a soft object
  107274. */
  107275. damping?: number;
  107276. /**
  107277. * The path for a rope based on an extrusion
  107278. */
  107279. path?: any;
  107280. /**
  107281. * The shape of an extrusion used for a rope based on an extrusion
  107282. */
  107283. shape?: any;
  107284. }
  107285. /**
  107286. * Interface for a physics-enabled object
  107287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107288. */
  107289. export interface IPhysicsEnabledObject {
  107290. /**
  107291. * The position of the physics-enabled object
  107292. */
  107293. position: Vector3;
  107294. /**
  107295. * The rotation of the physics-enabled object
  107296. */
  107297. rotationQuaternion: Nullable<Quaternion>;
  107298. /**
  107299. * The scale of the physics-enabled object
  107300. */
  107301. scaling: Vector3;
  107302. /**
  107303. * The rotation of the physics-enabled object
  107304. */
  107305. rotation?: Vector3;
  107306. /**
  107307. * The parent of the physics-enabled object
  107308. */
  107309. parent?: any;
  107310. /**
  107311. * The bounding info of the physics-enabled object
  107312. * @returns The bounding info of the physics-enabled object
  107313. */
  107314. getBoundingInfo(): BoundingInfo;
  107315. /**
  107316. * Computes the world matrix
  107317. * @param force Specifies if the world matrix should be computed by force
  107318. * @returns A world matrix
  107319. */
  107320. computeWorldMatrix(force: boolean): Matrix;
  107321. /**
  107322. * Gets the world matrix
  107323. * @returns A world matrix
  107324. */
  107325. getWorldMatrix?(): Matrix;
  107326. /**
  107327. * Gets the child meshes
  107328. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107329. * @returns An array of abstract meshes
  107330. */
  107331. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107332. /**
  107333. * Gets the vertex data
  107334. * @param kind The type of vertex data
  107335. * @returns A nullable array of numbers, or a float32 array
  107336. */
  107337. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107338. /**
  107339. * Gets the indices from the mesh
  107340. * @returns A nullable array of index arrays
  107341. */
  107342. getIndices?(): Nullable<IndicesArray>;
  107343. /**
  107344. * Gets the scene from the mesh
  107345. * @returns the indices array or null
  107346. */
  107347. getScene?(): Scene;
  107348. /**
  107349. * Gets the absolute position from the mesh
  107350. * @returns the absolute position
  107351. */
  107352. getAbsolutePosition(): Vector3;
  107353. /**
  107354. * Gets the absolute pivot point from the mesh
  107355. * @returns the absolute pivot point
  107356. */
  107357. getAbsolutePivotPoint(): Vector3;
  107358. /**
  107359. * Rotates the mesh
  107360. * @param axis The axis of rotation
  107361. * @param amount The amount of rotation
  107362. * @param space The space of the rotation
  107363. * @returns The rotation transform node
  107364. */
  107365. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107366. /**
  107367. * Translates the mesh
  107368. * @param axis The axis of translation
  107369. * @param distance The distance of translation
  107370. * @param space The space of the translation
  107371. * @returns The transform node
  107372. */
  107373. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107374. /**
  107375. * Sets the absolute position of the mesh
  107376. * @param absolutePosition The absolute position of the mesh
  107377. * @returns The transform node
  107378. */
  107379. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107380. /**
  107381. * Gets the class name of the mesh
  107382. * @returns The class name
  107383. */
  107384. getClassName(): string;
  107385. }
  107386. /**
  107387. * Represents a physics imposter
  107388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107389. */
  107390. export class PhysicsImpostor {
  107391. /**
  107392. * The physics-enabled object used as the physics imposter
  107393. */
  107394. object: IPhysicsEnabledObject;
  107395. /**
  107396. * The type of the physics imposter
  107397. */
  107398. type: number;
  107399. private _options;
  107400. private _scene?;
  107401. /**
  107402. * The default object size of the imposter
  107403. */
  107404. static DEFAULT_OBJECT_SIZE: Vector3;
  107405. /**
  107406. * The identity quaternion of the imposter
  107407. */
  107408. static IDENTITY_QUATERNION: Quaternion;
  107409. /** @hidden */
  107410. _pluginData: any;
  107411. private _physicsEngine;
  107412. private _physicsBody;
  107413. private _bodyUpdateRequired;
  107414. private _onBeforePhysicsStepCallbacks;
  107415. private _onAfterPhysicsStepCallbacks;
  107416. /** @hidden */
  107417. _onPhysicsCollideCallbacks: Array<{
  107418. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107419. otherImpostors: Array<PhysicsImpostor>;
  107420. }>;
  107421. private _deltaPosition;
  107422. private _deltaRotation;
  107423. private _deltaRotationConjugated;
  107424. /** @hidden */
  107425. _isFromLine: boolean;
  107426. private _parent;
  107427. private _isDisposed;
  107428. private static _tmpVecs;
  107429. private static _tmpQuat;
  107430. /**
  107431. * Specifies if the physics imposter is disposed
  107432. */
  107433. get isDisposed(): boolean;
  107434. /**
  107435. * Gets the mass of the physics imposter
  107436. */
  107437. get mass(): number;
  107438. set mass(value: number);
  107439. /**
  107440. * Gets the coefficient of friction
  107441. */
  107442. get friction(): number;
  107443. /**
  107444. * Sets the coefficient of friction
  107445. */
  107446. set friction(value: number);
  107447. /**
  107448. * Gets the coefficient of restitution
  107449. */
  107450. get restitution(): number;
  107451. /**
  107452. * Sets the coefficient of restitution
  107453. */
  107454. set restitution(value: number);
  107455. /**
  107456. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  107457. */
  107458. get pressure(): number;
  107459. /**
  107460. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  107461. */
  107462. set pressure(value: number);
  107463. /**
  107464. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107465. */
  107466. get stiffness(): number;
  107467. /**
  107468. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107469. */
  107470. set stiffness(value: number);
  107471. /**
  107472. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107473. */
  107474. get velocityIterations(): number;
  107475. /**
  107476. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107477. */
  107478. set velocityIterations(value: number);
  107479. /**
  107480. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107481. */
  107482. get positionIterations(): number;
  107483. /**
  107484. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107485. */
  107486. set positionIterations(value: number);
  107487. /**
  107488. * The unique id of the physics imposter
  107489. * set by the physics engine when adding this impostor to the array
  107490. */
  107491. uniqueId: number;
  107492. /**
  107493. * @hidden
  107494. */
  107495. soft: boolean;
  107496. /**
  107497. * @hidden
  107498. */
  107499. segments: number;
  107500. private _joints;
  107501. /**
  107502. * Initializes the physics imposter
  107503. * @param object The physics-enabled object used as the physics imposter
  107504. * @param type The type of the physics imposter
  107505. * @param _options The options for the physics imposter
  107506. * @param _scene The Babylon scene
  107507. */
  107508. constructor(
  107509. /**
  107510. * The physics-enabled object used as the physics imposter
  107511. */
  107512. object: IPhysicsEnabledObject,
  107513. /**
  107514. * The type of the physics imposter
  107515. */
  107516. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  107517. /**
  107518. * This function will completly initialize this impostor.
  107519. * It will create a new body - but only if this mesh has no parent.
  107520. * If it has, this impostor will not be used other than to define the impostor
  107521. * of the child mesh.
  107522. * @hidden
  107523. */
  107524. _init(): void;
  107525. private _getPhysicsParent;
  107526. /**
  107527. * Should a new body be generated.
  107528. * @returns boolean specifying if body initialization is required
  107529. */
  107530. isBodyInitRequired(): boolean;
  107531. /**
  107532. * Sets the updated scaling
  107533. * @param updated Specifies if the scaling is updated
  107534. */
  107535. setScalingUpdated(): void;
  107536. /**
  107537. * Force a regeneration of this or the parent's impostor's body.
  107538. * Use under cautious - This will remove all joints already implemented.
  107539. */
  107540. forceUpdate(): void;
  107541. /**
  107542. * Gets the body that holds this impostor. Either its own, or its parent.
  107543. */
  107544. get physicsBody(): any;
  107545. /**
  107546. * Get the parent of the physics imposter
  107547. * @returns Physics imposter or null
  107548. */
  107549. get parent(): Nullable<PhysicsImpostor>;
  107550. /**
  107551. * Sets the parent of the physics imposter
  107552. */
  107553. set parent(value: Nullable<PhysicsImpostor>);
  107554. /**
  107555. * Set the physics body. Used mainly by the physics engine/plugin
  107556. */
  107557. set physicsBody(physicsBody: any);
  107558. /**
  107559. * Resets the update flags
  107560. */
  107561. resetUpdateFlags(): void;
  107562. /**
  107563. * Gets the object extend size
  107564. * @returns the object extend size
  107565. */
  107566. getObjectExtendSize(): Vector3;
  107567. /**
  107568. * Gets the object center
  107569. * @returns The object center
  107570. */
  107571. getObjectCenter(): Vector3;
  107572. /**
  107573. * Get a specific parameter from the options parameters
  107574. * @param paramName The object parameter name
  107575. * @returns The object parameter
  107576. */
  107577. getParam(paramName: string): any;
  107578. /**
  107579. * Sets a specific parameter in the options given to the physics plugin
  107580. * @param paramName The parameter name
  107581. * @param value The value of the parameter
  107582. */
  107583. setParam(paramName: string, value: number): void;
  107584. /**
  107585. * Specifically change the body's mass option. Won't recreate the physics body object
  107586. * @param mass The mass of the physics imposter
  107587. */
  107588. setMass(mass: number): void;
  107589. /**
  107590. * Gets the linear velocity
  107591. * @returns linear velocity or null
  107592. */
  107593. getLinearVelocity(): Nullable<Vector3>;
  107594. /**
  107595. * Sets the linear velocity
  107596. * @param velocity linear velocity or null
  107597. */
  107598. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107599. /**
  107600. * Gets the angular velocity
  107601. * @returns angular velocity or null
  107602. */
  107603. getAngularVelocity(): Nullable<Vector3>;
  107604. /**
  107605. * Sets the angular velocity
  107606. * @param velocity The velocity or null
  107607. */
  107608. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107609. /**
  107610. * Execute a function with the physics plugin native code
  107611. * Provide a function the will have two variables - the world object and the physics body object
  107612. * @param func The function to execute with the physics plugin native code
  107613. */
  107614. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107615. /**
  107616. * Register a function that will be executed before the physics world is stepping forward
  107617. * @param func The function to execute before the physics world is stepped forward
  107618. */
  107619. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107620. /**
  107621. * Unregister a function that will be executed before the physics world is stepping forward
  107622. * @param func The function to execute before the physics world is stepped forward
  107623. */
  107624. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107625. /**
  107626. * Register a function that will be executed after the physics step
  107627. * @param func The function to execute after physics step
  107628. */
  107629. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107630. /**
  107631. * Unregisters a function that will be executed after the physics step
  107632. * @param func The function to execute after physics step
  107633. */
  107634. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107635. /**
  107636. * register a function that will be executed when this impostor collides against a different body
  107637. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107638. * @param func Callback that is executed on collision
  107639. */
  107640. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107641. /**
  107642. * Unregisters the physics imposter on contact
  107643. * @param collideAgainst The physics object to collide against
  107644. * @param func Callback to execute on collision
  107645. */
  107646. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107647. private _tmpQuat;
  107648. private _tmpQuat2;
  107649. /**
  107650. * Get the parent rotation
  107651. * @returns The parent rotation
  107652. */
  107653. getParentsRotation(): Quaternion;
  107654. /**
  107655. * this function is executed by the physics engine.
  107656. */
  107657. beforeStep: () => void;
  107658. /**
  107659. * this function is executed by the physics engine
  107660. */
  107661. afterStep: () => void;
  107662. /**
  107663. * Legacy collision detection event support
  107664. */
  107665. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107666. /**
  107667. * event and body object due to cannon's event-based architecture.
  107668. */
  107669. onCollide: (e: {
  107670. body: any;
  107671. }) => void;
  107672. /**
  107673. * Apply a force
  107674. * @param force The force to apply
  107675. * @param contactPoint The contact point for the force
  107676. * @returns The physics imposter
  107677. */
  107678. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107679. /**
  107680. * Apply an impulse
  107681. * @param force The impulse force
  107682. * @param contactPoint The contact point for the impulse force
  107683. * @returns The physics imposter
  107684. */
  107685. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107686. /**
  107687. * A help function to create a joint
  107688. * @param otherImpostor A physics imposter used to create a joint
  107689. * @param jointType The type of joint
  107690. * @param jointData The data for the joint
  107691. * @returns The physics imposter
  107692. */
  107693. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107694. /**
  107695. * Add a joint to this impostor with a different impostor
  107696. * @param otherImpostor A physics imposter used to add a joint
  107697. * @param joint The joint to add
  107698. * @returns The physics imposter
  107699. */
  107700. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107701. /**
  107702. * Add an anchor to a cloth impostor
  107703. * @param otherImpostor rigid impostor to anchor to
  107704. * @param width ratio across width from 0 to 1
  107705. * @param height ratio up height from 0 to 1
  107706. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107707. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107708. * @returns impostor the soft imposter
  107709. */
  107710. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107711. /**
  107712. * Add a hook to a rope impostor
  107713. * @param otherImpostor rigid impostor to anchor to
  107714. * @param length ratio across rope from 0 to 1
  107715. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107716. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107717. * @returns impostor the rope imposter
  107718. */
  107719. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107720. /**
  107721. * Will keep this body still, in a sleep mode.
  107722. * @returns the physics imposter
  107723. */
  107724. sleep(): PhysicsImpostor;
  107725. /**
  107726. * Wake the body up.
  107727. * @returns The physics imposter
  107728. */
  107729. wakeUp(): PhysicsImpostor;
  107730. /**
  107731. * Clones the physics imposter
  107732. * @param newObject The physics imposter clones to this physics-enabled object
  107733. * @returns A nullable physics imposter
  107734. */
  107735. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107736. /**
  107737. * Disposes the physics imposter
  107738. */
  107739. dispose(): void;
  107740. /**
  107741. * Sets the delta position
  107742. * @param position The delta position amount
  107743. */
  107744. setDeltaPosition(position: Vector3): void;
  107745. /**
  107746. * Sets the delta rotation
  107747. * @param rotation The delta rotation amount
  107748. */
  107749. setDeltaRotation(rotation: Quaternion): void;
  107750. /**
  107751. * Gets the box size of the physics imposter and stores the result in the input parameter
  107752. * @param result Stores the box size
  107753. * @returns The physics imposter
  107754. */
  107755. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  107756. /**
  107757. * Gets the radius of the physics imposter
  107758. * @returns Radius of the physics imposter
  107759. */
  107760. getRadius(): number;
  107761. /**
  107762. * Sync a bone with this impostor
  107763. * @param bone The bone to sync to the impostor.
  107764. * @param boneMesh The mesh that the bone is influencing.
  107765. * @param jointPivot The pivot of the joint / bone in local space.
  107766. * @param distToJoint Optional distance from the impostor to the joint.
  107767. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107768. */
  107769. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  107770. /**
  107771. * Sync impostor to a bone
  107772. * @param bone The bone that the impostor will be synced to.
  107773. * @param boneMesh The mesh that the bone is influencing.
  107774. * @param jointPivot The pivot of the joint / bone in local space.
  107775. * @param distToJoint Optional distance from the impostor to the joint.
  107776. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107777. * @param boneAxis Optional vector3 axis the bone is aligned with
  107778. */
  107779. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  107780. /**
  107781. * No-Imposter type
  107782. */
  107783. static NoImpostor: number;
  107784. /**
  107785. * Sphere-Imposter type
  107786. */
  107787. static SphereImpostor: number;
  107788. /**
  107789. * Box-Imposter type
  107790. */
  107791. static BoxImpostor: number;
  107792. /**
  107793. * Plane-Imposter type
  107794. */
  107795. static PlaneImpostor: number;
  107796. /**
  107797. * Mesh-imposter type
  107798. */
  107799. static MeshImpostor: number;
  107800. /**
  107801. * Capsule-Impostor type (Ammo.js plugin only)
  107802. */
  107803. static CapsuleImpostor: number;
  107804. /**
  107805. * Cylinder-Imposter type
  107806. */
  107807. static CylinderImpostor: number;
  107808. /**
  107809. * Particle-Imposter type
  107810. */
  107811. static ParticleImpostor: number;
  107812. /**
  107813. * Heightmap-Imposter type
  107814. */
  107815. static HeightmapImpostor: number;
  107816. /**
  107817. * ConvexHull-Impostor type (Ammo.js plugin only)
  107818. */
  107819. static ConvexHullImpostor: number;
  107820. /**
  107821. * Custom-Imposter type (Ammo.js plugin only)
  107822. */
  107823. static CustomImpostor: number;
  107824. /**
  107825. * Rope-Imposter type
  107826. */
  107827. static RopeImpostor: number;
  107828. /**
  107829. * Cloth-Imposter type
  107830. */
  107831. static ClothImpostor: number;
  107832. /**
  107833. * Softbody-Imposter type
  107834. */
  107835. static SoftbodyImpostor: number;
  107836. }
  107837. }
  107838. declare module BABYLON {
  107839. /**
  107840. * @hidden
  107841. **/
  107842. export class _CreationDataStorage {
  107843. closePath?: boolean;
  107844. closeArray?: boolean;
  107845. idx: number[];
  107846. dashSize: number;
  107847. gapSize: number;
  107848. path3D: Path3D;
  107849. pathArray: Vector3[][];
  107850. arc: number;
  107851. radius: number;
  107852. cap: number;
  107853. tessellation: number;
  107854. }
  107855. /**
  107856. * @hidden
  107857. **/
  107858. class _InstanceDataStorage {
  107859. visibleInstances: any;
  107860. batchCache: _InstancesBatch;
  107861. instancesBufferSize: number;
  107862. instancesBuffer: Nullable<Buffer>;
  107863. instancesData: Float32Array;
  107864. overridenInstanceCount: number;
  107865. isFrozen: boolean;
  107866. previousBatch: Nullable<_InstancesBatch>;
  107867. hardwareInstancedRendering: boolean;
  107868. sideOrientation: number;
  107869. manualUpdate: boolean;
  107870. }
  107871. /**
  107872. * @hidden
  107873. **/
  107874. export class _InstancesBatch {
  107875. mustReturn: boolean;
  107876. visibleInstances: Nullable<InstancedMesh[]>[];
  107877. renderSelf: boolean[];
  107878. hardwareInstancedRendering: boolean[];
  107879. }
  107880. /**
  107881. * @hidden
  107882. **/
  107883. class _ThinInstanceDataStorage {
  107884. instancesCount: number;
  107885. matrixBuffer: Nullable<Buffer>;
  107886. matrixBufferSize: number;
  107887. matrixData: Nullable<Float32Array>;
  107888. boundingVectors: Array<Vector3>;
  107889. worldMatrices: Nullable<Matrix[]>;
  107890. }
  107891. /**
  107892. * Class used to represent renderable models
  107893. */
  107894. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  107895. /**
  107896. * Mesh side orientation : usually the external or front surface
  107897. */
  107898. static readonly FRONTSIDE: number;
  107899. /**
  107900. * Mesh side orientation : usually the internal or back surface
  107901. */
  107902. static readonly BACKSIDE: number;
  107903. /**
  107904. * Mesh side orientation : both internal and external or front and back surfaces
  107905. */
  107906. static readonly DOUBLESIDE: number;
  107907. /**
  107908. * Mesh side orientation : by default, `FRONTSIDE`
  107909. */
  107910. static readonly DEFAULTSIDE: number;
  107911. /**
  107912. * Mesh cap setting : no cap
  107913. */
  107914. static readonly NO_CAP: number;
  107915. /**
  107916. * Mesh cap setting : one cap at the beginning of the mesh
  107917. */
  107918. static readonly CAP_START: number;
  107919. /**
  107920. * Mesh cap setting : one cap at the end of the mesh
  107921. */
  107922. static readonly CAP_END: number;
  107923. /**
  107924. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  107925. */
  107926. static readonly CAP_ALL: number;
  107927. /**
  107928. * Mesh pattern setting : no flip or rotate
  107929. */
  107930. static readonly NO_FLIP: number;
  107931. /**
  107932. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  107933. */
  107934. static readonly FLIP_TILE: number;
  107935. /**
  107936. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  107937. */
  107938. static readonly ROTATE_TILE: number;
  107939. /**
  107940. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  107941. */
  107942. static readonly FLIP_ROW: number;
  107943. /**
  107944. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  107945. */
  107946. static readonly ROTATE_ROW: number;
  107947. /**
  107948. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  107949. */
  107950. static readonly FLIP_N_ROTATE_TILE: number;
  107951. /**
  107952. * Mesh pattern setting : rotate pattern and rotate
  107953. */
  107954. static readonly FLIP_N_ROTATE_ROW: number;
  107955. /**
  107956. * Mesh tile positioning : part tiles same on left/right or top/bottom
  107957. */
  107958. static readonly CENTER: number;
  107959. /**
  107960. * Mesh tile positioning : part tiles on left
  107961. */
  107962. static readonly LEFT: number;
  107963. /**
  107964. * Mesh tile positioning : part tiles on right
  107965. */
  107966. static readonly RIGHT: number;
  107967. /**
  107968. * Mesh tile positioning : part tiles on top
  107969. */
  107970. static readonly TOP: number;
  107971. /**
  107972. * Mesh tile positioning : part tiles on bottom
  107973. */
  107974. static readonly BOTTOM: number;
  107975. /**
  107976. * Gets the default side orientation.
  107977. * @param orientation the orientation to value to attempt to get
  107978. * @returns the default orientation
  107979. * @hidden
  107980. */
  107981. static _GetDefaultSideOrientation(orientation?: number): number;
  107982. private _internalMeshDataInfo;
  107983. get computeBonesUsingShaders(): boolean;
  107984. set computeBonesUsingShaders(value: boolean);
  107985. /**
  107986. * An event triggered before rendering the mesh
  107987. */
  107988. get onBeforeRenderObservable(): Observable<Mesh>;
  107989. /**
  107990. * An event triggered before binding the mesh
  107991. */
  107992. get onBeforeBindObservable(): Observable<Mesh>;
  107993. /**
  107994. * An event triggered after rendering the mesh
  107995. */
  107996. get onAfterRenderObservable(): Observable<Mesh>;
  107997. /**
  107998. * An event triggered before drawing the mesh
  107999. */
  108000. get onBeforeDrawObservable(): Observable<Mesh>;
  108001. private _onBeforeDrawObserver;
  108002. /**
  108003. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108004. */
  108005. set onBeforeDraw(callback: () => void);
  108006. get hasInstances(): boolean;
  108007. get hasThinInstances(): boolean;
  108008. /**
  108009. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108010. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108011. */
  108012. delayLoadState: number;
  108013. /**
  108014. * Gets the list of instances created from this mesh
  108015. * it is not supposed to be modified manually.
  108016. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108017. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108018. */
  108019. instances: InstancedMesh[];
  108020. /**
  108021. * Gets the file containing delay loading data for this mesh
  108022. */
  108023. delayLoadingFile: string;
  108024. /** @hidden */
  108025. _binaryInfo: any;
  108026. /**
  108027. * User defined function used to change how LOD level selection is done
  108028. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108029. */
  108030. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108031. /**
  108032. * Gets or sets the morph target manager
  108033. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108034. */
  108035. get morphTargetManager(): Nullable<MorphTargetManager>;
  108036. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108037. /** @hidden */
  108038. _creationDataStorage: Nullable<_CreationDataStorage>;
  108039. /** @hidden */
  108040. _geometry: Nullable<Geometry>;
  108041. /** @hidden */
  108042. _delayInfo: Array<string>;
  108043. /** @hidden */
  108044. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108045. /** @hidden */
  108046. _instanceDataStorage: _InstanceDataStorage;
  108047. /** @hidden */
  108048. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108049. private _effectiveMaterial;
  108050. /** @hidden */
  108051. _shouldGenerateFlatShading: boolean;
  108052. /** @hidden */
  108053. _originalBuilderSideOrientation: number;
  108054. /**
  108055. * Use this property to change the original side orientation defined at construction time
  108056. */
  108057. overrideMaterialSideOrientation: Nullable<number>;
  108058. /**
  108059. * Gets the source mesh (the one used to clone this one from)
  108060. */
  108061. get source(): Nullable<Mesh>;
  108062. /**
  108063. * Gets the list of clones of this mesh
  108064. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108065. * Note that useClonedMeshMap=true is the default setting
  108066. */
  108067. get cloneMeshMap(): Nullable<{
  108068. [id: string]: Mesh | undefined;
  108069. }>;
  108070. /**
  108071. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108072. */
  108073. get isUnIndexed(): boolean;
  108074. set isUnIndexed(value: boolean);
  108075. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108076. get worldMatrixInstancedBuffer(): Float32Array;
  108077. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108078. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108079. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108080. /**
  108081. * @constructor
  108082. * @param name The value used by scene.getMeshByName() to do a lookup.
  108083. * @param scene The scene to add this mesh to.
  108084. * @param parent The parent of this mesh, if it has one
  108085. * @param source An optional Mesh from which geometry is shared, cloned.
  108086. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108087. * When false, achieved by calling a clone(), also passing False.
  108088. * This will make creation of children, recursive.
  108089. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108090. */
  108091. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108092. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108093. doNotInstantiate: boolean;
  108094. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108095. /**
  108096. * Gets the class name
  108097. * @returns the string "Mesh".
  108098. */
  108099. getClassName(): string;
  108100. /** @hidden */
  108101. get _isMesh(): boolean;
  108102. /**
  108103. * Returns a description of this mesh
  108104. * @param fullDetails define if full details about this mesh must be used
  108105. * @returns a descriptive string representing this mesh
  108106. */
  108107. toString(fullDetails?: boolean): string;
  108108. /** @hidden */
  108109. _unBindEffect(): void;
  108110. /**
  108111. * Gets a boolean indicating if this mesh has LOD
  108112. */
  108113. get hasLODLevels(): boolean;
  108114. /**
  108115. * Gets the list of MeshLODLevel associated with the current mesh
  108116. * @returns an array of MeshLODLevel
  108117. */
  108118. getLODLevels(): MeshLODLevel[];
  108119. private _sortLODLevels;
  108120. /**
  108121. * Add a mesh as LOD level triggered at the given distance.
  108122. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108123. * @param distance The distance from the center of the object to show this level
  108124. * @param mesh The mesh to be added as LOD level (can be null)
  108125. * @return This mesh (for chaining)
  108126. */
  108127. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108128. /**
  108129. * Returns the LOD level mesh at the passed distance or null if not found.
  108130. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108131. * @param distance The distance from the center of the object to show this level
  108132. * @returns a Mesh or `null`
  108133. */
  108134. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108135. /**
  108136. * Remove a mesh from the LOD array
  108137. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108138. * @param mesh defines the mesh to be removed
  108139. * @return This mesh (for chaining)
  108140. */
  108141. removeLODLevel(mesh: Mesh): Mesh;
  108142. /**
  108143. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108145. * @param camera defines the camera to use to compute distance
  108146. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108147. * @return This mesh (for chaining)
  108148. */
  108149. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108150. /**
  108151. * Gets the mesh internal Geometry object
  108152. */
  108153. get geometry(): Nullable<Geometry>;
  108154. /**
  108155. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108156. * @returns the total number of vertices
  108157. */
  108158. getTotalVertices(): number;
  108159. /**
  108160. * Returns the content of an associated vertex buffer
  108161. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108162. * - VertexBuffer.PositionKind
  108163. * - VertexBuffer.UVKind
  108164. * - VertexBuffer.UV2Kind
  108165. * - VertexBuffer.UV3Kind
  108166. * - VertexBuffer.UV4Kind
  108167. * - VertexBuffer.UV5Kind
  108168. * - VertexBuffer.UV6Kind
  108169. * - VertexBuffer.ColorKind
  108170. * - VertexBuffer.MatricesIndicesKind
  108171. * - VertexBuffer.MatricesIndicesExtraKind
  108172. * - VertexBuffer.MatricesWeightsKind
  108173. * - VertexBuffer.MatricesWeightsExtraKind
  108174. * @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
  108175. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108176. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108177. */
  108178. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108179. /**
  108180. * Returns the mesh VertexBuffer object from the requested `kind`
  108181. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108182. * - VertexBuffer.PositionKind
  108183. * - VertexBuffer.NormalKind
  108184. * - VertexBuffer.UVKind
  108185. * - VertexBuffer.UV2Kind
  108186. * - VertexBuffer.UV3Kind
  108187. * - VertexBuffer.UV4Kind
  108188. * - VertexBuffer.UV5Kind
  108189. * - VertexBuffer.UV6Kind
  108190. * - VertexBuffer.ColorKind
  108191. * - VertexBuffer.MatricesIndicesKind
  108192. * - VertexBuffer.MatricesIndicesExtraKind
  108193. * - VertexBuffer.MatricesWeightsKind
  108194. * - VertexBuffer.MatricesWeightsExtraKind
  108195. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108196. */
  108197. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108198. /**
  108199. * Tests if a specific vertex buffer is associated with this mesh
  108200. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108201. * - VertexBuffer.PositionKind
  108202. * - VertexBuffer.NormalKind
  108203. * - VertexBuffer.UVKind
  108204. * - VertexBuffer.UV2Kind
  108205. * - VertexBuffer.UV3Kind
  108206. * - VertexBuffer.UV4Kind
  108207. * - VertexBuffer.UV5Kind
  108208. * - VertexBuffer.UV6Kind
  108209. * - VertexBuffer.ColorKind
  108210. * - VertexBuffer.MatricesIndicesKind
  108211. * - VertexBuffer.MatricesIndicesExtraKind
  108212. * - VertexBuffer.MatricesWeightsKind
  108213. * - VertexBuffer.MatricesWeightsExtraKind
  108214. * @returns a boolean
  108215. */
  108216. isVerticesDataPresent(kind: string): boolean;
  108217. /**
  108218. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108219. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108220. * - VertexBuffer.PositionKind
  108221. * - VertexBuffer.UVKind
  108222. * - VertexBuffer.UV2Kind
  108223. * - VertexBuffer.UV3Kind
  108224. * - VertexBuffer.UV4Kind
  108225. * - VertexBuffer.UV5Kind
  108226. * - VertexBuffer.UV6Kind
  108227. * - VertexBuffer.ColorKind
  108228. * - VertexBuffer.MatricesIndicesKind
  108229. * - VertexBuffer.MatricesIndicesExtraKind
  108230. * - VertexBuffer.MatricesWeightsKind
  108231. * - VertexBuffer.MatricesWeightsExtraKind
  108232. * @returns a boolean
  108233. */
  108234. isVertexBufferUpdatable(kind: string): boolean;
  108235. /**
  108236. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108237. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108238. * - VertexBuffer.PositionKind
  108239. * - VertexBuffer.NormalKind
  108240. * - VertexBuffer.UVKind
  108241. * - VertexBuffer.UV2Kind
  108242. * - VertexBuffer.UV3Kind
  108243. * - VertexBuffer.UV4Kind
  108244. * - VertexBuffer.UV5Kind
  108245. * - VertexBuffer.UV6Kind
  108246. * - VertexBuffer.ColorKind
  108247. * - VertexBuffer.MatricesIndicesKind
  108248. * - VertexBuffer.MatricesIndicesExtraKind
  108249. * - VertexBuffer.MatricesWeightsKind
  108250. * - VertexBuffer.MatricesWeightsExtraKind
  108251. * @returns an array of strings
  108252. */
  108253. getVerticesDataKinds(): string[];
  108254. /**
  108255. * Returns a positive integer : the total number of indices in this mesh geometry.
  108256. * @returns the numner of indices or zero if the mesh has no geometry.
  108257. */
  108258. getTotalIndices(): number;
  108259. /**
  108260. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108261. * @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.
  108262. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108263. * @returns the indices array or an empty array if the mesh has no geometry
  108264. */
  108265. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108266. get isBlocked(): boolean;
  108267. /**
  108268. * Determine if the current mesh is ready to be rendered
  108269. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108270. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108271. * @returns true if all associated assets are ready (material, textures, shaders)
  108272. */
  108273. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108274. /**
  108275. * 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.
  108276. */
  108277. get areNormalsFrozen(): boolean;
  108278. /**
  108279. * 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.
  108280. * @returns the current mesh
  108281. */
  108282. freezeNormals(): Mesh;
  108283. /**
  108284. * 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
  108285. * @returns the current mesh
  108286. */
  108287. unfreezeNormals(): Mesh;
  108288. /**
  108289. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108290. */
  108291. set overridenInstanceCount(count: number);
  108292. /** @hidden */
  108293. _preActivate(): Mesh;
  108294. /** @hidden */
  108295. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108296. /** @hidden */
  108297. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108298. protected _afterComputeWorldMatrix(): void;
  108299. /** @hidden */
  108300. _postActivate(): void;
  108301. /**
  108302. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108303. * This means the mesh underlying bounding box and sphere are recomputed.
  108304. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108305. * @returns the current mesh
  108306. */
  108307. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108308. /** @hidden */
  108309. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108310. /**
  108311. * This function will subdivide the mesh into multiple submeshes
  108312. * @param count defines the expected number of submeshes
  108313. */
  108314. subdivide(count: number): void;
  108315. /**
  108316. * Copy a FloatArray into a specific associated vertex buffer
  108317. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108318. * - VertexBuffer.PositionKind
  108319. * - VertexBuffer.UVKind
  108320. * - VertexBuffer.UV2Kind
  108321. * - VertexBuffer.UV3Kind
  108322. * - VertexBuffer.UV4Kind
  108323. * - VertexBuffer.UV5Kind
  108324. * - VertexBuffer.UV6Kind
  108325. * - VertexBuffer.ColorKind
  108326. * - VertexBuffer.MatricesIndicesKind
  108327. * - VertexBuffer.MatricesIndicesExtraKind
  108328. * - VertexBuffer.MatricesWeightsKind
  108329. * - VertexBuffer.MatricesWeightsExtraKind
  108330. * @param data defines the data source
  108331. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108332. * @param stride defines the data stride size (can be null)
  108333. * @returns the current mesh
  108334. */
  108335. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108336. /**
  108337. * Delete a vertex buffer associated with this mesh
  108338. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108339. * - VertexBuffer.PositionKind
  108340. * - VertexBuffer.UVKind
  108341. * - VertexBuffer.UV2Kind
  108342. * - VertexBuffer.UV3Kind
  108343. * - VertexBuffer.UV4Kind
  108344. * - VertexBuffer.UV5Kind
  108345. * - VertexBuffer.UV6Kind
  108346. * - VertexBuffer.ColorKind
  108347. * - VertexBuffer.MatricesIndicesKind
  108348. * - VertexBuffer.MatricesIndicesExtraKind
  108349. * - VertexBuffer.MatricesWeightsKind
  108350. * - VertexBuffer.MatricesWeightsExtraKind
  108351. */
  108352. removeVerticesData(kind: string): void;
  108353. /**
  108354. * Flags an associated vertex buffer as updatable
  108355. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108356. * - VertexBuffer.PositionKind
  108357. * - VertexBuffer.UVKind
  108358. * - VertexBuffer.UV2Kind
  108359. * - VertexBuffer.UV3Kind
  108360. * - VertexBuffer.UV4Kind
  108361. * - VertexBuffer.UV5Kind
  108362. * - VertexBuffer.UV6Kind
  108363. * - VertexBuffer.ColorKind
  108364. * - VertexBuffer.MatricesIndicesKind
  108365. * - VertexBuffer.MatricesIndicesExtraKind
  108366. * - VertexBuffer.MatricesWeightsKind
  108367. * - VertexBuffer.MatricesWeightsExtraKind
  108368. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108369. */
  108370. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108371. /**
  108372. * Sets the mesh global Vertex Buffer
  108373. * @param buffer defines the buffer to use
  108374. * @returns the current mesh
  108375. */
  108376. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108377. /**
  108378. * Update a specific associated vertex buffer
  108379. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108380. * - VertexBuffer.PositionKind
  108381. * - VertexBuffer.UVKind
  108382. * - VertexBuffer.UV2Kind
  108383. * - VertexBuffer.UV3Kind
  108384. * - VertexBuffer.UV4Kind
  108385. * - VertexBuffer.UV5Kind
  108386. * - VertexBuffer.UV6Kind
  108387. * - VertexBuffer.ColorKind
  108388. * - VertexBuffer.MatricesIndicesKind
  108389. * - VertexBuffer.MatricesIndicesExtraKind
  108390. * - VertexBuffer.MatricesWeightsKind
  108391. * - VertexBuffer.MatricesWeightsExtraKind
  108392. * @param data defines the data source
  108393. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108394. * @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)
  108395. * @returns the current mesh
  108396. */
  108397. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108398. /**
  108399. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108400. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108401. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108402. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108403. * @returns the current mesh
  108404. */
  108405. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108406. /**
  108407. * Creates a un-shared specific occurence of the geometry for the mesh.
  108408. * @returns the current mesh
  108409. */
  108410. makeGeometryUnique(): Mesh;
  108411. /**
  108412. * Set the index buffer of this mesh
  108413. * @param indices defines the source data
  108414. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108415. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108416. * @returns the current mesh
  108417. */
  108418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108419. /**
  108420. * Update the current index buffer
  108421. * @param indices defines the source data
  108422. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108423. * @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)
  108424. * @returns the current mesh
  108425. */
  108426. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108427. /**
  108428. * Invert the geometry to move from a right handed system to a left handed one.
  108429. * @returns the current mesh
  108430. */
  108431. toLeftHanded(): Mesh;
  108432. /** @hidden */
  108433. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108434. /** @hidden */
  108435. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108436. /**
  108437. * Registers for this mesh a javascript function called just before the rendering process
  108438. * @param func defines the function to call before rendering this mesh
  108439. * @returns the current mesh
  108440. */
  108441. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108442. /**
  108443. * Disposes a previously registered javascript function called before the rendering
  108444. * @param func defines the function to remove
  108445. * @returns the current mesh
  108446. */
  108447. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108448. /**
  108449. * Registers for this mesh a javascript function called just after the rendering is complete
  108450. * @param func defines the function to call after rendering this mesh
  108451. * @returns the current mesh
  108452. */
  108453. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108454. /**
  108455. * Disposes a previously registered javascript function called after the rendering.
  108456. * @param func defines the function to remove
  108457. * @returns the current mesh
  108458. */
  108459. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108460. /** @hidden */
  108461. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  108462. /** @hidden */
  108463. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  108464. /** @hidden */
  108465. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  108466. /** @hidden */
  108467. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  108468. /** @hidden */
  108469. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  108470. /** @hidden */
  108471. _rebuild(): void;
  108472. /** @hidden */
  108473. _freeze(): void;
  108474. /** @hidden */
  108475. _unFreeze(): void;
  108476. /**
  108477. * 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
  108478. * @param subMesh defines the subMesh to render
  108479. * @param enableAlphaMode defines if alpha mode can be changed
  108480. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  108481. * @returns the current mesh
  108482. */
  108483. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  108484. private _onBeforeDraw;
  108485. /**
  108486. * Renormalize the mesh and patch it up if there are no weights
  108487. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  108488. * However in the case of zero weights then we set just a single influence to 1.
  108489. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  108490. */
  108491. cleanMatrixWeights(): void;
  108492. private normalizeSkinFourWeights;
  108493. private normalizeSkinWeightsAndExtra;
  108494. /**
  108495. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  108496. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  108497. * the user know there was an issue with importing the mesh
  108498. * @returns a validation object with skinned, valid and report string
  108499. */
  108500. validateSkinning(): {
  108501. skinned: boolean;
  108502. valid: boolean;
  108503. report: string;
  108504. };
  108505. /** @hidden */
  108506. _checkDelayState(): Mesh;
  108507. private _queueLoad;
  108508. /**
  108509. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108510. * A mesh is in the frustum if its bounding box intersects the frustum
  108511. * @param frustumPlanes defines the frustum to test
  108512. * @returns true if the mesh is in the frustum planes
  108513. */
  108514. isInFrustum(frustumPlanes: Plane[]): boolean;
  108515. /**
  108516. * Sets the mesh material by the material or multiMaterial `id` property
  108517. * @param id is a string identifying the material or the multiMaterial
  108518. * @returns the current mesh
  108519. */
  108520. setMaterialByID(id: string): Mesh;
  108521. /**
  108522. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  108523. * @returns an array of IAnimatable
  108524. */
  108525. getAnimatables(): IAnimatable[];
  108526. /**
  108527. * Modifies the mesh geometry according to the passed transformation matrix.
  108528. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  108529. * The mesh normals are modified using the same transformation.
  108530. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108531. * @param transform defines the transform matrix to use
  108532. * @see https://doc.babylonjs.com/resources/baking_transformations
  108533. * @returns the current mesh
  108534. */
  108535. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108536. /**
  108537. * Modifies the mesh geometry according to its own current World Matrix.
  108538. * The mesh World Matrix is then reset.
  108539. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108540. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108541. * @see https://doc.babylonjs.com/resources/baking_transformations
  108542. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108543. * @returns the current mesh
  108544. */
  108545. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108546. /** @hidden */
  108547. get _positions(): Nullable<Vector3[]>;
  108548. /** @hidden */
  108549. _resetPointsArrayCache(): Mesh;
  108550. /** @hidden */
  108551. _generatePointsArray(): boolean;
  108552. /**
  108553. * Returns a new Mesh object generated from the current mesh properties.
  108554. * This method must not get confused with createInstance()
  108555. * @param name is a string, the name given to the new mesh
  108556. * @param newParent can be any Node object (default `null`)
  108557. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108558. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108559. * @returns a new mesh
  108560. */
  108561. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108562. /**
  108563. * Releases resources associated with this mesh.
  108564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108566. */
  108567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108568. /** @hidden */
  108569. _disposeInstanceSpecificData(): void;
  108570. /** @hidden */
  108571. _disposeThinInstanceSpecificData(): void;
  108572. /**
  108573. * Modifies the mesh geometry according to a displacement map.
  108574. * 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.
  108575. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108576. * @param url is a string, the URL from the image file is to be downloaded.
  108577. * @param minHeight is the lower limit of the displacement.
  108578. * @param maxHeight is the upper limit of the displacement.
  108579. * @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.
  108580. * @param uvOffset is an optional vector2 used to offset UV.
  108581. * @param uvScale is an optional vector2 used to scale UV.
  108582. * @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.
  108583. * @returns the Mesh.
  108584. */
  108585. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108586. /**
  108587. * Modifies the mesh geometry according to a displacementMap buffer.
  108588. * 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.
  108589. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108590. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108591. * @param heightMapWidth is the width of the buffer image.
  108592. * @param heightMapHeight is the height of the buffer image.
  108593. * @param minHeight is the lower limit of the displacement.
  108594. * @param maxHeight is the upper limit of the displacement.
  108595. * @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.
  108596. * @param uvOffset is an optional vector2 used to offset UV.
  108597. * @param uvScale is an optional vector2 used to scale UV.
  108598. * @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.
  108599. * @returns the Mesh.
  108600. */
  108601. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108602. /**
  108603. * Modify the mesh to get a flat shading rendering.
  108604. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108605. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108606. * @returns current mesh
  108607. */
  108608. convertToFlatShadedMesh(): Mesh;
  108609. /**
  108610. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108611. * In other words, more vertices, no more indices and a single bigger VBO.
  108612. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108613. * @returns current mesh
  108614. */
  108615. convertToUnIndexedMesh(): Mesh;
  108616. /**
  108617. * Inverses facet orientations.
  108618. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108619. * @param flipNormals will also inverts the normals
  108620. * @returns current mesh
  108621. */
  108622. flipFaces(flipNormals?: boolean): Mesh;
  108623. /**
  108624. * Increase the number of facets and hence vertices in a mesh
  108625. * Vertex normals are interpolated from existing vertex normals
  108626. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108627. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108628. */
  108629. increaseVertices(numberPerEdge: number): void;
  108630. /**
  108631. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108632. * This will undo any application of covertToFlatShadedMesh
  108633. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108634. */
  108635. forceSharedVertices(): void;
  108636. /** @hidden */
  108637. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108638. /** @hidden */
  108639. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108640. /**
  108641. * Creates a new InstancedMesh object from the mesh model.
  108642. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108643. * @param name defines the name of the new instance
  108644. * @returns a new InstancedMesh
  108645. */
  108646. createInstance(name: string): InstancedMesh;
  108647. /**
  108648. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108649. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108650. * @returns the current mesh
  108651. */
  108652. synchronizeInstances(): Mesh;
  108653. /**
  108654. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108655. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108656. * This should be used together with the simplification to avoid disappearing triangles.
  108657. * @param successCallback an optional success callback to be called after the optimization finished.
  108658. * @returns the current mesh
  108659. */
  108660. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108661. /**
  108662. * Serialize current mesh
  108663. * @param serializationObject defines the object which will receive the serialization data
  108664. */
  108665. serialize(serializationObject: any): void;
  108666. /** @hidden */
  108667. _syncGeometryWithMorphTargetManager(): void;
  108668. /** @hidden */
  108669. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108670. /**
  108671. * Returns a new Mesh object parsed from the source provided.
  108672. * @param parsedMesh is the source
  108673. * @param scene defines the hosting scene
  108674. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108675. * @returns a new Mesh
  108676. */
  108677. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108678. /**
  108679. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108680. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108681. * @param name defines the name of the mesh to create
  108682. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108683. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108684. * @param closePath creates a seam between the first and the last points of each path of the path array
  108685. * @param offset is taken in account only if the `pathArray` is containing a single path
  108686. * @param scene defines the hosting scene
  108687. * @param updatable defines if the mesh must be flagged as updatable
  108688. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108689. * @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)
  108690. * @returns a new Mesh
  108691. */
  108692. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108693. /**
  108694. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108695. * @param name defines the name of the mesh to create
  108696. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108697. * @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
  108698. * @param scene defines the hosting scene
  108699. * @param updatable defines if the mesh must be flagged as updatable
  108700. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108701. * @returns a new Mesh
  108702. */
  108703. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108704. /**
  108705. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108706. * @param name defines the name of the mesh to create
  108707. * @param size sets the size (float) of each box side (default 1)
  108708. * @param scene defines the hosting scene
  108709. * @param updatable defines if the mesh must be flagged as updatable
  108710. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108711. * @returns a new Mesh
  108712. */
  108713. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108714. /**
  108715. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108716. * @param name defines the name of the mesh to create
  108717. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108718. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108719. * @param scene defines the hosting scene
  108720. * @param updatable defines if the mesh must be flagged as updatable
  108721. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108722. * @returns a new Mesh
  108723. */
  108724. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108725. /**
  108726. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108727. * @param name defines the name of the mesh to create
  108728. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108729. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108730. * @param scene defines the hosting scene
  108731. * @returns a new Mesh
  108732. */
  108733. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  108734. /**
  108735. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  108736. * @param name defines the name of the mesh to create
  108737. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  108738. * @param diameterTop set the top cap diameter (floats, default 1)
  108739. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  108740. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  108741. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  108742. * @param scene defines the hosting scene
  108743. * @param updatable defines if the mesh must be flagged as updatable
  108744. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108745. * @returns a new Mesh
  108746. */
  108747. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  108748. /**
  108749. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  108750. * @param name defines the name of the mesh to create
  108751. * @param diameter sets the diameter size (float) of the torus (default 1)
  108752. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  108753. * @param tessellation sets the number of torus sides (postive integer, default 16)
  108754. * @param scene defines the hosting scene
  108755. * @param updatable defines if the mesh must be flagged as updatable
  108756. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108757. * @returns a new Mesh
  108758. */
  108759. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108760. /**
  108761. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  108762. * @param name defines the name of the mesh to create
  108763. * @param radius sets the global radius size (float) of the torus knot (default 2)
  108764. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  108765. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  108766. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  108767. * @param p the number of windings on X axis (positive integers, default 2)
  108768. * @param q the number of windings on Y axis (positive integers, default 3)
  108769. * @param scene defines the hosting scene
  108770. * @param updatable defines if the mesh must be flagged as updatable
  108771. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108772. * @returns a new Mesh
  108773. */
  108774. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108775. /**
  108776. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  108777. * @param name defines the name of the mesh to create
  108778. * @param points is an array successive Vector3
  108779. * @param scene defines the hosting scene
  108780. * @param updatable defines if the mesh must be flagged as updatable
  108781. * @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).
  108782. * @returns a new Mesh
  108783. */
  108784. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  108785. /**
  108786. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  108787. * @param name defines the name of the mesh to create
  108788. * @param points is an array successive Vector3
  108789. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  108790. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108791. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  108792. * @param scene defines the hosting scene
  108793. * @param updatable defines if the mesh must be flagged as updatable
  108794. * @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)
  108795. * @returns a new Mesh
  108796. */
  108797. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  108798. /**
  108799. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  108800. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  108801. * 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.
  108802. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108803. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108804. * Remember you can only change the shape positions, not their number when updating a polygon.
  108805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108806. * @param name defines the name of the mesh to create
  108807. * @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
  108808. * @param scene defines the hosting scene
  108809. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108810. * @param updatable defines if the mesh must be flagged as updatable
  108811. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108812. * @param earcutInjection can be used to inject your own earcut reference
  108813. * @returns a new Mesh
  108814. */
  108815. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108816. /**
  108817. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  108818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  108819. * @param name defines the name of the mesh to create
  108820. * @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
  108821. * @param depth defines the height of extrusion
  108822. * @param scene defines the hosting scene
  108823. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108824. * @param updatable defines if the mesh must be flagged as updatable
  108825. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108826. * @param earcutInjection can be used to inject your own earcut reference
  108827. * @returns a new Mesh
  108828. */
  108829. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108830. /**
  108831. * Creates an extruded shape mesh.
  108832. * 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
  108833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108835. * @param name defines the name of the mesh to create
  108836. * @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
  108837. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108838. * @param scale is the value to scale the shape
  108839. * @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
  108840. * @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
  108841. * @param scene defines the hosting scene
  108842. * @param updatable defines if the mesh must be flagged as updatable
  108843. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108844. * @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)
  108845. * @returns a new Mesh
  108846. */
  108847. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108848. /**
  108849. * Creates an custom extruded shape mesh.
  108850. * The custom extrusion is a parametric shape.
  108851. * It has no predefined shape. Its final shape will depend on the input parameters.
  108852. * Please consider using the same method from the MeshBuilder class instead
  108853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108854. * @param name defines the name of the mesh to create
  108855. * @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
  108856. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108857. * @param scaleFunction is a custom Javascript function called on each path point
  108858. * @param rotationFunction is a custom Javascript function called on each path point
  108859. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108860. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  108861. * @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
  108862. * @param scene defines the hosting scene
  108863. * @param updatable defines if the mesh must be flagged as updatable
  108864. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108865. * @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)
  108866. * @returns a new Mesh
  108867. */
  108868. 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;
  108869. /**
  108870. * Creates lathe mesh.
  108871. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  108872. * Please consider using the same method from the MeshBuilder class instead
  108873. * @param name defines the name of the mesh to create
  108874. * @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
  108875. * @param radius is the radius value of the lathe
  108876. * @param tessellation is the side number of the lathe.
  108877. * @param scene defines the hosting scene
  108878. * @param updatable defines if the mesh must be flagged as updatable
  108879. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108880. * @returns a new Mesh
  108881. */
  108882. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108883. /**
  108884. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  108885. * @param name defines the name of the mesh to create
  108886. * @param size sets the size (float) of both sides of the plane at once (default 1)
  108887. * @param scene defines the hosting scene
  108888. * @param updatable defines if the mesh must be flagged as updatable
  108889. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108890. * @returns a new Mesh
  108891. */
  108892. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108893. /**
  108894. * Creates a ground mesh.
  108895. * Please consider using the same method from the MeshBuilder class instead
  108896. * @param name defines the name of the mesh to create
  108897. * @param width set the width of the ground
  108898. * @param height set the height of the ground
  108899. * @param subdivisions sets the number of subdivisions per side
  108900. * @param scene defines the hosting scene
  108901. * @param updatable defines if the mesh must be flagged as updatable
  108902. * @returns a new Mesh
  108903. */
  108904. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  108905. /**
  108906. * Creates a tiled ground mesh.
  108907. * Please consider using the same method from the MeshBuilder class instead
  108908. * @param name defines the name of the mesh to create
  108909. * @param xmin set the ground minimum X coordinate
  108910. * @param zmin set the ground minimum Y coordinate
  108911. * @param xmax set the ground maximum X coordinate
  108912. * @param zmax set the ground maximum Z coordinate
  108913. * @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
  108914. * @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
  108915. * @param scene defines the hosting scene
  108916. * @param updatable defines if the mesh must be flagged as updatable
  108917. * @returns a new Mesh
  108918. */
  108919. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  108920. w: number;
  108921. h: number;
  108922. }, precision: {
  108923. w: number;
  108924. h: number;
  108925. }, scene: Scene, updatable?: boolean): Mesh;
  108926. /**
  108927. * Creates a ground mesh from a height map.
  108928. * Please consider using the same method from the MeshBuilder class instead
  108929. * @see https://doc.babylonjs.com/babylon101/height_map
  108930. * @param name defines the name of the mesh to create
  108931. * @param url sets the URL of the height map image resource
  108932. * @param width set the ground width size
  108933. * @param height set the ground height size
  108934. * @param subdivisions sets the number of subdivision per side
  108935. * @param minHeight is the minimum altitude on the ground
  108936. * @param maxHeight is the maximum altitude on the ground
  108937. * @param scene defines the hosting scene
  108938. * @param updatable defines if the mesh must be flagged as updatable
  108939. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  108940. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108941. * @returns a new Mesh
  108942. */
  108943. 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;
  108944. /**
  108945. * Creates a tube mesh.
  108946. * The tube is a parametric shape.
  108947. * It has no predefined shape. Its final shape will depend on the input parameters.
  108948. * Please consider using the same method from the MeshBuilder class instead
  108949. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108950. * @param name defines the name of the mesh to create
  108951. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  108952. * @param radius sets the tube radius size
  108953. * @param tessellation is the number of sides on the tubular surface
  108954. * @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
  108955. * @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
  108956. * @param scene defines the hosting scene
  108957. * @param updatable defines if the mesh must be flagged as updatable
  108958. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108959. * @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)
  108960. * @returns a new Mesh
  108961. */
  108962. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  108963. (i: number, distance: number): number;
  108964. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108965. /**
  108966. * Creates a polyhedron mesh.
  108967. * Please consider using the same method from the MeshBuilder class instead.
  108968. * * 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
  108969. * * The parameter `size` (positive float, default 1) sets the polygon size
  108970. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108971. * * 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`
  108972. * * 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
  108973. * * 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)`)
  108974. * * 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
  108975. * * 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
  108976. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108979. * @param name defines the name of the mesh to create
  108980. * @param options defines the options used to create the mesh
  108981. * @param scene defines the hosting scene
  108982. * @returns a new Mesh
  108983. */
  108984. static CreatePolyhedron(name: string, options: {
  108985. type?: number;
  108986. size?: number;
  108987. sizeX?: number;
  108988. sizeY?: number;
  108989. sizeZ?: number;
  108990. custom?: any;
  108991. faceUV?: Vector4[];
  108992. faceColors?: Color4[];
  108993. updatable?: boolean;
  108994. sideOrientation?: number;
  108995. }, scene: Scene): Mesh;
  108996. /**
  108997. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108998. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108999. * * 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`)
  109000. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109001. * * 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
  109002. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109005. * @param name defines the name of the mesh
  109006. * @param options defines the options used to create the mesh
  109007. * @param scene defines the hosting scene
  109008. * @returns a new Mesh
  109009. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109010. */
  109011. static CreateIcoSphere(name: string, options: {
  109012. radius?: number;
  109013. flat?: boolean;
  109014. subdivisions?: number;
  109015. sideOrientation?: number;
  109016. updatable?: boolean;
  109017. }, scene: Scene): Mesh;
  109018. /**
  109019. * Creates a decal mesh.
  109020. * Please consider using the same method from the MeshBuilder class instead.
  109021. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109022. * @param name defines the name of the mesh
  109023. * @param sourceMesh defines the mesh receiving the decal
  109024. * @param position sets the position of the decal in world coordinates
  109025. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109026. * @param size sets the decal scaling
  109027. * @param angle sets the angle to rotate the decal
  109028. * @returns a new Mesh
  109029. */
  109030. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109031. /**
  109032. * Prepare internal position array for software CPU skinning
  109033. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109034. */
  109035. setPositionsForCPUSkinning(): Float32Array;
  109036. /**
  109037. * Prepare internal normal array for software CPU skinning
  109038. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109039. */
  109040. setNormalsForCPUSkinning(): Float32Array;
  109041. /**
  109042. * Updates the vertex buffer by applying transformation from the bones
  109043. * @param skeleton defines the skeleton to apply to current mesh
  109044. * @returns the current mesh
  109045. */
  109046. applySkeleton(skeleton: Skeleton): Mesh;
  109047. /**
  109048. * 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
  109049. * @param meshes defines the list of meshes to scan
  109050. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109051. */
  109052. static MinMax(meshes: AbstractMesh[]): {
  109053. min: Vector3;
  109054. max: Vector3;
  109055. };
  109056. /**
  109057. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109058. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109059. * @returns a vector3
  109060. */
  109061. static Center(meshesOrMinMaxVector: {
  109062. min: Vector3;
  109063. max: Vector3;
  109064. } | AbstractMesh[]): Vector3;
  109065. /**
  109066. * Merge the array of meshes into a single mesh for performance reasons.
  109067. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109068. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109069. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109070. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109071. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109072. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109073. * @returns a new mesh
  109074. */
  109075. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109076. /** @hidden */
  109077. addInstance(instance: InstancedMesh): void;
  109078. /** @hidden */
  109079. removeInstance(instance: InstancedMesh): void;
  109080. }
  109081. }
  109082. declare module BABYLON {
  109083. /**
  109084. * This is the base class of all the camera used in the application.
  109085. * @see https://doc.babylonjs.com/features/cameras
  109086. */
  109087. export class Camera extends Node {
  109088. /** @hidden */
  109089. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109090. /**
  109091. * This is the default projection mode used by the cameras.
  109092. * It helps recreating a feeling of perspective and better appreciate depth.
  109093. * This is the best way to simulate real life cameras.
  109094. */
  109095. static readonly PERSPECTIVE_CAMERA: number;
  109096. /**
  109097. * This helps creating camera with an orthographic mode.
  109098. * 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.
  109099. */
  109100. static readonly ORTHOGRAPHIC_CAMERA: number;
  109101. /**
  109102. * This is the default FOV mode for perspective cameras.
  109103. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109104. */
  109105. static readonly FOVMODE_VERTICAL_FIXED: number;
  109106. /**
  109107. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109108. */
  109109. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109110. /**
  109111. * This specifies ther is no need for a camera rig.
  109112. * Basically only one eye is rendered corresponding to the camera.
  109113. */
  109114. static readonly RIG_MODE_NONE: number;
  109115. /**
  109116. * Simulates a camera Rig with one blue eye and one red eye.
  109117. * This can be use with 3d blue and red glasses.
  109118. */
  109119. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109120. /**
  109121. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109122. */
  109123. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109124. /**
  109125. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109126. */
  109127. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109128. /**
  109129. * Defines that both eyes of the camera will be rendered over under each other.
  109130. */
  109131. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109132. /**
  109133. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109134. */
  109135. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109136. /**
  109137. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109138. */
  109139. static readonly RIG_MODE_VR: number;
  109140. /**
  109141. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109142. */
  109143. static readonly RIG_MODE_WEBVR: number;
  109144. /**
  109145. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109146. */
  109147. static readonly RIG_MODE_CUSTOM: number;
  109148. /**
  109149. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109150. */
  109151. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109152. /**
  109153. * Define the input manager associated with the camera.
  109154. */
  109155. inputs: CameraInputsManager<Camera>;
  109156. /** @hidden */
  109157. _position: Vector3;
  109158. /**
  109159. * Define the current local position of the camera in the scene
  109160. */
  109161. get position(): Vector3;
  109162. set position(newPosition: Vector3);
  109163. protected _upVector: Vector3;
  109164. /**
  109165. * The vector the camera should consider as up.
  109166. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109167. */
  109168. set upVector(vec: Vector3);
  109169. get upVector(): Vector3;
  109170. /**
  109171. * Define the current limit on the left side for an orthographic camera
  109172. * In scene unit
  109173. */
  109174. orthoLeft: Nullable<number>;
  109175. /**
  109176. * Define the current limit on the right side for an orthographic camera
  109177. * In scene unit
  109178. */
  109179. orthoRight: Nullable<number>;
  109180. /**
  109181. * Define the current limit on the bottom side for an orthographic camera
  109182. * In scene unit
  109183. */
  109184. orthoBottom: Nullable<number>;
  109185. /**
  109186. * Define the current limit on the top side for an orthographic camera
  109187. * In scene unit
  109188. */
  109189. orthoTop: Nullable<number>;
  109190. /**
  109191. * Field Of View is set in Radians. (default is 0.8)
  109192. */
  109193. fov: number;
  109194. /**
  109195. * Define the minimum distance the camera can see from.
  109196. * This is important to note that the depth buffer are not infinite and the closer it starts
  109197. * the more your scene might encounter depth fighting issue.
  109198. */
  109199. minZ: number;
  109200. /**
  109201. * Define the maximum distance the camera can see to.
  109202. * This is important to note that the depth buffer are not infinite and the further it end
  109203. * the more your scene might encounter depth fighting issue.
  109204. */
  109205. maxZ: number;
  109206. /**
  109207. * Define the default inertia of the camera.
  109208. * This helps giving a smooth feeling to the camera movement.
  109209. */
  109210. inertia: number;
  109211. /**
  109212. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109213. */
  109214. mode: number;
  109215. /**
  109216. * Define whether the camera is intermediate.
  109217. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109218. */
  109219. isIntermediate: boolean;
  109220. /**
  109221. * Define the viewport of the camera.
  109222. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109223. */
  109224. viewport: Viewport;
  109225. /**
  109226. * Restricts the camera to viewing objects with the same layerMask.
  109227. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109228. */
  109229. layerMask: number;
  109230. /**
  109231. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109232. */
  109233. fovMode: number;
  109234. /**
  109235. * Rig mode of the camera.
  109236. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109237. * This is normally controlled byt the camera themselves as internal use.
  109238. */
  109239. cameraRigMode: number;
  109240. /**
  109241. * Defines the distance between both "eyes" in case of a RIG
  109242. */
  109243. interaxialDistance: number;
  109244. /**
  109245. * Defines if stereoscopic rendering is done side by side or over under.
  109246. */
  109247. isStereoscopicSideBySide: boolean;
  109248. /**
  109249. * 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
  109250. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109251. * else in the scene. (Eg. security camera)
  109252. *
  109253. * 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)
  109254. */
  109255. customRenderTargets: RenderTargetTexture[];
  109256. /**
  109257. * When set, the camera will render to this render target instead of the default canvas
  109258. *
  109259. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109260. */
  109261. outputRenderTarget: Nullable<RenderTargetTexture>;
  109262. /**
  109263. * Observable triggered when the camera view matrix has changed.
  109264. */
  109265. onViewMatrixChangedObservable: Observable<Camera>;
  109266. /**
  109267. * Observable triggered when the camera Projection matrix has changed.
  109268. */
  109269. onProjectionMatrixChangedObservable: Observable<Camera>;
  109270. /**
  109271. * Observable triggered when the inputs have been processed.
  109272. */
  109273. onAfterCheckInputsObservable: Observable<Camera>;
  109274. /**
  109275. * Observable triggered when reset has been called and applied to the camera.
  109276. */
  109277. onRestoreStateObservable: Observable<Camera>;
  109278. /**
  109279. * Is this camera a part of a rig system?
  109280. */
  109281. isRigCamera: boolean;
  109282. /**
  109283. * If isRigCamera set to true this will be set with the parent camera.
  109284. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109285. */
  109286. rigParent?: Camera;
  109287. /** @hidden */
  109288. _cameraRigParams: any;
  109289. /** @hidden */
  109290. _rigCameras: Camera[];
  109291. /** @hidden */
  109292. _rigPostProcess: Nullable<PostProcess>;
  109293. protected _webvrViewMatrix: Matrix;
  109294. /** @hidden */
  109295. _skipRendering: boolean;
  109296. /** @hidden */
  109297. _projectionMatrix: Matrix;
  109298. /** @hidden */
  109299. _postProcesses: Nullable<PostProcess>[];
  109300. /** @hidden */
  109301. _activeMeshes: SmartArray<AbstractMesh>;
  109302. protected _globalPosition: Vector3;
  109303. /** @hidden */
  109304. _computedViewMatrix: Matrix;
  109305. private _doNotComputeProjectionMatrix;
  109306. private _transformMatrix;
  109307. private _frustumPlanes;
  109308. private _refreshFrustumPlanes;
  109309. private _storedFov;
  109310. private _stateStored;
  109311. /**
  109312. * Instantiates a new camera object.
  109313. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109314. * @see https://doc.babylonjs.com/features/cameras
  109315. * @param name Defines the name of the camera in the scene
  109316. * @param position Defines the position of the camera
  109317. * @param scene Defines the scene the camera belongs too
  109318. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109319. */
  109320. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109321. /**
  109322. * Store current camera state (fov, position, etc..)
  109323. * @returns the camera
  109324. */
  109325. storeState(): Camera;
  109326. /**
  109327. * Restores the camera state values if it has been stored. You must call storeState() first
  109328. */
  109329. protected _restoreStateValues(): boolean;
  109330. /**
  109331. * Restored camera state. You must call storeState() first.
  109332. * @returns true if restored and false otherwise
  109333. */
  109334. restoreState(): boolean;
  109335. /**
  109336. * Gets the class name of the camera.
  109337. * @returns the class name
  109338. */
  109339. getClassName(): string;
  109340. /** @hidden */
  109341. readonly _isCamera: boolean;
  109342. /**
  109343. * Gets a string representation of the camera useful for debug purpose.
  109344. * @param fullDetails Defines that a more verboe level of logging is required
  109345. * @returns the string representation
  109346. */
  109347. toString(fullDetails?: boolean): string;
  109348. /**
  109349. * Gets the current world space position of the camera.
  109350. */
  109351. get globalPosition(): Vector3;
  109352. /**
  109353. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109354. * @returns the active meshe list
  109355. */
  109356. getActiveMeshes(): SmartArray<AbstractMesh>;
  109357. /**
  109358. * Check whether a mesh is part of the current active mesh list of the camera
  109359. * @param mesh Defines the mesh to check
  109360. * @returns true if active, false otherwise
  109361. */
  109362. isActiveMesh(mesh: Mesh): boolean;
  109363. /**
  109364. * Is this camera ready to be used/rendered
  109365. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109366. * @return true if the camera is ready
  109367. */
  109368. isReady(completeCheck?: boolean): boolean;
  109369. /** @hidden */
  109370. _initCache(): void;
  109371. /** @hidden */
  109372. _updateCache(ignoreParentClass?: boolean): void;
  109373. /** @hidden */
  109374. _isSynchronized(): boolean;
  109375. /** @hidden */
  109376. _isSynchronizedViewMatrix(): boolean;
  109377. /** @hidden */
  109378. _isSynchronizedProjectionMatrix(): boolean;
  109379. /**
  109380. * Attach the input controls to a specific dom element to get the input from.
  109381. * @param element Defines the element the controls should be listened from
  109382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109383. */
  109384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109385. /**
  109386. * Detach the current controls from the specified dom element.
  109387. * @param element Defines the element to stop listening the inputs from
  109388. */
  109389. detachControl(element: HTMLElement): void;
  109390. /**
  109391. * Update the camera state according to the different inputs gathered during the frame.
  109392. */
  109393. update(): void;
  109394. /** @hidden */
  109395. _checkInputs(): void;
  109396. /** @hidden */
  109397. get rigCameras(): Camera[];
  109398. /**
  109399. * Gets the post process used by the rig cameras
  109400. */
  109401. get rigPostProcess(): Nullable<PostProcess>;
  109402. /**
  109403. * Internal, gets the first post proces.
  109404. * @returns the first post process to be run on this camera.
  109405. */
  109406. _getFirstPostProcess(): Nullable<PostProcess>;
  109407. private _cascadePostProcessesToRigCams;
  109408. /**
  109409. * Attach a post process to the camera.
  109410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109411. * @param postProcess The post process to attach to the camera
  109412. * @param insertAt The position of the post process in case several of them are in use in the scene
  109413. * @returns the position the post process has been inserted at
  109414. */
  109415. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109416. /**
  109417. * Detach a post process to the camera.
  109418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109419. * @param postProcess The post process to detach from the camera
  109420. */
  109421. detachPostProcess(postProcess: PostProcess): void;
  109422. /**
  109423. * Gets the current world matrix of the camera
  109424. */
  109425. getWorldMatrix(): Matrix;
  109426. /** @hidden */
  109427. _getViewMatrix(): Matrix;
  109428. /**
  109429. * Gets the current view matrix of the camera.
  109430. * @param force forces the camera to recompute the matrix without looking at the cached state
  109431. * @returns the view matrix
  109432. */
  109433. getViewMatrix(force?: boolean): Matrix;
  109434. /**
  109435. * Freeze the projection matrix.
  109436. * It will prevent the cache check of the camera projection compute and can speed up perf
  109437. * if no parameter of the camera are meant to change
  109438. * @param projection Defines manually a projection if necessary
  109439. */
  109440. freezeProjectionMatrix(projection?: Matrix): void;
  109441. /**
  109442. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  109443. */
  109444. unfreezeProjectionMatrix(): void;
  109445. /**
  109446. * Gets the current projection matrix of the camera.
  109447. * @param force forces the camera to recompute the matrix without looking at the cached state
  109448. * @returns the projection matrix
  109449. */
  109450. getProjectionMatrix(force?: boolean): Matrix;
  109451. /**
  109452. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  109453. * @returns a Matrix
  109454. */
  109455. getTransformationMatrix(): Matrix;
  109456. private _updateFrustumPlanes;
  109457. /**
  109458. * Checks if a cullable object (mesh...) is in the camera frustum
  109459. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  109460. * @param target The object to check
  109461. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  109462. * @returns true if the object is in frustum otherwise false
  109463. */
  109464. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  109465. /**
  109466. * Checks if a cullable object (mesh...) is in the camera frustum
  109467. * Unlike isInFrustum this cheks the full bounding box
  109468. * @param target The object to check
  109469. * @returns true if the object is in frustum otherwise false
  109470. */
  109471. isCompletelyInFrustum(target: ICullable): boolean;
  109472. /**
  109473. * Gets a ray in the forward direction from the camera.
  109474. * @param length Defines the length of the ray to create
  109475. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109476. * @param origin Defines the start point of the ray which defaults to the camera position
  109477. * @returns the forward ray
  109478. */
  109479. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109480. /**
  109481. * Gets a ray in the forward direction from the camera.
  109482. * @param refRay the ray to (re)use when setting the values
  109483. * @param length Defines the length of the ray to create
  109484. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109485. * @param origin Defines the start point of the ray which defaults to the camera position
  109486. * @returns the forward ray
  109487. */
  109488. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109489. /**
  109490. * Releases resources associated with this node.
  109491. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109492. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109493. */
  109494. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109495. /** @hidden */
  109496. _isLeftCamera: boolean;
  109497. /**
  109498. * Gets the left camera of a rig setup in case of Rigged Camera
  109499. */
  109500. get isLeftCamera(): boolean;
  109501. /** @hidden */
  109502. _isRightCamera: boolean;
  109503. /**
  109504. * Gets the right camera of a rig setup in case of Rigged Camera
  109505. */
  109506. get isRightCamera(): boolean;
  109507. /**
  109508. * Gets the left camera of a rig setup in case of Rigged Camera
  109509. */
  109510. get leftCamera(): Nullable<FreeCamera>;
  109511. /**
  109512. * Gets the right camera of a rig setup in case of Rigged Camera
  109513. */
  109514. get rightCamera(): Nullable<FreeCamera>;
  109515. /**
  109516. * Gets the left camera target of a rig setup in case of Rigged Camera
  109517. * @returns the target position
  109518. */
  109519. getLeftTarget(): Nullable<Vector3>;
  109520. /**
  109521. * Gets the right camera target of a rig setup in case of Rigged Camera
  109522. * @returns the target position
  109523. */
  109524. getRightTarget(): Nullable<Vector3>;
  109525. /**
  109526. * @hidden
  109527. */
  109528. setCameraRigMode(mode: number, rigParams: any): void;
  109529. /** @hidden */
  109530. static _setStereoscopicRigMode(camera: Camera): void;
  109531. /** @hidden */
  109532. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109533. /** @hidden */
  109534. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109535. /** @hidden */
  109536. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109537. /** @hidden */
  109538. _getVRProjectionMatrix(): Matrix;
  109539. protected _updateCameraRotationMatrix(): void;
  109540. protected _updateWebVRCameraRotationMatrix(): void;
  109541. /**
  109542. * This function MUST be overwritten by the different WebVR cameras available.
  109543. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109544. * @hidden
  109545. */
  109546. _getWebVRProjectionMatrix(): Matrix;
  109547. /**
  109548. * This function MUST be overwritten by the different WebVR cameras available.
  109549. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109550. * @hidden
  109551. */
  109552. _getWebVRViewMatrix(): Matrix;
  109553. /** @hidden */
  109554. setCameraRigParameter(name: string, value: any): void;
  109555. /**
  109556. * needs to be overridden by children so sub has required properties to be copied
  109557. * @hidden
  109558. */
  109559. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109560. /**
  109561. * May need to be overridden by children
  109562. * @hidden
  109563. */
  109564. _updateRigCameras(): void;
  109565. /** @hidden */
  109566. _setupInputs(): void;
  109567. /**
  109568. * Serialiaze the camera setup to a json represention
  109569. * @returns the JSON representation
  109570. */
  109571. serialize(): any;
  109572. /**
  109573. * Clones the current camera.
  109574. * @param name The cloned camera name
  109575. * @returns the cloned camera
  109576. */
  109577. clone(name: string): Camera;
  109578. /**
  109579. * Gets the direction of the camera relative to a given local axis.
  109580. * @param localAxis Defines the reference axis to provide a relative direction.
  109581. * @return the direction
  109582. */
  109583. getDirection(localAxis: Vector3): Vector3;
  109584. /**
  109585. * Returns the current camera absolute rotation
  109586. */
  109587. get absoluteRotation(): Quaternion;
  109588. /**
  109589. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109590. * @param localAxis Defines the reference axis to provide a relative direction.
  109591. * @param result Defines the vector to store the result in
  109592. */
  109593. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109594. /**
  109595. * Gets a camera constructor for a given camera type
  109596. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109597. * @param name The name of the camera the result will be able to instantiate
  109598. * @param scene The scene the result will construct the camera in
  109599. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109600. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109601. * @returns a factory method to construc the camera
  109602. */
  109603. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109604. /**
  109605. * Compute the world matrix of the camera.
  109606. * @returns the camera world matrix
  109607. */
  109608. computeWorldMatrix(): Matrix;
  109609. /**
  109610. * Parse a JSON and creates the camera from the parsed information
  109611. * @param parsedCamera The JSON to parse
  109612. * @param scene The scene to instantiate the camera in
  109613. * @returns the newly constructed camera
  109614. */
  109615. static Parse(parsedCamera: any, scene: Scene): Camera;
  109616. }
  109617. }
  109618. declare module BABYLON {
  109619. /**
  109620. * Class containing static functions to help procedurally build meshes
  109621. */
  109622. export class DiscBuilder {
  109623. /**
  109624. * Creates a plane polygonal mesh. By default, this is a disc
  109625. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109626. * * 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
  109627. * * 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
  109628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109631. * @param name defines the name of the mesh
  109632. * @param options defines the options used to create the mesh
  109633. * @param scene defines the hosting scene
  109634. * @returns the plane polygonal mesh
  109635. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109636. */
  109637. static CreateDisc(name: string, options: {
  109638. radius?: number;
  109639. tessellation?: number;
  109640. arc?: number;
  109641. updatable?: boolean;
  109642. sideOrientation?: number;
  109643. frontUVs?: Vector4;
  109644. backUVs?: Vector4;
  109645. }, scene?: Nullable<Scene>): Mesh;
  109646. }
  109647. }
  109648. declare module BABYLON {
  109649. /**
  109650. * Options to be used when creating a FresnelParameters.
  109651. */
  109652. export type IFresnelParametersCreationOptions = {
  109653. /**
  109654. * Define the color used on edges (grazing angle)
  109655. */
  109656. leftColor?: Color3;
  109657. /**
  109658. * Define the color used on center
  109659. */
  109660. rightColor?: Color3;
  109661. /**
  109662. * Define bias applied to computed fresnel term
  109663. */
  109664. bias?: number;
  109665. /**
  109666. * Defined the power exponent applied to fresnel term
  109667. */
  109668. power?: number;
  109669. /**
  109670. * Define if the fresnel effect is enable or not.
  109671. */
  109672. isEnabled?: boolean;
  109673. };
  109674. /**
  109675. * Serialized format for FresnelParameters.
  109676. */
  109677. export type IFresnelParametersSerialized = {
  109678. /**
  109679. * Define the color used on edges (grazing angle) [as an array]
  109680. */
  109681. leftColor: number[];
  109682. /**
  109683. * Define the color used on center [as an array]
  109684. */
  109685. rightColor: number[];
  109686. /**
  109687. * Define bias applied to computed fresnel term
  109688. */
  109689. bias: number;
  109690. /**
  109691. * Defined the power exponent applied to fresnel term
  109692. */
  109693. power?: number;
  109694. /**
  109695. * Define if the fresnel effect is enable or not.
  109696. */
  109697. isEnabled: boolean;
  109698. };
  109699. /**
  109700. * This represents all the required information to add a fresnel effect on a material:
  109701. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109702. */
  109703. export class FresnelParameters {
  109704. private _isEnabled;
  109705. /**
  109706. * Define if the fresnel effect is enable or not.
  109707. */
  109708. get isEnabled(): boolean;
  109709. set isEnabled(value: boolean);
  109710. /**
  109711. * Define the color used on edges (grazing angle)
  109712. */
  109713. leftColor: Color3;
  109714. /**
  109715. * Define the color used on center
  109716. */
  109717. rightColor: Color3;
  109718. /**
  109719. * Define bias applied to computed fresnel term
  109720. */
  109721. bias: number;
  109722. /**
  109723. * Defined the power exponent applied to fresnel term
  109724. */
  109725. power: number;
  109726. /**
  109727. * Creates a new FresnelParameters object.
  109728. *
  109729. * @param options provide your own settings to optionally to override defaults
  109730. */
  109731. constructor(options?: IFresnelParametersCreationOptions);
  109732. /**
  109733. * Clones the current fresnel and its valuues
  109734. * @returns a clone fresnel configuration
  109735. */
  109736. clone(): FresnelParameters;
  109737. /**
  109738. * Determines equality between FresnelParameters objects
  109739. * @param otherFresnelParameters defines the second operand
  109740. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  109741. */
  109742. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  109743. /**
  109744. * Serializes the current fresnel parameters to a JSON representation.
  109745. * @return the JSON serialization
  109746. */
  109747. serialize(): IFresnelParametersSerialized;
  109748. /**
  109749. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  109750. * @param parsedFresnelParameters Define the JSON representation
  109751. * @returns the parsed parameters
  109752. */
  109753. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  109754. }
  109755. }
  109756. declare module BABYLON {
  109757. /**
  109758. * This groups all the flags used to control the materials channel.
  109759. */
  109760. export class MaterialFlags {
  109761. private static _DiffuseTextureEnabled;
  109762. /**
  109763. * Are diffuse textures enabled in the application.
  109764. */
  109765. static get DiffuseTextureEnabled(): boolean;
  109766. static set DiffuseTextureEnabled(value: boolean);
  109767. private static _DetailTextureEnabled;
  109768. /**
  109769. * Are detail textures enabled in the application.
  109770. */
  109771. static get DetailTextureEnabled(): boolean;
  109772. static set DetailTextureEnabled(value: boolean);
  109773. private static _AmbientTextureEnabled;
  109774. /**
  109775. * Are ambient textures enabled in the application.
  109776. */
  109777. static get AmbientTextureEnabled(): boolean;
  109778. static set AmbientTextureEnabled(value: boolean);
  109779. private static _OpacityTextureEnabled;
  109780. /**
  109781. * Are opacity textures enabled in the application.
  109782. */
  109783. static get OpacityTextureEnabled(): boolean;
  109784. static set OpacityTextureEnabled(value: boolean);
  109785. private static _ReflectionTextureEnabled;
  109786. /**
  109787. * Are reflection textures enabled in the application.
  109788. */
  109789. static get ReflectionTextureEnabled(): boolean;
  109790. static set ReflectionTextureEnabled(value: boolean);
  109791. private static _EmissiveTextureEnabled;
  109792. /**
  109793. * Are emissive textures enabled in the application.
  109794. */
  109795. static get EmissiveTextureEnabled(): boolean;
  109796. static set EmissiveTextureEnabled(value: boolean);
  109797. private static _SpecularTextureEnabled;
  109798. /**
  109799. * Are specular textures enabled in the application.
  109800. */
  109801. static get SpecularTextureEnabled(): boolean;
  109802. static set SpecularTextureEnabled(value: boolean);
  109803. private static _BumpTextureEnabled;
  109804. /**
  109805. * Are bump textures enabled in the application.
  109806. */
  109807. static get BumpTextureEnabled(): boolean;
  109808. static set BumpTextureEnabled(value: boolean);
  109809. private static _LightmapTextureEnabled;
  109810. /**
  109811. * Are lightmap textures enabled in the application.
  109812. */
  109813. static get LightmapTextureEnabled(): boolean;
  109814. static set LightmapTextureEnabled(value: boolean);
  109815. private static _RefractionTextureEnabled;
  109816. /**
  109817. * Are refraction textures enabled in the application.
  109818. */
  109819. static get RefractionTextureEnabled(): boolean;
  109820. static set RefractionTextureEnabled(value: boolean);
  109821. private static _ColorGradingTextureEnabled;
  109822. /**
  109823. * Are color grading textures enabled in the application.
  109824. */
  109825. static get ColorGradingTextureEnabled(): boolean;
  109826. static set ColorGradingTextureEnabled(value: boolean);
  109827. private static _FresnelEnabled;
  109828. /**
  109829. * Are fresnels enabled in the application.
  109830. */
  109831. static get FresnelEnabled(): boolean;
  109832. static set FresnelEnabled(value: boolean);
  109833. private static _ClearCoatTextureEnabled;
  109834. /**
  109835. * Are clear coat textures enabled in the application.
  109836. */
  109837. static get ClearCoatTextureEnabled(): boolean;
  109838. static set ClearCoatTextureEnabled(value: boolean);
  109839. private static _ClearCoatBumpTextureEnabled;
  109840. /**
  109841. * Are clear coat bump textures enabled in the application.
  109842. */
  109843. static get ClearCoatBumpTextureEnabled(): boolean;
  109844. static set ClearCoatBumpTextureEnabled(value: boolean);
  109845. private static _ClearCoatTintTextureEnabled;
  109846. /**
  109847. * Are clear coat tint textures enabled in the application.
  109848. */
  109849. static get ClearCoatTintTextureEnabled(): boolean;
  109850. static set ClearCoatTintTextureEnabled(value: boolean);
  109851. private static _SheenTextureEnabled;
  109852. /**
  109853. * Are sheen textures enabled in the application.
  109854. */
  109855. static get SheenTextureEnabled(): boolean;
  109856. static set SheenTextureEnabled(value: boolean);
  109857. private static _AnisotropicTextureEnabled;
  109858. /**
  109859. * Are anisotropic textures enabled in the application.
  109860. */
  109861. static get AnisotropicTextureEnabled(): boolean;
  109862. static set AnisotropicTextureEnabled(value: boolean);
  109863. private static _ThicknessTextureEnabled;
  109864. /**
  109865. * Are thickness textures enabled in the application.
  109866. */
  109867. static get ThicknessTextureEnabled(): boolean;
  109868. static set ThicknessTextureEnabled(value: boolean);
  109869. }
  109870. }
  109871. declare module BABYLON {
  109872. /** @hidden */
  109873. export var defaultFragmentDeclaration: {
  109874. name: string;
  109875. shader: string;
  109876. };
  109877. }
  109878. declare module BABYLON {
  109879. /** @hidden */
  109880. export var defaultUboDeclaration: {
  109881. name: string;
  109882. shader: string;
  109883. };
  109884. }
  109885. declare module BABYLON {
  109886. /** @hidden */
  109887. export var prePassDeclaration: {
  109888. name: string;
  109889. shader: string;
  109890. };
  109891. }
  109892. declare module BABYLON {
  109893. /** @hidden */
  109894. export var lightFragmentDeclaration: {
  109895. name: string;
  109896. shader: string;
  109897. };
  109898. }
  109899. declare module BABYLON {
  109900. /** @hidden */
  109901. export var lightUboDeclaration: {
  109902. name: string;
  109903. shader: string;
  109904. };
  109905. }
  109906. declare module BABYLON {
  109907. /** @hidden */
  109908. export var lightsFragmentFunctions: {
  109909. name: string;
  109910. shader: string;
  109911. };
  109912. }
  109913. declare module BABYLON {
  109914. /** @hidden */
  109915. export var shadowsFragmentFunctions: {
  109916. name: string;
  109917. shader: string;
  109918. };
  109919. }
  109920. declare module BABYLON {
  109921. /** @hidden */
  109922. export var fresnelFunction: {
  109923. name: string;
  109924. shader: string;
  109925. };
  109926. }
  109927. declare module BABYLON {
  109928. /** @hidden */
  109929. export var bumpFragmentMainFunctions: {
  109930. name: string;
  109931. shader: string;
  109932. };
  109933. }
  109934. declare module BABYLON {
  109935. /** @hidden */
  109936. export var bumpFragmentFunctions: {
  109937. name: string;
  109938. shader: string;
  109939. };
  109940. }
  109941. declare module BABYLON {
  109942. /** @hidden */
  109943. export var logDepthDeclaration: {
  109944. name: string;
  109945. shader: string;
  109946. };
  109947. }
  109948. declare module BABYLON {
  109949. /** @hidden */
  109950. export var bumpFragment: {
  109951. name: string;
  109952. shader: string;
  109953. };
  109954. }
  109955. declare module BABYLON {
  109956. /** @hidden */
  109957. export var depthPrePass: {
  109958. name: string;
  109959. shader: string;
  109960. };
  109961. }
  109962. declare module BABYLON {
  109963. /** @hidden */
  109964. export var lightFragment: {
  109965. name: string;
  109966. shader: string;
  109967. };
  109968. }
  109969. declare module BABYLON {
  109970. /** @hidden */
  109971. export var logDepthFragment: {
  109972. name: string;
  109973. shader: string;
  109974. };
  109975. }
  109976. declare module BABYLON {
  109977. /** @hidden */
  109978. export var defaultPixelShader: {
  109979. name: string;
  109980. shader: string;
  109981. };
  109982. }
  109983. declare module BABYLON {
  109984. /** @hidden */
  109985. export var defaultVertexDeclaration: {
  109986. name: string;
  109987. shader: string;
  109988. };
  109989. }
  109990. declare module BABYLON {
  109991. /** @hidden */
  109992. export var bumpVertexDeclaration: {
  109993. name: string;
  109994. shader: string;
  109995. };
  109996. }
  109997. declare module BABYLON {
  109998. /** @hidden */
  109999. export var bumpVertex: {
  110000. name: string;
  110001. shader: string;
  110002. };
  110003. }
  110004. declare module BABYLON {
  110005. /** @hidden */
  110006. export var fogVertex: {
  110007. name: string;
  110008. shader: string;
  110009. };
  110010. }
  110011. declare module BABYLON {
  110012. /** @hidden */
  110013. export var shadowsVertex: {
  110014. name: string;
  110015. shader: string;
  110016. };
  110017. }
  110018. declare module BABYLON {
  110019. /** @hidden */
  110020. export var pointCloudVertex: {
  110021. name: string;
  110022. shader: string;
  110023. };
  110024. }
  110025. declare module BABYLON {
  110026. /** @hidden */
  110027. export var logDepthVertex: {
  110028. name: string;
  110029. shader: string;
  110030. };
  110031. }
  110032. declare module BABYLON {
  110033. /** @hidden */
  110034. export var defaultVertexShader: {
  110035. name: string;
  110036. shader: string;
  110037. };
  110038. }
  110039. declare module BABYLON {
  110040. /**
  110041. * @hidden
  110042. */
  110043. export interface IMaterialDetailMapDefines {
  110044. DETAIL: boolean;
  110045. DETAILDIRECTUV: number;
  110046. DETAIL_NORMALBLENDMETHOD: number;
  110047. /** @hidden */
  110048. _areTexturesDirty: boolean;
  110049. }
  110050. /**
  110051. * Define the code related to the detail map parameters of a material
  110052. *
  110053. * Inspired from:
  110054. * 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
  110055. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110056. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110057. */
  110058. export class DetailMapConfiguration {
  110059. private _texture;
  110060. /**
  110061. * The detail texture of the material.
  110062. */
  110063. texture: Nullable<BaseTexture>;
  110064. /**
  110065. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110066. * Bigger values mean stronger blending
  110067. */
  110068. diffuseBlendLevel: number;
  110069. /**
  110070. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110071. * Bigger values mean stronger blending. Only used with PBR materials
  110072. */
  110073. roughnessBlendLevel: number;
  110074. /**
  110075. * Defines how strong the bump effect from the detail map is
  110076. * Bigger values mean stronger effect
  110077. */
  110078. bumpLevel: number;
  110079. private _normalBlendMethod;
  110080. /**
  110081. * The method used to blend the bump and detail normals together
  110082. */
  110083. normalBlendMethod: number;
  110084. private _isEnabled;
  110085. /**
  110086. * Enable or disable the detail map on this material
  110087. */
  110088. isEnabled: boolean;
  110089. /** @hidden */
  110090. private _internalMarkAllSubMeshesAsTexturesDirty;
  110091. /** @hidden */
  110092. _markAllSubMeshesAsTexturesDirty(): void;
  110093. /**
  110094. * Instantiate a new detail map
  110095. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110096. */
  110097. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110098. /**
  110099. * Gets whether the submesh is ready to be used or not.
  110100. * @param defines the list of "defines" to update.
  110101. * @param scene defines the scene the material belongs to.
  110102. * @returns - boolean indicating that the submesh is ready or not.
  110103. */
  110104. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110105. /**
  110106. * Update the defines for detail map usage
  110107. * @param defines the list of "defines" to update.
  110108. * @param scene defines the scene the material belongs to.
  110109. */
  110110. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110111. /**
  110112. * Binds the material data.
  110113. * @param uniformBuffer defines the Uniform buffer to fill in.
  110114. * @param scene defines the scene the material belongs to.
  110115. * @param isFrozen defines whether the material is frozen or not.
  110116. */
  110117. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110118. /**
  110119. * Checks to see if a texture is used in the material.
  110120. * @param texture - Base texture to use.
  110121. * @returns - Boolean specifying if a texture is used in the material.
  110122. */
  110123. hasTexture(texture: BaseTexture): boolean;
  110124. /**
  110125. * Returns an array of the actively used textures.
  110126. * @param activeTextures Array of BaseTextures
  110127. */
  110128. getActiveTextures(activeTextures: BaseTexture[]): void;
  110129. /**
  110130. * Returns the animatable textures.
  110131. * @param animatables Array of animatable textures.
  110132. */
  110133. getAnimatables(animatables: IAnimatable[]): void;
  110134. /**
  110135. * Disposes the resources of the material.
  110136. * @param forceDisposeTextures - Forces the disposal of all textures.
  110137. */
  110138. dispose(forceDisposeTextures?: boolean): void;
  110139. /**
  110140. * Get the current class name useful for serialization or dynamic coding.
  110141. * @returns "DetailMap"
  110142. */
  110143. getClassName(): string;
  110144. /**
  110145. * Add the required uniforms to the current list.
  110146. * @param uniforms defines the current uniform list.
  110147. */
  110148. static AddUniforms(uniforms: string[]): void;
  110149. /**
  110150. * Add the required samplers to the current list.
  110151. * @param samplers defines the current sampler list.
  110152. */
  110153. static AddSamplers(samplers: string[]): void;
  110154. /**
  110155. * Add the required uniforms to the current buffer.
  110156. * @param uniformBuffer defines the current uniform buffer.
  110157. */
  110158. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110159. /**
  110160. * Makes a duplicate of the current instance into another one.
  110161. * @param detailMap define the instance where to copy the info
  110162. */
  110163. copyTo(detailMap: DetailMapConfiguration): void;
  110164. /**
  110165. * Serializes this detail map instance
  110166. * @returns - An object with the serialized instance.
  110167. */
  110168. serialize(): any;
  110169. /**
  110170. * Parses a detail map setting from a serialized object.
  110171. * @param source - Serialized object.
  110172. * @param scene Defines the scene we are parsing for
  110173. * @param rootUrl Defines the rootUrl to load from
  110174. */
  110175. parse(source: any, scene: Scene, rootUrl: string): void;
  110176. }
  110177. }
  110178. declare module BABYLON {
  110179. /** @hidden */
  110180. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110181. MAINUV1: boolean;
  110182. MAINUV2: boolean;
  110183. DIFFUSE: boolean;
  110184. DIFFUSEDIRECTUV: number;
  110185. DETAIL: boolean;
  110186. DETAILDIRECTUV: number;
  110187. DETAIL_NORMALBLENDMETHOD: number;
  110188. AMBIENT: boolean;
  110189. AMBIENTDIRECTUV: number;
  110190. OPACITY: boolean;
  110191. OPACITYDIRECTUV: number;
  110192. OPACITYRGB: boolean;
  110193. REFLECTION: boolean;
  110194. EMISSIVE: boolean;
  110195. EMISSIVEDIRECTUV: number;
  110196. SPECULAR: boolean;
  110197. SPECULARDIRECTUV: number;
  110198. BUMP: boolean;
  110199. BUMPDIRECTUV: number;
  110200. PARALLAX: boolean;
  110201. PARALLAXOCCLUSION: boolean;
  110202. SPECULAROVERALPHA: boolean;
  110203. CLIPPLANE: boolean;
  110204. CLIPPLANE2: boolean;
  110205. CLIPPLANE3: boolean;
  110206. CLIPPLANE4: boolean;
  110207. CLIPPLANE5: boolean;
  110208. CLIPPLANE6: boolean;
  110209. ALPHATEST: boolean;
  110210. DEPTHPREPASS: boolean;
  110211. ALPHAFROMDIFFUSE: boolean;
  110212. POINTSIZE: boolean;
  110213. FOG: boolean;
  110214. SPECULARTERM: boolean;
  110215. DIFFUSEFRESNEL: boolean;
  110216. OPACITYFRESNEL: boolean;
  110217. REFLECTIONFRESNEL: boolean;
  110218. REFRACTIONFRESNEL: boolean;
  110219. EMISSIVEFRESNEL: boolean;
  110220. FRESNEL: boolean;
  110221. NORMAL: boolean;
  110222. UV1: boolean;
  110223. UV2: boolean;
  110224. VERTEXCOLOR: boolean;
  110225. VERTEXALPHA: boolean;
  110226. NUM_BONE_INFLUENCERS: number;
  110227. BonesPerMesh: number;
  110228. BONETEXTURE: boolean;
  110229. INSTANCES: boolean;
  110230. THIN_INSTANCES: boolean;
  110231. GLOSSINESS: boolean;
  110232. ROUGHNESS: boolean;
  110233. EMISSIVEASILLUMINATION: boolean;
  110234. LINKEMISSIVEWITHDIFFUSE: boolean;
  110235. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110236. LIGHTMAP: boolean;
  110237. LIGHTMAPDIRECTUV: number;
  110238. OBJECTSPACE_NORMALMAP: boolean;
  110239. USELIGHTMAPASSHADOWMAP: boolean;
  110240. REFLECTIONMAP_3D: boolean;
  110241. REFLECTIONMAP_SPHERICAL: boolean;
  110242. REFLECTIONMAP_PLANAR: boolean;
  110243. REFLECTIONMAP_CUBIC: boolean;
  110244. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110245. REFLECTIONMAP_PROJECTION: boolean;
  110246. REFLECTIONMAP_SKYBOX: boolean;
  110247. REFLECTIONMAP_EXPLICIT: boolean;
  110248. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110249. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110250. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110251. INVERTCUBICMAP: boolean;
  110252. LOGARITHMICDEPTH: boolean;
  110253. REFRACTION: boolean;
  110254. REFRACTIONMAP_3D: boolean;
  110255. REFLECTIONOVERALPHA: boolean;
  110256. TWOSIDEDLIGHTING: boolean;
  110257. SHADOWFLOAT: boolean;
  110258. MORPHTARGETS: boolean;
  110259. MORPHTARGETS_NORMAL: boolean;
  110260. MORPHTARGETS_TANGENT: boolean;
  110261. MORPHTARGETS_UV: boolean;
  110262. NUM_MORPH_INFLUENCERS: number;
  110263. NONUNIFORMSCALING: boolean;
  110264. PREMULTIPLYALPHA: boolean;
  110265. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110266. ALPHABLEND: boolean;
  110267. PREPASS: boolean;
  110268. SCENE_MRT_COUNT: number;
  110269. RGBDLIGHTMAP: boolean;
  110270. RGBDREFLECTION: boolean;
  110271. RGBDREFRACTION: boolean;
  110272. IMAGEPROCESSING: boolean;
  110273. VIGNETTE: boolean;
  110274. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110275. VIGNETTEBLENDMODEOPAQUE: boolean;
  110276. TONEMAPPING: boolean;
  110277. TONEMAPPING_ACES: boolean;
  110278. CONTRAST: boolean;
  110279. COLORCURVES: boolean;
  110280. COLORGRADING: boolean;
  110281. COLORGRADING3D: boolean;
  110282. SAMPLER3DGREENDEPTH: boolean;
  110283. SAMPLER3DBGRMAP: boolean;
  110284. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110285. MULTIVIEW: boolean;
  110286. /**
  110287. * If the reflection texture on this material is in linear color space
  110288. * @hidden
  110289. */
  110290. IS_REFLECTION_LINEAR: boolean;
  110291. /**
  110292. * If the refraction texture on this material is in linear color space
  110293. * @hidden
  110294. */
  110295. IS_REFRACTION_LINEAR: boolean;
  110296. EXPOSURE: boolean;
  110297. constructor();
  110298. setReflectionMode(modeToEnable: string): void;
  110299. }
  110300. /**
  110301. * This is the default material used in Babylon. It is the best trade off between quality
  110302. * and performances.
  110303. * @see https://doc.babylonjs.com/babylon101/materials
  110304. */
  110305. export class StandardMaterial extends PushMaterial {
  110306. private _diffuseTexture;
  110307. /**
  110308. * The basic texture of the material as viewed under a light.
  110309. */
  110310. diffuseTexture: Nullable<BaseTexture>;
  110311. private _ambientTexture;
  110312. /**
  110313. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110314. */
  110315. ambientTexture: Nullable<BaseTexture>;
  110316. private _opacityTexture;
  110317. /**
  110318. * Define the transparency of the material from a texture.
  110319. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110320. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110321. */
  110322. opacityTexture: Nullable<BaseTexture>;
  110323. private _reflectionTexture;
  110324. /**
  110325. * Define the texture used to display the reflection.
  110326. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110327. */
  110328. reflectionTexture: Nullable<BaseTexture>;
  110329. private _emissiveTexture;
  110330. /**
  110331. * Define texture of the material as if self lit.
  110332. * This will be mixed in the final result even in the absence of light.
  110333. */
  110334. emissiveTexture: Nullable<BaseTexture>;
  110335. private _specularTexture;
  110336. /**
  110337. * Define how the color and intensity of the highlight given by the light in the material.
  110338. */
  110339. specularTexture: Nullable<BaseTexture>;
  110340. private _bumpTexture;
  110341. /**
  110342. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110343. * 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.
  110344. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110345. */
  110346. bumpTexture: Nullable<BaseTexture>;
  110347. private _lightmapTexture;
  110348. /**
  110349. * Complex lighting can be computationally expensive to compute at runtime.
  110350. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110351. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110352. */
  110353. lightmapTexture: Nullable<BaseTexture>;
  110354. private _refractionTexture;
  110355. /**
  110356. * Define the texture used to display the refraction.
  110357. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110358. */
  110359. refractionTexture: Nullable<BaseTexture>;
  110360. /**
  110361. * The color of the material lit by the environmental background lighting.
  110362. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110363. */
  110364. ambientColor: Color3;
  110365. /**
  110366. * The basic color of the material as viewed under a light.
  110367. */
  110368. diffuseColor: Color3;
  110369. /**
  110370. * Define how the color and intensity of the highlight given by the light in the material.
  110371. */
  110372. specularColor: Color3;
  110373. /**
  110374. * Define the color of the material as if self lit.
  110375. * This will be mixed in the final result even in the absence of light.
  110376. */
  110377. emissiveColor: Color3;
  110378. /**
  110379. * Defines how sharp are the highlights in the material.
  110380. * The bigger the value the sharper giving a more glossy feeling to the result.
  110381. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110382. */
  110383. specularPower: number;
  110384. private _useAlphaFromDiffuseTexture;
  110385. /**
  110386. * Does the transparency come from the diffuse texture alpha channel.
  110387. */
  110388. useAlphaFromDiffuseTexture: boolean;
  110389. private _useEmissiveAsIllumination;
  110390. /**
  110391. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110392. */
  110393. useEmissiveAsIllumination: boolean;
  110394. private _linkEmissiveWithDiffuse;
  110395. /**
  110396. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110397. * the emissive level when the final color is close to one.
  110398. */
  110399. linkEmissiveWithDiffuse: boolean;
  110400. private _useSpecularOverAlpha;
  110401. /**
  110402. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110403. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110404. */
  110405. useSpecularOverAlpha: boolean;
  110406. private _useReflectionOverAlpha;
  110407. /**
  110408. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110409. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110410. */
  110411. useReflectionOverAlpha: boolean;
  110412. private _disableLighting;
  110413. /**
  110414. * Does lights from the scene impacts this material.
  110415. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110416. */
  110417. disableLighting: boolean;
  110418. private _useObjectSpaceNormalMap;
  110419. /**
  110420. * Allows using an object space normal map (instead of tangent space).
  110421. */
  110422. useObjectSpaceNormalMap: boolean;
  110423. private _useParallax;
  110424. /**
  110425. * Is parallax enabled or not.
  110426. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110427. */
  110428. useParallax: boolean;
  110429. private _useParallaxOcclusion;
  110430. /**
  110431. * Is parallax occlusion enabled or not.
  110432. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110433. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110434. */
  110435. useParallaxOcclusion: boolean;
  110436. /**
  110437. * 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.
  110438. */
  110439. parallaxScaleBias: number;
  110440. private _roughness;
  110441. /**
  110442. * Helps to define how blurry the reflections should appears in the material.
  110443. */
  110444. roughness: number;
  110445. /**
  110446. * In case of refraction, define the value of the index of refraction.
  110447. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110448. */
  110449. indexOfRefraction: number;
  110450. /**
  110451. * Invert the refraction texture alongside the y axis.
  110452. * It can be useful with procedural textures or probe for instance.
  110453. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110454. */
  110455. invertRefractionY: boolean;
  110456. /**
  110457. * Defines the alpha limits in alpha test mode.
  110458. */
  110459. alphaCutOff: number;
  110460. private _useLightmapAsShadowmap;
  110461. /**
  110462. * In case of light mapping, define whether the map contains light or shadow informations.
  110463. */
  110464. useLightmapAsShadowmap: boolean;
  110465. private _diffuseFresnelParameters;
  110466. /**
  110467. * Define the diffuse fresnel parameters of the material.
  110468. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110469. */
  110470. diffuseFresnelParameters: FresnelParameters;
  110471. private _opacityFresnelParameters;
  110472. /**
  110473. * Define the opacity fresnel parameters of the material.
  110474. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110475. */
  110476. opacityFresnelParameters: FresnelParameters;
  110477. private _reflectionFresnelParameters;
  110478. /**
  110479. * Define the reflection fresnel parameters of the material.
  110480. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110481. */
  110482. reflectionFresnelParameters: FresnelParameters;
  110483. private _refractionFresnelParameters;
  110484. /**
  110485. * Define the refraction fresnel parameters of the material.
  110486. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110487. */
  110488. refractionFresnelParameters: FresnelParameters;
  110489. private _emissiveFresnelParameters;
  110490. /**
  110491. * Define the emissive fresnel parameters of the material.
  110492. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110493. */
  110494. emissiveFresnelParameters: FresnelParameters;
  110495. private _useReflectionFresnelFromSpecular;
  110496. /**
  110497. * If true automatically deducts the fresnels values from the material specularity.
  110498. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110499. */
  110500. useReflectionFresnelFromSpecular: boolean;
  110501. private _useGlossinessFromSpecularMapAlpha;
  110502. /**
  110503. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  110504. */
  110505. useGlossinessFromSpecularMapAlpha: boolean;
  110506. private _maxSimultaneousLights;
  110507. /**
  110508. * Defines the maximum number of lights that can be used in the material
  110509. */
  110510. maxSimultaneousLights: number;
  110511. private _invertNormalMapX;
  110512. /**
  110513. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110514. */
  110515. invertNormalMapX: boolean;
  110516. private _invertNormalMapY;
  110517. /**
  110518. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110519. */
  110520. invertNormalMapY: boolean;
  110521. private _twoSidedLighting;
  110522. /**
  110523. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110524. */
  110525. twoSidedLighting: boolean;
  110526. /**
  110527. * Default configuration related to image processing available in the standard Material.
  110528. */
  110529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110530. /**
  110531. * Gets the image processing configuration used either in this material.
  110532. */
  110533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110534. /**
  110535. * Sets the Default image processing configuration used either in the this material.
  110536. *
  110537. * If sets to null, the scene one is in use.
  110538. */
  110539. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110540. /**
  110541. * Keep track of the image processing observer to allow dispose and replace.
  110542. */
  110543. private _imageProcessingObserver;
  110544. /**
  110545. * Attaches a new image processing configuration to the Standard Material.
  110546. * @param configuration
  110547. */
  110548. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110549. /**
  110550. * Gets wether the color curves effect is enabled.
  110551. */
  110552. get cameraColorCurvesEnabled(): boolean;
  110553. /**
  110554. * Sets wether the color curves effect is enabled.
  110555. */
  110556. set cameraColorCurvesEnabled(value: boolean);
  110557. /**
  110558. * Gets wether the color grading effect is enabled.
  110559. */
  110560. get cameraColorGradingEnabled(): boolean;
  110561. /**
  110562. * Gets wether the color grading effect is enabled.
  110563. */
  110564. set cameraColorGradingEnabled(value: boolean);
  110565. /**
  110566. * Gets wether tonemapping is enabled or not.
  110567. */
  110568. get cameraToneMappingEnabled(): boolean;
  110569. /**
  110570. * Sets wether tonemapping is enabled or not
  110571. */
  110572. set cameraToneMappingEnabled(value: boolean);
  110573. /**
  110574. * The camera exposure used on this material.
  110575. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110576. * This corresponds to a photographic exposure.
  110577. */
  110578. get cameraExposure(): number;
  110579. /**
  110580. * The camera exposure used on this material.
  110581. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110582. * This corresponds to a photographic exposure.
  110583. */
  110584. set cameraExposure(value: number);
  110585. /**
  110586. * Gets The camera contrast used on this material.
  110587. */
  110588. get cameraContrast(): number;
  110589. /**
  110590. * Sets The camera contrast used on this material.
  110591. */
  110592. set cameraContrast(value: number);
  110593. /**
  110594. * Gets the Color Grading 2D Lookup Texture.
  110595. */
  110596. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110597. /**
  110598. * Sets the Color Grading 2D Lookup Texture.
  110599. */
  110600. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110601. /**
  110602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110604. * 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;
  110605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110606. */
  110607. get cameraColorCurves(): Nullable<ColorCurves>;
  110608. /**
  110609. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110610. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110611. * 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;
  110612. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110613. */
  110614. set cameraColorCurves(value: Nullable<ColorCurves>);
  110615. /**
  110616. * Can this material render to several textures at once
  110617. */
  110618. get canRenderToMRT(): boolean;
  110619. /**
  110620. * Defines the detail map parameters for the material.
  110621. */
  110622. readonly detailMap: DetailMapConfiguration;
  110623. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110624. protected _worldViewProjectionMatrix: Matrix;
  110625. protected _globalAmbientColor: Color3;
  110626. protected _useLogarithmicDepth: boolean;
  110627. protected _rebuildInParallel: boolean;
  110628. /**
  110629. * Instantiates a new standard material.
  110630. * This is the default material used in Babylon. It is the best trade off between quality
  110631. * and performances.
  110632. * @see https://doc.babylonjs.com/babylon101/materials
  110633. * @param name Define the name of the material in the scene
  110634. * @param scene Define the scene the material belong to
  110635. */
  110636. constructor(name: string, scene: Scene);
  110637. /**
  110638. * Gets a boolean indicating that current material needs to register RTT
  110639. */
  110640. get hasRenderTargetTextures(): boolean;
  110641. /**
  110642. * Gets the current class name of the material e.g. "StandardMaterial"
  110643. * Mainly use in serialization.
  110644. * @returns the class name
  110645. */
  110646. getClassName(): string;
  110647. /**
  110648. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110649. * You can try switching to logarithmic depth.
  110650. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110651. */
  110652. get useLogarithmicDepth(): boolean;
  110653. set useLogarithmicDepth(value: boolean);
  110654. /**
  110655. * Specifies if the material will require alpha blending
  110656. * @returns a boolean specifying if alpha blending is needed
  110657. */
  110658. needAlphaBlending(): boolean;
  110659. /**
  110660. * Specifies if this material should be rendered in alpha test mode
  110661. * @returns a boolean specifying if an alpha test is needed.
  110662. */
  110663. needAlphaTesting(): boolean;
  110664. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110665. /**
  110666. * Get the texture used for alpha test purpose.
  110667. * @returns the diffuse texture in case of the standard material.
  110668. */
  110669. getAlphaTestTexture(): Nullable<BaseTexture>;
  110670. /**
  110671. * Get if the submesh is ready to be used and all its information available.
  110672. * Child classes can use it to update shaders
  110673. * @param mesh defines the mesh to check
  110674. * @param subMesh defines which submesh to check
  110675. * @param useInstances specifies that instances should be used
  110676. * @returns a boolean indicating that the submesh is ready or not
  110677. */
  110678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110679. /**
  110680. * Builds the material UBO layouts.
  110681. * Used internally during the effect preparation.
  110682. */
  110683. buildUniformLayout(): void;
  110684. /**
  110685. * Unbinds the material from the mesh
  110686. */
  110687. unbind(): void;
  110688. /**
  110689. * Binds the submesh to this material by preparing the effect and shader to draw
  110690. * @param world defines the world transformation matrix
  110691. * @param mesh defines the mesh containing the submesh
  110692. * @param subMesh defines the submesh to bind the material to
  110693. */
  110694. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110695. /**
  110696. * Get the list of animatables in the material.
  110697. * @returns the list of animatables object used in the material
  110698. */
  110699. getAnimatables(): IAnimatable[];
  110700. /**
  110701. * Gets the active textures from the material
  110702. * @returns an array of textures
  110703. */
  110704. getActiveTextures(): BaseTexture[];
  110705. /**
  110706. * Specifies if the material uses a texture
  110707. * @param texture defines the texture to check against the material
  110708. * @returns a boolean specifying if the material uses the texture
  110709. */
  110710. hasTexture(texture: BaseTexture): boolean;
  110711. /**
  110712. * Disposes the material
  110713. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110714. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110715. */
  110716. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110717. /**
  110718. * Makes a duplicate of the material, and gives it a new name
  110719. * @param name defines the new name for the duplicated material
  110720. * @returns the cloned material
  110721. */
  110722. clone(name: string): StandardMaterial;
  110723. /**
  110724. * Serializes this material in a JSON representation
  110725. * @returns the serialized material object
  110726. */
  110727. serialize(): any;
  110728. /**
  110729. * Creates a standard material from parsed material data
  110730. * @param source defines the JSON representation of the material
  110731. * @param scene defines the hosting scene
  110732. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110733. * @returns a new standard material
  110734. */
  110735. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  110736. /**
  110737. * Are diffuse textures enabled in the application.
  110738. */
  110739. static get DiffuseTextureEnabled(): boolean;
  110740. static set DiffuseTextureEnabled(value: boolean);
  110741. /**
  110742. * Are detail textures enabled in the application.
  110743. */
  110744. static get DetailTextureEnabled(): boolean;
  110745. static set DetailTextureEnabled(value: boolean);
  110746. /**
  110747. * Are ambient textures enabled in the application.
  110748. */
  110749. static get AmbientTextureEnabled(): boolean;
  110750. static set AmbientTextureEnabled(value: boolean);
  110751. /**
  110752. * Are opacity textures enabled in the application.
  110753. */
  110754. static get OpacityTextureEnabled(): boolean;
  110755. static set OpacityTextureEnabled(value: boolean);
  110756. /**
  110757. * Are reflection textures enabled in the application.
  110758. */
  110759. static get ReflectionTextureEnabled(): boolean;
  110760. static set ReflectionTextureEnabled(value: boolean);
  110761. /**
  110762. * Are emissive textures enabled in the application.
  110763. */
  110764. static get EmissiveTextureEnabled(): boolean;
  110765. static set EmissiveTextureEnabled(value: boolean);
  110766. /**
  110767. * Are specular textures enabled in the application.
  110768. */
  110769. static get SpecularTextureEnabled(): boolean;
  110770. static set SpecularTextureEnabled(value: boolean);
  110771. /**
  110772. * Are bump textures enabled in the application.
  110773. */
  110774. static get BumpTextureEnabled(): boolean;
  110775. static set BumpTextureEnabled(value: boolean);
  110776. /**
  110777. * Are lightmap textures enabled in the application.
  110778. */
  110779. static get LightmapTextureEnabled(): boolean;
  110780. static set LightmapTextureEnabled(value: boolean);
  110781. /**
  110782. * Are refraction textures enabled in the application.
  110783. */
  110784. static get RefractionTextureEnabled(): boolean;
  110785. static set RefractionTextureEnabled(value: boolean);
  110786. /**
  110787. * Are color grading textures enabled in the application.
  110788. */
  110789. static get ColorGradingTextureEnabled(): boolean;
  110790. static set ColorGradingTextureEnabled(value: boolean);
  110791. /**
  110792. * Are fresnels enabled in the application.
  110793. */
  110794. static get FresnelEnabled(): boolean;
  110795. static set FresnelEnabled(value: boolean);
  110796. }
  110797. }
  110798. declare module BABYLON {
  110799. /**
  110800. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  110801. *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.
  110802. * The SPS is also a particle system. It provides some methods to manage the particles.
  110803. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  110804. *
  110805. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  110806. */
  110807. export class SolidParticleSystem implements IDisposable {
  110808. /**
  110809. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  110810. * Example : var p = SPS.particles[i];
  110811. */
  110812. particles: SolidParticle[];
  110813. /**
  110814. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  110815. */
  110816. nbParticles: number;
  110817. /**
  110818. * If the particles must ever face the camera (default false). Useful for planar particles.
  110819. */
  110820. billboard: boolean;
  110821. /**
  110822. * Recompute normals when adding a shape
  110823. */
  110824. recomputeNormals: boolean;
  110825. /**
  110826. * This a counter ofr your own usage. It's not set by any SPS functions.
  110827. */
  110828. counter: number;
  110829. /**
  110830. * The SPS name. This name is also given to the underlying mesh.
  110831. */
  110832. name: string;
  110833. /**
  110834. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  110835. */
  110836. mesh: Mesh;
  110837. /**
  110838. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110839. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  110840. */
  110841. vars: any;
  110842. /**
  110843. * This array is populated when the SPS is set as 'pickable'.
  110844. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  110845. * Each element of this array is an object `{idx: int, faceId: int}`.
  110846. * `idx` is the picked particle index in the `SPS.particles` array
  110847. * `faceId` is the picked face index counted within this particle.
  110848. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  110849. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  110850. * Use the method SPS.pickedParticle(pickingInfo) instead.
  110851. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110852. */
  110853. pickedParticles: {
  110854. idx: number;
  110855. faceId: number;
  110856. }[];
  110857. /**
  110858. * This array is populated when the SPS is set as 'pickable'
  110859. * Each key of this array is a submesh index.
  110860. * Each element of this array is a second array defined like this :
  110861. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  110862. * Each element of this second array is an object `{idx: int, faceId: int}`.
  110863. * `idx` is the picked particle index in the `SPS.particles` array
  110864. * `faceId` is the picked face index counted within this particle.
  110865. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  110866. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110867. */
  110868. pickedBySubMesh: {
  110869. idx: number;
  110870. faceId: number;
  110871. }[][];
  110872. /**
  110873. * This array is populated when `enableDepthSort` is set to true.
  110874. * Each element of this array is an instance of the class DepthSortedParticle.
  110875. */
  110876. depthSortedParticles: DepthSortedParticle[];
  110877. /**
  110878. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  110879. * @hidden
  110880. */
  110881. _bSphereOnly: boolean;
  110882. /**
  110883. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  110884. * @hidden
  110885. */
  110886. _bSphereRadiusFactor: number;
  110887. private _scene;
  110888. private _positions;
  110889. private _indices;
  110890. private _normals;
  110891. private _colors;
  110892. private _uvs;
  110893. private _indices32;
  110894. private _positions32;
  110895. private _normals32;
  110896. private _fixedNormal32;
  110897. private _colors32;
  110898. private _uvs32;
  110899. private _index;
  110900. private _updatable;
  110901. private _pickable;
  110902. private _isVisibilityBoxLocked;
  110903. private _alwaysVisible;
  110904. private _depthSort;
  110905. private _expandable;
  110906. private _shapeCounter;
  110907. private _copy;
  110908. private _color;
  110909. private _computeParticleColor;
  110910. private _computeParticleTexture;
  110911. private _computeParticleRotation;
  110912. private _computeParticleVertex;
  110913. private _computeBoundingBox;
  110914. private _depthSortParticles;
  110915. private _camera;
  110916. private _mustUnrotateFixedNormals;
  110917. private _particlesIntersect;
  110918. private _needs32Bits;
  110919. private _isNotBuilt;
  110920. private _lastParticleId;
  110921. private _idxOfId;
  110922. private _multimaterialEnabled;
  110923. private _useModelMaterial;
  110924. private _indicesByMaterial;
  110925. private _materialIndexes;
  110926. private _depthSortFunction;
  110927. private _materialSortFunction;
  110928. private _materials;
  110929. private _multimaterial;
  110930. private _materialIndexesById;
  110931. private _defaultMaterial;
  110932. private _autoUpdateSubMeshes;
  110933. private _tmpVertex;
  110934. /**
  110935. * Creates a SPS (Solid Particle System) object.
  110936. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110937. * @param scene (Scene) is the scene in which the SPS is added.
  110938. * @param options defines the options of the sps e.g.
  110939. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110940. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110941. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110942. * * 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.
  110943. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  110944. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  110945. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110946. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110947. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110948. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110949. */
  110950. constructor(name: string, scene: Scene, options?: {
  110951. updatable?: boolean;
  110952. isPickable?: boolean;
  110953. enableDepthSort?: boolean;
  110954. particleIntersection?: boolean;
  110955. boundingSphereOnly?: boolean;
  110956. bSphereRadiusFactor?: number;
  110957. expandable?: boolean;
  110958. useModelMaterial?: boolean;
  110959. enableMultiMaterial?: boolean;
  110960. });
  110961. /**
  110962. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110963. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110964. * @returns the created mesh
  110965. */
  110966. buildMesh(): Mesh;
  110967. /**
  110968. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110969. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110970. * Thus the particles generated from `digest()` have their property `position` set yet.
  110971. * @param mesh ( Mesh ) is the mesh to be digested
  110972. * @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
  110973. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110974. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110975. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110976. * @returns the current SPS
  110977. */
  110978. digest(mesh: Mesh, options?: {
  110979. facetNb?: number;
  110980. number?: number;
  110981. delta?: number;
  110982. storage?: [];
  110983. }): SolidParticleSystem;
  110984. /**
  110985. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  110986. * @hidden
  110987. */
  110988. private _unrotateFixedNormals;
  110989. /**
  110990. * Resets the temporary working copy particle
  110991. * @hidden
  110992. */
  110993. private _resetCopy;
  110994. /**
  110995. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  110996. * @param p the current index in the positions array to be updated
  110997. * @param ind the current index in the indices array
  110998. * @param shape a Vector3 array, the shape geometry
  110999. * @param positions the positions array to be updated
  111000. * @param meshInd the shape indices array
  111001. * @param indices the indices array to be updated
  111002. * @param meshUV the shape uv array
  111003. * @param uvs the uv array to be updated
  111004. * @param meshCol the shape color array
  111005. * @param colors the color array to be updated
  111006. * @param meshNor the shape normals array
  111007. * @param normals the normals array to be updated
  111008. * @param idx the particle index
  111009. * @param idxInShape the particle index in its shape
  111010. * @param options the addShape() method passed options
  111011. * @model the particle model
  111012. * @hidden
  111013. */
  111014. private _meshBuilder;
  111015. /**
  111016. * Returns a shape Vector3 array from positions float array
  111017. * @param positions float array
  111018. * @returns a vector3 array
  111019. * @hidden
  111020. */
  111021. private _posToShape;
  111022. /**
  111023. * Returns a shapeUV array from a float uvs (array deep copy)
  111024. * @param uvs as a float array
  111025. * @returns a shapeUV array
  111026. * @hidden
  111027. */
  111028. private _uvsToShapeUV;
  111029. /**
  111030. * Adds a new particle object in the particles array
  111031. * @param idx particle index in particles array
  111032. * @param id particle id
  111033. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111034. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111035. * @param model particle ModelShape object
  111036. * @param shapeId model shape identifier
  111037. * @param idxInShape index of the particle in the current model
  111038. * @param bInfo model bounding info object
  111039. * @param storage target storage array, if any
  111040. * @hidden
  111041. */
  111042. private _addParticle;
  111043. /**
  111044. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111045. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111046. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111047. * @param nb (positive integer) the number of particles to be created from this model
  111048. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111049. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111050. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111051. * @returns the number of shapes in the system
  111052. */
  111053. addShape(mesh: Mesh, nb: number, options?: {
  111054. positionFunction?: any;
  111055. vertexFunction?: any;
  111056. storage?: [];
  111057. }): number;
  111058. /**
  111059. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111060. * @hidden
  111061. */
  111062. private _rebuildParticle;
  111063. /**
  111064. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111065. * @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.
  111066. * @returns the SPS.
  111067. */
  111068. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111069. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111070. * Returns an array with the removed particles.
  111071. * 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.
  111072. * The SPS can't be empty so at least one particle needs to remain in place.
  111073. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111074. * @param start index of the first particle to remove
  111075. * @param end index of the last particle to remove (included)
  111076. * @returns an array populated with the removed particles
  111077. */
  111078. removeParticles(start: number, end: number): SolidParticle[];
  111079. /**
  111080. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111081. * @param solidParticleArray an array populated with Solid Particles objects
  111082. * @returns the SPS
  111083. */
  111084. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111085. /**
  111086. * Creates a new particle and modifies the SPS mesh geometry :
  111087. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111088. * - calls _addParticle() to populate the particle array
  111089. * factorized code from addShape() and insertParticlesFromArray()
  111090. * @param idx particle index in the particles array
  111091. * @param i particle index in its shape
  111092. * @param modelShape particle ModelShape object
  111093. * @param shape shape vertex array
  111094. * @param meshInd shape indices array
  111095. * @param meshUV shape uv array
  111096. * @param meshCol shape color array
  111097. * @param meshNor shape normals array
  111098. * @param bbInfo shape bounding info
  111099. * @param storage target particle storage
  111100. * @options addShape() passed options
  111101. * @hidden
  111102. */
  111103. private _insertNewParticle;
  111104. /**
  111105. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111106. * This method calls `updateParticle()` for each particle of the SPS.
  111107. * For an animated SPS, it is usually called within the render loop.
  111108. * 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.
  111109. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111110. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111111. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111112. * @returns the SPS.
  111113. */
  111114. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111115. /**
  111116. * Disposes the SPS.
  111117. */
  111118. dispose(): void;
  111119. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111120. * idx is the particle index in the SPS
  111121. * faceId is the picked face index counted within this particle.
  111122. * Returns null if the pickInfo can't identify a picked particle.
  111123. * @param pickingInfo (PickingInfo object)
  111124. * @returns {idx: number, faceId: number} or null
  111125. */
  111126. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111127. idx: number;
  111128. faceId: number;
  111129. }>;
  111130. /**
  111131. * Returns a SolidParticle object from its identifier : particle.id
  111132. * @param id (integer) the particle Id
  111133. * @returns the searched particle or null if not found in the SPS.
  111134. */
  111135. getParticleById(id: number): Nullable<SolidParticle>;
  111136. /**
  111137. * Returns a new array populated with the particles having the passed shapeId.
  111138. * @param shapeId (integer) the shape identifier
  111139. * @returns a new solid particle array
  111140. */
  111141. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111142. /**
  111143. * Populates the passed array "ref" with the particles having the passed shapeId.
  111144. * @param shapeId the shape identifier
  111145. * @returns the SPS
  111146. * @param ref
  111147. */
  111148. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111149. /**
  111150. * Computes the required SubMeshes according the materials assigned to the particles.
  111151. * @returns the solid particle system.
  111152. * Does nothing if called before the SPS mesh is built.
  111153. */
  111154. computeSubMeshes(): SolidParticleSystem;
  111155. /**
  111156. * Sorts the solid particles by material when MultiMaterial is enabled.
  111157. * Updates the indices32 array.
  111158. * Updates the indicesByMaterial array.
  111159. * Updates the mesh indices array.
  111160. * @returns the SPS
  111161. * @hidden
  111162. */
  111163. private _sortParticlesByMaterial;
  111164. /**
  111165. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111166. * @hidden
  111167. */
  111168. private _setMaterialIndexesById;
  111169. /**
  111170. * Returns an array with unique values of Materials from the passed array
  111171. * @param array the material array to be checked and filtered
  111172. * @hidden
  111173. */
  111174. private _filterUniqueMaterialId;
  111175. /**
  111176. * Sets a new Standard Material as _defaultMaterial if not already set.
  111177. * @hidden
  111178. */
  111179. private _setDefaultMaterial;
  111180. /**
  111181. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111182. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111183. * @returns the SPS.
  111184. */
  111185. refreshVisibleSize(): SolidParticleSystem;
  111186. /**
  111187. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111188. * @param size the size (float) of the visibility box
  111189. * note : this doesn't lock the SPS mesh bounding box.
  111190. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111191. */
  111192. setVisibilityBox(size: number): void;
  111193. /**
  111194. * Gets whether the SPS as always visible or not
  111195. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111196. */
  111197. get isAlwaysVisible(): boolean;
  111198. /**
  111199. * Sets the SPS as always visible or not
  111200. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111201. */
  111202. set isAlwaysVisible(val: boolean);
  111203. /**
  111204. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111205. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111206. */
  111207. set isVisibilityBoxLocked(val: boolean);
  111208. /**
  111209. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111210. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111211. */
  111212. get isVisibilityBoxLocked(): boolean;
  111213. /**
  111214. * Tells to `setParticles()` to compute the particle rotations or not.
  111215. * Default value : true. The SPS is faster when it's set to false.
  111216. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111217. */
  111218. set computeParticleRotation(val: boolean);
  111219. /**
  111220. * Tells to `setParticles()` to compute the particle colors or not.
  111221. * Default value : true. The SPS is faster when it's set to false.
  111222. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111223. */
  111224. set computeParticleColor(val: boolean);
  111225. set computeParticleTexture(val: boolean);
  111226. /**
  111227. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111228. * Default value : false. The SPS is faster when it's set to false.
  111229. * Note : the particle custom vertex positions aren't stored values.
  111230. */
  111231. set computeParticleVertex(val: boolean);
  111232. /**
  111233. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111234. */
  111235. set computeBoundingBox(val: boolean);
  111236. /**
  111237. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111238. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111239. * Default : `true`
  111240. */
  111241. set depthSortParticles(val: boolean);
  111242. /**
  111243. * Gets if `setParticles()` computes the particle rotations or not.
  111244. * Default value : true. The SPS is faster when it's set to false.
  111245. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111246. */
  111247. get computeParticleRotation(): boolean;
  111248. /**
  111249. * Gets if `setParticles()` computes the particle colors or not.
  111250. * Default value : true. The SPS is faster when it's set to false.
  111251. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111252. */
  111253. get computeParticleColor(): boolean;
  111254. /**
  111255. * Gets if `setParticles()` computes the particle textures or not.
  111256. * Default value : true. The SPS is faster when it's set to false.
  111257. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111258. */
  111259. get computeParticleTexture(): boolean;
  111260. /**
  111261. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111262. * Default value : false. The SPS is faster when it's set to false.
  111263. * Note : the particle custom vertex positions aren't stored values.
  111264. */
  111265. get computeParticleVertex(): boolean;
  111266. /**
  111267. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111268. */
  111269. get computeBoundingBox(): boolean;
  111270. /**
  111271. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111272. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111273. * Default : `true`
  111274. */
  111275. get depthSortParticles(): boolean;
  111276. /**
  111277. * Gets if the SPS is created as expandable at construction time.
  111278. * Default : `false`
  111279. */
  111280. get expandable(): boolean;
  111281. /**
  111282. * Gets if the SPS supports the Multi Materials
  111283. */
  111284. get multimaterialEnabled(): boolean;
  111285. /**
  111286. * Gets if the SPS uses the model materials for its own multimaterial.
  111287. */
  111288. get useModelMaterial(): boolean;
  111289. /**
  111290. * The SPS used material array.
  111291. */
  111292. get materials(): Material[];
  111293. /**
  111294. * Sets the SPS MultiMaterial from the passed materials.
  111295. * Note : the passed array is internally copied and not used then by reference.
  111296. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111297. */
  111298. setMultiMaterial(materials: Material[]): void;
  111299. /**
  111300. * The SPS computed multimaterial object
  111301. */
  111302. get multimaterial(): MultiMaterial;
  111303. set multimaterial(mm: MultiMaterial);
  111304. /**
  111305. * If the subMeshes must be updated on the next call to setParticles()
  111306. */
  111307. get autoUpdateSubMeshes(): boolean;
  111308. set autoUpdateSubMeshes(val: boolean);
  111309. /**
  111310. * This function does nothing. It may be overwritten to set all the particle first values.
  111311. * The SPS doesn't call this function, you may have to call it by your own.
  111312. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111313. */
  111314. initParticles(): void;
  111315. /**
  111316. * This function does nothing. It may be overwritten to recycle a particle.
  111317. * The SPS doesn't call this function, you may have to call it by your own.
  111318. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111319. * @param particle The particle to recycle
  111320. * @returns the recycled particle
  111321. */
  111322. recycleParticle(particle: SolidParticle): SolidParticle;
  111323. /**
  111324. * Updates a particle : this function should be overwritten by the user.
  111325. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111326. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111327. * @example : just set a particle position or velocity and recycle conditions
  111328. * @param particle The particle to update
  111329. * @returns the updated particle
  111330. */
  111331. updateParticle(particle: SolidParticle): SolidParticle;
  111332. /**
  111333. * Updates a vertex of a particle : it can be overwritten by the user.
  111334. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111335. * @param particle the current particle
  111336. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111337. * @param pt the index of the current vertex in the particle shape
  111338. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111339. * @example : just set a vertex particle position or color
  111340. * @returns the sps
  111341. */
  111342. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111343. /**
  111344. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111345. * This does nothing and may be overwritten by the user.
  111346. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111347. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111348. * @param update the boolean update value actually passed to setParticles()
  111349. */
  111350. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111351. /**
  111352. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111353. * This will be passed three parameters.
  111354. * This does nothing and may be overwritten by the user.
  111355. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111356. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111357. * @param update the boolean update value actually passed to setParticles()
  111358. */
  111359. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111360. }
  111361. }
  111362. declare module BABYLON {
  111363. /**
  111364. * Represents one particle of a solid particle system.
  111365. */
  111366. export class SolidParticle {
  111367. /**
  111368. * particle global index
  111369. */
  111370. idx: number;
  111371. /**
  111372. * particle identifier
  111373. */
  111374. id: number;
  111375. /**
  111376. * The color of the particle
  111377. */
  111378. color: Nullable<Color4>;
  111379. /**
  111380. * The world space position of the particle.
  111381. */
  111382. position: Vector3;
  111383. /**
  111384. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111385. */
  111386. rotation: Vector3;
  111387. /**
  111388. * The world space rotation quaternion of the particle.
  111389. */
  111390. rotationQuaternion: Nullable<Quaternion>;
  111391. /**
  111392. * The scaling of the particle.
  111393. */
  111394. scaling: Vector3;
  111395. /**
  111396. * The uvs of the particle.
  111397. */
  111398. uvs: Vector4;
  111399. /**
  111400. * The current speed of the particle.
  111401. */
  111402. velocity: Vector3;
  111403. /**
  111404. * The pivot point in the particle local space.
  111405. */
  111406. pivot: Vector3;
  111407. /**
  111408. * Must the particle be translated from its pivot point in its local space ?
  111409. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111410. * Default : false
  111411. */
  111412. translateFromPivot: boolean;
  111413. /**
  111414. * Is the particle active or not ?
  111415. */
  111416. alive: boolean;
  111417. /**
  111418. * Is the particle visible or not ?
  111419. */
  111420. isVisible: boolean;
  111421. /**
  111422. * Index of this particle in the global "positions" array (Internal use)
  111423. * @hidden
  111424. */
  111425. _pos: number;
  111426. /**
  111427. * @hidden Index of this particle in the global "indices" array (Internal use)
  111428. */
  111429. _ind: number;
  111430. /**
  111431. * @hidden ModelShape of this particle (Internal use)
  111432. */
  111433. _model: ModelShape;
  111434. /**
  111435. * ModelShape id of this particle
  111436. */
  111437. shapeId: number;
  111438. /**
  111439. * Index of the particle in its shape id
  111440. */
  111441. idxInShape: number;
  111442. /**
  111443. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  111444. */
  111445. _modelBoundingInfo: BoundingInfo;
  111446. /**
  111447. * @hidden Particle BoundingInfo object (Internal use)
  111448. */
  111449. _boundingInfo: BoundingInfo;
  111450. /**
  111451. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  111452. */
  111453. _sps: SolidParticleSystem;
  111454. /**
  111455. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111456. */
  111457. _stillInvisible: boolean;
  111458. /**
  111459. * @hidden Last computed particle rotation matrix
  111460. */
  111461. _rotationMatrix: number[];
  111462. /**
  111463. * Parent particle Id, if any.
  111464. * Default null.
  111465. */
  111466. parentId: Nullable<number>;
  111467. /**
  111468. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  111469. */
  111470. materialIndex: Nullable<number>;
  111471. /**
  111472. * Custom object or properties.
  111473. */
  111474. props: Nullable<any>;
  111475. /**
  111476. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111477. * The possible values are :
  111478. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111479. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111480. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111481. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111482. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111483. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111484. * */
  111485. cullingStrategy: number;
  111486. /**
  111487. * @hidden Internal global position in the SPS.
  111488. */
  111489. _globalPosition: Vector3;
  111490. /**
  111491. * Creates a Solid Particle object.
  111492. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  111493. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  111494. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  111495. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  111496. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  111497. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  111498. * @param shapeId (integer) is the model shape identifier in the SPS.
  111499. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  111500. * @param sps defines the sps it is associated to
  111501. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  111502. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  111503. */
  111504. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  111505. /**
  111506. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  111507. * @param target the particle target
  111508. * @returns the current particle
  111509. */
  111510. copyToRef(target: SolidParticle): SolidParticle;
  111511. /**
  111512. * Legacy support, changed scale to scaling
  111513. */
  111514. get scale(): Vector3;
  111515. /**
  111516. * Legacy support, changed scale to scaling
  111517. */
  111518. set scale(scale: Vector3);
  111519. /**
  111520. * Legacy support, changed quaternion to rotationQuaternion
  111521. */
  111522. get quaternion(): Nullable<Quaternion>;
  111523. /**
  111524. * Legacy support, changed quaternion to rotationQuaternion
  111525. */
  111526. set quaternion(q: Nullable<Quaternion>);
  111527. /**
  111528. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111529. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111530. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111531. * @returns true if it intersects
  111532. */
  111533. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111534. /**
  111535. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111536. * A particle is in the frustum if its bounding box intersects the frustum
  111537. * @param frustumPlanes defines the frustum to test
  111538. * @returns true if the particle is in the frustum planes
  111539. */
  111540. isInFrustum(frustumPlanes: Plane[]): boolean;
  111541. /**
  111542. * get the rotation matrix of the particle
  111543. * @hidden
  111544. */
  111545. getRotationMatrix(m: Matrix): void;
  111546. }
  111547. /**
  111548. * Represents the shape of the model used by one particle of a solid particle system.
  111549. * SPS internal tool, don't use it manually.
  111550. */
  111551. export class ModelShape {
  111552. /**
  111553. * The shape id
  111554. * @hidden
  111555. */
  111556. shapeID: number;
  111557. /**
  111558. * flat array of model positions (internal use)
  111559. * @hidden
  111560. */
  111561. _shape: Vector3[];
  111562. /**
  111563. * flat array of model UVs (internal use)
  111564. * @hidden
  111565. */
  111566. _shapeUV: number[];
  111567. /**
  111568. * color array of the model
  111569. * @hidden
  111570. */
  111571. _shapeColors: number[];
  111572. /**
  111573. * indices array of the model
  111574. * @hidden
  111575. */
  111576. _indices: number[];
  111577. /**
  111578. * normals array of the model
  111579. * @hidden
  111580. */
  111581. _normals: number[];
  111582. /**
  111583. * length of the shape in the model indices array (internal use)
  111584. * @hidden
  111585. */
  111586. _indicesLength: number;
  111587. /**
  111588. * Custom position function (internal use)
  111589. * @hidden
  111590. */
  111591. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111592. /**
  111593. * Custom vertex function (internal use)
  111594. * @hidden
  111595. */
  111596. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111597. /**
  111598. * Model material (internal use)
  111599. * @hidden
  111600. */
  111601. _material: Nullable<Material>;
  111602. /**
  111603. * 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.
  111604. * SPS internal tool, don't use it manually.
  111605. * @hidden
  111606. */
  111607. 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>);
  111608. }
  111609. /**
  111610. * Represents a Depth Sorted Particle in the solid particle system.
  111611. * @hidden
  111612. */
  111613. export class DepthSortedParticle {
  111614. /**
  111615. * Particle index
  111616. */
  111617. idx: number;
  111618. /**
  111619. * Index of the particle in the "indices" array
  111620. */
  111621. ind: number;
  111622. /**
  111623. * Length of the particle shape in the "indices" array
  111624. */
  111625. indicesLength: number;
  111626. /**
  111627. * Squared distance from the particle to the camera
  111628. */
  111629. sqDistance: number;
  111630. /**
  111631. * Material index when used with MultiMaterials
  111632. */
  111633. materialIndex: number;
  111634. /**
  111635. * Creates a new sorted particle
  111636. * @param materialIndex
  111637. */
  111638. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111639. }
  111640. /**
  111641. * Represents a solid particle vertex
  111642. */
  111643. export class SolidParticleVertex {
  111644. /**
  111645. * Vertex position
  111646. */
  111647. position: Vector3;
  111648. /**
  111649. * Vertex color
  111650. */
  111651. color: Color4;
  111652. /**
  111653. * Vertex UV
  111654. */
  111655. uv: Vector2;
  111656. /**
  111657. * Creates a new solid particle vertex
  111658. */
  111659. constructor();
  111660. /** Vertex x coordinate */
  111661. get x(): number;
  111662. set x(val: number);
  111663. /** Vertex y coordinate */
  111664. get y(): number;
  111665. set y(val: number);
  111666. /** Vertex z coordinate */
  111667. get z(): number;
  111668. set z(val: number);
  111669. }
  111670. }
  111671. declare module BABYLON {
  111672. /**
  111673. * @hidden
  111674. */
  111675. export class _MeshCollisionData {
  111676. _checkCollisions: boolean;
  111677. _collisionMask: number;
  111678. _collisionGroup: number;
  111679. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111680. _collider: Nullable<Collider>;
  111681. _oldPositionForCollisions: Vector3;
  111682. _diffPositionForCollisions: Vector3;
  111683. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111684. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111685. }
  111686. }
  111687. declare module BABYLON {
  111688. /** @hidden */
  111689. class _FacetDataStorage {
  111690. facetPositions: Vector3[];
  111691. facetNormals: Vector3[];
  111692. facetPartitioning: number[][];
  111693. facetNb: number;
  111694. partitioningSubdivisions: number;
  111695. partitioningBBoxRatio: number;
  111696. facetDataEnabled: boolean;
  111697. facetParameters: any;
  111698. bbSize: Vector3;
  111699. subDiv: {
  111700. max: number;
  111701. X: number;
  111702. Y: number;
  111703. Z: number;
  111704. };
  111705. facetDepthSort: boolean;
  111706. facetDepthSortEnabled: boolean;
  111707. depthSortedIndices: IndicesArray;
  111708. depthSortedFacets: {
  111709. ind: number;
  111710. sqDistance: number;
  111711. }[];
  111712. facetDepthSortFunction: (f1: {
  111713. ind: number;
  111714. sqDistance: number;
  111715. }, f2: {
  111716. ind: number;
  111717. sqDistance: number;
  111718. }) => number;
  111719. facetDepthSortFrom: Vector3;
  111720. facetDepthSortOrigin: Vector3;
  111721. invertedMatrix: Matrix;
  111722. }
  111723. /**
  111724. * @hidden
  111725. **/
  111726. class _InternalAbstractMeshDataInfo {
  111727. _hasVertexAlpha: boolean;
  111728. _useVertexColors: boolean;
  111729. _numBoneInfluencers: number;
  111730. _applyFog: boolean;
  111731. _receiveShadows: boolean;
  111732. _facetData: _FacetDataStorage;
  111733. _visibility: number;
  111734. _skeleton: Nullable<Skeleton>;
  111735. _layerMask: number;
  111736. _computeBonesUsingShaders: boolean;
  111737. _isActive: boolean;
  111738. _onlyForInstances: boolean;
  111739. _isActiveIntermediate: boolean;
  111740. _onlyForInstancesIntermediate: boolean;
  111741. _actAsRegularMesh: boolean;
  111742. }
  111743. /**
  111744. * Class used to store all common mesh properties
  111745. */
  111746. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  111747. /** No occlusion */
  111748. static OCCLUSION_TYPE_NONE: number;
  111749. /** Occlusion set to optimisitic */
  111750. static OCCLUSION_TYPE_OPTIMISTIC: number;
  111751. /** Occlusion set to strict */
  111752. static OCCLUSION_TYPE_STRICT: number;
  111753. /** Use an accurante occlusion algorithm */
  111754. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  111755. /** Use a conservative occlusion algorithm */
  111756. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  111757. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  111758. * Test order :
  111759. * Is the bounding sphere outside the frustum ?
  111760. * If not, are the bounding box vertices outside the frustum ?
  111761. * It not, then the cullable object is in the frustum.
  111762. */
  111763. static readonly CULLINGSTRATEGY_STANDARD: number;
  111764. /** Culling strategy : Bounding Sphere Only.
  111765. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  111766. * It's also less accurate than the standard because some not visible objects can still be selected.
  111767. * Test : is the bounding sphere outside the frustum ?
  111768. * If not, then the cullable object is in the frustum.
  111769. */
  111770. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  111771. /** Culling strategy : Optimistic Inclusion.
  111772. * This in an inclusion test first, then the standard exclusion test.
  111773. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  111774. * 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.
  111775. * Anyway, it's as accurate as the standard strategy.
  111776. * Test :
  111777. * Is the cullable object bounding sphere center in the frustum ?
  111778. * If not, apply the default culling strategy.
  111779. */
  111780. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  111781. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  111782. * This in an inclusion test first, then the bounding sphere only exclusion test.
  111783. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  111784. * 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.
  111785. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  111786. * Test :
  111787. * Is the cullable object bounding sphere center in the frustum ?
  111788. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  111789. */
  111790. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  111791. /**
  111792. * No billboard
  111793. */
  111794. static get BILLBOARDMODE_NONE(): number;
  111795. /** Billboard on X axis */
  111796. static get BILLBOARDMODE_X(): number;
  111797. /** Billboard on Y axis */
  111798. static get BILLBOARDMODE_Y(): number;
  111799. /** Billboard on Z axis */
  111800. static get BILLBOARDMODE_Z(): number;
  111801. /** Billboard on all axes */
  111802. static get BILLBOARDMODE_ALL(): number;
  111803. /** Billboard on using position instead of orientation */
  111804. static get BILLBOARDMODE_USE_POSITION(): number;
  111805. /** @hidden */
  111806. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  111807. /**
  111808. * The culling strategy to use to check whether the mesh must be rendered or not.
  111809. * This value can be changed at any time and will be used on the next render mesh selection.
  111810. * The possible values are :
  111811. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111812. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111813. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111814. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111815. * Please read each static variable documentation to get details about the culling process.
  111816. * */
  111817. cullingStrategy: number;
  111818. /**
  111819. * Gets the number of facets in the mesh
  111820. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111821. */
  111822. get facetNb(): number;
  111823. /**
  111824. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  111825. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111826. */
  111827. get partitioningSubdivisions(): number;
  111828. set partitioningSubdivisions(nb: number);
  111829. /**
  111830. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  111831. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  111832. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111833. */
  111834. get partitioningBBoxRatio(): number;
  111835. set partitioningBBoxRatio(ratio: number);
  111836. /**
  111837. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  111838. * Works only for updatable meshes.
  111839. * Doesn't work with multi-materials
  111840. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111841. */
  111842. get mustDepthSortFacets(): boolean;
  111843. set mustDepthSortFacets(sort: boolean);
  111844. /**
  111845. * The location (Vector3) where the facet depth sort must be computed from.
  111846. * By default, the active camera position.
  111847. * Used only when facet depth sort is enabled
  111848. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111849. */
  111850. get facetDepthSortFrom(): Vector3;
  111851. set facetDepthSortFrom(location: Vector3);
  111852. /**
  111853. * gets a boolean indicating if facetData is enabled
  111854. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111855. */
  111856. get isFacetDataEnabled(): boolean;
  111857. /** @hidden */
  111858. _updateNonUniformScalingState(value: boolean): boolean;
  111859. /**
  111860. * An event triggered when this mesh collides with another one
  111861. */
  111862. onCollideObservable: Observable<AbstractMesh>;
  111863. /** Set a function to call when this mesh collides with another one */
  111864. set onCollide(callback: () => void);
  111865. /**
  111866. * An event triggered when the collision's position changes
  111867. */
  111868. onCollisionPositionChangeObservable: Observable<Vector3>;
  111869. /** Set a function to call when the collision's position changes */
  111870. set onCollisionPositionChange(callback: () => void);
  111871. /**
  111872. * An event triggered when material is changed
  111873. */
  111874. onMaterialChangedObservable: Observable<AbstractMesh>;
  111875. /**
  111876. * Gets or sets the orientation for POV movement & rotation
  111877. */
  111878. definedFacingForward: boolean;
  111879. /** @hidden */
  111880. _occlusionQuery: Nullable<WebGLQuery>;
  111881. /** @hidden */
  111882. _renderingGroup: Nullable<RenderingGroup>;
  111883. /**
  111884. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111885. */
  111886. get visibility(): number;
  111887. /**
  111888. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111889. */
  111890. set visibility(value: number);
  111891. /** Gets or sets the alpha index used to sort transparent meshes
  111892. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  111893. */
  111894. alphaIndex: number;
  111895. /**
  111896. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  111897. */
  111898. isVisible: boolean;
  111899. /**
  111900. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  111901. */
  111902. isPickable: boolean;
  111903. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  111904. showSubMeshesBoundingBox: boolean;
  111905. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  111906. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111907. */
  111908. isBlocker: boolean;
  111909. /**
  111910. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  111911. */
  111912. enablePointerMoveEvents: boolean;
  111913. private _renderingGroupId;
  111914. /**
  111915. * Specifies the rendering group id for this mesh (0 by default)
  111916. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  111917. */
  111918. get renderingGroupId(): number;
  111919. set renderingGroupId(value: number);
  111920. private _material;
  111921. /** Gets or sets current material */
  111922. get material(): Nullable<Material>;
  111923. set material(value: Nullable<Material>);
  111924. /**
  111925. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  111926. * @see https://doc.babylonjs.com/babylon101/shadows
  111927. */
  111928. get receiveShadows(): boolean;
  111929. set receiveShadows(value: boolean);
  111930. /** Defines color to use when rendering outline */
  111931. outlineColor: Color3;
  111932. /** Define width to use when rendering outline */
  111933. outlineWidth: number;
  111934. /** Defines color to use when rendering overlay */
  111935. overlayColor: Color3;
  111936. /** Defines alpha to use when rendering overlay */
  111937. overlayAlpha: number;
  111938. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  111939. get hasVertexAlpha(): boolean;
  111940. set hasVertexAlpha(value: boolean);
  111941. /** 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) */
  111942. get useVertexColors(): boolean;
  111943. set useVertexColors(value: boolean);
  111944. /**
  111945. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  111946. */
  111947. get computeBonesUsingShaders(): boolean;
  111948. set computeBonesUsingShaders(value: boolean);
  111949. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  111950. get numBoneInfluencers(): number;
  111951. set numBoneInfluencers(value: number);
  111952. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  111953. get applyFog(): boolean;
  111954. set applyFog(value: boolean);
  111955. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  111956. useOctreeForRenderingSelection: boolean;
  111957. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  111958. useOctreeForPicking: boolean;
  111959. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  111960. useOctreeForCollisions: boolean;
  111961. /**
  111962. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  111963. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  111964. */
  111965. get layerMask(): number;
  111966. set layerMask(value: number);
  111967. /**
  111968. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  111969. */
  111970. alwaysSelectAsActiveMesh: boolean;
  111971. /**
  111972. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  111973. */
  111974. doNotSyncBoundingInfo: boolean;
  111975. /**
  111976. * Gets or sets the current action manager
  111977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111978. */
  111979. actionManager: Nullable<AbstractActionManager>;
  111980. private _meshCollisionData;
  111981. /**
  111982. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  111983. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111984. */
  111985. ellipsoid: Vector3;
  111986. /**
  111987. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  111988. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111989. */
  111990. ellipsoidOffset: Vector3;
  111991. /**
  111992. * Gets or sets a collision mask used to mask collisions (default is -1).
  111993. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111994. */
  111995. get collisionMask(): number;
  111996. set collisionMask(mask: number);
  111997. /**
  111998. * Gets or sets the current collision group mask (-1 by default).
  111999. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112000. */
  112001. get collisionGroup(): number;
  112002. set collisionGroup(mask: number);
  112003. /**
  112004. * Gets or sets current surrounding meshes (null by default).
  112005. *
  112006. * By default collision detection is tested against every mesh in the scene.
  112007. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112008. * meshes will be tested for the collision.
  112009. *
  112010. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112011. */
  112012. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112013. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112014. /**
  112015. * Defines edge width used when edgesRenderer is enabled
  112016. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112017. */
  112018. edgesWidth: number;
  112019. /**
  112020. * Defines edge color used when edgesRenderer is enabled
  112021. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112022. */
  112023. edgesColor: Color4;
  112024. /** @hidden */
  112025. _edgesRenderer: Nullable<IEdgesRenderer>;
  112026. /** @hidden */
  112027. _masterMesh: Nullable<AbstractMesh>;
  112028. /** @hidden */
  112029. _boundingInfo: Nullable<BoundingInfo>;
  112030. /** @hidden */
  112031. _renderId: number;
  112032. /**
  112033. * Gets or sets the list of subMeshes
  112034. * @see https://doc.babylonjs.com/how_to/multi_materials
  112035. */
  112036. subMeshes: SubMesh[];
  112037. /** @hidden */
  112038. _intersectionsInProgress: AbstractMesh[];
  112039. /** @hidden */
  112040. _unIndexed: boolean;
  112041. /** @hidden */
  112042. _lightSources: Light[];
  112043. /** Gets the list of lights affecting that mesh */
  112044. get lightSources(): Light[];
  112045. /** @hidden */
  112046. get _positions(): Nullable<Vector3[]>;
  112047. /** @hidden */
  112048. _waitingData: {
  112049. lods: Nullable<any>;
  112050. actions: Nullable<any>;
  112051. freezeWorldMatrix: Nullable<boolean>;
  112052. };
  112053. /** @hidden */
  112054. _bonesTransformMatrices: Nullable<Float32Array>;
  112055. /** @hidden */
  112056. _transformMatrixTexture: Nullable<RawTexture>;
  112057. /**
  112058. * Gets or sets a skeleton to apply skining transformations
  112059. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112060. */
  112061. set skeleton(value: Nullable<Skeleton>);
  112062. get skeleton(): Nullable<Skeleton>;
  112063. /**
  112064. * An event triggered when the mesh is rebuilt.
  112065. */
  112066. onRebuildObservable: Observable<AbstractMesh>;
  112067. /**
  112068. * Creates a new AbstractMesh
  112069. * @param name defines the name of the mesh
  112070. * @param scene defines the hosting scene
  112071. */
  112072. constructor(name: string, scene?: Nullable<Scene>);
  112073. /**
  112074. * Returns the string "AbstractMesh"
  112075. * @returns "AbstractMesh"
  112076. */
  112077. getClassName(): string;
  112078. /**
  112079. * Gets a string representation of the current mesh
  112080. * @param fullDetails defines a boolean indicating if full details must be included
  112081. * @returns a string representation of the current mesh
  112082. */
  112083. toString(fullDetails?: boolean): string;
  112084. /**
  112085. * @hidden
  112086. */
  112087. protected _getEffectiveParent(): Nullable<Node>;
  112088. /** @hidden */
  112089. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112090. /** @hidden */
  112091. _rebuild(): void;
  112092. /** @hidden */
  112093. _resyncLightSources(): void;
  112094. /** @hidden */
  112095. _resyncLightSource(light: Light): void;
  112096. /** @hidden */
  112097. _unBindEffect(): void;
  112098. /** @hidden */
  112099. _removeLightSource(light: Light, dispose: boolean): void;
  112100. private _markSubMeshesAsDirty;
  112101. /** @hidden */
  112102. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112103. /** @hidden */
  112104. _markSubMeshesAsAttributesDirty(): void;
  112105. /** @hidden */
  112106. _markSubMeshesAsMiscDirty(): void;
  112107. /**
  112108. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112109. */
  112110. get scaling(): Vector3;
  112111. set scaling(newScaling: Vector3);
  112112. /**
  112113. * Returns true if the mesh is blocked. Implemented by child classes
  112114. */
  112115. get isBlocked(): boolean;
  112116. /**
  112117. * Returns the mesh itself by default. Implemented by child classes
  112118. * @param camera defines the camera to use to pick the right LOD level
  112119. * @returns the currentAbstractMesh
  112120. */
  112121. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112122. /**
  112123. * Returns 0 by default. Implemented by child classes
  112124. * @returns an integer
  112125. */
  112126. getTotalVertices(): number;
  112127. /**
  112128. * Returns a positive integer : the total number of indices in this mesh geometry.
  112129. * @returns the numner of indices or zero if the mesh has no geometry.
  112130. */
  112131. getTotalIndices(): number;
  112132. /**
  112133. * Returns null by default. Implemented by child classes
  112134. * @returns null
  112135. */
  112136. getIndices(): Nullable<IndicesArray>;
  112137. /**
  112138. * Returns the array of the requested vertex data kind. Implemented by child classes
  112139. * @param kind defines the vertex data kind to use
  112140. * @returns null
  112141. */
  112142. getVerticesData(kind: string): Nullable<FloatArray>;
  112143. /**
  112144. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112145. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112146. * Note that a new underlying VertexBuffer object is created each call.
  112147. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112148. * @param kind defines vertex data kind:
  112149. * * VertexBuffer.PositionKind
  112150. * * VertexBuffer.UVKind
  112151. * * VertexBuffer.UV2Kind
  112152. * * VertexBuffer.UV3Kind
  112153. * * VertexBuffer.UV4Kind
  112154. * * VertexBuffer.UV5Kind
  112155. * * VertexBuffer.UV6Kind
  112156. * * VertexBuffer.ColorKind
  112157. * * VertexBuffer.MatricesIndicesKind
  112158. * * VertexBuffer.MatricesIndicesExtraKind
  112159. * * VertexBuffer.MatricesWeightsKind
  112160. * * VertexBuffer.MatricesWeightsExtraKind
  112161. * @param data defines the data source
  112162. * @param updatable defines if the data must be flagged as updatable (or static)
  112163. * @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
  112164. * @returns the current mesh
  112165. */
  112166. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112167. /**
  112168. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112169. * If the mesh has no geometry, it is simply returned as it is.
  112170. * @param kind defines vertex data kind:
  112171. * * VertexBuffer.PositionKind
  112172. * * VertexBuffer.UVKind
  112173. * * VertexBuffer.UV2Kind
  112174. * * VertexBuffer.UV3Kind
  112175. * * VertexBuffer.UV4Kind
  112176. * * VertexBuffer.UV5Kind
  112177. * * VertexBuffer.UV6Kind
  112178. * * VertexBuffer.ColorKind
  112179. * * VertexBuffer.MatricesIndicesKind
  112180. * * VertexBuffer.MatricesIndicesExtraKind
  112181. * * VertexBuffer.MatricesWeightsKind
  112182. * * VertexBuffer.MatricesWeightsExtraKind
  112183. * @param data defines the data source
  112184. * @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
  112185. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112186. * @returns the current mesh
  112187. */
  112188. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112189. /**
  112190. * Sets the mesh indices,
  112191. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112192. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112193. * @param totalVertices Defines the total number of vertices
  112194. * @returns the current mesh
  112195. */
  112196. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112197. /**
  112198. * Gets a boolean indicating if specific vertex data is present
  112199. * @param kind defines the vertex data kind to use
  112200. * @returns true is data kind is present
  112201. */
  112202. isVerticesDataPresent(kind: string): boolean;
  112203. /**
  112204. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112205. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112206. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112207. * @returns a BoundingInfo
  112208. */
  112209. getBoundingInfo(): BoundingInfo;
  112210. /**
  112211. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112212. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112213. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112214. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112215. * @returns the current mesh
  112216. */
  112217. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112218. /**
  112219. * Overwrite the current bounding info
  112220. * @param boundingInfo defines the new bounding info
  112221. * @returns the current mesh
  112222. */
  112223. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112224. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112225. get useBones(): boolean;
  112226. /** @hidden */
  112227. _preActivate(): void;
  112228. /** @hidden */
  112229. _preActivateForIntermediateRendering(renderId: number): void;
  112230. /** @hidden */
  112231. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112232. /** @hidden */
  112233. _postActivate(): void;
  112234. /** @hidden */
  112235. _freeze(): void;
  112236. /** @hidden */
  112237. _unFreeze(): void;
  112238. /**
  112239. * Gets the current world matrix
  112240. * @returns a Matrix
  112241. */
  112242. getWorldMatrix(): Matrix;
  112243. /** @hidden */
  112244. _getWorldMatrixDeterminant(): number;
  112245. /**
  112246. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112247. */
  112248. get isAnInstance(): boolean;
  112249. /**
  112250. * Gets a boolean indicating if this mesh has instances
  112251. */
  112252. get hasInstances(): boolean;
  112253. /**
  112254. * Gets a boolean indicating if this mesh has thin instances
  112255. */
  112256. get hasThinInstances(): boolean;
  112257. /**
  112258. * Perform relative position change from the point of view of behind the front of the mesh.
  112259. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112260. * Supports definition of mesh facing forward or backward
  112261. * @param amountRight defines the distance on the right axis
  112262. * @param amountUp defines the distance on the up axis
  112263. * @param amountForward defines the distance on the forward axis
  112264. * @returns the current mesh
  112265. */
  112266. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112267. /**
  112268. * Calculate relative position change from the point of view of behind the front of the mesh.
  112269. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112270. * Supports definition of mesh facing forward or backward
  112271. * @param amountRight defines the distance on the right axis
  112272. * @param amountUp defines the distance on the up axis
  112273. * @param amountForward defines the distance on the forward axis
  112274. * @returns the new displacement vector
  112275. */
  112276. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112277. /**
  112278. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112279. * Supports definition of mesh facing forward or backward
  112280. * @param flipBack defines the flip
  112281. * @param twirlClockwise defines the twirl
  112282. * @param tiltRight defines the tilt
  112283. * @returns the current mesh
  112284. */
  112285. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112286. /**
  112287. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112288. * Supports definition of mesh facing forward or backward.
  112289. * @param flipBack defines the flip
  112290. * @param twirlClockwise defines the twirl
  112291. * @param tiltRight defines the tilt
  112292. * @returns the new rotation vector
  112293. */
  112294. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112295. /**
  112296. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112297. * This means the mesh underlying bounding box and sphere are recomputed.
  112298. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112299. * @returns the current mesh
  112300. */
  112301. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112302. /** @hidden */
  112303. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112304. /** @hidden */
  112305. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112306. /** @hidden */
  112307. _updateBoundingInfo(): AbstractMesh;
  112308. /** @hidden */
  112309. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112310. /** @hidden */
  112311. protected _afterComputeWorldMatrix(): void;
  112312. /** @hidden */
  112313. get _effectiveMesh(): AbstractMesh;
  112314. /**
  112315. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112316. * A mesh is in the frustum if its bounding box intersects the frustum
  112317. * @param frustumPlanes defines the frustum to test
  112318. * @returns true if the mesh is in the frustum planes
  112319. */
  112320. isInFrustum(frustumPlanes: Plane[]): boolean;
  112321. /**
  112322. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112323. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112324. * @param frustumPlanes defines the frustum to test
  112325. * @returns true if the mesh is completely in the frustum planes
  112326. */
  112327. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112328. /**
  112329. * True if the mesh intersects another mesh or a SolidParticle object
  112330. * @param mesh defines a target mesh or SolidParticle to test
  112331. * @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)
  112332. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112333. * @returns true if there is an intersection
  112334. */
  112335. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112336. /**
  112337. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112338. * @param point defines the point to test
  112339. * @returns true if there is an intersection
  112340. */
  112341. intersectsPoint(point: Vector3): boolean;
  112342. /**
  112343. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112344. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112345. */
  112346. get checkCollisions(): boolean;
  112347. set checkCollisions(collisionEnabled: boolean);
  112348. /**
  112349. * Gets Collider object used to compute collisions (not physics)
  112350. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112351. */
  112352. get collider(): Nullable<Collider>;
  112353. /**
  112354. * Move the mesh using collision engine
  112355. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112356. * @param displacement defines the requested displacement vector
  112357. * @returns the current mesh
  112358. */
  112359. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112360. private _onCollisionPositionChange;
  112361. /** @hidden */
  112362. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112363. /** @hidden */
  112364. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112365. /** @hidden */
  112366. _checkCollision(collider: Collider): AbstractMesh;
  112367. /** @hidden */
  112368. _generatePointsArray(): boolean;
  112369. /**
  112370. * Checks if the passed Ray intersects with the mesh
  112371. * @param ray defines the ray to use
  112372. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112373. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112374. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112375. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112376. * @returns the picking info
  112377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112378. */
  112379. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112380. /**
  112381. * Clones the current mesh
  112382. * @param name defines the mesh name
  112383. * @param newParent defines the new mesh parent
  112384. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112385. * @returns the new mesh
  112386. */
  112387. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112388. /**
  112389. * Disposes all the submeshes of the current meshnp
  112390. * @returns the current mesh
  112391. */
  112392. releaseSubMeshes(): AbstractMesh;
  112393. /**
  112394. * Releases resources associated with this abstract mesh.
  112395. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112396. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112397. */
  112398. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112399. /**
  112400. * Adds the passed mesh as a child to the current mesh
  112401. * @param mesh defines the child mesh
  112402. * @returns the current mesh
  112403. */
  112404. addChild(mesh: AbstractMesh): AbstractMesh;
  112405. /**
  112406. * Removes the passed mesh from the current mesh children list
  112407. * @param mesh defines the child mesh
  112408. * @returns the current mesh
  112409. */
  112410. removeChild(mesh: AbstractMesh): AbstractMesh;
  112411. /** @hidden */
  112412. private _initFacetData;
  112413. /**
  112414. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112415. * This method can be called within the render loop.
  112416. * 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
  112417. * @returns the current mesh
  112418. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112419. */
  112420. updateFacetData(): AbstractMesh;
  112421. /**
  112422. * Returns the facetLocalNormals array.
  112423. * The normals are expressed in the mesh local spac
  112424. * @returns an array of Vector3
  112425. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112426. */
  112427. getFacetLocalNormals(): Vector3[];
  112428. /**
  112429. * Returns the facetLocalPositions array.
  112430. * The facet positions are expressed in the mesh local space
  112431. * @returns an array of Vector3
  112432. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112433. */
  112434. getFacetLocalPositions(): Vector3[];
  112435. /**
  112436. * Returns the facetLocalPartioning array
  112437. * @returns an array of array of numbers
  112438. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112439. */
  112440. getFacetLocalPartitioning(): number[][];
  112441. /**
  112442. * Returns the i-th facet position in the world system.
  112443. * This method allocates a new Vector3 per call
  112444. * @param i defines the facet index
  112445. * @returns a new Vector3
  112446. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112447. */
  112448. getFacetPosition(i: number): Vector3;
  112449. /**
  112450. * Sets the reference Vector3 with the i-th facet position in the world system
  112451. * @param i defines the facet index
  112452. * @param ref defines the target vector
  112453. * @returns the current mesh
  112454. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112455. */
  112456. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  112457. /**
  112458. * Returns the i-th facet normal in the world system.
  112459. * This method allocates a new Vector3 per call
  112460. * @param i defines the facet index
  112461. * @returns a new Vector3
  112462. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112463. */
  112464. getFacetNormal(i: number): Vector3;
  112465. /**
  112466. * Sets the reference Vector3 with the i-th facet normal in the world system
  112467. * @param i defines the facet index
  112468. * @param ref defines the target vector
  112469. * @returns the current mesh
  112470. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112471. */
  112472. getFacetNormalToRef(i: number, ref: Vector3): this;
  112473. /**
  112474. * 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)
  112475. * @param x defines x coordinate
  112476. * @param y defines y coordinate
  112477. * @param z defines z coordinate
  112478. * @returns the array of facet indexes
  112479. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112480. */
  112481. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  112482. /**
  112483. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  112484. * @param projected sets as the (x,y,z) world projection on the facet
  112485. * @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
  112486. * @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
  112487. * @param x defines x coordinate
  112488. * @param y defines y coordinate
  112489. * @param z defines z coordinate
  112490. * @returns the face index if found (or null instead)
  112491. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112492. */
  112493. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112494. /**
  112495. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  112496. * @param projected sets as the (x,y,z) local projection on the facet
  112497. * @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
  112498. * @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
  112499. * @param x defines x coordinate
  112500. * @param y defines y coordinate
  112501. * @param z defines z coordinate
  112502. * @returns the face index if found (or null instead)
  112503. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112504. */
  112505. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112506. /**
  112507. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  112508. * @returns the parameters
  112509. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112510. */
  112511. getFacetDataParameters(): any;
  112512. /**
  112513. * Disables the feature FacetData and frees the related memory
  112514. * @returns the current mesh
  112515. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112516. */
  112517. disableFacetData(): AbstractMesh;
  112518. /**
  112519. * Updates the AbstractMesh indices array
  112520. * @param indices defines the data source
  112521. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  112522. * @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)
  112523. * @returns the current mesh
  112524. */
  112525. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  112526. /**
  112527. * Creates new normals data for the mesh
  112528. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  112529. * @returns the current mesh
  112530. */
  112531. createNormals(updatable: boolean): AbstractMesh;
  112532. /**
  112533. * Align the mesh with a normal
  112534. * @param normal defines the normal to use
  112535. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112536. * @returns the current mesh
  112537. */
  112538. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112539. /** @hidden */
  112540. _checkOcclusionQuery(): boolean;
  112541. /**
  112542. * Disables the mesh edge rendering mode
  112543. * @returns the currentAbstractMesh
  112544. */
  112545. disableEdgesRendering(): AbstractMesh;
  112546. /**
  112547. * Enables the edge rendering mode on the mesh.
  112548. * This mode makes the mesh edges visible
  112549. * @param epsilon defines the maximal distance between two angles to detect a face
  112550. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112551. * @returns the currentAbstractMesh
  112552. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112553. */
  112554. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112555. /**
  112556. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112557. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112558. */
  112559. getConnectedParticleSystems(): IParticleSystem[];
  112560. }
  112561. }
  112562. declare module BABYLON {
  112563. /**
  112564. * Interface used to define ActionEvent
  112565. */
  112566. export interface IActionEvent {
  112567. /** The mesh or sprite that triggered the action */
  112568. source: any;
  112569. /** The X mouse cursor position at the time of the event */
  112570. pointerX: number;
  112571. /** The Y mouse cursor position at the time of the event */
  112572. pointerY: number;
  112573. /** The mesh that is currently pointed at (can be null) */
  112574. meshUnderPointer: Nullable<AbstractMesh>;
  112575. /** the original (browser) event that triggered the ActionEvent */
  112576. sourceEvent?: any;
  112577. /** additional data for the event */
  112578. additionalData?: any;
  112579. }
  112580. /**
  112581. * ActionEvent is the event being sent when an action is triggered.
  112582. */
  112583. export class ActionEvent implements IActionEvent {
  112584. /** The mesh or sprite that triggered the action */
  112585. source: any;
  112586. /** The X mouse cursor position at the time of the event */
  112587. pointerX: number;
  112588. /** The Y mouse cursor position at the time of the event */
  112589. pointerY: number;
  112590. /** The mesh that is currently pointed at (can be null) */
  112591. meshUnderPointer: Nullable<AbstractMesh>;
  112592. /** the original (browser) event that triggered the ActionEvent */
  112593. sourceEvent?: any;
  112594. /** additional data for the event */
  112595. additionalData?: any;
  112596. /**
  112597. * Creates a new ActionEvent
  112598. * @param source The mesh or sprite that triggered the action
  112599. * @param pointerX The X mouse cursor position at the time of the event
  112600. * @param pointerY The Y mouse cursor position at the time of the event
  112601. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112602. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112603. * @param additionalData additional data for the event
  112604. */
  112605. constructor(
  112606. /** The mesh or sprite that triggered the action */
  112607. source: any,
  112608. /** The X mouse cursor position at the time of the event */
  112609. pointerX: number,
  112610. /** The Y mouse cursor position at the time of the event */
  112611. pointerY: number,
  112612. /** The mesh that is currently pointed at (can be null) */
  112613. meshUnderPointer: Nullable<AbstractMesh>,
  112614. /** the original (browser) event that triggered the ActionEvent */
  112615. sourceEvent?: any,
  112616. /** additional data for the event */
  112617. additionalData?: any);
  112618. /**
  112619. * Helper function to auto-create an ActionEvent from a source mesh.
  112620. * @param source The source mesh that triggered the event
  112621. * @param evt The original (browser) event
  112622. * @param additionalData additional data for the event
  112623. * @returns the new ActionEvent
  112624. */
  112625. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112626. /**
  112627. * Helper function to auto-create an ActionEvent from a source sprite
  112628. * @param source The source sprite that triggered the event
  112629. * @param scene Scene associated with the sprite
  112630. * @param evt The original (browser) event
  112631. * @param additionalData additional data for the event
  112632. * @returns the new ActionEvent
  112633. */
  112634. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112635. /**
  112636. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112637. * @param scene the scene where the event occurred
  112638. * @param evt The original (browser) event
  112639. * @returns the new ActionEvent
  112640. */
  112641. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112642. /**
  112643. * Helper function to auto-create an ActionEvent from a primitive
  112644. * @param prim defines the target primitive
  112645. * @param pointerPos defines the pointer position
  112646. * @param evt The original (browser) event
  112647. * @param additionalData additional data for the event
  112648. * @returns the new ActionEvent
  112649. */
  112650. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112651. }
  112652. }
  112653. declare module BABYLON {
  112654. /**
  112655. * Abstract class used to decouple action Manager from scene and meshes.
  112656. * Do not instantiate.
  112657. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112658. */
  112659. export abstract class AbstractActionManager implements IDisposable {
  112660. /** Gets the list of active triggers */
  112661. static Triggers: {
  112662. [key: string]: number;
  112663. };
  112664. /** Gets the cursor to use when hovering items */
  112665. hoverCursor: string;
  112666. /** Gets the list of actions */
  112667. actions: IAction[];
  112668. /**
  112669. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112670. */
  112671. isRecursive: boolean;
  112672. /**
  112673. * Releases all associated resources
  112674. */
  112675. abstract dispose(): void;
  112676. /**
  112677. * Does this action manager has pointer triggers
  112678. */
  112679. abstract get hasPointerTriggers(): boolean;
  112680. /**
  112681. * Does this action manager has pick triggers
  112682. */
  112683. abstract get hasPickTriggers(): boolean;
  112684. /**
  112685. * Process a specific trigger
  112686. * @param trigger defines the trigger to process
  112687. * @param evt defines the event details to be processed
  112688. */
  112689. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112690. /**
  112691. * Does this action manager handles actions of any of the given triggers
  112692. * @param triggers defines the triggers to be tested
  112693. * @return a boolean indicating whether one (or more) of the triggers is handled
  112694. */
  112695. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112696. /**
  112697. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112698. * speed.
  112699. * @param triggerA defines the trigger to be tested
  112700. * @param triggerB defines the trigger to be tested
  112701. * @return a boolean indicating whether one (or more) of the triggers is handled
  112702. */
  112703. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112704. /**
  112705. * Does this action manager handles actions of a given trigger
  112706. * @param trigger defines the trigger to be tested
  112707. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112708. * @return whether the trigger is handled
  112709. */
  112710. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112711. /**
  112712. * Serialize this manager to a JSON object
  112713. * @param name defines the property name to store this manager
  112714. * @returns a JSON representation of this manager
  112715. */
  112716. abstract serialize(name: string): any;
  112717. /**
  112718. * Registers an action to this action manager
  112719. * @param action defines the action to be registered
  112720. * @return the action amended (prepared) after registration
  112721. */
  112722. abstract registerAction(action: IAction): Nullable<IAction>;
  112723. /**
  112724. * Unregisters an action to this action manager
  112725. * @param action defines the action to be unregistered
  112726. * @return a boolean indicating whether the action has been unregistered
  112727. */
  112728. abstract unregisterAction(action: IAction): Boolean;
  112729. /**
  112730. * Does exist one action manager with at least one trigger
  112731. **/
  112732. static get HasTriggers(): boolean;
  112733. /**
  112734. * Does exist one action manager with at least one pick trigger
  112735. **/
  112736. static get HasPickTriggers(): boolean;
  112737. /**
  112738. * Does exist one action manager that handles actions of a given trigger
  112739. * @param trigger defines the trigger to be tested
  112740. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  112741. **/
  112742. static HasSpecificTrigger(trigger: number): boolean;
  112743. }
  112744. }
  112745. declare module BABYLON {
  112746. /**
  112747. * Defines how a node can be built from a string name.
  112748. */
  112749. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  112750. /**
  112751. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  112752. */
  112753. export class Node implements IBehaviorAware<Node> {
  112754. /** @hidden */
  112755. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  112756. private static _NodeConstructors;
  112757. /**
  112758. * Add a new node constructor
  112759. * @param type defines the type name of the node to construct
  112760. * @param constructorFunc defines the constructor function
  112761. */
  112762. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  112763. /**
  112764. * Returns a node constructor based on type name
  112765. * @param type defines the type name
  112766. * @param name defines the new node name
  112767. * @param scene defines the hosting scene
  112768. * @param options defines optional options to transmit to constructors
  112769. * @returns the new constructor or null
  112770. */
  112771. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  112772. /**
  112773. * Gets or sets the name of the node
  112774. */
  112775. name: string;
  112776. /**
  112777. * Gets or sets the id of the node
  112778. */
  112779. id: string;
  112780. /**
  112781. * Gets or sets the unique id of the node
  112782. */
  112783. uniqueId: number;
  112784. /**
  112785. * Gets or sets a string used to store user defined state for the node
  112786. */
  112787. state: string;
  112788. /**
  112789. * Gets or sets an object used to store user defined information for the node
  112790. */
  112791. metadata: any;
  112792. /**
  112793. * For internal use only. Please do not use.
  112794. */
  112795. reservedDataStore: any;
  112796. /**
  112797. * List of inspectable custom properties (used by the Inspector)
  112798. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112799. */
  112800. inspectableCustomProperties: IInspectable[];
  112801. private _doNotSerialize;
  112802. /**
  112803. * Gets or sets a boolean used to define if the node must be serialized
  112804. */
  112805. get doNotSerialize(): boolean;
  112806. set doNotSerialize(value: boolean);
  112807. /** @hidden */
  112808. _isDisposed: boolean;
  112809. /**
  112810. * Gets a list of Animations associated with the node
  112811. */
  112812. animations: Animation[];
  112813. protected _ranges: {
  112814. [name: string]: Nullable<AnimationRange>;
  112815. };
  112816. /**
  112817. * Callback raised when the node is ready to be used
  112818. */
  112819. onReady: Nullable<(node: Node) => void>;
  112820. private _isEnabled;
  112821. private _isParentEnabled;
  112822. private _isReady;
  112823. /** @hidden */
  112824. _currentRenderId: number;
  112825. private _parentUpdateId;
  112826. /** @hidden */
  112827. _childUpdateId: number;
  112828. /** @hidden */
  112829. _waitingParentId: Nullable<string>;
  112830. /** @hidden */
  112831. _scene: Scene;
  112832. /** @hidden */
  112833. _cache: any;
  112834. private _parentNode;
  112835. private _children;
  112836. /** @hidden */
  112837. _worldMatrix: Matrix;
  112838. /** @hidden */
  112839. _worldMatrixDeterminant: number;
  112840. /** @hidden */
  112841. _worldMatrixDeterminantIsDirty: boolean;
  112842. /** @hidden */
  112843. private _sceneRootNodesIndex;
  112844. /**
  112845. * Gets a boolean indicating if the node has been disposed
  112846. * @returns true if the node was disposed
  112847. */
  112848. isDisposed(): boolean;
  112849. /**
  112850. * Gets or sets the parent of the node (without keeping the current position in the scene)
  112851. * @see https://doc.babylonjs.com/how_to/parenting
  112852. */
  112853. set parent(parent: Nullable<Node>);
  112854. get parent(): Nullable<Node>;
  112855. /** @hidden */
  112856. _addToSceneRootNodes(): void;
  112857. /** @hidden */
  112858. _removeFromSceneRootNodes(): void;
  112859. private _animationPropertiesOverride;
  112860. /**
  112861. * Gets or sets the animation properties override
  112862. */
  112863. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112864. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112865. /**
  112866. * Gets a string identifying the name of the class
  112867. * @returns "Node" string
  112868. */
  112869. getClassName(): string;
  112870. /** @hidden */
  112871. readonly _isNode: boolean;
  112872. /**
  112873. * An event triggered when the mesh is disposed
  112874. */
  112875. onDisposeObservable: Observable<Node>;
  112876. private _onDisposeObserver;
  112877. /**
  112878. * Sets a callback that will be raised when the node will be disposed
  112879. */
  112880. set onDispose(callback: () => void);
  112881. /**
  112882. * Creates a new Node
  112883. * @param name the name and id to be given to this node
  112884. * @param scene the scene this node will be added to
  112885. */
  112886. constructor(name: string, scene?: Nullable<Scene>);
  112887. /**
  112888. * Gets the scene of the node
  112889. * @returns a scene
  112890. */
  112891. getScene(): Scene;
  112892. /**
  112893. * Gets the engine of the node
  112894. * @returns a Engine
  112895. */
  112896. getEngine(): Engine;
  112897. private _behaviors;
  112898. /**
  112899. * Attach a behavior to the node
  112900. * @see https://doc.babylonjs.com/features/behaviour
  112901. * @param behavior defines the behavior to attach
  112902. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  112903. * @returns the current Node
  112904. */
  112905. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  112906. /**
  112907. * Remove an attached behavior
  112908. * @see https://doc.babylonjs.com/features/behaviour
  112909. * @param behavior defines the behavior to attach
  112910. * @returns the current Node
  112911. */
  112912. removeBehavior(behavior: Behavior<Node>): Node;
  112913. /**
  112914. * Gets the list of attached behaviors
  112915. * @see https://doc.babylonjs.com/features/behaviour
  112916. */
  112917. get behaviors(): Behavior<Node>[];
  112918. /**
  112919. * Gets an attached behavior by name
  112920. * @param name defines the name of the behavior to look for
  112921. * @see https://doc.babylonjs.com/features/behaviour
  112922. * @returns null if behavior was not found else the requested behavior
  112923. */
  112924. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  112925. /**
  112926. * Returns the latest update of the World matrix
  112927. * @returns a Matrix
  112928. */
  112929. getWorldMatrix(): Matrix;
  112930. /** @hidden */
  112931. _getWorldMatrixDeterminant(): number;
  112932. /**
  112933. * Returns directly the latest state of the mesh World matrix.
  112934. * A Matrix is returned.
  112935. */
  112936. get worldMatrixFromCache(): Matrix;
  112937. /** @hidden */
  112938. _initCache(): void;
  112939. /** @hidden */
  112940. updateCache(force?: boolean): void;
  112941. /** @hidden */
  112942. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112943. /** @hidden */
  112944. _updateCache(ignoreParentClass?: boolean): void;
  112945. /** @hidden */
  112946. _isSynchronized(): boolean;
  112947. /** @hidden */
  112948. _markSyncedWithParent(): void;
  112949. /** @hidden */
  112950. isSynchronizedWithParent(): boolean;
  112951. /** @hidden */
  112952. isSynchronized(): boolean;
  112953. /**
  112954. * Is this node ready to be used/rendered
  112955. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112956. * @return true if the node is ready
  112957. */
  112958. isReady(completeCheck?: boolean): boolean;
  112959. /**
  112960. * Is this node enabled?
  112961. * 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
  112962. * @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
  112963. * @return whether this node (and its parent) is enabled
  112964. */
  112965. isEnabled(checkAncestors?: boolean): boolean;
  112966. /** @hidden */
  112967. protected _syncParentEnabledState(): void;
  112968. /**
  112969. * Set the enabled state of this node
  112970. * @param value defines the new enabled state
  112971. */
  112972. setEnabled(value: boolean): void;
  112973. /**
  112974. * Is this node a descendant of the given node?
  112975. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  112976. * @param ancestor defines the parent node to inspect
  112977. * @returns a boolean indicating if this node is a descendant of the given node
  112978. */
  112979. isDescendantOf(ancestor: Node): boolean;
  112980. /** @hidden */
  112981. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  112982. /**
  112983. * Will return all nodes that have this node as ascendant
  112984. * @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
  112985. * @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
  112986. * @return all children nodes of all types
  112987. */
  112988. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  112989. /**
  112990. * Get all child-meshes of this node
  112991. * @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)
  112992. * @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
  112993. * @returns an array of AbstractMesh
  112994. */
  112995. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  112996. /**
  112997. * Get all direct children of this node
  112998. * @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
  112999. * @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)
  113000. * @returns an array of Node
  113001. */
  113002. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113003. /** @hidden */
  113004. _setReady(state: boolean): void;
  113005. /**
  113006. * Get an animation by name
  113007. * @param name defines the name of the animation to look for
  113008. * @returns null if not found else the requested animation
  113009. */
  113010. getAnimationByName(name: string): Nullable<Animation>;
  113011. /**
  113012. * Creates an animation range for this node
  113013. * @param name defines the name of the range
  113014. * @param from defines the starting key
  113015. * @param to defines the end key
  113016. */
  113017. createAnimationRange(name: string, from: number, to: number): void;
  113018. /**
  113019. * Delete a specific animation range
  113020. * @param name defines the name of the range to delete
  113021. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113022. */
  113023. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113024. /**
  113025. * Get an animation range by name
  113026. * @param name defines the name of the animation range to look for
  113027. * @returns null if not found else the requested animation range
  113028. */
  113029. getAnimationRange(name: string): Nullable<AnimationRange>;
  113030. /**
  113031. * Gets the list of all animation ranges defined on this node
  113032. * @returns an array
  113033. */
  113034. getAnimationRanges(): Nullable<AnimationRange>[];
  113035. /**
  113036. * Will start the animation sequence
  113037. * @param name defines the range frames for animation sequence
  113038. * @param loop defines if the animation should loop (false by default)
  113039. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113040. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113041. * @returns the object created for this animation. If range does not exist, it will return null
  113042. */
  113043. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113044. /**
  113045. * Serialize animation ranges into a JSON compatible object
  113046. * @returns serialization object
  113047. */
  113048. serializeAnimationRanges(): any;
  113049. /**
  113050. * Computes the world matrix of the node
  113051. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113052. * @returns the world matrix
  113053. */
  113054. computeWorldMatrix(force?: boolean): Matrix;
  113055. /**
  113056. * Releases resources associated with this node.
  113057. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113058. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113059. */
  113060. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113061. /**
  113062. * Parse animation range data from a serialization object and store them into a given node
  113063. * @param node defines where to store the animation ranges
  113064. * @param parsedNode defines the serialization object to read data from
  113065. * @param scene defines the hosting scene
  113066. */
  113067. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113068. /**
  113069. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113070. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113071. * @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
  113072. * @returns the new bounding vectors
  113073. */
  113074. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113075. min: Vector3;
  113076. max: Vector3;
  113077. };
  113078. }
  113079. }
  113080. declare module BABYLON {
  113081. /**
  113082. * @hidden
  113083. */
  113084. export class _IAnimationState {
  113085. key: number;
  113086. repeatCount: number;
  113087. workValue?: any;
  113088. loopMode?: number;
  113089. offsetValue?: any;
  113090. highLimitValue?: any;
  113091. }
  113092. /**
  113093. * Class used to store any kind of animation
  113094. */
  113095. export class Animation {
  113096. /**Name of the animation */
  113097. name: string;
  113098. /**Property to animate */
  113099. targetProperty: string;
  113100. /**The frames per second of the animation */
  113101. framePerSecond: number;
  113102. /**The data type of the animation */
  113103. dataType: number;
  113104. /**The loop mode of the animation */
  113105. loopMode?: number | undefined;
  113106. /**Specifies if blending should be enabled */
  113107. enableBlending?: boolean | undefined;
  113108. /**
  113109. * Use matrix interpolation instead of using direct key value when animating matrices
  113110. */
  113111. static AllowMatricesInterpolation: boolean;
  113112. /**
  113113. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113114. */
  113115. static AllowMatrixDecomposeForInterpolation: boolean;
  113116. /** Define the Url to load snippets */
  113117. static SnippetUrl: string;
  113118. /** Snippet ID if the animation was created from the snippet server */
  113119. snippetId: string;
  113120. /**
  113121. * Stores the key frames of the animation
  113122. */
  113123. private _keys;
  113124. /**
  113125. * Stores the easing function of the animation
  113126. */
  113127. private _easingFunction;
  113128. /**
  113129. * @hidden Internal use only
  113130. */
  113131. _runtimeAnimations: RuntimeAnimation[];
  113132. /**
  113133. * The set of event that will be linked to this animation
  113134. */
  113135. private _events;
  113136. /**
  113137. * Stores an array of target property paths
  113138. */
  113139. targetPropertyPath: string[];
  113140. /**
  113141. * Stores the blending speed of the animation
  113142. */
  113143. blendingSpeed: number;
  113144. /**
  113145. * Stores the animation ranges for the animation
  113146. */
  113147. private _ranges;
  113148. /**
  113149. * @hidden Internal use
  113150. */
  113151. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113152. /**
  113153. * Sets up an animation
  113154. * @param property The property to animate
  113155. * @param animationType The animation type to apply
  113156. * @param framePerSecond The frames per second of the animation
  113157. * @param easingFunction The easing function used in the animation
  113158. * @returns The created animation
  113159. */
  113160. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113161. /**
  113162. * Create and start an animation on a node
  113163. * @param name defines the name of the global animation that will be run on all nodes
  113164. * @param node defines the root node where the animation will take place
  113165. * @param targetProperty defines property to animate
  113166. * @param framePerSecond defines the number of frame per second yo use
  113167. * @param totalFrame defines the number of frames in total
  113168. * @param from defines the initial value
  113169. * @param to defines the final value
  113170. * @param loopMode defines which loop mode you want to use (off by default)
  113171. * @param easingFunction defines the easing function to use (linear by default)
  113172. * @param onAnimationEnd defines the callback to call when animation end
  113173. * @returns the animatable created for this animation
  113174. */
  113175. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113176. /**
  113177. * Create and start an animation on a node and its descendants
  113178. * @param name defines the name of the global animation that will be run on all nodes
  113179. * @param node defines the root node where the animation will take place
  113180. * @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
  113181. * @param targetProperty defines property to animate
  113182. * @param framePerSecond defines the number of frame per second to use
  113183. * @param totalFrame defines the number of frames in total
  113184. * @param from defines the initial value
  113185. * @param to defines the final value
  113186. * @param loopMode defines which loop mode you want to use (off by default)
  113187. * @param easingFunction defines the easing function to use (linear by default)
  113188. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113189. * @returns the list of animatables created for all nodes
  113190. * @example https://www.babylonjs-playground.com/#MH0VLI
  113191. */
  113192. 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[]>;
  113193. /**
  113194. * Creates a new animation, merges it with the existing animations and starts it
  113195. * @param name Name of the animation
  113196. * @param node Node which contains the scene that begins the animations
  113197. * @param targetProperty Specifies which property to animate
  113198. * @param framePerSecond The frames per second of the animation
  113199. * @param totalFrame The total number of frames
  113200. * @param from The frame at the beginning of the animation
  113201. * @param to The frame at the end of the animation
  113202. * @param loopMode Specifies the loop mode of the animation
  113203. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113204. * @param onAnimationEnd Callback to run once the animation is complete
  113205. * @returns Nullable animation
  113206. */
  113207. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113208. /**
  113209. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113210. * @param sourceAnimation defines the Animation containing keyframes to convert
  113211. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113212. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113213. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113214. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113215. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113216. */
  113217. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113218. /**
  113219. * Transition property of an host to the target Value
  113220. * @param property The property to transition
  113221. * @param targetValue The target Value of the property
  113222. * @param host The object where the property to animate belongs
  113223. * @param scene Scene used to run the animation
  113224. * @param frameRate Framerate (in frame/s) to use
  113225. * @param transition The transition type we want to use
  113226. * @param duration The duration of the animation, in milliseconds
  113227. * @param onAnimationEnd Callback trigger at the end of the animation
  113228. * @returns Nullable animation
  113229. */
  113230. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113231. /**
  113232. * Return the array of runtime animations currently using this animation
  113233. */
  113234. get runtimeAnimations(): RuntimeAnimation[];
  113235. /**
  113236. * Specifies if any of the runtime animations are currently running
  113237. */
  113238. get hasRunningRuntimeAnimations(): boolean;
  113239. /**
  113240. * Initializes the animation
  113241. * @param name Name of the animation
  113242. * @param targetProperty Property to animate
  113243. * @param framePerSecond The frames per second of the animation
  113244. * @param dataType The data type of the animation
  113245. * @param loopMode The loop mode of the animation
  113246. * @param enableBlending Specifies if blending should be enabled
  113247. */
  113248. constructor(
  113249. /**Name of the animation */
  113250. name: string,
  113251. /**Property to animate */
  113252. targetProperty: string,
  113253. /**The frames per second of the animation */
  113254. framePerSecond: number,
  113255. /**The data type of the animation */
  113256. dataType: number,
  113257. /**The loop mode of the animation */
  113258. loopMode?: number | undefined,
  113259. /**Specifies if blending should be enabled */
  113260. enableBlending?: boolean | undefined);
  113261. /**
  113262. * Converts the animation to a string
  113263. * @param fullDetails support for multiple levels of logging within scene loading
  113264. * @returns String form of the animation
  113265. */
  113266. toString(fullDetails?: boolean): string;
  113267. /**
  113268. * Add an event to this animation
  113269. * @param event Event to add
  113270. */
  113271. addEvent(event: AnimationEvent): void;
  113272. /**
  113273. * Remove all events found at the given frame
  113274. * @param frame The frame to remove events from
  113275. */
  113276. removeEvents(frame: number): void;
  113277. /**
  113278. * Retrieves all the events from the animation
  113279. * @returns Events from the animation
  113280. */
  113281. getEvents(): AnimationEvent[];
  113282. /**
  113283. * Creates an animation range
  113284. * @param name Name of the animation range
  113285. * @param from Starting frame of the animation range
  113286. * @param to Ending frame of the animation
  113287. */
  113288. createRange(name: string, from: number, to: number): void;
  113289. /**
  113290. * Deletes an animation range by name
  113291. * @param name Name of the animation range to delete
  113292. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113293. */
  113294. deleteRange(name: string, deleteFrames?: boolean): void;
  113295. /**
  113296. * Gets the animation range by name, or null if not defined
  113297. * @param name Name of the animation range
  113298. * @returns Nullable animation range
  113299. */
  113300. getRange(name: string): Nullable<AnimationRange>;
  113301. /**
  113302. * Gets the key frames from the animation
  113303. * @returns The key frames of the animation
  113304. */
  113305. getKeys(): Array<IAnimationKey>;
  113306. /**
  113307. * Gets the highest frame rate of the animation
  113308. * @returns Highest frame rate of the animation
  113309. */
  113310. getHighestFrame(): number;
  113311. /**
  113312. * Gets the easing function of the animation
  113313. * @returns Easing function of the animation
  113314. */
  113315. getEasingFunction(): IEasingFunction;
  113316. /**
  113317. * Sets the easing function of the animation
  113318. * @param easingFunction A custom mathematical formula for animation
  113319. */
  113320. setEasingFunction(easingFunction: EasingFunction): void;
  113321. /**
  113322. * Interpolates a scalar linearly
  113323. * @param startValue Start value of the animation curve
  113324. * @param endValue End value of the animation curve
  113325. * @param gradient Scalar amount to interpolate
  113326. * @returns Interpolated scalar value
  113327. */
  113328. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113329. /**
  113330. * Interpolates a scalar cubically
  113331. * @param startValue Start value of the animation curve
  113332. * @param outTangent End tangent of the animation
  113333. * @param endValue End value of the animation curve
  113334. * @param inTangent Start tangent of the animation curve
  113335. * @param gradient Scalar amount to interpolate
  113336. * @returns Interpolated scalar value
  113337. */
  113338. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113339. /**
  113340. * Interpolates a quaternion using a spherical linear interpolation
  113341. * @param startValue Start value of the animation curve
  113342. * @param endValue End value of the animation curve
  113343. * @param gradient Scalar amount to interpolate
  113344. * @returns Interpolated quaternion value
  113345. */
  113346. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113347. /**
  113348. * Interpolates a quaternion cubically
  113349. * @param startValue Start value of the animation curve
  113350. * @param outTangent End tangent of the animation curve
  113351. * @param endValue End value of the animation curve
  113352. * @param inTangent Start tangent of the animation curve
  113353. * @param gradient Scalar amount to interpolate
  113354. * @returns Interpolated quaternion value
  113355. */
  113356. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113357. /**
  113358. * Interpolates a Vector3 linearl
  113359. * @param startValue Start value of the animation curve
  113360. * @param endValue End value of the animation curve
  113361. * @param gradient Scalar amount to interpolate
  113362. * @returns Interpolated scalar value
  113363. */
  113364. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113365. /**
  113366. * Interpolates a Vector3 cubically
  113367. * @param startValue Start value of the animation curve
  113368. * @param outTangent End tangent of the animation
  113369. * @param endValue End value of the animation curve
  113370. * @param inTangent Start tangent of the animation curve
  113371. * @param gradient Scalar amount to interpolate
  113372. * @returns InterpolatedVector3 value
  113373. */
  113374. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113375. /**
  113376. * Interpolates a Vector2 linearly
  113377. * @param startValue Start value of the animation curve
  113378. * @param endValue End value of the animation curve
  113379. * @param gradient Scalar amount to interpolate
  113380. * @returns Interpolated Vector2 value
  113381. */
  113382. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113383. /**
  113384. * Interpolates a Vector2 cubically
  113385. * @param startValue Start value of the animation curve
  113386. * @param outTangent End tangent of the animation
  113387. * @param endValue End value of the animation curve
  113388. * @param inTangent Start tangent of the animation curve
  113389. * @param gradient Scalar amount to interpolate
  113390. * @returns Interpolated Vector2 value
  113391. */
  113392. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113393. /**
  113394. * Interpolates a size linearly
  113395. * @param startValue Start value of the animation curve
  113396. * @param endValue End value of the animation curve
  113397. * @param gradient Scalar amount to interpolate
  113398. * @returns Interpolated Size value
  113399. */
  113400. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113401. /**
  113402. * Interpolates a Color3 linearly
  113403. * @param startValue Start value of the animation curve
  113404. * @param endValue End value of the animation curve
  113405. * @param gradient Scalar amount to interpolate
  113406. * @returns Interpolated Color3 value
  113407. */
  113408. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113409. /**
  113410. * Interpolates a Color4 linearly
  113411. * @param startValue Start value of the animation curve
  113412. * @param endValue End value of the animation curve
  113413. * @param gradient Scalar amount to interpolate
  113414. * @returns Interpolated Color3 value
  113415. */
  113416. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113417. /**
  113418. * @hidden Internal use only
  113419. */
  113420. _getKeyValue(value: any): any;
  113421. /**
  113422. * @hidden Internal use only
  113423. */
  113424. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113425. /**
  113426. * Defines the function to use to interpolate matrices
  113427. * @param startValue defines the start matrix
  113428. * @param endValue defines the end matrix
  113429. * @param gradient defines the gradient between both matrices
  113430. * @param result defines an optional target matrix where to store the interpolation
  113431. * @returns the interpolated matrix
  113432. */
  113433. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  113434. /**
  113435. * Makes a copy of the animation
  113436. * @returns Cloned animation
  113437. */
  113438. clone(): Animation;
  113439. /**
  113440. * Sets the key frames of the animation
  113441. * @param values The animation key frames to set
  113442. */
  113443. setKeys(values: Array<IAnimationKey>): void;
  113444. /**
  113445. * Serializes the animation to an object
  113446. * @returns Serialized object
  113447. */
  113448. serialize(): any;
  113449. /**
  113450. * Float animation type
  113451. */
  113452. static readonly ANIMATIONTYPE_FLOAT: number;
  113453. /**
  113454. * Vector3 animation type
  113455. */
  113456. static readonly ANIMATIONTYPE_VECTOR3: number;
  113457. /**
  113458. * Quaternion animation type
  113459. */
  113460. static readonly ANIMATIONTYPE_QUATERNION: number;
  113461. /**
  113462. * Matrix animation type
  113463. */
  113464. static readonly ANIMATIONTYPE_MATRIX: number;
  113465. /**
  113466. * Color3 animation type
  113467. */
  113468. static readonly ANIMATIONTYPE_COLOR3: number;
  113469. /**
  113470. * Color3 animation type
  113471. */
  113472. static readonly ANIMATIONTYPE_COLOR4: number;
  113473. /**
  113474. * Vector2 animation type
  113475. */
  113476. static readonly ANIMATIONTYPE_VECTOR2: number;
  113477. /**
  113478. * Size animation type
  113479. */
  113480. static readonly ANIMATIONTYPE_SIZE: number;
  113481. /**
  113482. * Relative Loop Mode
  113483. */
  113484. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  113485. /**
  113486. * Cycle Loop Mode
  113487. */
  113488. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  113489. /**
  113490. * Constant Loop Mode
  113491. */
  113492. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  113493. /** @hidden */
  113494. static _UniversalLerp(left: any, right: any, amount: number): any;
  113495. /**
  113496. * Parses an animation object and creates an animation
  113497. * @param parsedAnimation Parsed animation object
  113498. * @returns Animation object
  113499. */
  113500. static Parse(parsedAnimation: any): Animation;
  113501. /**
  113502. * Appends the serialized animations from the source animations
  113503. * @param source Source containing the animations
  113504. * @param destination Target to store the animations
  113505. */
  113506. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113507. /**
  113508. * Creates a new animation or an array of animations from a snippet saved in a remote file
  113509. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  113510. * @param url defines the url to load from
  113511. * @returns a promise that will resolve to the new animation or an array of animations
  113512. */
  113513. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  113514. /**
  113515. * Creates an animation or an array of animations from a snippet saved by the Inspector
  113516. * @param snippetId defines the snippet to load
  113517. * @returns a promise that will resolve to the new animation or a new array of animations
  113518. */
  113519. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  113520. }
  113521. }
  113522. declare module BABYLON {
  113523. /**
  113524. * Interface containing an array of animations
  113525. */
  113526. export interface IAnimatable {
  113527. /**
  113528. * Array of animations
  113529. */
  113530. animations: Nullable<Array<Animation>>;
  113531. }
  113532. }
  113533. declare module BABYLON {
  113534. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113535. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113536. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113537. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113538. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113539. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113540. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113541. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113542. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113543. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113544. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113545. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113546. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113547. /**
  113548. * Decorator used to define property that can be serialized as reference to a camera
  113549. * @param sourceName defines the name of the property to decorate
  113550. */
  113551. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113552. /**
  113553. * Class used to help serialization objects
  113554. */
  113555. export class SerializationHelper {
  113556. /** @hidden */
  113557. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113558. /** @hidden */
  113559. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113560. /** @hidden */
  113561. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113562. /** @hidden */
  113563. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113564. /**
  113565. * Appends the serialized animations from the source animations
  113566. * @param source Source containing the animations
  113567. * @param destination Target to store the animations
  113568. */
  113569. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113570. /**
  113571. * Static function used to serialized a specific entity
  113572. * @param entity defines the entity to serialize
  113573. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113574. * @returns a JSON compatible object representing the serialization of the entity
  113575. */
  113576. static Serialize<T>(entity: T, serializationObject?: any): any;
  113577. /**
  113578. * Creates a new entity from a serialization data object
  113579. * @param creationFunction defines a function used to instanciated the new entity
  113580. * @param source defines the source serialization data
  113581. * @param scene defines the hosting scene
  113582. * @param rootUrl defines the root url for resources
  113583. * @returns a new entity
  113584. */
  113585. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113586. /**
  113587. * Clones an object
  113588. * @param creationFunction defines the function used to instanciate the new object
  113589. * @param source defines the source object
  113590. * @returns the cloned object
  113591. */
  113592. static Clone<T>(creationFunction: () => T, source: T): T;
  113593. /**
  113594. * Instanciates a new object based on a source one (some data will be shared between both object)
  113595. * @param creationFunction defines the function used to instanciate the new object
  113596. * @param source defines the source object
  113597. * @returns the new object
  113598. */
  113599. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113600. }
  113601. }
  113602. declare module BABYLON {
  113603. /**
  113604. * Base class of all the textures in babylon.
  113605. * It groups all the common properties the materials, post process, lights... might need
  113606. * in order to make a correct use of the texture.
  113607. */
  113608. export class BaseTexture implements IAnimatable {
  113609. /**
  113610. * Default anisotropic filtering level for the application.
  113611. * It is set to 4 as a good tradeoff between perf and quality.
  113612. */
  113613. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113614. /**
  113615. * Gets or sets the unique id of the texture
  113616. */
  113617. uniqueId: number;
  113618. /**
  113619. * Define the name of the texture.
  113620. */
  113621. name: string;
  113622. /**
  113623. * Gets or sets an object used to store user defined information.
  113624. */
  113625. metadata: any;
  113626. /**
  113627. * For internal use only. Please do not use.
  113628. */
  113629. reservedDataStore: any;
  113630. private _hasAlpha;
  113631. /**
  113632. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113633. */
  113634. set hasAlpha(value: boolean);
  113635. get hasAlpha(): boolean;
  113636. /**
  113637. * Defines if the alpha value should be determined via the rgb values.
  113638. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113639. */
  113640. getAlphaFromRGB: boolean;
  113641. /**
  113642. * Intensity or strength of the texture.
  113643. * It is commonly used by materials to fine tune the intensity of the texture
  113644. */
  113645. level: number;
  113646. /**
  113647. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113648. * This is part of the texture as textures usually maps to one uv set.
  113649. */
  113650. coordinatesIndex: number;
  113651. protected _coordinatesMode: number;
  113652. /**
  113653. * How a texture is mapped.
  113654. *
  113655. * | Value | Type | Description |
  113656. * | ----- | ----------------------------------- | ----------- |
  113657. * | 0 | EXPLICIT_MODE | |
  113658. * | 1 | SPHERICAL_MODE | |
  113659. * | 2 | PLANAR_MODE | |
  113660. * | 3 | CUBIC_MODE | |
  113661. * | 4 | PROJECTION_MODE | |
  113662. * | 5 | SKYBOX_MODE | |
  113663. * | 6 | INVCUBIC_MODE | |
  113664. * | 7 | EQUIRECTANGULAR_MODE | |
  113665. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113666. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113667. */
  113668. set coordinatesMode(value: number);
  113669. get coordinatesMode(): number;
  113670. private _wrapU;
  113671. /**
  113672. * | Value | Type | Description |
  113673. * | ----- | ------------------ | ----------- |
  113674. * | 0 | CLAMP_ADDRESSMODE | |
  113675. * | 1 | WRAP_ADDRESSMODE | |
  113676. * | 2 | MIRROR_ADDRESSMODE | |
  113677. */
  113678. get wrapU(): number;
  113679. set wrapU(value: number);
  113680. private _wrapV;
  113681. /**
  113682. * | Value | Type | Description |
  113683. * | ----- | ------------------ | ----------- |
  113684. * | 0 | CLAMP_ADDRESSMODE | |
  113685. * | 1 | WRAP_ADDRESSMODE | |
  113686. * | 2 | MIRROR_ADDRESSMODE | |
  113687. */
  113688. get wrapV(): number;
  113689. set wrapV(value: number);
  113690. /**
  113691. * | Value | Type | Description |
  113692. * | ----- | ------------------ | ----------- |
  113693. * | 0 | CLAMP_ADDRESSMODE | |
  113694. * | 1 | WRAP_ADDRESSMODE | |
  113695. * | 2 | MIRROR_ADDRESSMODE | |
  113696. */
  113697. wrapR: number;
  113698. /**
  113699. * With compliant hardware and browser (supporting anisotropic filtering)
  113700. * this defines the level of anisotropic filtering in the texture.
  113701. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113702. */
  113703. anisotropicFilteringLevel: number;
  113704. /**
  113705. * Define if the texture is a cube texture or if false a 2d texture.
  113706. */
  113707. get isCube(): boolean;
  113708. set isCube(value: boolean);
  113709. /**
  113710. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113711. */
  113712. get is3D(): boolean;
  113713. set is3D(value: boolean);
  113714. /**
  113715. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  113716. */
  113717. get is2DArray(): boolean;
  113718. set is2DArray(value: boolean);
  113719. private _gammaSpace;
  113720. /**
  113721. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  113722. * HDR texture are usually stored in linear space.
  113723. * This only impacts the PBR and Background materials
  113724. */
  113725. get gammaSpace(): boolean;
  113726. set gammaSpace(gamma: boolean);
  113727. /**
  113728. * Gets or sets whether or not the texture contains RGBD data.
  113729. */
  113730. get isRGBD(): boolean;
  113731. set isRGBD(value: boolean);
  113732. /**
  113733. * Is Z inverted in the texture (useful in a cube texture).
  113734. */
  113735. invertZ: boolean;
  113736. /**
  113737. * Are mip maps generated for this texture or not.
  113738. */
  113739. get noMipmap(): boolean;
  113740. /**
  113741. * @hidden
  113742. */
  113743. lodLevelInAlpha: boolean;
  113744. /**
  113745. * With prefiltered texture, defined the offset used during the prefiltering steps.
  113746. */
  113747. get lodGenerationOffset(): number;
  113748. set lodGenerationOffset(value: number);
  113749. /**
  113750. * With prefiltered texture, defined the scale used during the prefiltering steps.
  113751. */
  113752. get lodGenerationScale(): number;
  113753. set lodGenerationScale(value: number);
  113754. /**
  113755. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  113756. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  113757. * average roughness values.
  113758. */
  113759. get linearSpecularLOD(): boolean;
  113760. set linearSpecularLOD(value: boolean);
  113761. /**
  113762. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  113763. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  113764. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  113765. */
  113766. get irradianceTexture(): Nullable<BaseTexture>;
  113767. set irradianceTexture(value: Nullable<BaseTexture>);
  113768. /**
  113769. * Define if the texture is a render target.
  113770. */
  113771. isRenderTarget: boolean;
  113772. /**
  113773. * Define the unique id of the texture in the scene.
  113774. */
  113775. get uid(): string;
  113776. /** @hidden */
  113777. _prefiltered: boolean;
  113778. /**
  113779. * Return a string representation of the texture.
  113780. * @returns the texture as a string
  113781. */
  113782. toString(): string;
  113783. /**
  113784. * Get the class name of the texture.
  113785. * @returns "BaseTexture"
  113786. */
  113787. getClassName(): string;
  113788. /**
  113789. * Define the list of animation attached to the texture.
  113790. */
  113791. animations: Animation[];
  113792. /**
  113793. * An event triggered when the texture is disposed.
  113794. */
  113795. onDisposeObservable: Observable<BaseTexture>;
  113796. private _onDisposeObserver;
  113797. /**
  113798. * Callback triggered when the texture has been disposed.
  113799. * Kept for back compatibility, you can use the onDisposeObservable instead.
  113800. */
  113801. set onDispose(callback: () => void);
  113802. /**
  113803. * Define the current state of the loading sequence when in delayed load mode.
  113804. */
  113805. delayLoadState: number;
  113806. protected _scene: Nullable<Scene>;
  113807. protected _engine: Nullable<ThinEngine>;
  113808. /** @hidden */
  113809. _texture: Nullable<InternalTexture>;
  113810. private _uid;
  113811. /**
  113812. * Define if the texture is preventinga material to render or not.
  113813. * If not and the texture is not ready, the engine will use a default black texture instead.
  113814. */
  113815. get isBlocking(): boolean;
  113816. /**
  113817. * Instantiates a new BaseTexture.
  113818. * Base class of all the textures in babylon.
  113819. * It groups all the common properties the materials, post process, lights... might need
  113820. * in order to make a correct use of the texture.
  113821. * @param sceneOrEngine Define the scene or engine the texture blongs to
  113822. */
  113823. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  113824. /**
  113825. * Get the scene the texture belongs to.
  113826. * @returns the scene or null if undefined
  113827. */
  113828. getScene(): Nullable<Scene>;
  113829. /** @hidden */
  113830. protected _getEngine(): Nullable<ThinEngine>;
  113831. /**
  113832. * Get the texture transform matrix used to offset tile the texture for istance.
  113833. * @returns the transformation matrix
  113834. */
  113835. getTextureMatrix(): Matrix;
  113836. /**
  113837. * Get the texture reflection matrix used to rotate/transform the reflection.
  113838. * @returns the reflection matrix
  113839. */
  113840. getReflectionTextureMatrix(): Matrix;
  113841. /**
  113842. * Get the underlying lower level texture from Babylon.
  113843. * @returns the insternal texture
  113844. */
  113845. getInternalTexture(): Nullable<InternalTexture>;
  113846. /**
  113847. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  113848. * @returns true if ready or not blocking
  113849. */
  113850. isReadyOrNotBlocking(): boolean;
  113851. /**
  113852. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  113853. * @returns true if fully ready
  113854. */
  113855. isReady(): boolean;
  113856. private _cachedSize;
  113857. /**
  113858. * Get the size of the texture.
  113859. * @returns the texture size.
  113860. */
  113861. getSize(): ISize;
  113862. /**
  113863. * Get the base size of the texture.
  113864. * It can be different from the size if the texture has been resized for POT for instance
  113865. * @returns the base size
  113866. */
  113867. getBaseSize(): ISize;
  113868. /**
  113869. * Update the sampling mode of the texture.
  113870. * Default is Trilinear mode.
  113871. *
  113872. * | Value | Type | Description |
  113873. * | ----- | ------------------ | ----------- |
  113874. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  113875. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  113876. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  113877. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  113878. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  113879. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  113880. * | 7 | NEAREST_LINEAR | |
  113881. * | 8 | NEAREST_NEAREST | |
  113882. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  113883. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  113884. * | 11 | LINEAR_LINEAR | |
  113885. * | 12 | LINEAR_NEAREST | |
  113886. *
  113887. * > _mag_: magnification filter (close to the viewer)
  113888. * > _min_: minification filter (far from the viewer)
  113889. * > _mip_: filter used between mip map levels
  113890. *@param samplingMode Define the new sampling mode of the texture
  113891. */
  113892. updateSamplingMode(samplingMode: number): void;
  113893. /**
  113894. * Scales the texture if is `canRescale()`
  113895. * @param ratio the resize factor we want to use to rescale
  113896. */
  113897. scale(ratio: number): void;
  113898. /**
  113899. * Get if the texture can rescale.
  113900. */
  113901. get canRescale(): boolean;
  113902. /** @hidden */
  113903. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  113904. /** @hidden */
  113905. _rebuild(): void;
  113906. /**
  113907. * Triggers the load sequence in delayed load mode.
  113908. */
  113909. delayLoad(): void;
  113910. /**
  113911. * Clones the texture.
  113912. * @returns the cloned texture
  113913. */
  113914. clone(): Nullable<BaseTexture>;
  113915. /**
  113916. * Get the texture underlying type (INT, FLOAT...)
  113917. */
  113918. get textureType(): number;
  113919. /**
  113920. * Get the texture underlying format (RGB, RGBA...)
  113921. */
  113922. get textureFormat(): number;
  113923. /**
  113924. * Indicates that textures need to be re-calculated for all materials
  113925. */
  113926. protected _markAllSubMeshesAsTexturesDirty(): void;
  113927. /**
  113928. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  113929. * This will returns an RGBA array buffer containing either in values (0-255) or
  113930. * float values (0-1) depending of the underlying buffer type.
  113931. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  113932. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  113933. * @param buffer defines a user defined buffer to fill with data (can be null)
  113934. * @returns The Array buffer containing the pixels data.
  113935. */
  113936. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  113937. /**
  113938. * Release and destroy the underlying lower level texture aka internalTexture.
  113939. */
  113940. releaseInternalTexture(): void;
  113941. /** @hidden */
  113942. get _lodTextureHigh(): Nullable<BaseTexture>;
  113943. /** @hidden */
  113944. get _lodTextureMid(): Nullable<BaseTexture>;
  113945. /** @hidden */
  113946. get _lodTextureLow(): Nullable<BaseTexture>;
  113947. /**
  113948. * Dispose the texture and release its associated resources.
  113949. */
  113950. dispose(): void;
  113951. /**
  113952. * Serialize the texture into a JSON representation that can be parsed later on.
  113953. * @returns the JSON representation of the texture
  113954. */
  113955. serialize(): any;
  113956. /**
  113957. * Helper function to be called back once a list of texture contains only ready textures.
  113958. * @param textures Define the list of textures to wait for
  113959. * @param callback Define the callback triggered once the entire list will be ready
  113960. */
  113961. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  113962. private static _isScene;
  113963. }
  113964. }
  113965. declare module BABYLON {
  113966. /**
  113967. * Options to be used when creating an effect.
  113968. */
  113969. export interface IEffectCreationOptions {
  113970. /**
  113971. * Atrributes that will be used in the shader.
  113972. */
  113973. attributes: string[];
  113974. /**
  113975. * Uniform varible names that will be set in the shader.
  113976. */
  113977. uniformsNames: string[];
  113978. /**
  113979. * Uniform buffer variable names that will be set in the shader.
  113980. */
  113981. uniformBuffersNames: string[];
  113982. /**
  113983. * Sampler texture variable names that will be set in the shader.
  113984. */
  113985. samplers: string[];
  113986. /**
  113987. * Define statements that will be set in the shader.
  113988. */
  113989. defines: any;
  113990. /**
  113991. * Possible fallbacks for this effect to improve performance when needed.
  113992. */
  113993. fallbacks: Nullable<IEffectFallbacks>;
  113994. /**
  113995. * Callback that will be called when the shader is compiled.
  113996. */
  113997. onCompiled: Nullable<(effect: Effect) => void>;
  113998. /**
  113999. * Callback that will be called if an error occurs during shader compilation.
  114000. */
  114001. onError: Nullable<(effect: Effect, errors: string) => void>;
  114002. /**
  114003. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114004. */
  114005. indexParameters?: any;
  114006. /**
  114007. * Max number of lights that can be used in the shader.
  114008. */
  114009. maxSimultaneousLights?: number;
  114010. /**
  114011. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114012. */
  114013. transformFeedbackVaryings?: Nullable<string[]>;
  114014. /**
  114015. * 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
  114016. */
  114017. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114018. /**
  114019. * Is this effect rendering to several color attachments ?
  114020. */
  114021. multiTarget?: boolean;
  114022. }
  114023. /**
  114024. * Effect containing vertex and fragment shader that can be executed on an object.
  114025. */
  114026. export class Effect implements IDisposable {
  114027. /**
  114028. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114029. */
  114030. static ShadersRepository: string;
  114031. /**
  114032. * Enable logging of the shader code when a compilation error occurs
  114033. */
  114034. static LogShaderCodeOnCompilationError: boolean;
  114035. /**
  114036. * Name of the effect.
  114037. */
  114038. name: any;
  114039. /**
  114040. * String container all the define statements that should be set on the shader.
  114041. */
  114042. defines: string;
  114043. /**
  114044. * Callback that will be called when the shader is compiled.
  114045. */
  114046. onCompiled: Nullable<(effect: Effect) => void>;
  114047. /**
  114048. * Callback that will be called if an error occurs during shader compilation.
  114049. */
  114050. onError: Nullable<(effect: Effect, errors: string) => void>;
  114051. /**
  114052. * Callback that will be called when effect is bound.
  114053. */
  114054. onBind: Nullable<(effect: Effect) => void>;
  114055. /**
  114056. * Unique ID of the effect.
  114057. */
  114058. uniqueId: number;
  114059. /**
  114060. * Observable that will be called when the shader is compiled.
  114061. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114062. */
  114063. onCompileObservable: Observable<Effect>;
  114064. /**
  114065. * Observable that will be called if an error occurs during shader compilation.
  114066. */
  114067. onErrorObservable: Observable<Effect>;
  114068. /** @hidden */
  114069. _onBindObservable: Nullable<Observable<Effect>>;
  114070. /**
  114071. * @hidden
  114072. * Specifies if the effect was previously ready
  114073. */
  114074. _wasPreviouslyReady: boolean;
  114075. /**
  114076. * Observable that will be called when effect is bound.
  114077. */
  114078. get onBindObservable(): Observable<Effect>;
  114079. /** @hidden */
  114080. _bonesComputationForcedToCPU: boolean;
  114081. /** @hidden */
  114082. _multiTarget: boolean;
  114083. private static _uniqueIdSeed;
  114084. private _engine;
  114085. private _uniformBuffersNames;
  114086. private _uniformBuffersNamesList;
  114087. private _uniformsNames;
  114088. private _samplerList;
  114089. private _samplers;
  114090. private _isReady;
  114091. private _compilationError;
  114092. private _allFallbacksProcessed;
  114093. private _attributesNames;
  114094. private _attributes;
  114095. private _attributeLocationByName;
  114096. private _uniforms;
  114097. /**
  114098. * Key for the effect.
  114099. * @hidden
  114100. */
  114101. _key: string;
  114102. private _indexParameters;
  114103. private _fallbacks;
  114104. private _vertexSourceCode;
  114105. private _fragmentSourceCode;
  114106. private _vertexSourceCodeOverride;
  114107. private _fragmentSourceCodeOverride;
  114108. private _transformFeedbackVaryings;
  114109. /**
  114110. * Compiled shader to webGL program.
  114111. * @hidden
  114112. */
  114113. _pipelineContext: Nullable<IPipelineContext>;
  114114. private _valueCache;
  114115. private static _baseCache;
  114116. /**
  114117. * Instantiates an effect.
  114118. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114119. * @param baseName Name of the effect.
  114120. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114121. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114122. * @param samplers List of sampler variables that will be passed to the shader.
  114123. * @param engine Engine to be used to render the effect
  114124. * @param defines Define statements to be added to the shader.
  114125. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114126. * @param onCompiled Callback that will be called when the shader is compiled.
  114127. * @param onError Callback that will be called if an error occurs during shader compilation.
  114128. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114129. */
  114130. 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);
  114131. private _useFinalCode;
  114132. /**
  114133. * Unique key for this effect
  114134. */
  114135. get key(): string;
  114136. /**
  114137. * If the effect has been compiled and prepared.
  114138. * @returns if the effect is compiled and prepared.
  114139. */
  114140. isReady(): boolean;
  114141. private _isReadyInternal;
  114142. /**
  114143. * The engine the effect was initialized with.
  114144. * @returns the engine.
  114145. */
  114146. getEngine(): Engine;
  114147. /**
  114148. * The pipeline context for this effect
  114149. * @returns the associated pipeline context
  114150. */
  114151. getPipelineContext(): Nullable<IPipelineContext>;
  114152. /**
  114153. * The set of names of attribute variables for the shader.
  114154. * @returns An array of attribute names.
  114155. */
  114156. getAttributesNames(): string[];
  114157. /**
  114158. * Returns the attribute at the given index.
  114159. * @param index The index of the attribute.
  114160. * @returns The location of the attribute.
  114161. */
  114162. getAttributeLocation(index: number): number;
  114163. /**
  114164. * Returns the attribute based on the name of the variable.
  114165. * @param name of the attribute to look up.
  114166. * @returns the attribute location.
  114167. */
  114168. getAttributeLocationByName(name: string): number;
  114169. /**
  114170. * The number of attributes.
  114171. * @returns the numnber of attributes.
  114172. */
  114173. getAttributesCount(): number;
  114174. /**
  114175. * Gets the index of a uniform variable.
  114176. * @param uniformName of the uniform to look up.
  114177. * @returns the index.
  114178. */
  114179. getUniformIndex(uniformName: string): number;
  114180. /**
  114181. * Returns the attribute based on the name of the variable.
  114182. * @param uniformName of the uniform to look up.
  114183. * @returns the location of the uniform.
  114184. */
  114185. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114186. /**
  114187. * Returns an array of sampler variable names
  114188. * @returns The array of sampler variable names.
  114189. */
  114190. getSamplers(): string[];
  114191. /**
  114192. * Returns an array of uniform variable names
  114193. * @returns The array of uniform variable names.
  114194. */
  114195. getUniformNames(): string[];
  114196. /**
  114197. * Returns an array of uniform buffer variable names
  114198. * @returns The array of uniform buffer variable names.
  114199. */
  114200. getUniformBuffersNames(): string[];
  114201. /**
  114202. * Returns the index parameters used to create the effect
  114203. * @returns The index parameters object
  114204. */
  114205. getIndexParameters(): any;
  114206. /**
  114207. * The error from the last compilation.
  114208. * @returns the error string.
  114209. */
  114210. getCompilationError(): string;
  114211. /**
  114212. * Gets a boolean indicating that all fallbacks were used during compilation
  114213. * @returns true if all fallbacks were used
  114214. */
  114215. allFallbacksProcessed(): boolean;
  114216. /**
  114217. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114218. * @param func The callback to be used.
  114219. */
  114220. executeWhenCompiled(func: (effect: Effect) => void): void;
  114221. private _checkIsReady;
  114222. private _loadShader;
  114223. /**
  114224. * Gets the vertex shader source code of this effect
  114225. */
  114226. get vertexSourceCode(): string;
  114227. /**
  114228. * Gets the fragment shader source code of this effect
  114229. */
  114230. get fragmentSourceCode(): string;
  114231. /**
  114232. * Recompiles the webGL program
  114233. * @param vertexSourceCode The source code for the vertex shader.
  114234. * @param fragmentSourceCode The source code for the fragment shader.
  114235. * @param onCompiled Callback called when completed.
  114236. * @param onError Callback called on error.
  114237. * @hidden
  114238. */
  114239. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114240. /**
  114241. * Prepares the effect
  114242. * @hidden
  114243. */
  114244. _prepareEffect(): void;
  114245. private _getShaderCodeAndErrorLine;
  114246. private _processCompilationErrors;
  114247. /**
  114248. * Checks if the effect is supported. (Must be called after compilation)
  114249. */
  114250. get isSupported(): boolean;
  114251. /**
  114252. * Binds a texture to the engine to be used as output of the shader.
  114253. * @param channel Name of the output variable.
  114254. * @param texture Texture to bind.
  114255. * @hidden
  114256. */
  114257. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114258. /**
  114259. * Sets a texture on the engine to be used in the shader.
  114260. * @param channel Name of the sampler variable.
  114261. * @param texture Texture to set.
  114262. */
  114263. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114264. /**
  114265. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114266. * @param channel Name of the sampler variable.
  114267. * @param texture Texture to set.
  114268. */
  114269. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114270. /**
  114271. * Sets an array of textures on the engine to be used in the shader.
  114272. * @param channel Name of the variable.
  114273. * @param textures Textures to set.
  114274. */
  114275. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114276. /**
  114277. * 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)
  114278. * @param channel Name of the sampler variable.
  114279. * @param postProcess Post process to get the input texture from.
  114280. */
  114281. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114282. /**
  114283. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114284. * 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)
  114285. * @param channel Name of the sampler variable.
  114286. * @param postProcess Post process to get the output texture from.
  114287. */
  114288. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114289. /** @hidden */
  114290. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114291. /** @hidden */
  114292. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114293. /** @hidden */
  114294. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114295. /** @hidden */
  114296. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114297. /**
  114298. * Binds a buffer to a uniform.
  114299. * @param buffer Buffer to bind.
  114300. * @param name Name of the uniform variable to bind to.
  114301. */
  114302. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114303. /**
  114304. * Binds block to a uniform.
  114305. * @param blockName Name of the block to bind.
  114306. * @param index Index to bind.
  114307. */
  114308. bindUniformBlock(blockName: string, index: number): void;
  114309. /**
  114310. * Sets an interger value on a uniform variable.
  114311. * @param uniformName Name of the variable.
  114312. * @param value Value to be set.
  114313. * @returns this effect.
  114314. */
  114315. setInt(uniformName: string, value: number): Effect;
  114316. /**
  114317. * Sets an int array on a uniform variable.
  114318. * @param uniformName Name of the variable.
  114319. * @param array array to be set.
  114320. * @returns this effect.
  114321. */
  114322. setIntArray(uniformName: string, array: Int32Array): Effect;
  114323. /**
  114324. * 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)
  114325. * @param uniformName Name of the variable.
  114326. * @param array array to be set.
  114327. * @returns this effect.
  114328. */
  114329. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114330. /**
  114331. * 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)
  114332. * @param uniformName Name of the variable.
  114333. * @param array array to be set.
  114334. * @returns this effect.
  114335. */
  114336. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114337. /**
  114338. * 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)
  114339. * @param uniformName Name of the variable.
  114340. * @param array array to be set.
  114341. * @returns this effect.
  114342. */
  114343. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114344. /**
  114345. * Sets an float array on a uniform variable.
  114346. * @param uniformName Name of the variable.
  114347. * @param array array to be set.
  114348. * @returns this effect.
  114349. */
  114350. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114351. /**
  114352. * 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)
  114353. * @param uniformName Name of the variable.
  114354. * @param array array to be set.
  114355. * @returns this effect.
  114356. */
  114357. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114358. /**
  114359. * 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)
  114360. * @param uniformName Name of the variable.
  114361. * @param array array to be set.
  114362. * @returns this effect.
  114363. */
  114364. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114365. /**
  114366. * 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)
  114367. * @param uniformName Name of the variable.
  114368. * @param array array to be set.
  114369. * @returns this effect.
  114370. */
  114371. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114372. /**
  114373. * Sets an array on a uniform variable.
  114374. * @param uniformName Name of the variable.
  114375. * @param array array to be set.
  114376. * @returns this effect.
  114377. */
  114378. setArray(uniformName: string, array: number[]): Effect;
  114379. /**
  114380. * 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)
  114381. * @param uniformName Name of the variable.
  114382. * @param array array to be set.
  114383. * @returns this effect.
  114384. */
  114385. setArray2(uniformName: string, array: number[]): Effect;
  114386. /**
  114387. * 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)
  114388. * @param uniformName Name of the variable.
  114389. * @param array array to be set.
  114390. * @returns this effect.
  114391. */
  114392. setArray3(uniformName: string, array: number[]): Effect;
  114393. /**
  114394. * 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)
  114395. * @param uniformName Name of the variable.
  114396. * @param array array to be set.
  114397. * @returns this effect.
  114398. */
  114399. setArray4(uniformName: string, array: number[]): Effect;
  114400. /**
  114401. * Sets matrices on a uniform variable.
  114402. * @param uniformName Name of the variable.
  114403. * @param matrices matrices to be set.
  114404. * @returns this effect.
  114405. */
  114406. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114407. /**
  114408. * Sets matrix on a uniform variable.
  114409. * @param uniformName Name of the variable.
  114410. * @param matrix matrix to be set.
  114411. * @returns this effect.
  114412. */
  114413. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114414. /**
  114415. * 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)
  114416. * @param uniformName Name of the variable.
  114417. * @param matrix matrix to be set.
  114418. * @returns this effect.
  114419. */
  114420. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114421. /**
  114422. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114423. * @param uniformName Name of the variable.
  114424. * @param matrix matrix to be set.
  114425. * @returns this effect.
  114426. */
  114427. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114428. /**
  114429. * Sets a float on a uniform variable.
  114430. * @param uniformName Name of the variable.
  114431. * @param value value to be set.
  114432. * @returns this effect.
  114433. */
  114434. setFloat(uniformName: string, value: number): Effect;
  114435. /**
  114436. * Sets a boolean on a uniform variable.
  114437. * @param uniformName Name of the variable.
  114438. * @param bool value to be set.
  114439. * @returns this effect.
  114440. */
  114441. setBool(uniformName: string, bool: boolean): Effect;
  114442. /**
  114443. * Sets a Vector2 on a uniform variable.
  114444. * @param uniformName Name of the variable.
  114445. * @param vector2 vector2 to be set.
  114446. * @returns this effect.
  114447. */
  114448. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  114449. /**
  114450. * Sets a float2 on a uniform variable.
  114451. * @param uniformName Name of the variable.
  114452. * @param x First float in float2.
  114453. * @param y Second float in float2.
  114454. * @returns this effect.
  114455. */
  114456. setFloat2(uniformName: string, x: number, y: number): Effect;
  114457. /**
  114458. * Sets a Vector3 on a uniform variable.
  114459. * @param uniformName Name of the variable.
  114460. * @param vector3 Value to be set.
  114461. * @returns this effect.
  114462. */
  114463. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  114464. /**
  114465. * Sets a float3 on a uniform variable.
  114466. * @param uniformName Name of the variable.
  114467. * @param x First float in float3.
  114468. * @param y Second float in float3.
  114469. * @param z Third float in float3.
  114470. * @returns this effect.
  114471. */
  114472. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  114473. /**
  114474. * Sets a Vector4 on a uniform variable.
  114475. * @param uniformName Name of the variable.
  114476. * @param vector4 Value to be set.
  114477. * @returns this effect.
  114478. */
  114479. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  114480. /**
  114481. * Sets a float4 on a uniform variable.
  114482. * @param uniformName Name of the variable.
  114483. * @param x First float in float4.
  114484. * @param y Second float in float4.
  114485. * @param z Third float in float4.
  114486. * @param w Fourth float in float4.
  114487. * @returns this effect.
  114488. */
  114489. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  114490. /**
  114491. * Sets a Color3 on a uniform variable.
  114492. * @param uniformName Name of the variable.
  114493. * @param color3 Value to be set.
  114494. * @returns this effect.
  114495. */
  114496. setColor3(uniformName: string, color3: IColor3Like): Effect;
  114497. /**
  114498. * Sets a Color4 on a uniform variable.
  114499. * @param uniformName Name of the variable.
  114500. * @param color3 Value to be set.
  114501. * @param alpha Alpha value to be set.
  114502. * @returns this effect.
  114503. */
  114504. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  114505. /**
  114506. * Sets a Color4 on a uniform variable
  114507. * @param uniformName defines the name of the variable
  114508. * @param color4 defines the value to be set
  114509. * @returns this effect.
  114510. */
  114511. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  114512. /** Release all associated resources */
  114513. dispose(): void;
  114514. /**
  114515. * This function will add a new shader to the shader store
  114516. * @param name the name of the shader
  114517. * @param pixelShader optional pixel shader content
  114518. * @param vertexShader optional vertex shader content
  114519. */
  114520. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  114521. /**
  114522. * Store of each shader (The can be looked up using effect.key)
  114523. */
  114524. static ShadersStore: {
  114525. [key: string]: string;
  114526. };
  114527. /**
  114528. * Store of each included file for a shader (The can be looked up using effect.key)
  114529. */
  114530. static IncludesShadersStore: {
  114531. [key: string]: string;
  114532. };
  114533. /**
  114534. * Resets the cache of effects.
  114535. */
  114536. static ResetCache(): void;
  114537. }
  114538. }
  114539. declare module BABYLON {
  114540. /**
  114541. * Interface used to describe the capabilities of the engine relatively to the current browser
  114542. */
  114543. export interface EngineCapabilities {
  114544. /** Maximum textures units per fragment shader */
  114545. maxTexturesImageUnits: number;
  114546. /** Maximum texture units per vertex shader */
  114547. maxVertexTextureImageUnits: number;
  114548. /** Maximum textures units in the entire pipeline */
  114549. maxCombinedTexturesImageUnits: number;
  114550. /** Maximum texture size */
  114551. maxTextureSize: number;
  114552. /** Maximum texture samples */
  114553. maxSamples?: number;
  114554. /** Maximum cube texture size */
  114555. maxCubemapTextureSize: number;
  114556. /** Maximum render texture size */
  114557. maxRenderTextureSize: number;
  114558. /** Maximum number of vertex attributes */
  114559. maxVertexAttribs: number;
  114560. /** Maximum number of varyings */
  114561. maxVaryingVectors: number;
  114562. /** Maximum number of uniforms per vertex shader */
  114563. maxVertexUniformVectors: number;
  114564. /** Maximum number of uniforms per fragment shader */
  114565. maxFragmentUniformVectors: number;
  114566. /** Defines if standard derivates (dx/dy) are supported */
  114567. standardDerivatives: boolean;
  114568. /** Defines if s3tc texture compression is supported */
  114569. s3tc?: WEBGL_compressed_texture_s3tc;
  114570. /** Defines if pvrtc texture compression is supported */
  114571. pvrtc: any;
  114572. /** Defines if etc1 texture compression is supported */
  114573. etc1: any;
  114574. /** Defines if etc2 texture compression is supported */
  114575. etc2: any;
  114576. /** Defines if astc texture compression is supported */
  114577. astc: any;
  114578. /** Defines if bptc texture compression is supported */
  114579. bptc: any;
  114580. /** Defines if float textures are supported */
  114581. textureFloat: boolean;
  114582. /** Defines if vertex array objects are supported */
  114583. vertexArrayObject: boolean;
  114584. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114585. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114586. /** Gets the maximum level of anisotropy supported */
  114587. maxAnisotropy: number;
  114588. /** Defines if instancing is supported */
  114589. instancedArrays: boolean;
  114590. /** Defines if 32 bits indices are supported */
  114591. uintIndices: boolean;
  114592. /** Defines if high precision shaders are supported */
  114593. highPrecisionShaderSupported: boolean;
  114594. /** Defines if depth reading in the fragment shader is supported */
  114595. fragmentDepthSupported: boolean;
  114596. /** Defines if float texture linear filtering is supported*/
  114597. textureFloatLinearFiltering: boolean;
  114598. /** Defines if rendering to float textures is supported */
  114599. textureFloatRender: boolean;
  114600. /** Defines if half float textures are supported*/
  114601. textureHalfFloat: boolean;
  114602. /** Defines if half float texture linear filtering is supported*/
  114603. textureHalfFloatLinearFiltering: boolean;
  114604. /** Defines if rendering to half float textures is supported */
  114605. textureHalfFloatRender: boolean;
  114606. /** Defines if textureLOD shader command is supported */
  114607. textureLOD: boolean;
  114608. /** Defines if draw buffers extension is supported */
  114609. drawBuffersExtension: boolean;
  114610. /** Defines if depth textures are supported */
  114611. depthTextureExtension: boolean;
  114612. /** Defines if float color buffer are supported */
  114613. colorBufferFloat: boolean;
  114614. /** Gets disjoint timer query extension (null if not supported) */
  114615. timerQuery?: EXT_disjoint_timer_query;
  114616. /** Defines if timestamp can be used with timer query */
  114617. canUseTimestampForTimerQuery: boolean;
  114618. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114619. multiview?: any;
  114620. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114621. oculusMultiview?: any;
  114622. /** Function used to let the system compiles shaders in background */
  114623. parallelShaderCompile?: {
  114624. COMPLETION_STATUS_KHR: number;
  114625. };
  114626. /** Max number of texture samples for MSAA */
  114627. maxMSAASamples: number;
  114628. /** Defines if the blend min max extension is supported */
  114629. blendMinMax: boolean;
  114630. }
  114631. }
  114632. declare module BABYLON {
  114633. /**
  114634. * @hidden
  114635. **/
  114636. export class DepthCullingState {
  114637. private _isDepthTestDirty;
  114638. private _isDepthMaskDirty;
  114639. private _isDepthFuncDirty;
  114640. private _isCullFaceDirty;
  114641. private _isCullDirty;
  114642. private _isZOffsetDirty;
  114643. private _isFrontFaceDirty;
  114644. private _depthTest;
  114645. private _depthMask;
  114646. private _depthFunc;
  114647. private _cull;
  114648. private _cullFace;
  114649. private _zOffset;
  114650. private _frontFace;
  114651. /**
  114652. * Initializes the state.
  114653. */
  114654. constructor();
  114655. get isDirty(): boolean;
  114656. get zOffset(): number;
  114657. set zOffset(value: number);
  114658. get cullFace(): Nullable<number>;
  114659. set cullFace(value: Nullable<number>);
  114660. get cull(): Nullable<boolean>;
  114661. set cull(value: Nullable<boolean>);
  114662. get depthFunc(): Nullable<number>;
  114663. set depthFunc(value: Nullable<number>);
  114664. get depthMask(): boolean;
  114665. set depthMask(value: boolean);
  114666. get depthTest(): boolean;
  114667. set depthTest(value: boolean);
  114668. get frontFace(): Nullable<number>;
  114669. set frontFace(value: Nullable<number>);
  114670. reset(): void;
  114671. apply(gl: WebGLRenderingContext): void;
  114672. }
  114673. }
  114674. declare module BABYLON {
  114675. /**
  114676. * @hidden
  114677. **/
  114678. export class StencilState {
  114679. /** 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 */
  114680. static readonly ALWAYS: number;
  114681. /** Passed to stencilOperation to specify that stencil value must be kept */
  114682. static readonly KEEP: number;
  114683. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114684. static readonly REPLACE: number;
  114685. private _isStencilTestDirty;
  114686. private _isStencilMaskDirty;
  114687. private _isStencilFuncDirty;
  114688. private _isStencilOpDirty;
  114689. private _stencilTest;
  114690. private _stencilMask;
  114691. private _stencilFunc;
  114692. private _stencilFuncRef;
  114693. private _stencilFuncMask;
  114694. private _stencilOpStencilFail;
  114695. private _stencilOpDepthFail;
  114696. private _stencilOpStencilDepthPass;
  114697. get isDirty(): boolean;
  114698. get stencilFunc(): number;
  114699. set stencilFunc(value: number);
  114700. get stencilFuncRef(): number;
  114701. set stencilFuncRef(value: number);
  114702. get stencilFuncMask(): number;
  114703. set stencilFuncMask(value: number);
  114704. get stencilOpStencilFail(): number;
  114705. set stencilOpStencilFail(value: number);
  114706. get stencilOpDepthFail(): number;
  114707. set stencilOpDepthFail(value: number);
  114708. get stencilOpStencilDepthPass(): number;
  114709. set stencilOpStencilDepthPass(value: number);
  114710. get stencilMask(): number;
  114711. set stencilMask(value: number);
  114712. get stencilTest(): boolean;
  114713. set stencilTest(value: boolean);
  114714. constructor();
  114715. reset(): void;
  114716. apply(gl: WebGLRenderingContext): void;
  114717. }
  114718. }
  114719. declare module BABYLON {
  114720. /**
  114721. * @hidden
  114722. **/
  114723. export class AlphaState {
  114724. private _isAlphaBlendDirty;
  114725. private _isBlendFunctionParametersDirty;
  114726. private _isBlendEquationParametersDirty;
  114727. private _isBlendConstantsDirty;
  114728. private _alphaBlend;
  114729. private _blendFunctionParameters;
  114730. private _blendEquationParameters;
  114731. private _blendConstants;
  114732. /**
  114733. * Initializes the state.
  114734. */
  114735. constructor();
  114736. get isDirty(): boolean;
  114737. get alphaBlend(): boolean;
  114738. set alphaBlend(value: boolean);
  114739. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  114740. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  114741. setAlphaEquationParameters(rgb: number, alpha: number): void;
  114742. reset(): void;
  114743. apply(gl: WebGLRenderingContext): void;
  114744. }
  114745. }
  114746. declare module BABYLON {
  114747. /** @hidden */
  114748. export class WebGL2ShaderProcessor implements IShaderProcessor {
  114749. attributeProcessor(attribute: string): string;
  114750. varyingProcessor(varying: string, isFragment: boolean): string;
  114751. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114752. }
  114753. }
  114754. declare module BABYLON {
  114755. /**
  114756. * Interface for attribute information associated with buffer instanciation
  114757. */
  114758. export interface InstancingAttributeInfo {
  114759. /**
  114760. * Name of the GLSL attribute
  114761. * if attribute index is not specified, this is used to retrieve the index from the effect
  114762. */
  114763. attributeName: string;
  114764. /**
  114765. * Index/offset of the attribute in the vertex shader
  114766. * if not specified, this will be computes from the name.
  114767. */
  114768. index?: number;
  114769. /**
  114770. * size of the attribute, 1, 2, 3 or 4
  114771. */
  114772. attributeSize: number;
  114773. /**
  114774. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  114775. */
  114776. offset: number;
  114777. /**
  114778. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  114779. * default to 1
  114780. */
  114781. divisor?: number;
  114782. /**
  114783. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  114784. * default is FLOAT
  114785. */
  114786. attributeType?: number;
  114787. /**
  114788. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  114789. */
  114790. normalized?: boolean;
  114791. }
  114792. }
  114793. declare module BABYLON {
  114794. interface ThinEngine {
  114795. /**
  114796. * Update a video texture
  114797. * @param texture defines the texture to update
  114798. * @param video defines the video element to use
  114799. * @param invertY defines if data must be stored with Y axis inverted
  114800. */
  114801. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  114802. }
  114803. }
  114804. declare module BABYLON {
  114805. interface ThinEngine {
  114806. /**
  114807. * Creates a dynamic texture
  114808. * @param width defines the width of the texture
  114809. * @param height defines the height of the texture
  114810. * @param generateMipMaps defines if the engine should generate the mip levels
  114811. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  114812. * @returns the dynamic texture inside an InternalTexture
  114813. */
  114814. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  114815. /**
  114816. * Update the content of a dynamic texture
  114817. * @param texture defines the texture to update
  114818. * @param canvas defines the canvas containing the source
  114819. * @param invertY defines if data must be stored with Y axis inverted
  114820. * @param premulAlpha defines if alpha is stored as premultiplied
  114821. * @param format defines the format of the data
  114822. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114823. */
  114824. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  114825. }
  114826. }
  114827. declare module BABYLON {
  114828. /**
  114829. * Settings for finer control over video usage
  114830. */
  114831. export interface VideoTextureSettings {
  114832. /**
  114833. * Applies `autoplay` to video, if specified
  114834. */
  114835. autoPlay?: boolean;
  114836. /**
  114837. * Applies `loop` to video, if specified
  114838. */
  114839. loop?: boolean;
  114840. /**
  114841. * Automatically updates internal texture from video at every frame in the render loop
  114842. */
  114843. autoUpdateTexture: boolean;
  114844. /**
  114845. * Image src displayed during the video loading or until the user interacts with the video.
  114846. */
  114847. poster?: string;
  114848. }
  114849. /**
  114850. * If you want to display a video in your scene, this is the special texture for that.
  114851. * This special texture works similar to other textures, with the exception of a few parameters.
  114852. * @see https://doc.babylonjs.com/how_to/video_texture
  114853. */
  114854. export class VideoTexture extends Texture {
  114855. /**
  114856. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  114857. */
  114858. readonly autoUpdateTexture: boolean;
  114859. /**
  114860. * The video instance used by the texture internally
  114861. */
  114862. readonly video: HTMLVideoElement;
  114863. private _onUserActionRequestedObservable;
  114864. /**
  114865. * Event triggerd when a dom action is required by the user to play the video.
  114866. * This happens due to recent changes in browser policies preventing video to auto start.
  114867. */
  114868. get onUserActionRequestedObservable(): Observable<Texture>;
  114869. private _generateMipMaps;
  114870. private _stillImageCaptured;
  114871. private _displayingPosterTexture;
  114872. private _settings;
  114873. private _createInternalTextureOnEvent;
  114874. private _frameId;
  114875. private _currentSrc;
  114876. /**
  114877. * Creates a video texture.
  114878. * If you want to display a video in your scene, this is the special texture for that.
  114879. * This special texture works similar to other textures, with the exception of a few parameters.
  114880. * @see https://doc.babylonjs.com/how_to/video_texture
  114881. * @param name optional name, will detect from video source, if not defined
  114882. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  114883. * @param scene is obviously the current scene.
  114884. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  114885. * @param invertY is false by default but can be used to invert video on Y axis
  114886. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  114887. * @param settings allows finer control over video usage
  114888. */
  114889. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  114890. private _getName;
  114891. private _getVideo;
  114892. private _createInternalTexture;
  114893. private reset;
  114894. /**
  114895. * @hidden Internal method to initiate `update`.
  114896. */
  114897. _rebuild(): void;
  114898. /**
  114899. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  114900. */
  114901. update(): void;
  114902. /**
  114903. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  114904. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  114905. */
  114906. updateTexture(isVisible: boolean): void;
  114907. protected _updateInternalTexture: () => void;
  114908. /**
  114909. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  114910. * @param url New url.
  114911. */
  114912. updateURL(url: string): void;
  114913. /**
  114914. * Clones the texture.
  114915. * @returns the cloned texture
  114916. */
  114917. clone(): VideoTexture;
  114918. /**
  114919. * Dispose the texture and release its associated resources.
  114920. */
  114921. dispose(): void;
  114922. /**
  114923. * Creates a video texture straight from a stream.
  114924. * @param scene Define the scene the texture should be created in
  114925. * @param stream Define the stream the texture should be created from
  114926. * @returns The created video texture as a promise
  114927. */
  114928. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  114929. /**
  114930. * Creates a video texture straight from your WebCam video feed.
  114931. * @param scene Define the scene the texture should be created in
  114932. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114933. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114934. * @returns The created video texture as a promise
  114935. */
  114936. static CreateFromWebCamAsync(scene: Scene, constraints: {
  114937. minWidth: number;
  114938. maxWidth: number;
  114939. minHeight: number;
  114940. maxHeight: number;
  114941. deviceId: string;
  114942. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  114943. /**
  114944. * Creates a video texture straight from your WebCam video feed.
  114945. * @param scene Define the scene the texture should be created in
  114946. * @param onReady Define a callback to triggered once the texture will be ready
  114947. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114948. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114949. */
  114950. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  114951. minWidth: number;
  114952. maxWidth: number;
  114953. minHeight: number;
  114954. maxHeight: number;
  114955. deviceId: string;
  114956. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  114957. }
  114958. }
  114959. declare module BABYLON {
  114960. /**
  114961. * Defines the interface used by objects working like Scene
  114962. * @hidden
  114963. */
  114964. export interface ISceneLike {
  114965. _addPendingData(data: any): void;
  114966. _removePendingData(data: any): void;
  114967. offlineProvider: IOfflineProvider;
  114968. }
  114969. /**
  114970. * Information about the current host
  114971. */
  114972. export interface HostInformation {
  114973. /**
  114974. * Defines if the current host is a mobile
  114975. */
  114976. isMobile: boolean;
  114977. }
  114978. /** Interface defining initialization parameters for Engine class */
  114979. export interface EngineOptions extends WebGLContextAttributes {
  114980. /**
  114981. * Defines if the engine should no exceed a specified device ratio
  114982. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  114983. */
  114984. limitDeviceRatio?: number;
  114985. /**
  114986. * Defines if webvr should be enabled automatically
  114987. * @see https://doc.babylonjs.com/how_to/webvr_camera
  114988. */
  114989. autoEnableWebVR?: boolean;
  114990. /**
  114991. * Defines if webgl2 should be turned off even if supported
  114992. * @see https://doc.babylonjs.com/features/webgl2
  114993. */
  114994. disableWebGL2Support?: boolean;
  114995. /**
  114996. * Defines if webaudio should be initialized as well
  114997. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114998. */
  114999. audioEngine?: boolean;
  115000. /**
  115001. * Defines if animations should run using a deterministic lock step
  115002. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115003. */
  115004. deterministicLockstep?: boolean;
  115005. /** Defines the maximum steps to use with deterministic lock step mode */
  115006. lockstepMaxSteps?: number;
  115007. /** Defines the seconds between each deterministic lock step */
  115008. timeStep?: number;
  115009. /**
  115010. * Defines that engine should ignore context lost events
  115011. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115012. */
  115013. doNotHandleContextLost?: boolean;
  115014. /**
  115015. * Defines that engine should ignore modifying touch action attribute and style
  115016. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115017. */
  115018. doNotHandleTouchAction?: boolean;
  115019. /**
  115020. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115021. */
  115022. useHighPrecisionFloats?: boolean;
  115023. /**
  115024. * Make the canvas XR Compatible for XR sessions
  115025. */
  115026. xrCompatible?: boolean;
  115027. /**
  115028. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115029. */
  115030. useHighPrecisionMatrix?: boolean;
  115031. }
  115032. /**
  115033. * The base engine class (root of all engines)
  115034. */
  115035. export class ThinEngine {
  115036. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115037. static ExceptionList: ({
  115038. key: string;
  115039. capture: string;
  115040. captureConstraint: number;
  115041. targets: string[];
  115042. } | {
  115043. key: string;
  115044. capture: null;
  115045. captureConstraint: null;
  115046. targets: string[];
  115047. })[];
  115048. /** @hidden */
  115049. static _TextureLoaders: IInternalTextureLoader[];
  115050. /**
  115051. * Returns the current npm package of the sdk
  115052. */
  115053. static get NpmPackage(): string;
  115054. /**
  115055. * Returns the current version of the framework
  115056. */
  115057. static get Version(): string;
  115058. /**
  115059. * Returns a string describing the current engine
  115060. */
  115061. get description(): string;
  115062. /**
  115063. * Gets or sets the epsilon value used by collision engine
  115064. */
  115065. static CollisionsEpsilon: number;
  115066. /**
  115067. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115068. */
  115069. static get ShadersRepository(): string;
  115070. static set ShadersRepository(value: string);
  115071. /** @hidden */
  115072. _shaderProcessor: IShaderProcessor;
  115073. /**
  115074. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115075. */
  115076. forcePOTTextures: boolean;
  115077. /**
  115078. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115079. */
  115080. isFullscreen: boolean;
  115081. /**
  115082. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115083. */
  115084. cullBackFaces: boolean;
  115085. /**
  115086. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115087. */
  115088. renderEvenInBackground: boolean;
  115089. /**
  115090. * Gets or sets a boolean indicating that cache can be kept between frames
  115091. */
  115092. preventCacheWipeBetweenFrames: boolean;
  115093. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115094. validateShaderPrograms: boolean;
  115095. /**
  115096. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115097. * This can provide greater z depth for distant objects.
  115098. */
  115099. useReverseDepthBuffer: boolean;
  115100. /**
  115101. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115102. */
  115103. disableUniformBuffers: boolean;
  115104. /** @hidden */
  115105. _uniformBuffers: UniformBuffer[];
  115106. /**
  115107. * Gets a boolean indicating that the engine supports uniform buffers
  115108. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115109. */
  115110. get supportsUniformBuffers(): boolean;
  115111. /** @hidden */
  115112. _gl: WebGLRenderingContext;
  115113. /** @hidden */
  115114. _webGLVersion: number;
  115115. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115116. protected _windowIsBackground: boolean;
  115117. protected _creationOptions: EngineOptions;
  115118. protected _highPrecisionShadersAllowed: boolean;
  115119. /** @hidden */
  115120. get _shouldUseHighPrecisionShader(): boolean;
  115121. /**
  115122. * Gets a boolean indicating that only power of 2 textures are supported
  115123. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115124. */
  115125. get needPOTTextures(): boolean;
  115126. /** @hidden */
  115127. _badOS: boolean;
  115128. /** @hidden */
  115129. _badDesktopOS: boolean;
  115130. private _hardwareScalingLevel;
  115131. /** @hidden */
  115132. _caps: EngineCapabilities;
  115133. private _isStencilEnable;
  115134. private _glVersion;
  115135. private _glRenderer;
  115136. private _glVendor;
  115137. /** @hidden */
  115138. _videoTextureSupported: boolean;
  115139. protected _renderingQueueLaunched: boolean;
  115140. protected _activeRenderLoops: (() => void)[];
  115141. /**
  115142. * Observable signaled when a context lost event is raised
  115143. */
  115144. onContextLostObservable: Observable<ThinEngine>;
  115145. /**
  115146. * Observable signaled when a context restored event is raised
  115147. */
  115148. onContextRestoredObservable: Observable<ThinEngine>;
  115149. private _onContextLost;
  115150. private _onContextRestored;
  115151. protected _contextWasLost: boolean;
  115152. /** @hidden */
  115153. _doNotHandleContextLost: boolean;
  115154. /**
  115155. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115156. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115157. */
  115158. get doNotHandleContextLost(): boolean;
  115159. set doNotHandleContextLost(value: boolean);
  115160. /**
  115161. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115162. */
  115163. disableVertexArrayObjects: boolean;
  115164. /** @hidden */
  115165. protected _colorWrite: boolean;
  115166. /** @hidden */
  115167. protected _colorWriteChanged: boolean;
  115168. /** @hidden */
  115169. protected _depthCullingState: DepthCullingState;
  115170. /** @hidden */
  115171. protected _stencilState: StencilState;
  115172. /** @hidden */
  115173. _alphaState: AlphaState;
  115174. /** @hidden */
  115175. _alphaMode: number;
  115176. /** @hidden */
  115177. _alphaEquation: number;
  115178. /** @hidden */
  115179. _internalTexturesCache: InternalTexture[];
  115180. /** @hidden */
  115181. protected _activeChannel: number;
  115182. private _currentTextureChannel;
  115183. /** @hidden */
  115184. protected _boundTexturesCache: {
  115185. [key: string]: Nullable<InternalTexture>;
  115186. };
  115187. /** @hidden */
  115188. protected _currentEffect: Nullable<Effect>;
  115189. /** @hidden */
  115190. protected _currentProgram: Nullable<WebGLProgram>;
  115191. private _compiledEffects;
  115192. private _vertexAttribArraysEnabled;
  115193. /** @hidden */
  115194. protected _cachedViewport: Nullable<IViewportLike>;
  115195. private _cachedVertexArrayObject;
  115196. /** @hidden */
  115197. protected _cachedVertexBuffers: any;
  115198. /** @hidden */
  115199. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115200. /** @hidden */
  115201. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115202. /** @hidden */
  115203. _currentRenderTarget: Nullable<InternalTexture>;
  115204. private _uintIndicesCurrentlySet;
  115205. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115206. /** @hidden */
  115207. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115208. /** @hidden */
  115209. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115210. private _currentBufferPointers;
  115211. private _currentInstanceLocations;
  115212. private _currentInstanceBuffers;
  115213. private _textureUnits;
  115214. /** @hidden */
  115215. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115216. /** @hidden */
  115217. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115218. /** @hidden */
  115219. _boundRenderFunction: any;
  115220. private _vaoRecordInProgress;
  115221. private _mustWipeVertexAttributes;
  115222. private _emptyTexture;
  115223. private _emptyCubeTexture;
  115224. private _emptyTexture3D;
  115225. private _emptyTexture2DArray;
  115226. /** @hidden */
  115227. _frameHandler: number;
  115228. private _nextFreeTextureSlots;
  115229. private _maxSimultaneousTextures;
  115230. private _activeRequests;
  115231. /** @hidden */
  115232. _transformTextureUrl: Nullable<(url: string) => string>;
  115233. /**
  115234. * Gets information about the current host
  115235. */
  115236. hostInformation: HostInformation;
  115237. protected get _supportsHardwareTextureRescaling(): boolean;
  115238. private _framebufferDimensionsObject;
  115239. /**
  115240. * sets the object from which width and height will be taken from when getting render width and height
  115241. * Will fallback to the gl object
  115242. * @param dimensions the framebuffer width and height that will be used.
  115243. */
  115244. set framebufferDimensionsObject(dimensions: Nullable<{
  115245. framebufferWidth: number;
  115246. framebufferHeight: number;
  115247. }>);
  115248. /**
  115249. * Gets the current viewport
  115250. */
  115251. get currentViewport(): Nullable<IViewportLike>;
  115252. /**
  115253. * Gets the default empty texture
  115254. */
  115255. get emptyTexture(): InternalTexture;
  115256. /**
  115257. * Gets the default empty 3D texture
  115258. */
  115259. get emptyTexture3D(): InternalTexture;
  115260. /**
  115261. * Gets the default empty 2D array texture
  115262. */
  115263. get emptyTexture2DArray(): InternalTexture;
  115264. /**
  115265. * Gets the default empty cube texture
  115266. */
  115267. get emptyCubeTexture(): InternalTexture;
  115268. /**
  115269. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115270. */
  115271. readonly premultipliedAlpha: boolean;
  115272. /**
  115273. * Observable event triggered before each texture is initialized
  115274. */
  115275. onBeforeTextureInitObservable: Observable<Texture>;
  115276. /**
  115277. * Creates a new engine
  115278. * @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
  115279. * @param antialias defines enable antialiasing (default: false)
  115280. * @param options defines further options to be sent to the getContext() function
  115281. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115282. */
  115283. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115284. private _rebuildInternalTextures;
  115285. private _rebuildEffects;
  115286. /**
  115287. * Gets a boolean indicating if all created effects are ready
  115288. * @returns true if all effects are ready
  115289. */
  115290. areAllEffectsReady(): boolean;
  115291. protected _rebuildBuffers(): void;
  115292. protected _initGLContext(): void;
  115293. /**
  115294. * Gets version of the current webGL context
  115295. */
  115296. get webGLVersion(): number;
  115297. /**
  115298. * Gets a string identifying the name of the class
  115299. * @returns "Engine" string
  115300. */
  115301. getClassName(): string;
  115302. /**
  115303. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115304. */
  115305. get isStencilEnable(): boolean;
  115306. /** @hidden */
  115307. _prepareWorkingCanvas(): void;
  115308. /**
  115309. * Reset the texture cache to empty state
  115310. */
  115311. resetTextureCache(): void;
  115312. /**
  115313. * Gets an object containing information about the current webGL context
  115314. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115315. */
  115316. getGlInfo(): {
  115317. vendor: string;
  115318. renderer: string;
  115319. version: string;
  115320. };
  115321. /**
  115322. * Defines the hardware scaling level.
  115323. * By default the hardware scaling level is computed from the window device ratio.
  115324. * 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.
  115325. * @param level defines the level to use
  115326. */
  115327. setHardwareScalingLevel(level: number): void;
  115328. /**
  115329. * Gets the current hardware scaling level.
  115330. * By default the hardware scaling level is computed from the window device ratio.
  115331. * 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.
  115332. * @returns a number indicating the current hardware scaling level
  115333. */
  115334. getHardwareScalingLevel(): number;
  115335. /**
  115336. * Gets the list of loaded textures
  115337. * @returns an array containing all loaded textures
  115338. */
  115339. getLoadedTexturesCache(): InternalTexture[];
  115340. /**
  115341. * Gets the object containing all engine capabilities
  115342. * @returns the EngineCapabilities object
  115343. */
  115344. getCaps(): EngineCapabilities;
  115345. /**
  115346. * stop executing a render loop function and remove it from the execution array
  115347. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115348. */
  115349. stopRenderLoop(renderFunction?: () => void): void;
  115350. /** @hidden */
  115351. _renderLoop(): void;
  115352. /**
  115353. * Gets the HTML canvas attached with the current webGL context
  115354. * @returns a HTML canvas
  115355. */
  115356. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115357. /**
  115358. * Gets host window
  115359. * @returns the host window object
  115360. */
  115361. getHostWindow(): Nullable<Window>;
  115362. /**
  115363. * Gets the current render width
  115364. * @param useScreen defines if screen size must be used (or the current render target if any)
  115365. * @returns a number defining the current render width
  115366. */
  115367. getRenderWidth(useScreen?: boolean): number;
  115368. /**
  115369. * Gets the current render height
  115370. * @param useScreen defines if screen size must be used (or the current render target if any)
  115371. * @returns a number defining the current render height
  115372. */
  115373. getRenderHeight(useScreen?: boolean): number;
  115374. /**
  115375. * Can be used to override the current requestAnimationFrame requester.
  115376. * @hidden
  115377. */
  115378. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115379. /**
  115380. * Register and execute a render loop. The engine can have more than one render function
  115381. * @param renderFunction defines the function to continuously execute
  115382. */
  115383. runRenderLoop(renderFunction: () => void): void;
  115384. /**
  115385. * Clear the current render buffer or the current render target (if any is set up)
  115386. * @param color defines the color to use
  115387. * @param backBuffer defines if the back buffer must be cleared
  115388. * @param depth defines if the depth buffer must be cleared
  115389. * @param stencil defines if the stencil buffer must be cleared
  115390. */
  115391. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115392. private _viewportCached;
  115393. /** @hidden */
  115394. _viewport(x: number, y: number, width: number, height: number): void;
  115395. /**
  115396. * Set the WebGL's viewport
  115397. * @param viewport defines the viewport element to be used
  115398. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115399. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115400. */
  115401. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115402. /**
  115403. * Begin a new frame
  115404. */
  115405. beginFrame(): void;
  115406. /**
  115407. * Enf the current frame
  115408. */
  115409. endFrame(): void;
  115410. /**
  115411. * Resize the view according to the canvas' size
  115412. */
  115413. resize(): void;
  115414. /**
  115415. * Force a specific size of the canvas
  115416. * @param width defines the new canvas' width
  115417. * @param height defines the new canvas' height
  115418. * @returns true if the size was changed
  115419. */
  115420. setSize(width: number, height: number): boolean;
  115421. /**
  115422. * Binds the frame buffer to the specified texture.
  115423. * @param texture The texture to render to or null for the default canvas
  115424. * @param faceIndex The face of the texture to render to in case of cube texture
  115425. * @param requiredWidth The width of the target to render to
  115426. * @param requiredHeight The height of the target to render to
  115427. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115428. * @param lodLevel defines the lod level to bind to the frame buffer
  115429. * @param layer defines the 2d array index to bind to frame buffer to
  115430. */
  115431. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  115432. /** @hidden */
  115433. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115434. /**
  115435. * Unbind the current render target texture from the webGL context
  115436. * @param texture defines the render target texture to unbind
  115437. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115438. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115439. */
  115440. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115441. /**
  115442. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  115443. */
  115444. flushFramebuffer(): void;
  115445. /**
  115446. * Unbind the current render target and bind the default framebuffer
  115447. */
  115448. restoreDefaultFramebuffer(): void;
  115449. /** @hidden */
  115450. protected _resetVertexBufferBinding(): void;
  115451. /**
  115452. * Creates a vertex buffer
  115453. * @param data the data for the vertex buffer
  115454. * @returns the new WebGL static buffer
  115455. */
  115456. createVertexBuffer(data: DataArray): DataBuffer;
  115457. private _createVertexBuffer;
  115458. /**
  115459. * Creates a dynamic vertex buffer
  115460. * @param data the data for the dynamic vertex buffer
  115461. * @returns the new WebGL dynamic buffer
  115462. */
  115463. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115464. protected _resetIndexBufferBinding(): void;
  115465. /**
  115466. * Creates a new index buffer
  115467. * @param indices defines the content of the index buffer
  115468. * @param updatable defines if the index buffer must be updatable
  115469. * @returns a new webGL buffer
  115470. */
  115471. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  115472. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  115473. /**
  115474. * Bind a webGL buffer to the webGL context
  115475. * @param buffer defines the buffer to bind
  115476. */
  115477. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  115478. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  115479. private bindBuffer;
  115480. /**
  115481. * update the bound buffer with the given data
  115482. * @param data defines the data to update
  115483. */
  115484. updateArrayBuffer(data: Float32Array): void;
  115485. private _vertexAttribPointer;
  115486. /** @hidden */
  115487. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  115488. private _bindVertexBuffersAttributes;
  115489. /**
  115490. * Records a vertex array object
  115491. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115492. * @param vertexBuffers defines the list of vertex buffers to store
  115493. * @param indexBuffer defines the index buffer to store
  115494. * @param effect defines the effect to store
  115495. * @returns the new vertex array object
  115496. */
  115497. recordVertexArrayObject(vertexBuffers: {
  115498. [key: string]: VertexBuffer;
  115499. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115500. /**
  115501. * Bind a specific vertex array object
  115502. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115503. * @param vertexArrayObject defines the vertex array object to bind
  115504. * @param indexBuffer defines the index buffer to bind
  115505. */
  115506. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  115507. /**
  115508. * Bind webGl buffers directly to the webGL context
  115509. * @param vertexBuffer defines the vertex buffer to bind
  115510. * @param indexBuffer defines the index buffer to bind
  115511. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  115512. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  115513. * @param effect defines the effect associated with the vertex buffer
  115514. */
  115515. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  115516. private _unbindVertexArrayObject;
  115517. /**
  115518. * Bind a list of vertex buffers to the webGL context
  115519. * @param vertexBuffers defines the list of vertex buffers to bind
  115520. * @param indexBuffer defines the index buffer to bind
  115521. * @param effect defines the effect associated with the vertex buffers
  115522. */
  115523. bindBuffers(vertexBuffers: {
  115524. [key: string]: Nullable<VertexBuffer>;
  115525. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  115526. /**
  115527. * Unbind all instance attributes
  115528. */
  115529. unbindInstanceAttributes(): void;
  115530. /**
  115531. * Release and free the memory of a vertex array object
  115532. * @param vao defines the vertex array object to delete
  115533. */
  115534. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  115535. /** @hidden */
  115536. _releaseBuffer(buffer: DataBuffer): boolean;
  115537. protected _deleteBuffer(buffer: DataBuffer): void;
  115538. /**
  115539. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  115540. * @param instancesBuffer defines the webGL buffer to update and bind
  115541. * @param data defines the data to store in the buffer
  115542. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  115543. */
  115544. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  115545. /**
  115546. * Bind the content of a webGL buffer used with instantiation
  115547. * @param instancesBuffer defines the webGL buffer to bind
  115548. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  115549. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  115550. */
  115551. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  115552. /**
  115553. * Disable the instance attribute corresponding to the name in parameter
  115554. * @param name defines the name of the attribute to disable
  115555. */
  115556. disableInstanceAttributeByName(name: string): void;
  115557. /**
  115558. * Disable the instance attribute corresponding to the location in parameter
  115559. * @param attributeLocation defines the attribute location of the attribute to disable
  115560. */
  115561. disableInstanceAttribute(attributeLocation: number): void;
  115562. /**
  115563. * Disable the attribute corresponding to the location in parameter
  115564. * @param attributeLocation defines the attribute location of the attribute to disable
  115565. */
  115566. disableAttributeByIndex(attributeLocation: number): void;
  115567. /**
  115568. * Send a draw order
  115569. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115570. * @param indexStart defines the starting index
  115571. * @param indexCount defines the number of index to draw
  115572. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115573. */
  115574. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115575. /**
  115576. * Draw a list of points
  115577. * @param verticesStart defines the index of first vertex to draw
  115578. * @param verticesCount defines the count of vertices to draw
  115579. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115580. */
  115581. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115582. /**
  115583. * Draw a list of unindexed primitives
  115584. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115585. * @param verticesStart defines the index of first vertex to draw
  115586. * @param verticesCount defines the count of vertices to draw
  115587. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115588. */
  115589. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115590. /**
  115591. * Draw a list of indexed primitives
  115592. * @param fillMode defines the primitive to use
  115593. * @param indexStart defines the starting index
  115594. * @param indexCount defines the number of index to draw
  115595. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115596. */
  115597. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115598. /**
  115599. * Draw a list of unindexed primitives
  115600. * @param fillMode defines the primitive to use
  115601. * @param verticesStart defines the index of first vertex to draw
  115602. * @param verticesCount defines the count of vertices to draw
  115603. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115604. */
  115605. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115606. private _drawMode;
  115607. /** @hidden */
  115608. protected _reportDrawCall(): void;
  115609. /** @hidden */
  115610. _releaseEffect(effect: Effect): void;
  115611. /** @hidden */
  115612. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115613. /**
  115614. * Create a new effect (used to store vertex/fragment shaders)
  115615. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115616. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115617. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115618. * @param samplers defines an array of string used to represent textures
  115619. * @param defines defines the string containing the defines to use to compile the shaders
  115620. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115621. * @param onCompiled defines a function to call when the effect creation is successful
  115622. * @param onError defines a function to call when the effect creation has failed
  115623. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115624. * @returns the new Effect
  115625. */
  115626. 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;
  115627. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115628. private _compileShader;
  115629. private _compileRawShader;
  115630. /** @hidden */
  115631. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115632. /**
  115633. * Directly creates a webGL program
  115634. * @param pipelineContext defines the pipeline context to attach to
  115635. * @param vertexCode defines the vertex shader code to use
  115636. * @param fragmentCode defines the fragment shader code to use
  115637. * @param context defines the webGL context to use (if not set, the current one will be used)
  115638. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115639. * @returns the new webGL program
  115640. */
  115641. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115642. /**
  115643. * Creates a webGL program
  115644. * @param pipelineContext defines the pipeline context to attach to
  115645. * @param vertexCode defines the vertex shader code to use
  115646. * @param fragmentCode defines the fragment shader code to use
  115647. * @param defines defines the string containing the defines to use to compile the shaders
  115648. * @param context defines the webGL context to use (if not set, the current one will be used)
  115649. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115650. * @returns the new webGL program
  115651. */
  115652. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115653. /**
  115654. * Creates a new pipeline context
  115655. * @returns the new pipeline
  115656. */
  115657. createPipelineContext(): IPipelineContext;
  115658. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115659. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115660. /** @hidden */
  115661. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115662. /** @hidden */
  115663. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115664. /** @hidden */
  115665. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115666. /**
  115667. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115668. * @param pipelineContext defines the pipeline context to use
  115669. * @param uniformsNames defines the list of uniform names
  115670. * @returns an array of webGL uniform locations
  115671. */
  115672. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115673. /**
  115674. * Gets the lsit of active attributes for a given webGL program
  115675. * @param pipelineContext defines the pipeline context to use
  115676. * @param attributesNames defines the list of attribute names to get
  115677. * @returns an array of indices indicating the offset of each attribute
  115678. */
  115679. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115680. /**
  115681. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115682. * @param effect defines the effect to activate
  115683. */
  115684. enableEffect(effect: Nullable<Effect>): void;
  115685. /**
  115686. * Set the value of an uniform to a number (int)
  115687. * @param uniform defines the webGL uniform location where to store the value
  115688. * @param value defines the int number to store
  115689. */
  115690. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115691. /**
  115692. * Set the value of an uniform to an array of int32
  115693. * @param uniform defines the webGL uniform location where to store the value
  115694. * @param array defines the array of int32 to store
  115695. */
  115696. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115697. /**
  115698. * Set the value of an uniform to an array of int32 (stored as vec2)
  115699. * @param uniform defines the webGL uniform location where to store the value
  115700. * @param array defines the array of int32 to store
  115701. */
  115702. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115703. /**
  115704. * Set the value of an uniform to an array of int32 (stored as vec3)
  115705. * @param uniform defines the webGL uniform location where to store the value
  115706. * @param array defines the array of int32 to store
  115707. */
  115708. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115709. /**
  115710. * Set the value of an uniform to an array of int32 (stored as vec4)
  115711. * @param uniform defines the webGL uniform location where to store the value
  115712. * @param array defines the array of int32 to store
  115713. */
  115714. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115715. /**
  115716. * Set the value of an uniform to an array of number
  115717. * @param uniform defines the webGL uniform location where to store the value
  115718. * @param array defines the array of number to store
  115719. */
  115720. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115721. /**
  115722. * Set the value of an uniform to an array of number (stored as vec2)
  115723. * @param uniform defines the webGL uniform location where to store the value
  115724. * @param array defines the array of number to store
  115725. */
  115726. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115727. /**
  115728. * Set the value of an uniform to an array of number (stored as vec3)
  115729. * @param uniform defines the webGL uniform location where to store the value
  115730. * @param array defines the array of number to store
  115731. */
  115732. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115733. /**
  115734. * Set the value of an uniform to an array of number (stored as vec4)
  115735. * @param uniform defines the webGL uniform location where to store the value
  115736. * @param array defines the array of number to store
  115737. */
  115738. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115739. /**
  115740. * Set the value of an uniform to an array of float32 (stored as matrices)
  115741. * @param uniform defines the webGL uniform location where to store the value
  115742. * @param matrices defines the array of float32 to store
  115743. */
  115744. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  115745. /**
  115746. * Set the value of an uniform to a matrix (3x3)
  115747. * @param uniform defines the webGL uniform location where to store the value
  115748. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  115749. */
  115750. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115751. /**
  115752. * Set the value of an uniform to a matrix (2x2)
  115753. * @param uniform defines the webGL uniform location where to store the value
  115754. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  115755. */
  115756. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115757. /**
  115758. * Set the value of an uniform to a number (float)
  115759. * @param uniform defines the webGL uniform location where to store the value
  115760. * @param value defines the float number to store
  115761. */
  115762. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115763. /**
  115764. * Set the value of an uniform to a vec2
  115765. * @param uniform defines the webGL uniform location where to store the value
  115766. * @param x defines the 1st component of the value
  115767. * @param y defines the 2nd component of the value
  115768. */
  115769. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  115770. /**
  115771. * Set the value of an uniform to a vec3
  115772. * @param uniform defines the webGL uniform location where to store the value
  115773. * @param x defines the 1st component of the value
  115774. * @param y defines the 2nd component of the value
  115775. * @param z defines the 3rd component of the value
  115776. */
  115777. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  115778. /**
  115779. * Set the value of an uniform to a vec4
  115780. * @param uniform defines the webGL uniform location where to store the value
  115781. * @param x defines the 1st component of the value
  115782. * @param y defines the 2nd component of the value
  115783. * @param z defines the 3rd component of the value
  115784. * @param w defines the 4th component of the value
  115785. */
  115786. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  115787. /**
  115788. * Apply all cached states (depth, culling, stencil and alpha)
  115789. */
  115790. applyStates(): void;
  115791. /**
  115792. * Enable or disable color writing
  115793. * @param enable defines the state to set
  115794. */
  115795. setColorWrite(enable: boolean): void;
  115796. /**
  115797. * Gets a boolean indicating if color writing is enabled
  115798. * @returns the current color writing state
  115799. */
  115800. getColorWrite(): boolean;
  115801. /**
  115802. * Gets the depth culling state manager
  115803. */
  115804. get depthCullingState(): DepthCullingState;
  115805. /**
  115806. * Gets the alpha state manager
  115807. */
  115808. get alphaState(): AlphaState;
  115809. /**
  115810. * Gets the stencil state manager
  115811. */
  115812. get stencilState(): StencilState;
  115813. /**
  115814. * Clears the list of texture accessible through engine.
  115815. * This can help preventing texture load conflict due to name collision.
  115816. */
  115817. clearInternalTexturesCache(): void;
  115818. /**
  115819. * Force the entire cache to be cleared
  115820. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  115821. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  115822. */
  115823. wipeCaches(bruteForce?: boolean): void;
  115824. /** @hidden */
  115825. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  115826. min: number;
  115827. mag: number;
  115828. };
  115829. /** @hidden */
  115830. _createTexture(): WebGLTexture;
  115831. /**
  115832. * Usually called from Texture.ts.
  115833. * Passed information to create a WebGLTexture
  115834. * @param url defines a value which contains one of the following:
  115835. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115836. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115837. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115838. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115839. * @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)
  115840. * @param scene needed for loading to the correct scene
  115841. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  115842. * @param onLoad optional callback to be called upon successful completion
  115843. * @param onError optional callback to be called upon failure
  115844. * @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
  115845. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115846. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115847. * @param forcedExtension defines the extension to use to pick the right loader
  115848. * @param mimeType defines an optional mime type
  115849. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115850. */
  115851. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  115852. /**
  115853. * Loads an image as an HTMLImageElement.
  115854. * @param input url string, ArrayBuffer, or Blob to load
  115855. * @param onLoad callback called when the image successfully loads
  115856. * @param onError callback called when the image fails to load
  115857. * @param offlineProvider offline provider for caching
  115858. * @param mimeType optional mime type
  115859. * @returns the HTMLImageElement of the loaded image
  115860. * @hidden
  115861. */
  115862. 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>;
  115863. /**
  115864. * @hidden
  115865. */
  115866. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115867. private _unpackFlipYCached;
  115868. /**
  115869. * In case you are sharing the context with other applications, it might
  115870. * be interested to not cache the unpack flip y state to ensure a consistent
  115871. * value would be set.
  115872. */
  115873. enableUnpackFlipYCached: boolean;
  115874. /** @hidden */
  115875. _unpackFlipY(value: boolean): void;
  115876. /** @hidden */
  115877. _getUnpackAlignement(): number;
  115878. private _getTextureTarget;
  115879. /**
  115880. * Update the sampling mode of a given texture
  115881. * @param samplingMode defines the required sampling mode
  115882. * @param texture defines the texture to update
  115883. * @param generateMipMaps defines whether to generate mipmaps for the texture
  115884. */
  115885. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  115886. /**
  115887. * Update the sampling mode of a given texture
  115888. * @param texture defines the texture to update
  115889. * @param wrapU defines the texture wrap mode of the u coordinates
  115890. * @param wrapV defines the texture wrap mode of the v coordinates
  115891. * @param wrapR defines the texture wrap mode of the r coordinates
  115892. */
  115893. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  115894. /** @hidden */
  115895. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  115896. width: number;
  115897. height: number;
  115898. layers?: number;
  115899. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  115900. /** @hidden */
  115901. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115902. /** @hidden */
  115903. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  115904. /**
  115905. * Update a portion of an internal texture
  115906. * @param texture defines the texture to update
  115907. * @param imageData defines the data to store into the texture
  115908. * @param xOffset defines the x coordinates of the update rectangle
  115909. * @param yOffset defines the y coordinates of the update rectangle
  115910. * @param width defines the width of the update rectangle
  115911. * @param height defines the height of the update rectangle
  115912. * @param faceIndex defines the face index if texture is a cube (0 by default)
  115913. * @param lod defines the lod level to update (0 by default)
  115914. */
  115915. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  115916. /** @hidden */
  115917. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115918. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  115919. private _prepareWebGLTexture;
  115920. /** @hidden */
  115921. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  115922. private _getDepthStencilBuffer;
  115923. /** @hidden */
  115924. _releaseFramebufferObjects(texture: InternalTexture): void;
  115925. /** @hidden */
  115926. _releaseTexture(texture: InternalTexture): void;
  115927. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115928. protected _setProgram(program: WebGLProgram): void;
  115929. protected _boundUniforms: {
  115930. [key: number]: WebGLUniformLocation;
  115931. };
  115932. /**
  115933. * Binds an effect to the webGL context
  115934. * @param effect defines the effect to bind
  115935. */
  115936. bindSamplers(effect: Effect): void;
  115937. private _activateCurrentTexture;
  115938. /** @hidden */
  115939. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  115940. /** @hidden */
  115941. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  115942. /**
  115943. * Unbind all textures from the webGL context
  115944. */
  115945. unbindAllTextures(): void;
  115946. /**
  115947. * Sets a texture to the according uniform.
  115948. * @param channel The texture channel
  115949. * @param uniform The uniform to set
  115950. * @param texture The texture to apply
  115951. */
  115952. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  115953. private _bindSamplerUniformToChannel;
  115954. private _getTextureWrapMode;
  115955. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115956. /**
  115957. * Sets an array of texture to the webGL context
  115958. * @param channel defines the channel where the texture array must be set
  115959. * @param uniform defines the associated uniform location
  115960. * @param textures defines the array of textures to bind
  115961. */
  115962. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  115963. /** @hidden */
  115964. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  115965. private _setTextureParameterFloat;
  115966. private _setTextureParameterInteger;
  115967. /**
  115968. * Unbind all vertex attributes from the webGL context
  115969. */
  115970. unbindAllAttributes(): void;
  115971. /**
  115972. * 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
  115973. */
  115974. releaseEffects(): void;
  115975. /**
  115976. * Dispose and release all associated resources
  115977. */
  115978. dispose(): void;
  115979. /**
  115980. * Attach a new callback raised when context lost event is fired
  115981. * @param callback defines the callback to call
  115982. */
  115983. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115984. /**
  115985. * Attach a new callback raised when context restored event is fired
  115986. * @param callback defines the callback to call
  115987. */
  115988. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115989. /**
  115990. * Get the current error code of the webGL context
  115991. * @returns the error code
  115992. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  115993. */
  115994. getError(): number;
  115995. private _canRenderToFloatFramebuffer;
  115996. private _canRenderToHalfFloatFramebuffer;
  115997. private _canRenderToFramebuffer;
  115998. /** @hidden */
  115999. _getWebGLTextureType(type: number): number;
  116000. /** @hidden */
  116001. _getInternalFormat(format: number): number;
  116002. /** @hidden */
  116003. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116004. /** @hidden */
  116005. _getRGBAMultiSampleBufferFormat(type: number): number;
  116006. /** @hidden */
  116007. _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;
  116008. /**
  116009. * Loads a file from a url
  116010. * @param url url to load
  116011. * @param onSuccess callback called when the file successfully loads
  116012. * @param onProgress callback called while file is loading (if the server supports this mode)
  116013. * @param offlineProvider defines the offline provider for caching
  116014. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116015. * @param onError callback called when the file fails to load
  116016. * @returns a file request object
  116017. * @hidden
  116018. */
  116019. 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;
  116020. /**
  116021. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116022. * @param x defines the x coordinate of the rectangle where pixels must be read
  116023. * @param y defines the y coordinate of the rectangle where pixels must be read
  116024. * @param width defines the width of the rectangle where pixels must be read
  116025. * @param height defines the height of the rectangle where pixels must be read
  116026. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116027. * @returns a Uint8Array containing RGBA colors
  116028. */
  116029. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116030. private static _isSupported;
  116031. /**
  116032. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116033. * @returns true if the engine can be created
  116034. * @ignorenaming
  116035. */
  116036. static isSupported(): boolean;
  116037. /**
  116038. * Find the next highest power of two.
  116039. * @param x Number to start search from.
  116040. * @return Next highest power of two.
  116041. */
  116042. static CeilingPOT(x: number): number;
  116043. /**
  116044. * Find the next lowest power of two.
  116045. * @param x Number to start search from.
  116046. * @return Next lowest power of two.
  116047. */
  116048. static FloorPOT(x: number): number;
  116049. /**
  116050. * Find the nearest power of two.
  116051. * @param x Number to start search from.
  116052. * @return Next nearest power of two.
  116053. */
  116054. static NearestPOT(x: number): number;
  116055. /**
  116056. * Get the closest exponent of two
  116057. * @param value defines the value to approximate
  116058. * @param max defines the maximum value to return
  116059. * @param mode defines how to define the closest value
  116060. * @returns closest exponent of two of the given value
  116061. */
  116062. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116063. /**
  116064. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116065. * @param func - the function to be called
  116066. * @param requester - the object that will request the next frame. Falls back to window.
  116067. * @returns frame number
  116068. */
  116069. static QueueNewFrame(func: () => void, requester?: any): number;
  116070. /**
  116071. * Gets host document
  116072. * @returns the host document object
  116073. */
  116074. getHostDocument(): Nullable<Document>;
  116075. }
  116076. }
  116077. declare module BABYLON {
  116078. /**
  116079. * Class representing spherical harmonics coefficients to the 3rd degree
  116080. */
  116081. export class SphericalHarmonics {
  116082. /**
  116083. * Defines whether or not the harmonics have been prescaled for rendering.
  116084. */
  116085. preScaled: boolean;
  116086. /**
  116087. * The l0,0 coefficients of the spherical harmonics
  116088. */
  116089. l00: Vector3;
  116090. /**
  116091. * The l1,-1 coefficients of the spherical harmonics
  116092. */
  116093. l1_1: Vector3;
  116094. /**
  116095. * The l1,0 coefficients of the spherical harmonics
  116096. */
  116097. l10: Vector3;
  116098. /**
  116099. * The l1,1 coefficients of the spherical harmonics
  116100. */
  116101. l11: Vector3;
  116102. /**
  116103. * The l2,-2 coefficients of the spherical harmonics
  116104. */
  116105. l2_2: Vector3;
  116106. /**
  116107. * The l2,-1 coefficients of the spherical harmonics
  116108. */
  116109. l2_1: Vector3;
  116110. /**
  116111. * The l2,0 coefficients of the spherical harmonics
  116112. */
  116113. l20: Vector3;
  116114. /**
  116115. * The l2,1 coefficients of the spherical harmonics
  116116. */
  116117. l21: Vector3;
  116118. /**
  116119. * The l2,2 coefficients of the spherical harmonics
  116120. */
  116121. l22: Vector3;
  116122. /**
  116123. * Adds a light to the spherical harmonics
  116124. * @param direction the direction of the light
  116125. * @param color the color of the light
  116126. * @param deltaSolidAngle the delta solid angle of the light
  116127. */
  116128. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116129. /**
  116130. * Scales the spherical harmonics by the given amount
  116131. * @param scale the amount to scale
  116132. */
  116133. scaleInPlace(scale: number): void;
  116134. /**
  116135. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116136. *
  116137. * ```
  116138. * E_lm = A_l * L_lm
  116139. * ```
  116140. *
  116141. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116142. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116143. * the scaling factors are given in equation 9.
  116144. */
  116145. convertIncidentRadianceToIrradiance(): void;
  116146. /**
  116147. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116148. *
  116149. * ```
  116150. * L = (1/pi) * E * rho
  116151. * ```
  116152. *
  116153. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116154. */
  116155. convertIrradianceToLambertianRadiance(): void;
  116156. /**
  116157. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116158. * required operations at run time.
  116159. *
  116160. * This is simply done by scaling back the SH with Ylm constants parameter.
  116161. * The trigonometric part being applied by the shader at run time.
  116162. */
  116163. preScaleForRendering(): void;
  116164. /**
  116165. * Constructs a spherical harmonics from an array.
  116166. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116167. * @returns the spherical harmonics
  116168. */
  116169. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116170. /**
  116171. * Gets the spherical harmonics from polynomial
  116172. * @param polynomial the spherical polynomial
  116173. * @returns the spherical harmonics
  116174. */
  116175. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116176. }
  116177. /**
  116178. * Class representing spherical polynomial coefficients to the 3rd degree
  116179. */
  116180. export class SphericalPolynomial {
  116181. private _harmonics;
  116182. /**
  116183. * The spherical harmonics used to create the polynomials.
  116184. */
  116185. get preScaledHarmonics(): SphericalHarmonics;
  116186. /**
  116187. * The x coefficients of the spherical polynomial
  116188. */
  116189. x: Vector3;
  116190. /**
  116191. * The y coefficients of the spherical polynomial
  116192. */
  116193. y: Vector3;
  116194. /**
  116195. * The z coefficients of the spherical polynomial
  116196. */
  116197. z: Vector3;
  116198. /**
  116199. * The xx coefficients of the spherical polynomial
  116200. */
  116201. xx: Vector3;
  116202. /**
  116203. * The yy coefficients of the spherical polynomial
  116204. */
  116205. yy: Vector3;
  116206. /**
  116207. * The zz coefficients of the spherical polynomial
  116208. */
  116209. zz: Vector3;
  116210. /**
  116211. * The xy coefficients of the spherical polynomial
  116212. */
  116213. xy: Vector3;
  116214. /**
  116215. * The yz coefficients of the spherical polynomial
  116216. */
  116217. yz: Vector3;
  116218. /**
  116219. * The zx coefficients of the spherical polynomial
  116220. */
  116221. zx: Vector3;
  116222. /**
  116223. * Adds an ambient color to the spherical polynomial
  116224. * @param color the color to add
  116225. */
  116226. addAmbient(color: Color3): void;
  116227. /**
  116228. * Scales the spherical polynomial by the given amount
  116229. * @param scale the amount to scale
  116230. */
  116231. scaleInPlace(scale: number): void;
  116232. /**
  116233. * Gets the spherical polynomial from harmonics
  116234. * @param harmonics the spherical harmonics
  116235. * @returns the spherical polynomial
  116236. */
  116237. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116238. /**
  116239. * Constructs a spherical polynomial from an array.
  116240. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116241. * @returns the spherical polynomial
  116242. */
  116243. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116244. }
  116245. }
  116246. declare module BABYLON {
  116247. /**
  116248. * Defines the source of the internal texture
  116249. */
  116250. export enum InternalTextureSource {
  116251. /**
  116252. * The source of the texture data is unknown
  116253. */
  116254. Unknown = 0,
  116255. /**
  116256. * Texture data comes from an URL
  116257. */
  116258. Url = 1,
  116259. /**
  116260. * Texture data is only used for temporary storage
  116261. */
  116262. Temp = 2,
  116263. /**
  116264. * Texture data comes from raw data (ArrayBuffer)
  116265. */
  116266. Raw = 3,
  116267. /**
  116268. * Texture content is dynamic (video or dynamic texture)
  116269. */
  116270. Dynamic = 4,
  116271. /**
  116272. * Texture content is generated by rendering to it
  116273. */
  116274. RenderTarget = 5,
  116275. /**
  116276. * Texture content is part of a multi render target process
  116277. */
  116278. MultiRenderTarget = 6,
  116279. /**
  116280. * Texture data comes from a cube data file
  116281. */
  116282. Cube = 7,
  116283. /**
  116284. * Texture data comes from a raw cube data
  116285. */
  116286. CubeRaw = 8,
  116287. /**
  116288. * Texture data come from a prefiltered cube data file
  116289. */
  116290. CubePrefiltered = 9,
  116291. /**
  116292. * Texture content is raw 3D data
  116293. */
  116294. Raw3D = 10,
  116295. /**
  116296. * Texture content is raw 2D array data
  116297. */
  116298. Raw2DArray = 11,
  116299. /**
  116300. * Texture content is a depth texture
  116301. */
  116302. Depth = 12,
  116303. /**
  116304. * Texture data comes from a raw cube data encoded with RGBD
  116305. */
  116306. CubeRawRGBD = 13
  116307. }
  116308. /**
  116309. * Class used to store data associated with WebGL texture data for the engine
  116310. * This class should not be used directly
  116311. */
  116312. export class InternalTexture {
  116313. /** @hidden */
  116314. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116315. /**
  116316. * Defines if the texture is ready
  116317. */
  116318. isReady: boolean;
  116319. /**
  116320. * Defines if the texture is a cube texture
  116321. */
  116322. isCube: boolean;
  116323. /**
  116324. * Defines if the texture contains 3D data
  116325. */
  116326. is3D: boolean;
  116327. /**
  116328. * Defines if the texture contains 2D array data
  116329. */
  116330. is2DArray: boolean;
  116331. /**
  116332. * Defines if the texture contains multiview data
  116333. */
  116334. isMultiview: boolean;
  116335. /**
  116336. * Gets the URL used to load this texture
  116337. */
  116338. url: string;
  116339. /**
  116340. * Gets the sampling mode of the texture
  116341. */
  116342. samplingMode: number;
  116343. /**
  116344. * Gets a boolean indicating if the texture needs mipmaps generation
  116345. */
  116346. generateMipMaps: boolean;
  116347. /**
  116348. * Gets the number of samples used by the texture (WebGL2+ only)
  116349. */
  116350. samples: number;
  116351. /**
  116352. * Gets the type of the texture (int, float...)
  116353. */
  116354. type: number;
  116355. /**
  116356. * Gets the format of the texture (RGB, RGBA...)
  116357. */
  116358. format: number;
  116359. /**
  116360. * Observable called when the texture is loaded
  116361. */
  116362. onLoadedObservable: Observable<InternalTexture>;
  116363. /**
  116364. * Gets the width of the texture
  116365. */
  116366. width: number;
  116367. /**
  116368. * Gets the height of the texture
  116369. */
  116370. height: number;
  116371. /**
  116372. * Gets the depth of the texture
  116373. */
  116374. depth: number;
  116375. /**
  116376. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116377. */
  116378. baseWidth: number;
  116379. /**
  116380. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116381. */
  116382. baseHeight: number;
  116383. /**
  116384. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116385. */
  116386. baseDepth: number;
  116387. /**
  116388. * Gets a boolean indicating if the texture is inverted on Y axis
  116389. */
  116390. invertY: boolean;
  116391. /** @hidden */
  116392. _invertVScale: boolean;
  116393. /** @hidden */
  116394. _associatedChannel: number;
  116395. /** @hidden */
  116396. _source: InternalTextureSource;
  116397. /** @hidden */
  116398. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116399. /** @hidden */
  116400. _bufferView: Nullable<ArrayBufferView>;
  116401. /** @hidden */
  116402. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116403. /** @hidden */
  116404. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116405. /** @hidden */
  116406. _size: number;
  116407. /** @hidden */
  116408. _extension: string;
  116409. /** @hidden */
  116410. _files: Nullable<string[]>;
  116411. /** @hidden */
  116412. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116413. /** @hidden */
  116414. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116415. /** @hidden */
  116416. _framebuffer: Nullable<WebGLFramebuffer>;
  116417. /** @hidden */
  116418. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  116419. /** @hidden */
  116420. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  116421. /** @hidden */
  116422. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  116423. /** @hidden */
  116424. _attachments: Nullable<number[]>;
  116425. /** @hidden */
  116426. _textureArray: Nullable<InternalTexture[]>;
  116427. /** @hidden */
  116428. _cachedCoordinatesMode: Nullable<number>;
  116429. /** @hidden */
  116430. _cachedWrapU: Nullable<number>;
  116431. /** @hidden */
  116432. _cachedWrapV: Nullable<number>;
  116433. /** @hidden */
  116434. _cachedWrapR: Nullable<number>;
  116435. /** @hidden */
  116436. _cachedAnisotropicFilteringLevel: Nullable<number>;
  116437. /** @hidden */
  116438. _isDisabled: boolean;
  116439. /** @hidden */
  116440. _compression: Nullable<string>;
  116441. /** @hidden */
  116442. _generateStencilBuffer: boolean;
  116443. /** @hidden */
  116444. _generateDepthBuffer: boolean;
  116445. /** @hidden */
  116446. _comparisonFunction: number;
  116447. /** @hidden */
  116448. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  116449. /** @hidden */
  116450. _lodGenerationScale: number;
  116451. /** @hidden */
  116452. _lodGenerationOffset: number;
  116453. /** @hidden */
  116454. _depthStencilTexture: Nullable<InternalTexture>;
  116455. /** @hidden */
  116456. _colorTextureArray: Nullable<WebGLTexture>;
  116457. /** @hidden */
  116458. _depthStencilTextureArray: Nullable<WebGLTexture>;
  116459. /** @hidden */
  116460. _lodTextureHigh: Nullable<BaseTexture>;
  116461. /** @hidden */
  116462. _lodTextureMid: Nullable<BaseTexture>;
  116463. /** @hidden */
  116464. _lodTextureLow: Nullable<BaseTexture>;
  116465. /** @hidden */
  116466. _isRGBD: boolean;
  116467. /** @hidden */
  116468. _linearSpecularLOD: boolean;
  116469. /** @hidden */
  116470. _irradianceTexture: Nullable<BaseTexture>;
  116471. /** @hidden */
  116472. _webGLTexture: Nullable<WebGLTexture>;
  116473. /** @hidden */
  116474. _references: number;
  116475. /** @hidden */
  116476. _gammaSpace: Nullable<boolean>;
  116477. private _engine;
  116478. /**
  116479. * Gets the Engine the texture belongs to.
  116480. * @returns The babylon engine
  116481. */
  116482. getEngine(): ThinEngine;
  116483. /**
  116484. * Gets the data source type of the texture
  116485. */
  116486. get source(): InternalTextureSource;
  116487. /**
  116488. * Creates a new InternalTexture
  116489. * @param engine defines the engine to use
  116490. * @param source defines the type of data that will be used
  116491. * @param delayAllocation if the texture allocation should be delayed (default: false)
  116492. */
  116493. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  116494. /**
  116495. * Increments the number of references (ie. the number of Texture that point to it)
  116496. */
  116497. incrementReferences(): void;
  116498. /**
  116499. * Change the size of the texture (not the size of the content)
  116500. * @param width defines the new width
  116501. * @param height defines the new height
  116502. * @param depth defines the new depth (1 by default)
  116503. */
  116504. updateSize(width: int, height: int, depth?: int): void;
  116505. /** @hidden */
  116506. _rebuild(): void;
  116507. /** @hidden */
  116508. _swapAndDie(target: InternalTexture): void;
  116509. /**
  116510. * Dispose the current allocated resources
  116511. */
  116512. dispose(): void;
  116513. }
  116514. }
  116515. declare module BABYLON {
  116516. /**
  116517. * Class used to work with sound analyzer using fast fourier transform (FFT)
  116518. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116519. */
  116520. export class Analyser {
  116521. /**
  116522. * Gets or sets the smoothing
  116523. * @ignorenaming
  116524. */
  116525. SMOOTHING: number;
  116526. /**
  116527. * Gets or sets the FFT table size
  116528. * @ignorenaming
  116529. */
  116530. FFT_SIZE: number;
  116531. /**
  116532. * Gets or sets the bar graph amplitude
  116533. * @ignorenaming
  116534. */
  116535. BARGRAPHAMPLITUDE: number;
  116536. /**
  116537. * Gets or sets the position of the debug canvas
  116538. * @ignorenaming
  116539. */
  116540. DEBUGCANVASPOS: {
  116541. x: number;
  116542. y: number;
  116543. };
  116544. /**
  116545. * Gets or sets the debug canvas size
  116546. * @ignorenaming
  116547. */
  116548. DEBUGCANVASSIZE: {
  116549. width: number;
  116550. height: number;
  116551. };
  116552. private _byteFreqs;
  116553. private _byteTime;
  116554. private _floatFreqs;
  116555. private _webAudioAnalyser;
  116556. private _debugCanvas;
  116557. private _debugCanvasContext;
  116558. private _scene;
  116559. private _registerFunc;
  116560. private _audioEngine;
  116561. /**
  116562. * Creates a new analyser
  116563. * @param scene defines hosting scene
  116564. */
  116565. constructor(scene: Scene);
  116566. /**
  116567. * Get the number of data values you will have to play with for the visualization
  116568. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116569. * @returns a number
  116570. */
  116571. getFrequencyBinCount(): number;
  116572. /**
  116573. * Gets the current frequency data as a byte array
  116574. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116575. * @returns a Uint8Array
  116576. */
  116577. getByteFrequencyData(): Uint8Array;
  116578. /**
  116579. * Gets the current waveform as a byte array
  116580. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116581. * @returns a Uint8Array
  116582. */
  116583. getByteTimeDomainData(): Uint8Array;
  116584. /**
  116585. * Gets the current frequency data as a float array
  116586. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116587. * @returns a Float32Array
  116588. */
  116589. getFloatFrequencyData(): Float32Array;
  116590. /**
  116591. * Renders the debug canvas
  116592. */
  116593. drawDebugCanvas(): void;
  116594. /**
  116595. * Stops rendering the debug canvas and removes it
  116596. */
  116597. stopDebugCanvas(): void;
  116598. /**
  116599. * Connects two audio nodes
  116600. * @param inputAudioNode defines first node to connect
  116601. * @param outputAudioNode defines second node to connect
  116602. */
  116603. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116604. /**
  116605. * Releases all associated resources
  116606. */
  116607. dispose(): void;
  116608. }
  116609. }
  116610. declare module BABYLON {
  116611. /**
  116612. * This represents an audio engine and it is responsible
  116613. * to play, synchronize and analyse sounds throughout the application.
  116614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116615. */
  116616. export interface IAudioEngine extends IDisposable {
  116617. /**
  116618. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116619. */
  116620. readonly canUseWebAudio: boolean;
  116621. /**
  116622. * Gets the current AudioContext if available.
  116623. */
  116624. readonly audioContext: Nullable<AudioContext>;
  116625. /**
  116626. * The master gain node defines the global audio volume of your audio engine.
  116627. */
  116628. readonly masterGain: GainNode;
  116629. /**
  116630. * Gets whether or not mp3 are supported by your browser.
  116631. */
  116632. readonly isMP3supported: boolean;
  116633. /**
  116634. * Gets whether or not ogg are supported by your browser.
  116635. */
  116636. readonly isOGGsupported: boolean;
  116637. /**
  116638. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116639. * @ignoreNaming
  116640. */
  116641. WarnedWebAudioUnsupported: boolean;
  116642. /**
  116643. * Defines if the audio engine relies on a custom unlocked button.
  116644. * In this case, the embedded button will not be displayed.
  116645. */
  116646. useCustomUnlockedButton: boolean;
  116647. /**
  116648. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116649. */
  116650. readonly unlocked: boolean;
  116651. /**
  116652. * Event raised when audio has been unlocked on the browser.
  116653. */
  116654. onAudioUnlockedObservable: Observable<AudioEngine>;
  116655. /**
  116656. * Event raised when audio has been locked on the browser.
  116657. */
  116658. onAudioLockedObservable: Observable<AudioEngine>;
  116659. /**
  116660. * Flags the audio engine in Locked state.
  116661. * This happens due to new browser policies preventing audio to autoplay.
  116662. */
  116663. lock(): void;
  116664. /**
  116665. * Unlocks the audio engine once a user action has been done on the dom.
  116666. * This is helpful to resume play once browser policies have been satisfied.
  116667. */
  116668. unlock(): void;
  116669. /**
  116670. * Gets the global volume sets on the master gain.
  116671. * @returns the global volume if set or -1 otherwise
  116672. */
  116673. getGlobalVolume(): number;
  116674. /**
  116675. * Sets the global volume of your experience (sets on the master gain).
  116676. * @param newVolume Defines the new global volume of the application
  116677. */
  116678. setGlobalVolume(newVolume: number): void;
  116679. /**
  116680. * Connect the audio engine to an audio analyser allowing some amazing
  116681. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116682. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116683. * @param analyser The analyser to connect to the engine
  116684. */
  116685. connectToAnalyser(analyser: Analyser): void;
  116686. }
  116687. /**
  116688. * This represents the default audio engine used in babylon.
  116689. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116691. */
  116692. export class AudioEngine implements IAudioEngine {
  116693. private _audioContext;
  116694. private _audioContextInitialized;
  116695. private _muteButton;
  116696. private _hostElement;
  116697. /**
  116698. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116699. */
  116700. canUseWebAudio: boolean;
  116701. /**
  116702. * The master gain node defines the global audio volume of your audio engine.
  116703. */
  116704. masterGain: GainNode;
  116705. /**
  116706. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116707. * @ignoreNaming
  116708. */
  116709. WarnedWebAudioUnsupported: boolean;
  116710. /**
  116711. * Gets whether or not mp3 are supported by your browser.
  116712. */
  116713. isMP3supported: boolean;
  116714. /**
  116715. * Gets whether or not ogg are supported by your browser.
  116716. */
  116717. isOGGsupported: boolean;
  116718. /**
  116719. * Gets whether audio has been unlocked on the device.
  116720. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  116721. * a user interaction has happened.
  116722. */
  116723. unlocked: boolean;
  116724. /**
  116725. * Defines if the audio engine relies on a custom unlocked button.
  116726. * In this case, the embedded button will not be displayed.
  116727. */
  116728. useCustomUnlockedButton: boolean;
  116729. /**
  116730. * Event raised when audio has been unlocked on the browser.
  116731. */
  116732. onAudioUnlockedObservable: Observable<AudioEngine>;
  116733. /**
  116734. * Event raised when audio has been locked on the browser.
  116735. */
  116736. onAudioLockedObservable: Observable<AudioEngine>;
  116737. /**
  116738. * Gets the current AudioContext if available.
  116739. */
  116740. get audioContext(): Nullable<AudioContext>;
  116741. private _connectedAnalyser;
  116742. /**
  116743. * Instantiates a new audio engine.
  116744. *
  116745. * There should be only one per page as some browsers restrict the number
  116746. * of audio contexts you can create.
  116747. * @param hostElement defines the host element where to display the mute icon if necessary
  116748. */
  116749. constructor(hostElement?: Nullable<HTMLElement>);
  116750. /**
  116751. * Flags the audio engine in Locked state.
  116752. * This happens due to new browser policies preventing audio to autoplay.
  116753. */
  116754. lock(): void;
  116755. /**
  116756. * Unlocks the audio engine once a user action has been done on the dom.
  116757. * This is helpful to resume play once browser policies have been satisfied.
  116758. */
  116759. unlock(): void;
  116760. private _resumeAudioContext;
  116761. private _initializeAudioContext;
  116762. private _tryToRun;
  116763. private _triggerRunningState;
  116764. private _triggerSuspendedState;
  116765. private _displayMuteButton;
  116766. private _moveButtonToTopLeft;
  116767. private _onResize;
  116768. private _hideMuteButton;
  116769. /**
  116770. * Destroy and release the resources associated with the audio ccontext.
  116771. */
  116772. dispose(): void;
  116773. /**
  116774. * Gets the global volume sets on the master gain.
  116775. * @returns the global volume if set or -1 otherwise
  116776. */
  116777. getGlobalVolume(): number;
  116778. /**
  116779. * Sets the global volume of your experience (sets on the master gain).
  116780. * @param newVolume Defines the new global volume of the application
  116781. */
  116782. setGlobalVolume(newVolume: number): void;
  116783. /**
  116784. * Connect the audio engine to an audio analyser allowing some amazing
  116785. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116786. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116787. * @param analyser The analyser to connect to the engine
  116788. */
  116789. connectToAnalyser(analyser: Analyser): void;
  116790. }
  116791. }
  116792. declare module BABYLON {
  116793. /**
  116794. * Interface used to present a loading screen while loading a scene
  116795. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116796. */
  116797. export interface ILoadingScreen {
  116798. /**
  116799. * Function called to display the loading screen
  116800. */
  116801. displayLoadingUI: () => void;
  116802. /**
  116803. * Function called to hide the loading screen
  116804. */
  116805. hideLoadingUI: () => void;
  116806. /**
  116807. * Gets or sets the color to use for the background
  116808. */
  116809. loadingUIBackgroundColor: string;
  116810. /**
  116811. * Gets or sets the text to display while loading
  116812. */
  116813. loadingUIText: string;
  116814. }
  116815. /**
  116816. * Class used for the default loading screen
  116817. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116818. */
  116819. export class DefaultLoadingScreen implements ILoadingScreen {
  116820. private _renderingCanvas;
  116821. private _loadingText;
  116822. private _loadingDivBackgroundColor;
  116823. private _loadingDiv;
  116824. private _loadingTextDiv;
  116825. /** Gets or sets the logo url to use for the default loading screen */
  116826. static DefaultLogoUrl: string;
  116827. /** Gets or sets the spinner url to use for the default loading screen */
  116828. static DefaultSpinnerUrl: string;
  116829. /**
  116830. * Creates a new default loading screen
  116831. * @param _renderingCanvas defines the canvas used to render the scene
  116832. * @param _loadingText defines the default text to display
  116833. * @param _loadingDivBackgroundColor defines the default background color
  116834. */
  116835. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  116836. /**
  116837. * Function called to display the loading screen
  116838. */
  116839. displayLoadingUI(): void;
  116840. /**
  116841. * Function called to hide the loading screen
  116842. */
  116843. hideLoadingUI(): void;
  116844. /**
  116845. * Gets or sets the text to display while loading
  116846. */
  116847. set loadingUIText(text: string);
  116848. get loadingUIText(): string;
  116849. /**
  116850. * Gets or sets the color to use for the background
  116851. */
  116852. get loadingUIBackgroundColor(): string;
  116853. set loadingUIBackgroundColor(color: string);
  116854. private _resizeLoadingUI;
  116855. }
  116856. }
  116857. declare module BABYLON {
  116858. /**
  116859. * Interface for any object that can request an animation frame
  116860. */
  116861. export interface ICustomAnimationFrameRequester {
  116862. /**
  116863. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  116864. */
  116865. renderFunction?: Function;
  116866. /**
  116867. * Called to request the next frame to render to
  116868. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  116869. */
  116870. requestAnimationFrame: Function;
  116871. /**
  116872. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  116873. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  116874. */
  116875. requestID?: number;
  116876. }
  116877. }
  116878. declare module BABYLON {
  116879. /**
  116880. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  116881. */
  116882. export class PerformanceMonitor {
  116883. private _enabled;
  116884. private _rollingFrameTime;
  116885. private _lastFrameTimeMs;
  116886. /**
  116887. * constructor
  116888. * @param frameSampleSize The number of samples required to saturate the sliding window
  116889. */
  116890. constructor(frameSampleSize?: number);
  116891. /**
  116892. * Samples current frame
  116893. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  116894. */
  116895. sampleFrame(timeMs?: number): void;
  116896. /**
  116897. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116898. */
  116899. get averageFrameTime(): number;
  116900. /**
  116901. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116902. */
  116903. get averageFrameTimeVariance(): number;
  116904. /**
  116905. * Returns the frame time of the most recent frame
  116906. */
  116907. get instantaneousFrameTime(): number;
  116908. /**
  116909. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  116910. */
  116911. get averageFPS(): number;
  116912. /**
  116913. * Returns the average framerate in frames per second using the most recent frame time
  116914. */
  116915. get instantaneousFPS(): number;
  116916. /**
  116917. * Returns true if enough samples have been taken to completely fill the sliding window
  116918. */
  116919. get isSaturated(): boolean;
  116920. /**
  116921. * Enables contributions to the sliding window sample set
  116922. */
  116923. enable(): void;
  116924. /**
  116925. * Disables contributions to the sliding window sample set
  116926. * Samples will not be interpolated over the disabled period
  116927. */
  116928. disable(): void;
  116929. /**
  116930. * Returns true if sampling is enabled
  116931. */
  116932. get isEnabled(): boolean;
  116933. /**
  116934. * Resets performance monitor
  116935. */
  116936. reset(): void;
  116937. }
  116938. /**
  116939. * RollingAverage
  116940. *
  116941. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  116942. */
  116943. export class RollingAverage {
  116944. /**
  116945. * Current average
  116946. */
  116947. average: number;
  116948. /**
  116949. * Current variance
  116950. */
  116951. variance: number;
  116952. protected _samples: Array<number>;
  116953. protected _sampleCount: number;
  116954. protected _pos: number;
  116955. protected _m2: number;
  116956. /**
  116957. * constructor
  116958. * @param length The number of samples required to saturate the sliding window
  116959. */
  116960. constructor(length: number);
  116961. /**
  116962. * Adds a sample to the sample set
  116963. * @param v The sample value
  116964. */
  116965. add(v: number): void;
  116966. /**
  116967. * Returns previously added values or null if outside of history or outside the sliding window domain
  116968. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  116969. * @return Value previously recorded with add() or null if outside of range
  116970. */
  116971. history(i: number): number;
  116972. /**
  116973. * Returns true if enough samples have been taken to completely fill the sliding window
  116974. * @return true if sample-set saturated
  116975. */
  116976. isSaturated(): boolean;
  116977. /**
  116978. * Resets the rolling average (equivalent to 0 samples taken so far)
  116979. */
  116980. reset(): void;
  116981. /**
  116982. * Wraps a value around the sample range boundaries
  116983. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  116984. * @return Wrapped position in sample range
  116985. */
  116986. protected _wrapPosition(i: number): number;
  116987. }
  116988. }
  116989. declare module BABYLON {
  116990. /**
  116991. * This class is used to track a performance counter which is number based.
  116992. * The user has access to many properties which give statistics of different nature.
  116993. *
  116994. * The implementer can track two kinds of Performance Counter: time and count.
  116995. * 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.
  116996. * 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.
  116997. */
  116998. export class PerfCounter {
  116999. /**
  117000. * Gets or sets a global boolean to turn on and off all the counters
  117001. */
  117002. static Enabled: boolean;
  117003. /**
  117004. * Returns the smallest value ever
  117005. */
  117006. get min(): number;
  117007. /**
  117008. * Returns the biggest value ever
  117009. */
  117010. get max(): number;
  117011. /**
  117012. * Returns the average value since the performance counter is running
  117013. */
  117014. get average(): number;
  117015. /**
  117016. * Returns the average value of the last second the counter was monitored
  117017. */
  117018. get lastSecAverage(): number;
  117019. /**
  117020. * Returns the current value
  117021. */
  117022. get current(): number;
  117023. /**
  117024. * Gets the accumulated total
  117025. */
  117026. get total(): number;
  117027. /**
  117028. * Gets the total value count
  117029. */
  117030. get count(): number;
  117031. /**
  117032. * Creates a new counter
  117033. */
  117034. constructor();
  117035. /**
  117036. * Call this method to start monitoring a new frame.
  117037. * 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.
  117038. */
  117039. fetchNewFrame(): void;
  117040. /**
  117041. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117042. * @param newCount the count value to add to the monitored count
  117043. * @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.
  117044. */
  117045. addCount(newCount: number, fetchResult: boolean): void;
  117046. /**
  117047. * Start monitoring this performance counter
  117048. */
  117049. beginMonitoring(): void;
  117050. /**
  117051. * Compute the time lapsed since the previous beginMonitoring() call.
  117052. * @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
  117053. */
  117054. endMonitoring(newFrame?: boolean): void;
  117055. private _fetchResult;
  117056. private _startMonitoringTime;
  117057. private _min;
  117058. private _max;
  117059. private _average;
  117060. private _current;
  117061. private _totalValueCount;
  117062. private _totalAccumulated;
  117063. private _lastSecAverage;
  117064. private _lastSecAccumulated;
  117065. private _lastSecTime;
  117066. private _lastSecValueCount;
  117067. }
  117068. }
  117069. declare module BABYLON {
  117070. interface ThinEngine {
  117071. /** @hidden */
  117072. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117073. }
  117074. }
  117075. declare module BABYLON {
  117076. /**
  117077. * Defines the interface used by display changed events
  117078. */
  117079. export interface IDisplayChangedEventArgs {
  117080. /** Gets the vrDisplay object (if any) */
  117081. vrDisplay: Nullable<any>;
  117082. /** Gets a boolean indicating if webVR is supported */
  117083. vrSupported: boolean;
  117084. }
  117085. /**
  117086. * Defines the interface used by objects containing a viewport (like a camera)
  117087. */
  117088. interface IViewportOwnerLike {
  117089. /**
  117090. * Gets or sets the viewport
  117091. */
  117092. viewport: IViewportLike;
  117093. }
  117094. /**
  117095. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117096. */
  117097. export class Engine extends ThinEngine {
  117098. /** Defines that alpha blending is disabled */
  117099. static readonly ALPHA_DISABLE: number;
  117100. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117101. static readonly ALPHA_ADD: number;
  117102. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117103. static readonly ALPHA_COMBINE: number;
  117104. /** Defines that alpha blending to DEST - SRC * DEST */
  117105. static readonly ALPHA_SUBTRACT: number;
  117106. /** Defines that alpha blending to SRC * DEST */
  117107. static readonly ALPHA_MULTIPLY: number;
  117108. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117109. static readonly ALPHA_MAXIMIZED: number;
  117110. /** Defines that alpha blending to SRC + DEST */
  117111. static readonly ALPHA_ONEONE: number;
  117112. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117113. static readonly ALPHA_PREMULTIPLIED: number;
  117114. /**
  117115. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117116. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117117. */
  117118. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117119. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117120. static readonly ALPHA_INTERPOLATE: number;
  117121. /**
  117122. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117123. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117124. */
  117125. static readonly ALPHA_SCREENMODE: number;
  117126. /** Defines that the ressource is not delayed*/
  117127. static readonly DELAYLOADSTATE_NONE: number;
  117128. /** Defines that the ressource was successfully delay loaded */
  117129. static readonly DELAYLOADSTATE_LOADED: number;
  117130. /** Defines that the ressource is currently delay loading */
  117131. static readonly DELAYLOADSTATE_LOADING: number;
  117132. /** Defines that the ressource is delayed and has not started loading */
  117133. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117134. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117135. static readonly NEVER: number;
  117136. /** 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 */
  117137. static readonly ALWAYS: number;
  117138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117139. static readonly LESS: number;
  117140. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117141. static readonly EQUAL: number;
  117142. /** 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 */
  117143. static readonly LEQUAL: number;
  117144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117145. static readonly GREATER: number;
  117146. /** 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 */
  117147. static readonly GEQUAL: number;
  117148. /** 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 */
  117149. static readonly NOTEQUAL: number;
  117150. /** Passed to stencilOperation to specify that stencil value must be kept */
  117151. static readonly KEEP: number;
  117152. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117153. static readonly REPLACE: number;
  117154. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117155. static readonly INCR: number;
  117156. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117157. static readonly DECR: number;
  117158. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117159. static readonly INVERT: number;
  117160. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117161. static readonly INCR_WRAP: number;
  117162. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117163. static readonly DECR_WRAP: number;
  117164. /** Texture is not repeating outside of 0..1 UVs */
  117165. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117166. /** Texture is repeating outside of 0..1 UVs */
  117167. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117168. /** Texture is repeating and mirrored */
  117169. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117170. /** ALPHA */
  117171. static readonly TEXTUREFORMAT_ALPHA: number;
  117172. /** LUMINANCE */
  117173. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117174. /** LUMINANCE_ALPHA */
  117175. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117176. /** RGB */
  117177. static readonly TEXTUREFORMAT_RGB: number;
  117178. /** RGBA */
  117179. static readonly TEXTUREFORMAT_RGBA: number;
  117180. /** RED */
  117181. static readonly TEXTUREFORMAT_RED: number;
  117182. /** RED (2nd reference) */
  117183. static readonly TEXTUREFORMAT_R: number;
  117184. /** RG */
  117185. static readonly TEXTUREFORMAT_RG: number;
  117186. /** RED_INTEGER */
  117187. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117188. /** RED_INTEGER (2nd reference) */
  117189. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117190. /** RG_INTEGER */
  117191. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117192. /** RGB_INTEGER */
  117193. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117194. /** RGBA_INTEGER */
  117195. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117196. /** UNSIGNED_BYTE */
  117197. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117198. /** UNSIGNED_BYTE (2nd reference) */
  117199. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117200. /** FLOAT */
  117201. static readonly TEXTURETYPE_FLOAT: number;
  117202. /** HALF_FLOAT */
  117203. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117204. /** BYTE */
  117205. static readonly TEXTURETYPE_BYTE: number;
  117206. /** SHORT */
  117207. static readonly TEXTURETYPE_SHORT: number;
  117208. /** UNSIGNED_SHORT */
  117209. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117210. /** INT */
  117211. static readonly TEXTURETYPE_INT: number;
  117212. /** UNSIGNED_INT */
  117213. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117214. /** UNSIGNED_SHORT_4_4_4_4 */
  117215. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117216. /** UNSIGNED_SHORT_5_5_5_1 */
  117217. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117218. /** UNSIGNED_SHORT_5_6_5 */
  117219. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117220. /** UNSIGNED_INT_2_10_10_10_REV */
  117221. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117222. /** UNSIGNED_INT_24_8 */
  117223. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117224. /** UNSIGNED_INT_10F_11F_11F_REV */
  117225. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117226. /** UNSIGNED_INT_5_9_9_9_REV */
  117227. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117228. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117229. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117230. /** nearest is mag = nearest and min = nearest and mip = linear */
  117231. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117232. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117233. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117234. /** Trilinear is mag = linear and min = linear and mip = linear */
  117235. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117236. /** nearest is mag = nearest and min = nearest and mip = linear */
  117237. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117238. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117239. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117240. /** Trilinear is mag = linear and min = linear and mip = linear */
  117241. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117242. /** mag = nearest and min = nearest and mip = nearest */
  117243. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117244. /** mag = nearest and min = linear and mip = nearest */
  117245. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117246. /** mag = nearest and min = linear and mip = linear */
  117247. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117248. /** mag = nearest and min = linear and mip = none */
  117249. static readonly TEXTURE_NEAREST_LINEAR: number;
  117250. /** mag = nearest and min = nearest and mip = none */
  117251. static readonly TEXTURE_NEAREST_NEAREST: number;
  117252. /** mag = linear and min = nearest and mip = nearest */
  117253. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117254. /** mag = linear and min = nearest and mip = linear */
  117255. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117256. /** mag = linear and min = linear and mip = none */
  117257. static readonly TEXTURE_LINEAR_LINEAR: number;
  117258. /** mag = linear and min = nearest and mip = none */
  117259. static readonly TEXTURE_LINEAR_NEAREST: number;
  117260. /** Explicit coordinates mode */
  117261. static readonly TEXTURE_EXPLICIT_MODE: number;
  117262. /** Spherical coordinates mode */
  117263. static readonly TEXTURE_SPHERICAL_MODE: number;
  117264. /** Planar coordinates mode */
  117265. static readonly TEXTURE_PLANAR_MODE: number;
  117266. /** Cubic coordinates mode */
  117267. static readonly TEXTURE_CUBIC_MODE: number;
  117268. /** Projection coordinates mode */
  117269. static readonly TEXTURE_PROJECTION_MODE: number;
  117270. /** Skybox coordinates mode */
  117271. static readonly TEXTURE_SKYBOX_MODE: number;
  117272. /** Inverse Cubic coordinates mode */
  117273. static readonly TEXTURE_INVCUBIC_MODE: number;
  117274. /** Equirectangular coordinates mode */
  117275. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117276. /** Equirectangular Fixed coordinates mode */
  117277. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117278. /** Equirectangular Fixed Mirrored coordinates mode */
  117279. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117280. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117281. static readonly SCALEMODE_FLOOR: number;
  117282. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117283. static readonly SCALEMODE_NEAREST: number;
  117284. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117285. static readonly SCALEMODE_CEILING: number;
  117286. /**
  117287. * Returns the current npm package of the sdk
  117288. */
  117289. static get NpmPackage(): string;
  117290. /**
  117291. * Returns the current version of the framework
  117292. */
  117293. static get Version(): string;
  117294. /** Gets the list of created engines */
  117295. static get Instances(): Engine[];
  117296. /**
  117297. * Gets the latest created engine
  117298. */
  117299. static get LastCreatedEngine(): Nullable<Engine>;
  117300. /**
  117301. * Gets the latest created scene
  117302. */
  117303. static get LastCreatedScene(): Nullable<Scene>;
  117304. /**
  117305. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117306. * @param flag defines which part of the materials must be marked as dirty
  117307. * @param predicate defines a predicate used to filter which materials should be affected
  117308. */
  117309. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117310. /**
  117311. * Method called to create the default loading screen.
  117312. * This can be overriden in your own app.
  117313. * @param canvas The rendering canvas element
  117314. * @returns The loading screen
  117315. */
  117316. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117317. /**
  117318. * Method called to create the default rescale post process on each engine.
  117319. */
  117320. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117321. /**
  117322. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117323. **/
  117324. enableOfflineSupport: boolean;
  117325. /**
  117326. * 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)
  117327. **/
  117328. disableManifestCheck: boolean;
  117329. /**
  117330. * Gets the list of created scenes
  117331. */
  117332. scenes: Scene[];
  117333. /**
  117334. * Event raised when a new scene is created
  117335. */
  117336. onNewSceneAddedObservable: Observable<Scene>;
  117337. /**
  117338. * Gets the list of created postprocesses
  117339. */
  117340. postProcesses: PostProcess[];
  117341. /**
  117342. * Gets a boolean indicating if the pointer is currently locked
  117343. */
  117344. isPointerLock: boolean;
  117345. /**
  117346. * Observable event triggered each time the rendering canvas is resized
  117347. */
  117348. onResizeObservable: Observable<Engine>;
  117349. /**
  117350. * Observable event triggered each time the canvas loses focus
  117351. */
  117352. onCanvasBlurObservable: Observable<Engine>;
  117353. /**
  117354. * Observable event triggered each time the canvas gains focus
  117355. */
  117356. onCanvasFocusObservable: Observable<Engine>;
  117357. /**
  117358. * Observable event triggered each time the canvas receives pointerout event
  117359. */
  117360. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117361. /**
  117362. * Observable raised when the engine begins a new frame
  117363. */
  117364. onBeginFrameObservable: Observable<Engine>;
  117365. /**
  117366. * If set, will be used to request the next animation frame for the render loop
  117367. */
  117368. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117369. /**
  117370. * Observable raised when the engine ends the current frame
  117371. */
  117372. onEndFrameObservable: Observable<Engine>;
  117373. /**
  117374. * Observable raised when the engine is about to compile a shader
  117375. */
  117376. onBeforeShaderCompilationObservable: Observable<Engine>;
  117377. /**
  117378. * Observable raised when the engine has jsut compiled a shader
  117379. */
  117380. onAfterShaderCompilationObservable: Observable<Engine>;
  117381. /**
  117382. * Gets the audio engine
  117383. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117384. * @ignorenaming
  117385. */
  117386. static audioEngine: IAudioEngine;
  117387. /**
  117388. * Default AudioEngine factory responsible of creating the Audio Engine.
  117389. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117390. */
  117391. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117392. /**
  117393. * Default offline support factory responsible of creating a tool used to store data locally.
  117394. * By default, this will create a Database object if the workload has been embedded.
  117395. */
  117396. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117397. private _loadingScreen;
  117398. private _pointerLockRequested;
  117399. private _rescalePostProcess;
  117400. private _deterministicLockstep;
  117401. private _lockstepMaxSteps;
  117402. private _timeStep;
  117403. protected get _supportsHardwareTextureRescaling(): boolean;
  117404. private _fps;
  117405. private _deltaTime;
  117406. /** @hidden */
  117407. _drawCalls: PerfCounter;
  117408. /** 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 */
  117409. canvasTabIndex: number;
  117410. /**
  117411. * Turn this value on if you want to pause FPS computation when in background
  117412. */
  117413. disablePerformanceMonitorInBackground: boolean;
  117414. private _performanceMonitor;
  117415. /**
  117416. * Gets the performance monitor attached to this engine
  117417. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117418. */
  117419. get performanceMonitor(): PerformanceMonitor;
  117420. private _onFocus;
  117421. private _onBlur;
  117422. private _onCanvasPointerOut;
  117423. private _onCanvasBlur;
  117424. private _onCanvasFocus;
  117425. private _onFullscreenChange;
  117426. private _onPointerLockChange;
  117427. /**
  117428. * Gets the HTML element used to attach event listeners
  117429. * @returns a HTML element
  117430. */
  117431. getInputElement(): Nullable<HTMLElement>;
  117432. /**
  117433. * Creates a new engine
  117434. * @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
  117435. * @param antialias defines enable antialiasing (default: false)
  117436. * @param options defines further options to be sent to the getContext() function
  117437. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  117438. */
  117439. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  117440. /**
  117441. * Gets current aspect ratio
  117442. * @param viewportOwner defines the camera to use to get the aspect ratio
  117443. * @param useScreen defines if screen size must be used (or the current render target if any)
  117444. * @returns a number defining the aspect ratio
  117445. */
  117446. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  117447. /**
  117448. * Gets current screen aspect ratio
  117449. * @returns a number defining the aspect ratio
  117450. */
  117451. getScreenAspectRatio(): number;
  117452. /**
  117453. * Gets the client rect of the HTML canvas attached with the current webGL context
  117454. * @returns a client rectanglee
  117455. */
  117456. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  117457. /**
  117458. * Gets the client rect of the HTML element used for events
  117459. * @returns a client rectanglee
  117460. */
  117461. getInputElementClientRect(): Nullable<ClientRect>;
  117462. /**
  117463. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117464. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117465. * @returns true if engine is in deterministic lock step mode
  117466. */
  117467. isDeterministicLockStep(): boolean;
  117468. /**
  117469. * Gets the max steps when engine is running in deterministic lock step
  117470. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117471. * @returns the max steps
  117472. */
  117473. getLockstepMaxSteps(): number;
  117474. /**
  117475. * Returns the time in ms between steps when using deterministic lock step.
  117476. * @returns time step in (ms)
  117477. */
  117478. getTimeStep(): number;
  117479. /**
  117480. * Force the mipmap generation for the given render target texture
  117481. * @param texture defines the render target texture to use
  117482. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  117483. */
  117484. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  117485. /** States */
  117486. /**
  117487. * Set various states to the webGL context
  117488. * @param culling defines backface culling state
  117489. * @param zOffset defines the value to apply to zOffset (0 by default)
  117490. * @param force defines if states must be applied even if cache is up to date
  117491. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117492. */
  117493. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117494. /**
  117495. * Set the z offset to apply to current rendering
  117496. * @param value defines the offset to apply
  117497. */
  117498. setZOffset(value: number): void;
  117499. /**
  117500. * Gets the current value of the zOffset
  117501. * @returns the current zOffset state
  117502. */
  117503. getZOffset(): number;
  117504. /**
  117505. * Enable or disable depth buffering
  117506. * @param enable defines the state to set
  117507. */
  117508. setDepthBuffer(enable: boolean): void;
  117509. /**
  117510. * Gets a boolean indicating if depth writing is enabled
  117511. * @returns the current depth writing state
  117512. */
  117513. getDepthWrite(): boolean;
  117514. /**
  117515. * Enable or disable depth writing
  117516. * @param enable defines the state to set
  117517. */
  117518. setDepthWrite(enable: boolean): void;
  117519. /**
  117520. * Gets a boolean indicating if stencil buffer is enabled
  117521. * @returns the current stencil buffer state
  117522. */
  117523. getStencilBuffer(): boolean;
  117524. /**
  117525. * Enable or disable the stencil buffer
  117526. * @param enable defines if the stencil buffer must be enabled or disabled
  117527. */
  117528. setStencilBuffer(enable: boolean): void;
  117529. /**
  117530. * Gets the current stencil mask
  117531. * @returns a number defining the new stencil mask to use
  117532. */
  117533. getStencilMask(): number;
  117534. /**
  117535. * Sets the current stencil mask
  117536. * @param mask defines the new stencil mask to use
  117537. */
  117538. setStencilMask(mask: number): void;
  117539. /**
  117540. * Gets the current stencil function
  117541. * @returns a number defining the stencil function to use
  117542. */
  117543. getStencilFunction(): number;
  117544. /**
  117545. * Gets the current stencil reference value
  117546. * @returns a number defining the stencil reference value to use
  117547. */
  117548. getStencilFunctionReference(): number;
  117549. /**
  117550. * Gets the current stencil mask
  117551. * @returns a number defining the stencil mask to use
  117552. */
  117553. getStencilFunctionMask(): number;
  117554. /**
  117555. * Sets the current stencil function
  117556. * @param stencilFunc defines the new stencil function to use
  117557. */
  117558. setStencilFunction(stencilFunc: number): void;
  117559. /**
  117560. * Sets the current stencil reference
  117561. * @param reference defines the new stencil reference to use
  117562. */
  117563. setStencilFunctionReference(reference: number): void;
  117564. /**
  117565. * Sets the current stencil mask
  117566. * @param mask defines the new stencil mask to use
  117567. */
  117568. setStencilFunctionMask(mask: number): void;
  117569. /**
  117570. * Gets the current stencil operation when stencil fails
  117571. * @returns a number defining stencil operation to use when stencil fails
  117572. */
  117573. getStencilOperationFail(): number;
  117574. /**
  117575. * Gets the current stencil operation when depth fails
  117576. * @returns a number defining stencil operation to use when depth fails
  117577. */
  117578. getStencilOperationDepthFail(): number;
  117579. /**
  117580. * Gets the current stencil operation when stencil passes
  117581. * @returns a number defining stencil operation to use when stencil passes
  117582. */
  117583. getStencilOperationPass(): number;
  117584. /**
  117585. * Sets the stencil operation to use when stencil fails
  117586. * @param operation defines the stencil operation to use when stencil fails
  117587. */
  117588. setStencilOperationFail(operation: number): void;
  117589. /**
  117590. * Sets the stencil operation to use when depth fails
  117591. * @param operation defines the stencil operation to use when depth fails
  117592. */
  117593. setStencilOperationDepthFail(operation: number): void;
  117594. /**
  117595. * Sets the stencil operation to use when stencil passes
  117596. * @param operation defines the stencil operation to use when stencil passes
  117597. */
  117598. setStencilOperationPass(operation: number): void;
  117599. /**
  117600. * Sets a boolean indicating if the dithering state is enabled or disabled
  117601. * @param value defines the dithering state
  117602. */
  117603. setDitheringState(value: boolean): void;
  117604. /**
  117605. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117606. * @param value defines the rasterizer state
  117607. */
  117608. setRasterizerState(value: boolean): void;
  117609. /**
  117610. * Gets the current depth function
  117611. * @returns a number defining the depth function
  117612. */
  117613. getDepthFunction(): Nullable<number>;
  117614. /**
  117615. * Sets the current depth function
  117616. * @param depthFunc defines the function to use
  117617. */
  117618. setDepthFunction(depthFunc: number): void;
  117619. /**
  117620. * Sets the current depth function to GREATER
  117621. */
  117622. setDepthFunctionToGreater(): void;
  117623. /**
  117624. * Sets the current depth function to GEQUAL
  117625. */
  117626. setDepthFunctionToGreaterOrEqual(): void;
  117627. /**
  117628. * Sets the current depth function to LESS
  117629. */
  117630. setDepthFunctionToLess(): void;
  117631. /**
  117632. * Sets the current depth function to LEQUAL
  117633. */
  117634. setDepthFunctionToLessOrEqual(): void;
  117635. private _cachedStencilBuffer;
  117636. private _cachedStencilFunction;
  117637. private _cachedStencilMask;
  117638. private _cachedStencilOperationPass;
  117639. private _cachedStencilOperationFail;
  117640. private _cachedStencilOperationDepthFail;
  117641. private _cachedStencilReference;
  117642. /**
  117643. * Caches the the state of the stencil buffer
  117644. */
  117645. cacheStencilState(): void;
  117646. /**
  117647. * Restores the state of the stencil buffer
  117648. */
  117649. restoreStencilState(): void;
  117650. /**
  117651. * Directly set the WebGL Viewport
  117652. * @param x defines the x coordinate of the viewport (in screen space)
  117653. * @param y defines the y coordinate of the viewport (in screen space)
  117654. * @param width defines the width of the viewport (in screen space)
  117655. * @param height defines the height of the viewport (in screen space)
  117656. * @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
  117657. */
  117658. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117659. /**
  117660. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117661. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117662. * @param y defines the y-coordinate of the corner of the clear rectangle
  117663. * @param width defines the width of the clear rectangle
  117664. * @param height defines the height of the clear rectangle
  117665. * @param clearColor defines the clear color
  117666. */
  117667. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117668. /**
  117669. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117670. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117671. * @param y defines the y-coordinate of the corner of the clear rectangle
  117672. * @param width defines the width of the clear rectangle
  117673. * @param height defines the height of the clear rectangle
  117674. */
  117675. enableScissor(x: number, y: number, width: number, height: number): void;
  117676. /**
  117677. * Disable previously set scissor test rectangle
  117678. */
  117679. disableScissor(): void;
  117680. protected _reportDrawCall(): void;
  117681. /**
  117682. * Initializes a webVR display and starts listening to display change events
  117683. * The onVRDisplayChangedObservable will be notified upon these changes
  117684. * @returns The onVRDisplayChangedObservable
  117685. */
  117686. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117687. /** @hidden */
  117688. _prepareVRComponent(): void;
  117689. /** @hidden */
  117690. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117691. /** @hidden */
  117692. _submitVRFrame(): void;
  117693. /**
  117694. * Call this function to leave webVR mode
  117695. * Will do nothing if webVR is not supported or if there is no webVR device
  117696. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117697. */
  117698. disableVR(): void;
  117699. /**
  117700. * Gets a boolean indicating that the system is in VR mode and is presenting
  117701. * @returns true if VR mode is engaged
  117702. */
  117703. isVRPresenting(): boolean;
  117704. /** @hidden */
  117705. _requestVRFrame(): void;
  117706. /** @hidden */
  117707. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117708. /**
  117709. * Gets the source code of the vertex shader associated with a specific webGL program
  117710. * @param program defines the program to use
  117711. * @returns a string containing the source code of the vertex shader associated with the program
  117712. */
  117713. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117714. /**
  117715. * Gets the source code of the fragment shader associated with a specific webGL program
  117716. * @param program defines the program to use
  117717. * @returns a string containing the source code of the fragment shader associated with the program
  117718. */
  117719. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  117720. /**
  117721. * Sets a depth stencil texture from a render target to the according uniform.
  117722. * @param channel The texture channel
  117723. * @param uniform The uniform to set
  117724. * @param texture The render target texture containing the depth stencil texture to apply
  117725. */
  117726. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  117727. /**
  117728. * Sets a texture to the webGL context from a postprocess
  117729. * @param channel defines the channel to use
  117730. * @param postProcess defines the source postprocess
  117731. */
  117732. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  117733. /**
  117734. * Binds the output of the passed in post process to the texture channel specified
  117735. * @param channel The channel the texture should be bound to
  117736. * @param postProcess The post process which's output should be bound
  117737. */
  117738. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  117739. protected _rebuildBuffers(): void;
  117740. /** @hidden */
  117741. _renderFrame(): void;
  117742. _renderLoop(): void;
  117743. /** @hidden */
  117744. _renderViews(): boolean;
  117745. /**
  117746. * Toggle full screen mode
  117747. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117748. */
  117749. switchFullscreen(requestPointerLock: boolean): void;
  117750. /**
  117751. * Enters full screen mode
  117752. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117753. */
  117754. enterFullscreen(requestPointerLock: boolean): void;
  117755. /**
  117756. * Exits full screen mode
  117757. */
  117758. exitFullscreen(): void;
  117759. /**
  117760. * Enters Pointerlock mode
  117761. */
  117762. enterPointerlock(): void;
  117763. /**
  117764. * Exits Pointerlock mode
  117765. */
  117766. exitPointerlock(): void;
  117767. /**
  117768. * Begin a new frame
  117769. */
  117770. beginFrame(): void;
  117771. /**
  117772. * Enf the current frame
  117773. */
  117774. endFrame(): void;
  117775. resize(): void;
  117776. /**
  117777. * Force a specific size of the canvas
  117778. * @param width defines the new canvas' width
  117779. * @param height defines the new canvas' height
  117780. * @returns true if the size was changed
  117781. */
  117782. setSize(width: number, height: number): boolean;
  117783. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117784. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117785. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117786. _releaseTexture(texture: InternalTexture): void;
  117787. /**
  117788. * @hidden
  117789. * Rescales a texture
  117790. * @param source input texutre
  117791. * @param destination destination texture
  117792. * @param scene scene to use to render the resize
  117793. * @param internalFormat format to use when resizing
  117794. * @param onComplete callback to be called when resize has completed
  117795. */
  117796. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  117797. /**
  117798. * Gets the current framerate
  117799. * @returns a number representing the framerate
  117800. */
  117801. getFps(): number;
  117802. /**
  117803. * Gets the time spent between current and previous frame
  117804. * @returns a number representing the delta time in ms
  117805. */
  117806. getDeltaTime(): number;
  117807. private _measureFps;
  117808. /** @hidden */
  117809. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  117810. /**
  117811. * Updates the sample count of a render target texture
  117812. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117813. * @param texture defines the texture to update
  117814. * @param samples defines the sample count to set
  117815. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117816. */
  117817. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  117818. /**
  117819. * Updates a depth texture Comparison Mode and Function.
  117820. * If the comparison Function is equal to 0, the mode will be set to none.
  117821. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  117822. * @param texture The texture to set the comparison function for
  117823. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  117824. */
  117825. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  117826. /**
  117827. * Creates a webGL buffer to use with instanciation
  117828. * @param capacity defines the size of the buffer
  117829. * @returns the webGL buffer
  117830. */
  117831. createInstancesBuffer(capacity: number): DataBuffer;
  117832. /**
  117833. * Delete a webGL buffer used with instanciation
  117834. * @param buffer defines the webGL buffer to delete
  117835. */
  117836. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  117837. private _clientWaitAsync;
  117838. /** @hidden */
  117839. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  117840. dispose(): void;
  117841. private _disableTouchAction;
  117842. /**
  117843. * Display the loading screen
  117844. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117845. */
  117846. displayLoadingUI(): void;
  117847. /**
  117848. * Hide the loading screen
  117849. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117850. */
  117851. hideLoadingUI(): void;
  117852. /**
  117853. * Gets the current loading screen object
  117854. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117855. */
  117856. get loadingScreen(): ILoadingScreen;
  117857. /**
  117858. * Sets the current loading screen object
  117859. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117860. */
  117861. set loadingScreen(loadingScreen: ILoadingScreen);
  117862. /**
  117863. * Sets the current loading screen text
  117864. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117865. */
  117866. set loadingUIText(text: string);
  117867. /**
  117868. * Sets the current loading screen background color
  117869. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117870. */
  117871. set loadingUIBackgroundColor(color: string);
  117872. /** Pointerlock and fullscreen */
  117873. /**
  117874. * Ask the browser to promote the current element to pointerlock mode
  117875. * @param element defines the DOM element to promote
  117876. */
  117877. static _RequestPointerlock(element: HTMLElement): void;
  117878. /**
  117879. * Asks the browser to exit pointerlock mode
  117880. */
  117881. static _ExitPointerlock(): void;
  117882. /**
  117883. * Ask the browser to promote the current element to fullscreen rendering mode
  117884. * @param element defines the DOM element to promote
  117885. */
  117886. static _RequestFullscreen(element: HTMLElement): void;
  117887. /**
  117888. * Asks the browser to exit fullscreen mode
  117889. */
  117890. static _ExitFullscreen(): void;
  117891. }
  117892. }
  117893. declare module BABYLON {
  117894. /**
  117895. * The engine store class is responsible to hold all the instances of Engine and Scene created
  117896. * during the life time of the application.
  117897. */
  117898. export class EngineStore {
  117899. /** Gets the list of created engines */
  117900. static Instances: Engine[];
  117901. /** @hidden */
  117902. static _LastCreatedScene: Nullable<Scene>;
  117903. /**
  117904. * Gets the latest created engine
  117905. */
  117906. static get LastCreatedEngine(): Nullable<Engine>;
  117907. /**
  117908. * Gets the latest created scene
  117909. */
  117910. static get LastCreatedScene(): Nullable<Scene>;
  117911. /**
  117912. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117913. * @ignorenaming
  117914. */
  117915. static UseFallbackTexture: boolean;
  117916. /**
  117917. * Texture content used if a texture cannot loaded
  117918. * @ignorenaming
  117919. */
  117920. static FallbackTexture: string;
  117921. }
  117922. }
  117923. declare module BABYLON {
  117924. /**
  117925. * Helper class that provides a small promise polyfill
  117926. */
  117927. export class PromisePolyfill {
  117928. /**
  117929. * Static function used to check if the polyfill is required
  117930. * If this is the case then the function will inject the polyfill to window.Promise
  117931. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  117932. */
  117933. static Apply(force?: boolean): void;
  117934. }
  117935. }
  117936. declare module BABYLON {
  117937. /**
  117938. * Interface for screenshot methods with describe argument called `size` as object with options
  117939. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  117940. */
  117941. export interface IScreenshotSize {
  117942. /**
  117943. * number in pixels for canvas height
  117944. */
  117945. height?: number;
  117946. /**
  117947. * multiplier allowing render at a higher or lower resolution
  117948. * If value is defined then height and width will be ignored and taken from camera
  117949. */
  117950. precision?: number;
  117951. /**
  117952. * number in pixels for canvas width
  117953. */
  117954. width?: number;
  117955. }
  117956. }
  117957. declare module BABYLON {
  117958. interface IColor4Like {
  117959. r: float;
  117960. g: float;
  117961. b: float;
  117962. a: float;
  117963. }
  117964. /**
  117965. * Class containing a set of static utilities functions
  117966. */
  117967. export class Tools {
  117968. /**
  117969. * Gets or sets the base URL to use to load assets
  117970. */
  117971. static get BaseUrl(): string;
  117972. static set BaseUrl(value: string);
  117973. /**
  117974. * Enable/Disable Custom HTTP Request Headers globally.
  117975. * default = false
  117976. * @see CustomRequestHeaders
  117977. */
  117978. static UseCustomRequestHeaders: boolean;
  117979. /**
  117980. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117981. * i.e. when loading files, where the server/service expects an Authorization header
  117982. */
  117983. static CustomRequestHeaders: {
  117984. [key: string]: string;
  117985. };
  117986. /**
  117987. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  117988. */
  117989. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  117990. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  117991. /**
  117992. * Default behaviour for cors in the application.
  117993. * It can be a string if the expected behavior is identical in the entire app.
  117994. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  117995. */
  117996. static get CorsBehavior(): string | ((url: string | string[]) => string);
  117997. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  117998. /**
  117999. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118000. * @ignorenaming
  118001. */
  118002. static get UseFallbackTexture(): boolean;
  118003. static set UseFallbackTexture(value: boolean);
  118004. /**
  118005. * Use this object to register external classes like custom textures or material
  118006. * to allow the laoders to instantiate them
  118007. */
  118008. static get RegisteredExternalClasses(): {
  118009. [key: string]: Object;
  118010. };
  118011. static set RegisteredExternalClasses(classes: {
  118012. [key: string]: Object;
  118013. });
  118014. /**
  118015. * Texture content used if a texture cannot loaded
  118016. * @ignorenaming
  118017. */
  118018. static get fallbackTexture(): string;
  118019. static set fallbackTexture(value: string);
  118020. /**
  118021. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118022. * @param u defines the coordinate on X axis
  118023. * @param v defines the coordinate on Y axis
  118024. * @param width defines the width of the source data
  118025. * @param height defines the height of the source data
  118026. * @param pixels defines the source byte array
  118027. * @param color defines the output color
  118028. */
  118029. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118030. /**
  118031. * Interpolates between a and b via alpha
  118032. * @param a The lower value (returned when alpha = 0)
  118033. * @param b The upper value (returned when alpha = 1)
  118034. * @param alpha The interpolation-factor
  118035. * @return The mixed value
  118036. */
  118037. static Mix(a: number, b: number, alpha: number): number;
  118038. /**
  118039. * Tries to instantiate a new object from a given class name
  118040. * @param className defines the class name to instantiate
  118041. * @returns the new object or null if the system was not able to do the instantiation
  118042. */
  118043. static Instantiate(className: string): any;
  118044. /**
  118045. * Provides a slice function that will work even on IE
  118046. * @param data defines the array to slice
  118047. * @param start defines the start of the data (optional)
  118048. * @param end defines the end of the data (optional)
  118049. * @returns the new sliced array
  118050. */
  118051. static Slice<T>(data: T, start?: number, end?: number): T;
  118052. /**
  118053. * Polyfill for setImmediate
  118054. * @param action defines the action to execute after the current execution block
  118055. */
  118056. static SetImmediate(action: () => void): void;
  118057. /**
  118058. * Function indicating if a number is an exponent of 2
  118059. * @param value defines the value to test
  118060. * @returns true if the value is an exponent of 2
  118061. */
  118062. static IsExponentOfTwo(value: number): boolean;
  118063. private static _tmpFloatArray;
  118064. /**
  118065. * Returns the nearest 32-bit single precision float representation of a Number
  118066. * @param value A Number. If the parameter is of a different type, it will get converted
  118067. * to a number or to NaN if it cannot be converted
  118068. * @returns number
  118069. */
  118070. static FloatRound(value: number): number;
  118071. /**
  118072. * Extracts the filename from a path
  118073. * @param path defines the path to use
  118074. * @returns the filename
  118075. */
  118076. static GetFilename(path: string): string;
  118077. /**
  118078. * Extracts the "folder" part of a path (everything before the filename).
  118079. * @param uri The URI to extract the info from
  118080. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118081. * @returns The "folder" part of the path
  118082. */
  118083. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118084. /**
  118085. * Extracts text content from a DOM element hierarchy
  118086. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118087. */
  118088. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118089. /**
  118090. * Convert an angle in radians to degrees
  118091. * @param angle defines the angle to convert
  118092. * @returns the angle in degrees
  118093. */
  118094. static ToDegrees(angle: number): number;
  118095. /**
  118096. * Convert an angle in degrees to radians
  118097. * @param angle defines the angle to convert
  118098. * @returns the angle in radians
  118099. */
  118100. static ToRadians(angle: number): number;
  118101. /**
  118102. * Returns an array if obj is not an array
  118103. * @param obj defines the object to evaluate as an array
  118104. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118105. * @returns either obj directly if obj is an array or a new array containing obj
  118106. */
  118107. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118108. /**
  118109. * Gets the pointer prefix to use
  118110. * @param engine defines the engine we are finding the prefix for
  118111. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118112. */
  118113. static GetPointerPrefix(engine: Engine): string;
  118114. /**
  118115. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118116. * @param url define the url we are trying
  118117. * @param element define the dom element where to configure the cors policy
  118118. */
  118119. static SetCorsBehavior(url: string | string[], element: {
  118120. crossOrigin: string | null;
  118121. }): void;
  118122. /**
  118123. * Removes unwanted characters from an url
  118124. * @param url defines the url to clean
  118125. * @returns the cleaned url
  118126. */
  118127. static CleanUrl(url: string): string;
  118128. /**
  118129. * Gets or sets a function used to pre-process url before using them to load assets
  118130. */
  118131. static get PreprocessUrl(): (url: string) => string;
  118132. static set PreprocessUrl(processor: (url: string) => string);
  118133. /**
  118134. * Loads an image as an HTMLImageElement.
  118135. * @param input url string, ArrayBuffer, or Blob to load
  118136. * @param onLoad callback called when the image successfully loads
  118137. * @param onError callback called when the image fails to load
  118138. * @param offlineProvider offline provider for caching
  118139. * @param mimeType optional mime type
  118140. * @returns the HTMLImageElement of the loaded image
  118141. */
  118142. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118143. /**
  118144. * Loads a file from a url
  118145. * @param url url string, ArrayBuffer, or Blob to load
  118146. * @param onSuccess callback called when the file successfully loads
  118147. * @param onProgress callback called while file is loading (if the server supports this mode)
  118148. * @param offlineProvider defines the offline provider for caching
  118149. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118150. * @param onError callback called when the file fails to load
  118151. * @returns a file request object
  118152. */
  118153. 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;
  118154. /**
  118155. * Loads a file from a url
  118156. * @param url the file url to load
  118157. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118158. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118159. */
  118160. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118161. /**
  118162. * Load a script (identified by an url). When the url returns, the
  118163. * content of this file is added into a new script element, attached to the DOM (body element)
  118164. * @param scriptUrl defines the url of the script to laod
  118165. * @param onSuccess defines the callback called when the script is loaded
  118166. * @param onError defines the callback to call if an error occurs
  118167. * @param scriptId defines the id of the script element
  118168. */
  118169. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118170. /**
  118171. * Load an asynchronous script (identified by an url). When the url returns, the
  118172. * content of this file is added into a new script element, attached to the DOM (body element)
  118173. * @param scriptUrl defines the url of the script to laod
  118174. * @param scriptId defines the id of the script element
  118175. * @returns a promise request object
  118176. */
  118177. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118178. /**
  118179. * Loads a file from a blob
  118180. * @param fileToLoad defines the blob to use
  118181. * @param callback defines the callback to call when data is loaded
  118182. * @param progressCallback defines the callback to call during loading process
  118183. * @returns a file request object
  118184. */
  118185. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118186. /**
  118187. * Reads a file from a File object
  118188. * @param file defines the file to load
  118189. * @param onSuccess defines the callback to call when data is loaded
  118190. * @param onProgress defines the callback to call during loading process
  118191. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118192. * @param onError defines the callback to call when an error occurs
  118193. * @returns a file request object
  118194. */
  118195. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118196. /**
  118197. * Creates a data url from a given string content
  118198. * @param content defines the content to convert
  118199. * @returns the new data url link
  118200. */
  118201. static FileAsURL(content: string): string;
  118202. /**
  118203. * Format the given number to a specific decimal format
  118204. * @param value defines the number to format
  118205. * @param decimals defines the number of decimals to use
  118206. * @returns the formatted string
  118207. */
  118208. static Format(value: number, decimals?: number): string;
  118209. /**
  118210. * Tries to copy an object by duplicating every property
  118211. * @param source defines the source object
  118212. * @param destination defines the target object
  118213. * @param doNotCopyList defines a list of properties to avoid
  118214. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118215. */
  118216. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118217. /**
  118218. * Gets a boolean indicating if the given object has no own property
  118219. * @param obj defines the object to test
  118220. * @returns true if object has no own property
  118221. */
  118222. static IsEmpty(obj: any): boolean;
  118223. /**
  118224. * Function used to register events at window level
  118225. * @param windowElement defines the Window object to use
  118226. * @param events defines the events to register
  118227. */
  118228. static RegisterTopRootEvents(windowElement: Window, events: {
  118229. name: string;
  118230. handler: Nullable<(e: FocusEvent) => any>;
  118231. }[]): void;
  118232. /**
  118233. * Function used to unregister events from window level
  118234. * @param windowElement defines the Window object to use
  118235. * @param events defines the events to unregister
  118236. */
  118237. static UnregisterTopRootEvents(windowElement: Window, events: {
  118238. name: string;
  118239. handler: Nullable<(e: FocusEvent) => any>;
  118240. }[]): void;
  118241. /**
  118242. * @ignore
  118243. */
  118244. static _ScreenshotCanvas: HTMLCanvasElement;
  118245. /**
  118246. * Dumps the current bound framebuffer
  118247. * @param width defines the rendering width
  118248. * @param height defines the rendering height
  118249. * @param engine defines the hosting engine
  118250. * @param successCallback defines the callback triggered once the data are available
  118251. * @param mimeType defines the mime type of the result
  118252. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118253. */
  118254. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118255. /**
  118256. * Converts the canvas data to blob.
  118257. * This acts as a polyfill for browsers not supporting the to blob function.
  118258. * @param canvas Defines the canvas to extract the data from
  118259. * @param successCallback Defines the callback triggered once the data are available
  118260. * @param mimeType Defines the mime type of the result
  118261. */
  118262. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118263. /**
  118264. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118265. * @param successCallback defines the callback triggered once the data are available
  118266. * @param mimeType defines the mime type of the result
  118267. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118268. */
  118269. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118270. /**
  118271. * Downloads a blob in the browser
  118272. * @param blob defines the blob to download
  118273. * @param fileName defines the name of the downloaded file
  118274. */
  118275. static Download(blob: Blob, fileName: string): void;
  118276. /**
  118277. * Captures a screenshot of the current rendering
  118278. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118279. * @param engine defines the rendering engine
  118280. * @param camera defines the source camera
  118281. * @param size This parameter can be set to a single number or to an object with the
  118282. * following (optional) properties: precision, width, height. If a single number is passed,
  118283. * it will be used for both width and height. If an object is passed, the screenshot size
  118284. * will be derived from the parameters. The precision property is a multiplier allowing
  118285. * rendering at a higher or lower resolution
  118286. * @param successCallback defines the callback receives a single parameter which contains the
  118287. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118288. * src parameter of an <img> to display it
  118289. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118290. * Check your browser for supported MIME types
  118291. */
  118292. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118293. /**
  118294. * Captures a screenshot of the current rendering
  118295. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118296. * @param engine defines the rendering engine
  118297. * @param camera defines the source camera
  118298. * @param size This parameter can be set to a single number or to an object with the
  118299. * following (optional) properties: precision, width, height. If a single number is passed,
  118300. * it will be used for both width and height. If an object is passed, the screenshot size
  118301. * will be derived from the parameters. The precision property is a multiplier allowing
  118302. * rendering at a higher or lower resolution
  118303. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118304. * Check your browser for supported MIME types
  118305. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118306. * to the src parameter of an <img> to display it
  118307. */
  118308. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118309. /**
  118310. * Generates an image screenshot from the specified camera.
  118311. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118312. * @param engine The engine to use for rendering
  118313. * @param camera The camera to use for rendering
  118314. * @param size This parameter can be set to a single number or to an object with the
  118315. * following (optional) properties: precision, width, height. If a single number is passed,
  118316. * it will be used for both width and height. If an object is passed, the screenshot size
  118317. * will be derived from the parameters. The precision property is a multiplier allowing
  118318. * rendering at a higher or lower resolution
  118319. * @param successCallback The callback receives a single parameter which contains the
  118320. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118321. * src parameter of an <img> to display it
  118322. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118323. * Check your browser for supported MIME types
  118324. * @param samples Texture samples (default: 1)
  118325. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118326. * @param fileName A name for for the downloaded file.
  118327. */
  118328. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118329. /**
  118330. * Generates an image screenshot from the specified camera.
  118331. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118332. * @param engine The engine to use for rendering
  118333. * @param camera The camera to use for rendering
  118334. * @param size This parameter can be set to a single number or to an object with the
  118335. * following (optional) properties: precision, width, height. If a single number is passed,
  118336. * it will be used for both width and height. If an object is passed, the screenshot size
  118337. * will be derived from the parameters. The precision property is a multiplier allowing
  118338. * rendering at a higher or lower resolution
  118339. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118340. * Check your browser for supported MIME types
  118341. * @param samples Texture samples (default: 1)
  118342. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118343. * @param fileName A name for for the downloaded file.
  118344. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118345. * to the src parameter of an <img> to display it
  118346. */
  118347. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118348. /**
  118349. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118350. * Be aware Math.random() could cause collisions, but:
  118351. * "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"
  118352. * @returns a pseudo random id
  118353. */
  118354. static RandomId(): string;
  118355. /**
  118356. * Test if the given uri is a base64 string
  118357. * @param uri The uri to test
  118358. * @return True if the uri is a base64 string or false otherwise
  118359. */
  118360. static IsBase64(uri: string): boolean;
  118361. /**
  118362. * Decode the given base64 uri.
  118363. * @param uri The uri to decode
  118364. * @return The decoded base64 data.
  118365. */
  118366. static DecodeBase64(uri: string): ArrayBuffer;
  118367. /**
  118368. * Gets the absolute url.
  118369. * @param url the input url
  118370. * @return the absolute url
  118371. */
  118372. static GetAbsoluteUrl(url: string): string;
  118373. /**
  118374. * No log
  118375. */
  118376. static readonly NoneLogLevel: number;
  118377. /**
  118378. * Only message logs
  118379. */
  118380. static readonly MessageLogLevel: number;
  118381. /**
  118382. * Only warning logs
  118383. */
  118384. static readonly WarningLogLevel: number;
  118385. /**
  118386. * Only error logs
  118387. */
  118388. static readonly ErrorLogLevel: number;
  118389. /**
  118390. * All logs
  118391. */
  118392. static readonly AllLogLevel: number;
  118393. /**
  118394. * Gets a value indicating the number of loading errors
  118395. * @ignorenaming
  118396. */
  118397. static get errorsCount(): number;
  118398. /**
  118399. * Callback called when a new log is added
  118400. */
  118401. static OnNewCacheEntry: (entry: string) => void;
  118402. /**
  118403. * Log a message to the console
  118404. * @param message defines the message to log
  118405. */
  118406. static Log(message: string): void;
  118407. /**
  118408. * Write a warning message to the console
  118409. * @param message defines the message to log
  118410. */
  118411. static Warn(message: string): void;
  118412. /**
  118413. * Write an error message to the console
  118414. * @param message defines the message to log
  118415. */
  118416. static Error(message: string): void;
  118417. /**
  118418. * Gets current log cache (list of logs)
  118419. */
  118420. static get LogCache(): string;
  118421. /**
  118422. * Clears the log cache
  118423. */
  118424. static ClearLogCache(): void;
  118425. /**
  118426. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  118427. */
  118428. static set LogLevels(level: number);
  118429. /**
  118430. * Checks if the window object exists
  118431. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  118432. */
  118433. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  118434. /**
  118435. * No performance log
  118436. */
  118437. static readonly PerformanceNoneLogLevel: number;
  118438. /**
  118439. * Use user marks to log performance
  118440. */
  118441. static readonly PerformanceUserMarkLogLevel: number;
  118442. /**
  118443. * Log performance to the console
  118444. */
  118445. static readonly PerformanceConsoleLogLevel: number;
  118446. private static _performance;
  118447. /**
  118448. * Sets the current performance log level
  118449. */
  118450. static set PerformanceLogLevel(level: number);
  118451. private static _StartPerformanceCounterDisabled;
  118452. private static _EndPerformanceCounterDisabled;
  118453. private static _StartUserMark;
  118454. private static _EndUserMark;
  118455. private static _StartPerformanceConsole;
  118456. private static _EndPerformanceConsole;
  118457. /**
  118458. * Starts a performance counter
  118459. */
  118460. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118461. /**
  118462. * Ends a specific performance coutner
  118463. */
  118464. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118465. /**
  118466. * Gets either window.performance.now() if supported or Date.now() else
  118467. */
  118468. static get Now(): number;
  118469. /**
  118470. * This method will return the name of the class used to create the instance of the given object.
  118471. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  118472. * @param object the object to get the class name from
  118473. * @param isType defines if the object is actually a type
  118474. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  118475. */
  118476. static GetClassName(object: any, isType?: boolean): string;
  118477. /**
  118478. * Gets the first element of an array satisfying a given predicate
  118479. * @param array defines the array to browse
  118480. * @param predicate defines the predicate to use
  118481. * @returns null if not found or the element
  118482. */
  118483. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  118484. /**
  118485. * This method will return the name of the full name of the class, including its owning module (if any).
  118486. * 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).
  118487. * @param object the object to get the class name from
  118488. * @param isType defines if the object is actually a type
  118489. * @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.
  118490. * @ignorenaming
  118491. */
  118492. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  118493. /**
  118494. * Returns a promise that resolves after the given amount of time.
  118495. * @param delay Number of milliseconds to delay
  118496. * @returns Promise that resolves after the given amount of time
  118497. */
  118498. static DelayAsync(delay: number): Promise<void>;
  118499. /**
  118500. * Utility function to detect if the current user agent is Safari
  118501. * @returns whether or not the current user agent is safari
  118502. */
  118503. static IsSafari(): boolean;
  118504. }
  118505. /**
  118506. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  118507. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  118508. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  118509. * @param name The name of the class, case should be preserved
  118510. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  118511. */
  118512. export function className(name: string, module?: string): (target: Object) => void;
  118513. /**
  118514. * An implementation of a loop for asynchronous functions.
  118515. */
  118516. export class AsyncLoop {
  118517. /**
  118518. * Defines the number of iterations for the loop
  118519. */
  118520. iterations: number;
  118521. /**
  118522. * Defines the current index of the loop.
  118523. */
  118524. index: number;
  118525. private _done;
  118526. private _fn;
  118527. private _successCallback;
  118528. /**
  118529. * Constructor.
  118530. * @param iterations the number of iterations.
  118531. * @param func the function to run each iteration
  118532. * @param successCallback the callback that will be called upon succesful execution
  118533. * @param offset starting offset.
  118534. */
  118535. constructor(
  118536. /**
  118537. * Defines the number of iterations for the loop
  118538. */
  118539. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  118540. /**
  118541. * Execute the next iteration. Must be called after the last iteration was finished.
  118542. */
  118543. executeNext(): void;
  118544. /**
  118545. * Break the loop and run the success callback.
  118546. */
  118547. breakLoop(): void;
  118548. /**
  118549. * Create and run an async loop.
  118550. * @param iterations the number of iterations.
  118551. * @param fn the function to run each iteration
  118552. * @param successCallback the callback that will be called upon succesful execution
  118553. * @param offset starting offset.
  118554. * @returns the created async loop object
  118555. */
  118556. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  118557. /**
  118558. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118559. * @param iterations total number of iterations
  118560. * @param syncedIterations number of synchronous iterations in each async iteration.
  118561. * @param fn the function to call each iteration.
  118562. * @param callback a success call back that will be called when iterating stops.
  118563. * @param breakFunction a break condition (optional)
  118564. * @param timeout timeout settings for the setTimeout function. default - 0.
  118565. * @returns the created async loop object
  118566. */
  118567. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118568. }
  118569. }
  118570. declare module BABYLON {
  118571. /**
  118572. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118573. * The underlying implementation relies on an associative array to ensure the best performances.
  118574. * The value can be anything including 'null' but except 'undefined'
  118575. */
  118576. export class StringDictionary<T> {
  118577. /**
  118578. * This will clear this dictionary and copy the content from the 'source' one.
  118579. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118580. * @param source the dictionary to take the content from and copy to this dictionary
  118581. */
  118582. copyFrom(source: StringDictionary<T>): void;
  118583. /**
  118584. * Get a value based from its key
  118585. * @param key the given key to get the matching value from
  118586. * @return the value if found, otherwise undefined is returned
  118587. */
  118588. get(key: string): T | undefined;
  118589. /**
  118590. * Get a value from its key or add it if it doesn't exist.
  118591. * This method will ensure you that a given key/data will be present in the dictionary.
  118592. * @param key the given key to get the matching value from
  118593. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118594. * The factory will only be invoked if there's no data for the given key.
  118595. * @return the value corresponding to the key.
  118596. */
  118597. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118598. /**
  118599. * Get a value from its key if present in the dictionary otherwise add it
  118600. * @param key the key to get the value from
  118601. * @param val if there's no such key/value pair in the dictionary add it with this value
  118602. * @return the value corresponding to the key
  118603. */
  118604. getOrAdd(key: string, val: T): T;
  118605. /**
  118606. * Check if there's a given key in the dictionary
  118607. * @param key the key to check for
  118608. * @return true if the key is present, false otherwise
  118609. */
  118610. contains(key: string): boolean;
  118611. /**
  118612. * Add a new key and its corresponding value
  118613. * @param key the key to add
  118614. * @param value the value corresponding to the key
  118615. * @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
  118616. */
  118617. add(key: string, value: T): boolean;
  118618. /**
  118619. * Update a specific value associated to a key
  118620. * @param key defines the key to use
  118621. * @param value defines the value to store
  118622. * @returns true if the value was updated (or false if the key was not found)
  118623. */
  118624. set(key: string, value: T): boolean;
  118625. /**
  118626. * Get the element of the given key and remove it from the dictionary
  118627. * @param key defines the key to search
  118628. * @returns the value associated with the key or null if not found
  118629. */
  118630. getAndRemove(key: string): Nullable<T>;
  118631. /**
  118632. * Remove a key/value from the dictionary.
  118633. * @param key the key to remove
  118634. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118635. */
  118636. remove(key: string): boolean;
  118637. /**
  118638. * Clear the whole content of the dictionary
  118639. */
  118640. clear(): void;
  118641. /**
  118642. * Gets the current count
  118643. */
  118644. get count(): number;
  118645. /**
  118646. * Execute a callback on each key/val of the dictionary.
  118647. * Note that you can remove any element in this dictionary in the callback implementation
  118648. * @param callback the callback to execute on a given key/value pair
  118649. */
  118650. forEach(callback: (key: string, val: T) => void): void;
  118651. /**
  118652. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118653. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118654. * Note that you can remove any element in this dictionary in the callback implementation
  118655. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118656. * @returns the first item
  118657. */
  118658. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118659. private _count;
  118660. private _data;
  118661. }
  118662. }
  118663. declare module BABYLON {
  118664. /** @hidden */
  118665. export interface ICollisionCoordinator {
  118666. createCollider(): Collider;
  118667. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118668. init(scene: Scene): void;
  118669. }
  118670. /** @hidden */
  118671. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118672. private _scene;
  118673. private _scaledPosition;
  118674. private _scaledVelocity;
  118675. private _finalPosition;
  118676. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118677. createCollider(): Collider;
  118678. init(scene: Scene): void;
  118679. private _collideWithWorld;
  118680. }
  118681. }
  118682. declare module BABYLON {
  118683. /**
  118684. * Class used to manage all inputs for the scene.
  118685. */
  118686. export class InputManager {
  118687. /** The distance in pixel that you have to move to prevent some events */
  118688. static DragMovementThreshold: number;
  118689. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118690. static LongPressDelay: number;
  118691. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118692. static DoubleClickDelay: number;
  118693. /** If you need to check double click without raising a single click at first click, enable this flag */
  118694. static ExclusiveDoubleClickMode: boolean;
  118695. /** 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. */
  118696. private _alreadyAttached;
  118697. private _wheelEventName;
  118698. private _onPointerMove;
  118699. private _onPointerDown;
  118700. private _onPointerUp;
  118701. private _initClickEvent;
  118702. private _initActionManager;
  118703. private _delayedSimpleClick;
  118704. private _delayedSimpleClickTimeout;
  118705. private _previousDelayedSimpleClickTimeout;
  118706. private _meshPickProceed;
  118707. private _previousButtonPressed;
  118708. private _currentPickResult;
  118709. private _previousPickResult;
  118710. private _totalPointersPressed;
  118711. private _doubleClickOccured;
  118712. private _pointerOverMesh;
  118713. private _pickedDownMesh;
  118714. private _pickedUpMesh;
  118715. private _pointerX;
  118716. private _pointerY;
  118717. private _unTranslatedPointerX;
  118718. private _unTranslatedPointerY;
  118719. private _startingPointerPosition;
  118720. private _previousStartingPointerPosition;
  118721. private _startingPointerTime;
  118722. private _previousStartingPointerTime;
  118723. private _pointerCaptures;
  118724. private _meshUnderPointerId;
  118725. private _onKeyDown;
  118726. private _onKeyUp;
  118727. private _onCanvasFocusObserver;
  118728. private _onCanvasBlurObserver;
  118729. private _scene;
  118730. /**
  118731. * Creates a new InputManager
  118732. * @param scene defines the hosting scene
  118733. */
  118734. constructor(scene: Scene);
  118735. /**
  118736. * Gets the mesh that is currently under the pointer
  118737. */
  118738. get meshUnderPointer(): Nullable<AbstractMesh>;
  118739. /**
  118740. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  118741. * @param pointerId the pointer id to use
  118742. * @returns The mesh under this pointer id or null if not found
  118743. */
  118744. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  118745. /**
  118746. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  118747. */
  118748. get unTranslatedPointer(): Vector2;
  118749. /**
  118750. * Gets or sets the current on-screen X position of the pointer
  118751. */
  118752. get pointerX(): number;
  118753. set pointerX(value: number);
  118754. /**
  118755. * Gets or sets the current on-screen Y position of the pointer
  118756. */
  118757. get pointerY(): number;
  118758. set pointerY(value: number);
  118759. private _updatePointerPosition;
  118760. private _processPointerMove;
  118761. private _setRayOnPointerInfo;
  118762. private _checkPrePointerObservable;
  118763. /**
  118764. * Use this method to simulate a pointer move on a mesh
  118765. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118766. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118767. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118768. */
  118769. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118770. /**
  118771. * Use this method to simulate a pointer down on a mesh
  118772. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118773. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118774. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118775. */
  118776. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118777. private _processPointerDown;
  118778. /** @hidden */
  118779. _isPointerSwiping(): boolean;
  118780. /**
  118781. * Use this method to simulate a pointer up on a mesh
  118782. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118783. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118784. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118785. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118786. */
  118787. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  118788. private _processPointerUp;
  118789. /**
  118790. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118791. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118792. * @returns true if the pointer was captured
  118793. */
  118794. isPointerCaptured(pointerId?: number): boolean;
  118795. /**
  118796. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118797. * @param attachUp defines if you want to attach events to pointerup
  118798. * @param attachDown defines if you want to attach events to pointerdown
  118799. * @param attachMove defines if you want to attach events to pointermove
  118800. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  118801. */
  118802. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  118803. /**
  118804. * Detaches all event handlers
  118805. */
  118806. detachControl(): void;
  118807. /**
  118808. * Force the value of meshUnderPointer
  118809. * @param mesh defines the mesh to use
  118810. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  118811. */
  118812. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  118813. /**
  118814. * Gets the mesh under the pointer
  118815. * @returns a Mesh or null if no mesh is under the pointer
  118816. */
  118817. getPointerOverMesh(): Nullable<AbstractMesh>;
  118818. }
  118819. }
  118820. declare module BABYLON {
  118821. /**
  118822. * This class defines the direct association between an animation and a target
  118823. */
  118824. export class TargetedAnimation {
  118825. /**
  118826. * Animation to perform
  118827. */
  118828. animation: Animation;
  118829. /**
  118830. * Target to animate
  118831. */
  118832. target: any;
  118833. /**
  118834. * Returns the string "TargetedAnimation"
  118835. * @returns "TargetedAnimation"
  118836. */
  118837. getClassName(): string;
  118838. /**
  118839. * Serialize the object
  118840. * @returns the JSON object representing the current entity
  118841. */
  118842. serialize(): any;
  118843. }
  118844. /**
  118845. * Use this class to create coordinated animations on multiple targets
  118846. */
  118847. export class AnimationGroup implements IDisposable {
  118848. /** The name of the animation group */
  118849. name: string;
  118850. private _scene;
  118851. private _targetedAnimations;
  118852. private _animatables;
  118853. private _from;
  118854. private _to;
  118855. private _isStarted;
  118856. private _isPaused;
  118857. private _speedRatio;
  118858. private _loopAnimation;
  118859. private _isAdditive;
  118860. /**
  118861. * Gets or sets the unique id of the node
  118862. */
  118863. uniqueId: number;
  118864. /**
  118865. * This observable will notify when one animation have ended
  118866. */
  118867. onAnimationEndObservable: Observable<TargetedAnimation>;
  118868. /**
  118869. * Observer raised when one animation loops
  118870. */
  118871. onAnimationLoopObservable: Observable<TargetedAnimation>;
  118872. /**
  118873. * Observer raised when all animations have looped
  118874. */
  118875. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  118876. /**
  118877. * This observable will notify when all animations have ended.
  118878. */
  118879. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  118880. /**
  118881. * This observable will notify when all animations have paused.
  118882. */
  118883. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  118884. /**
  118885. * This observable will notify when all animations are playing.
  118886. */
  118887. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  118888. /**
  118889. * Gets the first frame
  118890. */
  118891. get from(): number;
  118892. /**
  118893. * Gets the last frame
  118894. */
  118895. get to(): number;
  118896. /**
  118897. * Define if the animations are started
  118898. */
  118899. get isStarted(): boolean;
  118900. /**
  118901. * Gets a value indicating that the current group is playing
  118902. */
  118903. get isPlaying(): boolean;
  118904. /**
  118905. * Gets or sets the speed ratio to use for all animations
  118906. */
  118907. get speedRatio(): number;
  118908. /**
  118909. * Gets or sets the speed ratio to use for all animations
  118910. */
  118911. set speedRatio(value: number);
  118912. /**
  118913. * Gets or sets if all animations should loop or not
  118914. */
  118915. get loopAnimation(): boolean;
  118916. set loopAnimation(value: boolean);
  118917. /**
  118918. * Gets or sets if all animations should be evaluated additively
  118919. */
  118920. get isAdditive(): boolean;
  118921. set isAdditive(value: boolean);
  118922. /**
  118923. * Gets the targeted animations for this animation group
  118924. */
  118925. get targetedAnimations(): Array<TargetedAnimation>;
  118926. /**
  118927. * returning the list of animatables controlled by this animation group.
  118928. */
  118929. get animatables(): Array<Animatable>;
  118930. /**
  118931. * Gets the list of target animations
  118932. */
  118933. get children(): TargetedAnimation[];
  118934. /**
  118935. * Instantiates a new Animation Group.
  118936. * This helps managing several animations at once.
  118937. * @see https://doc.babylonjs.com/how_to/group
  118938. * @param name Defines the name of the group
  118939. * @param scene Defines the scene the group belongs to
  118940. */
  118941. constructor(
  118942. /** The name of the animation group */
  118943. name: string, scene?: Nullable<Scene>);
  118944. /**
  118945. * Add an animation (with its target) in the group
  118946. * @param animation defines the animation we want to add
  118947. * @param target defines the target of the animation
  118948. * @returns the TargetedAnimation object
  118949. */
  118950. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  118951. /**
  118952. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  118953. * It can add constant keys at begin or end
  118954. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  118955. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  118956. * @returns the animation group
  118957. */
  118958. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  118959. private _animationLoopCount;
  118960. private _animationLoopFlags;
  118961. private _processLoop;
  118962. /**
  118963. * Start all animations on given targets
  118964. * @param loop defines if animations must loop
  118965. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  118966. * @param from defines the from key (optional)
  118967. * @param to defines the to key (optional)
  118968. * @param isAdditive defines the additive state for the resulting animatables (optional)
  118969. * @returns the current animation group
  118970. */
  118971. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  118972. /**
  118973. * Pause all animations
  118974. * @returns the animation group
  118975. */
  118976. pause(): AnimationGroup;
  118977. /**
  118978. * Play all animations to initial state
  118979. * This function will start() the animations if they were not started or will restart() them if they were paused
  118980. * @param loop defines if animations must loop
  118981. * @returns the animation group
  118982. */
  118983. play(loop?: boolean): AnimationGroup;
  118984. /**
  118985. * Reset all animations to initial state
  118986. * @returns the animation group
  118987. */
  118988. reset(): AnimationGroup;
  118989. /**
  118990. * Restart animations from key 0
  118991. * @returns the animation group
  118992. */
  118993. restart(): AnimationGroup;
  118994. /**
  118995. * Stop all animations
  118996. * @returns the animation group
  118997. */
  118998. stop(): AnimationGroup;
  118999. /**
  119000. * Set animation weight for all animatables
  119001. * @param weight defines the weight to use
  119002. * @return the animationGroup
  119003. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119004. */
  119005. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119006. /**
  119007. * Synchronize and normalize all animatables with a source animatable
  119008. * @param root defines the root animatable to synchronize with
  119009. * @return the animationGroup
  119010. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119011. */
  119012. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119013. /**
  119014. * Goes to a specific frame in this animation group
  119015. * @param frame the frame number to go to
  119016. * @return the animationGroup
  119017. */
  119018. goToFrame(frame: number): AnimationGroup;
  119019. /**
  119020. * Dispose all associated resources
  119021. */
  119022. dispose(): void;
  119023. private _checkAnimationGroupEnded;
  119024. /**
  119025. * Clone the current animation group and returns a copy
  119026. * @param newName defines the name of the new group
  119027. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119028. * @returns the new aniamtion group
  119029. */
  119030. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119031. /**
  119032. * Serializes the animationGroup to an object
  119033. * @returns Serialized object
  119034. */
  119035. serialize(): any;
  119036. /**
  119037. * Returns a new AnimationGroup object parsed from the source provided.
  119038. * @param parsedAnimationGroup defines the source
  119039. * @param scene defines the scene that will receive the animationGroup
  119040. * @returns a new AnimationGroup
  119041. */
  119042. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119043. /**
  119044. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119045. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119046. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119047. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119048. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119049. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119050. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119051. */
  119052. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119053. /**
  119054. * Returns the string "AnimationGroup"
  119055. * @returns "AnimationGroup"
  119056. */
  119057. getClassName(): string;
  119058. /**
  119059. * Creates a detailled string about the object
  119060. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119061. * @returns a string representing the object
  119062. */
  119063. toString(fullDetails?: boolean): string;
  119064. }
  119065. }
  119066. declare module BABYLON {
  119067. /**
  119068. * Define an interface for all classes that will hold resources
  119069. */
  119070. export interface IDisposable {
  119071. /**
  119072. * Releases all held resources
  119073. */
  119074. dispose(): void;
  119075. }
  119076. /** Interface defining initialization parameters for Scene class */
  119077. export interface SceneOptions {
  119078. /**
  119079. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119080. * It will improve performance when the number of geometries becomes important.
  119081. */
  119082. useGeometryUniqueIdsMap?: boolean;
  119083. /**
  119084. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119085. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119086. */
  119087. useMaterialMeshMap?: boolean;
  119088. /**
  119089. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119090. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119091. */
  119092. useClonedMeshMap?: boolean;
  119093. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119094. virtual?: boolean;
  119095. }
  119096. /**
  119097. * Represents a scene to be rendered by the engine.
  119098. * @see https://doc.babylonjs.com/features/scene
  119099. */
  119100. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119101. /** The fog is deactivated */
  119102. static readonly FOGMODE_NONE: number;
  119103. /** The fog density is following an exponential function */
  119104. static readonly FOGMODE_EXP: number;
  119105. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119106. static readonly FOGMODE_EXP2: number;
  119107. /** The fog density is following a linear function. */
  119108. static readonly FOGMODE_LINEAR: number;
  119109. /**
  119110. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119111. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119112. */
  119113. static MinDeltaTime: number;
  119114. /**
  119115. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119116. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119117. */
  119118. static MaxDeltaTime: number;
  119119. /**
  119120. * Factory used to create the default material.
  119121. * @param name The name of the material to create
  119122. * @param scene The scene to create the material for
  119123. * @returns The default material
  119124. */
  119125. static DefaultMaterialFactory(scene: Scene): Material;
  119126. /**
  119127. * Factory used to create the a collision coordinator.
  119128. * @returns The collision coordinator
  119129. */
  119130. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119131. /** @hidden */
  119132. _inputManager: InputManager;
  119133. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119134. cameraToUseForPointers: Nullable<Camera>;
  119135. /** @hidden */
  119136. readonly _isScene: boolean;
  119137. /** @hidden */
  119138. _blockEntityCollection: boolean;
  119139. /**
  119140. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119141. */
  119142. autoClear: boolean;
  119143. /**
  119144. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119145. */
  119146. autoClearDepthAndStencil: boolean;
  119147. /**
  119148. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119149. */
  119150. clearColor: Color4;
  119151. /**
  119152. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119153. */
  119154. ambientColor: Color3;
  119155. /**
  119156. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119157. * It should only be one of the following (if not the default embedded one):
  119158. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119159. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119160. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119161. * The material properties need to be setup according to the type of texture in use.
  119162. */
  119163. environmentBRDFTexture: BaseTexture;
  119164. /**
  119165. * Texture used in all pbr material as the reflection texture.
  119166. * As in the majority of the scene they are the same (exception for multi room and so on),
  119167. * this is easier to reference from here than from all the materials.
  119168. */
  119169. get environmentTexture(): Nullable<BaseTexture>;
  119170. /**
  119171. * Texture used in all pbr material as the reflection texture.
  119172. * As in the majority of the scene they are the same (exception for multi room and so on),
  119173. * this is easier to set here than in all the materials.
  119174. */
  119175. set environmentTexture(value: Nullable<BaseTexture>);
  119176. /** @hidden */
  119177. protected _environmentIntensity: number;
  119178. /**
  119179. * Intensity of the environment in all pbr material.
  119180. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119181. * As in the majority of the scene they are the same (exception for multi room and so on),
  119182. * this is easier to reference from here than from all the materials.
  119183. */
  119184. get environmentIntensity(): number;
  119185. /**
  119186. * Intensity of the environment in all pbr material.
  119187. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119188. * As in the majority of the scene they are the same (exception for multi room and so on),
  119189. * this is easier to set here than in all the materials.
  119190. */
  119191. set environmentIntensity(value: number);
  119192. /** @hidden */
  119193. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119194. /**
  119195. * Default image processing configuration used either in the rendering
  119196. * Forward main pass or through the imageProcessingPostProcess if present.
  119197. * As in the majority of the scene they are the same (exception for multi camera),
  119198. * this is easier to reference from here than from all the materials and post process.
  119199. *
  119200. * No setter as we it is a shared configuration, you can set the values instead.
  119201. */
  119202. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119203. private _forceWireframe;
  119204. /**
  119205. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119206. */
  119207. set forceWireframe(value: boolean);
  119208. get forceWireframe(): boolean;
  119209. private _skipFrustumClipping;
  119210. /**
  119211. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119212. */
  119213. set skipFrustumClipping(value: boolean);
  119214. get skipFrustumClipping(): boolean;
  119215. private _forcePointsCloud;
  119216. /**
  119217. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119218. */
  119219. set forcePointsCloud(value: boolean);
  119220. get forcePointsCloud(): boolean;
  119221. /**
  119222. * Gets or sets the active clipplane 1
  119223. */
  119224. clipPlane: Nullable<Plane>;
  119225. /**
  119226. * Gets or sets the active clipplane 2
  119227. */
  119228. clipPlane2: Nullable<Plane>;
  119229. /**
  119230. * Gets or sets the active clipplane 3
  119231. */
  119232. clipPlane3: Nullable<Plane>;
  119233. /**
  119234. * Gets or sets the active clipplane 4
  119235. */
  119236. clipPlane4: Nullable<Plane>;
  119237. /**
  119238. * Gets or sets the active clipplane 5
  119239. */
  119240. clipPlane5: Nullable<Plane>;
  119241. /**
  119242. * Gets or sets the active clipplane 6
  119243. */
  119244. clipPlane6: Nullable<Plane>;
  119245. /**
  119246. * Gets or sets a boolean indicating if animations are enabled
  119247. */
  119248. animationsEnabled: boolean;
  119249. private _animationPropertiesOverride;
  119250. /**
  119251. * Gets or sets the animation properties override
  119252. */
  119253. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119254. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119255. /**
  119256. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119257. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119258. */
  119259. useConstantAnimationDeltaTime: boolean;
  119260. /**
  119261. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119262. * Please note that it requires to run a ray cast through the scene on every frame
  119263. */
  119264. constantlyUpdateMeshUnderPointer: boolean;
  119265. /**
  119266. * Defines the HTML cursor to use when hovering over interactive elements
  119267. */
  119268. hoverCursor: string;
  119269. /**
  119270. * Defines the HTML default cursor to use (empty by default)
  119271. */
  119272. defaultCursor: string;
  119273. /**
  119274. * Defines whether cursors are handled by the scene.
  119275. */
  119276. doNotHandleCursors: boolean;
  119277. /**
  119278. * This is used to call preventDefault() on pointer down
  119279. * in order to block unwanted artifacts like system double clicks
  119280. */
  119281. preventDefaultOnPointerDown: boolean;
  119282. /**
  119283. * This is used to call preventDefault() on pointer up
  119284. * in order to block unwanted artifacts like system double clicks
  119285. */
  119286. preventDefaultOnPointerUp: boolean;
  119287. /**
  119288. * Gets or sets user defined metadata
  119289. */
  119290. metadata: any;
  119291. /**
  119292. * For internal use only. Please do not use.
  119293. */
  119294. reservedDataStore: any;
  119295. /**
  119296. * Gets the name of the plugin used to load this scene (null by default)
  119297. */
  119298. loadingPluginName: string;
  119299. /**
  119300. * Use this array to add regular expressions used to disable offline support for specific urls
  119301. */
  119302. disableOfflineSupportExceptionRules: RegExp[];
  119303. /**
  119304. * An event triggered when the scene is disposed.
  119305. */
  119306. onDisposeObservable: Observable<Scene>;
  119307. private _onDisposeObserver;
  119308. /** Sets a function to be executed when this scene is disposed. */
  119309. set onDispose(callback: () => void);
  119310. /**
  119311. * An event triggered before rendering the scene (right after animations and physics)
  119312. */
  119313. onBeforeRenderObservable: Observable<Scene>;
  119314. private _onBeforeRenderObserver;
  119315. /** Sets a function to be executed before rendering this scene */
  119316. set beforeRender(callback: Nullable<() => void>);
  119317. /**
  119318. * An event triggered after rendering the scene
  119319. */
  119320. onAfterRenderObservable: Observable<Scene>;
  119321. /**
  119322. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119323. */
  119324. onAfterRenderCameraObservable: Observable<Camera>;
  119325. private _onAfterRenderObserver;
  119326. /** Sets a function to be executed after rendering this scene */
  119327. set afterRender(callback: Nullable<() => void>);
  119328. /**
  119329. * An event triggered before animating the scene
  119330. */
  119331. onBeforeAnimationsObservable: Observable<Scene>;
  119332. /**
  119333. * An event triggered after animations processing
  119334. */
  119335. onAfterAnimationsObservable: Observable<Scene>;
  119336. /**
  119337. * An event triggered before draw calls are ready to be sent
  119338. */
  119339. onBeforeDrawPhaseObservable: Observable<Scene>;
  119340. /**
  119341. * An event triggered after draw calls have been sent
  119342. */
  119343. onAfterDrawPhaseObservable: Observable<Scene>;
  119344. /**
  119345. * An event triggered when the scene is ready
  119346. */
  119347. onReadyObservable: Observable<Scene>;
  119348. /**
  119349. * An event triggered before rendering a camera
  119350. */
  119351. onBeforeCameraRenderObservable: Observable<Camera>;
  119352. private _onBeforeCameraRenderObserver;
  119353. /** Sets a function to be executed before rendering a camera*/
  119354. set beforeCameraRender(callback: () => void);
  119355. /**
  119356. * An event triggered after rendering a camera
  119357. */
  119358. onAfterCameraRenderObservable: Observable<Camera>;
  119359. private _onAfterCameraRenderObserver;
  119360. /** Sets a function to be executed after rendering a camera*/
  119361. set afterCameraRender(callback: () => void);
  119362. /**
  119363. * An event triggered when active meshes evaluation is about to start
  119364. */
  119365. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119366. /**
  119367. * An event triggered when active meshes evaluation is done
  119368. */
  119369. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119370. /**
  119371. * An event triggered when particles rendering is about to start
  119372. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119373. */
  119374. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119375. /**
  119376. * An event triggered when particles rendering is done
  119377. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119378. */
  119379. onAfterParticlesRenderingObservable: Observable<Scene>;
  119380. /**
  119381. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119382. */
  119383. onDataLoadedObservable: Observable<Scene>;
  119384. /**
  119385. * An event triggered when a camera is created
  119386. */
  119387. onNewCameraAddedObservable: Observable<Camera>;
  119388. /**
  119389. * An event triggered when a camera is removed
  119390. */
  119391. onCameraRemovedObservable: Observable<Camera>;
  119392. /**
  119393. * An event triggered when a light is created
  119394. */
  119395. onNewLightAddedObservable: Observable<Light>;
  119396. /**
  119397. * An event triggered when a light is removed
  119398. */
  119399. onLightRemovedObservable: Observable<Light>;
  119400. /**
  119401. * An event triggered when a geometry is created
  119402. */
  119403. onNewGeometryAddedObservable: Observable<Geometry>;
  119404. /**
  119405. * An event triggered when a geometry is removed
  119406. */
  119407. onGeometryRemovedObservable: Observable<Geometry>;
  119408. /**
  119409. * An event triggered when a transform node is created
  119410. */
  119411. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  119412. /**
  119413. * An event triggered when a transform node is removed
  119414. */
  119415. onTransformNodeRemovedObservable: Observable<TransformNode>;
  119416. /**
  119417. * An event triggered when a mesh is created
  119418. */
  119419. onNewMeshAddedObservable: Observable<AbstractMesh>;
  119420. /**
  119421. * An event triggered when a mesh is removed
  119422. */
  119423. onMeshRemovedObservable: Observable<AbstractMesh>;
  119424. /**
  119425. * An event triggered when a skeleton is created
  119426. */
  119427. onNewSkeletonAddedObservable: Observable<Skeleton>;
  119428. /**
  119429. * An event triggered when a skeleton is removed
  119430. */
  119431. onSkeletonRemovedObservable: Observable<Skeleton>;
  119432. /**
  119433. * An event triggered when a material is created
  119434. */
  119435. onNewMaterialAddedObservable: Observable<Material>;
  119436. /**
  119437. * An event triggered when a material is removed
  119438. */
  119439. onMaterialRemovedObservable: Observable<Material>;
  119440. /**
  119441. * An event triggered when a texture is created
  119442. */
  119443. onNewTextureAddedObservable: Observable<BaseTexture>;
  119444. /**
  119445. * An event triggered when a texture is removed
  119446. */
  119447. onTextureRemovedObservable: Observable<BaseTexture>;
  119448. /**
  119449. * An event triggered when render targets are about to be rendered
  119450. * Can happen multiple times per frame.
  119451. */
  119452. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  119453. /**
  119454. * An event triggered when render targets were rendered.
  119455. * Can happen multiple times per frame.
  119456. */
  119457. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  119458. /**
  119459. * An event triggered before calculating deterministic simulation step
  119460. */
  119461. onBeforeStepObservable: Observable<Scene>;
  119462. /**
  119463. * An event triggered after calculating deterministic simulation step
  119464. */
  119465. onAfterStepObservable: Observable<Scene>;
  119466. /**
  119467. * An event triggered when the activeCamera property is updated
  119468. */
  119469. onActiveCameraChanged: Observable<Scene>;
  119470. /**
  119471. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  119472. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119473. * 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)
  119474. */
  119475. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119476. /**
  119477. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  119478. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119479. * 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)
  119480. */
  119481. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119482. /**
  119483. * This Observable will when a mesh has been imported into the scene.
  119484. */
  119485. onMeshImportedObservable: Observable<AbstractMesh>;
  119486. /**
  119487. * This Observable will when an animation file has been imported into the scene.
  119488. */
  119489. onAnimationFileImportedObservable: Observable<Scene>;
  119490. /**
  119491. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  119492. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  119493. */
  119494. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  119495. /** @hidden */
  119496. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  119497. /**
  119498. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  119499. */
  119500. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  119501. /**
  119502. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  119503. */
  119504. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  119505. /**
  119506. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  119507. */
  119508. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  119509. /** Callback called when a pointer move is detected */
  119510. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119511. /** Callback called when a pointer down is detected */
  119512. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119513. /** Callback called when a pointer up is detected */
  119514. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  119515. /** Callback called when a pointer pick is detected */
  119516. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  119517. /**
  119518. * 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).
  119519. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  119520. */
  119521. onPrePointerObservable: Observable<PointerInfoPre>;
  119522. /**
  119523. * Observable event triggered each time an input event is received from the rendering canvas
  119524. */
  119525. onPointerObservable: Observable<PointerInfo>;
  119526. /**
  119527. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  119528. */
  119529. get unTranslatedPointer(): Vector2;
  119530. /**
  119531. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  119532. */
  119533. static get DragMovementThreshold(): number;
  119534. static set DragMovementThreshold(value: number);
  119535. /**
  119536. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  119537. */
  119538. static get LongPressDelay(): number;
  119539. static set LongPressDelay(value: number);
  119540. /**
  119541. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  119542. */
  119543. static get DoubleClickDelay(): number;
  119544. static set DoubleClickDelay(value: number);
  119545. /** If you need to check double click without raising a single click at first click, enable this flag */
  119546. static get ExclusiveDoubleClickMode(): boolean;
  119547. static set ExclusiveDoubleClickMode(value: boolean);
  119548. /** @hidden */
  119549. _mirroredCameraPosition: Nullable<Vector3>;
  119550. /**
  119551. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  119552. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  119553. */
  119554. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  119555. /**
  119556. * Observable event triggered each time an keyboard event is received from the hosting window
  119557. */
  119558. onKeyboardObservable: Observable<KeyboardInfo>;
  119559. private _useRightHandedSystem;
  119560. /**
  119561. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  119562. */
  119563. set useRightHandedSystem(value: boolean);
  119564. get useRightHandedSystem(): boolean;
  119565. private _timeAccumulator;
  119566. private _currentStepId;
  119567. private _currentInternalStep;
  119568. /**
  119569. * Sets the step Id used by deterministic lock step
  119570. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119571. * @param newStepId defines the step Id
  119572. */
  119573. setStepId(newStepId: number): void;
  119574. /**
  119575. * Gets the step Id used by deterministic lock step
  119576. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119577. * @returns the step Id
  119578. */
  119579. getStepId(): number;
  119580. /**
  119581. * Gets the internal step used by deterministic lock step
  119582. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119583. * @returns the internal step
  119584. */
  119585. getInternalStep(): number;
  119586. private _fogEnabled;
  119587. /**
  119588. * Gets or sets a boolean indicating if fog is enabled on this scene
  119589. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119590. * (Default is true)
  119591. */
  119592. set fogEnabled(value: boolean);
  119593. get fogEnabled(): boolean;
  119594. private _fogMode;
  119595. /**
  119596. * Gets or sets the fog mode to use
  119597. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119598. * | mode | value |
  119599. * | --- | --- |
  119600. * | FOGMODE_NONE | 0 |
  119601. * | FOGMODE_EXP | 1 |
  119602. * | FOGMODE_EXP2 | 2 |
  119603. * | FOGMODE_LINEAR | 3 |
  119604. */
  119605. set fogMode(value: number);
  119606. get fogMode(): number;
  119607. /**
  119608. * Gets or sets the fog color to use
  119609. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119610. * (Default is Color3(0.2, 0.2, 0.3))
  119611. */
  119612. fogColor: Color3;
  119613. /**
  119614. * Gets or sets the fog density to use
  119615. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119616. * (Default is 0.1)
  119617. */
  119618. fogDensity: number;
  119619. /**
  119620. * Gets or sets the fog start distance to use
  119621. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119622. * (Default is 0)
  119623. */
  119624. fogStart: number;
  119625. /**
  119626. * Gets or sets the fog end distance to use
  119627. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119628. * (Default is 1000)
  119629. */
  119630. fogEnd: number;
  119631. /**
  119632. * Flag indicating that the frame buffer binding is handled by another component
  119633. */
  119634. prePass: boolean;
  119635. private _shadowsEnabled;
  119636. /**
  119637. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119638. */
  119639. set shadowsEnabled(value: boolean);
  119640. get shadowsEnabled(): boolean;
  119641. private _lightsEnabled;
  119642. /**
  119643. * Gets or sets a boolean indicating if lights are enabled on this scene
  119644. */
  119645. set lightsEnabled(value: boolean);
  119646. get lightsEnabled(): boolean;
  119647. /** All of the active cameras added to this scene. */
  119648. activeCameras: Camera[];
  119649. /** @hidden */
  119650. _activeCamera: Nullable<Camera>;
  119651. /** Gets or sets the current active camera */
  119652. get activeCamera(): Nullable<Camera>;
  119653. set activeCamera(value: Nullable<Camera>);
  119654. private _defaultMaterial;
  119655. /** The default material used on meshes when no material is affected */
  119656. get defaultMaterial(): Material;
  119657. /** The default material used on meshes when no material is affected */
  119658. set defaultMaterial(value: Material);
  119659. private _texturesEnabled;
  119660. /**
  119661. * Gets or sets a boolean indicating if textures are enabled on this scene
  119662. */
  119663. set texturesEnabled(value: boolean);
  119664. get texturesEnabled(): boolean;
  119665. /**
  119666. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119667. */
  119668. physicsEnabled: boolean;
  119669. /**
  119670. * Gets or sets a boolean indicating if particles are enabled on this scene
  119671. */
  119672. particlesEnabled: boolean;
  119673. /**
  119674. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119675. */
  119676. spritesEnabled: boolean;
  119677. private _skeletonsEnabled;
  119678. /**
  119679. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119680. */
  119681. set skeletonsEnabled(value: boolean);
  119682. get skeletonsEnabled(): boolean;
  119683. /**
  119684. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119685. */
  119686. lensFlaresEnabled: boolean;
  119687. /**
  119688. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119689. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119690. */
  119691. collisionsEnabled: boolean;
  119692. private _collisionCoordinator;
  119693. /** @hidden */
  119694. get collisionCoordinator(): ICollisionCoordinator;
  119695. /**
  119696. * Defines the gravity applied to this scene (used only for collisions)
  119697. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119698. */
  119699. gravity: Vector3;
  119700. /**
  119701. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119702. */
  119703. postProcessesEnabled: boolean;
  119704. /**
  119705. * Gets the current postprocess manager
  119706. */
  119707. postProcessManager: PostProcessManager;
  119708. /**
  119709. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119710. */
  119711. renderTargetsEnabled: boolean;
  119712. /**
  119713. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119714. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  119715. */
  119716. dumpNextRenderTargets: boolean;
  119717. /**
  119718. * The list of user defined render targets added to the scene
  119719. */
  119720. customRenderTargets: RenderTargetTexture[];
  119721. /**
  119722. * Defines if texture loading must be delayed
  119723. * If true, textures will only be loaded when they need to be rendered
  119724. */
  119725. useDelayedTextureLoading: boolean;
  119726. /**
  119727. * Gets the list of meshes imported to the scene through SceneLoader
  119728. */
  119729. importedMeshesFiles: String[];
  119730. /**
  119731. * Gets or sets a boolean indicating if probes are enabled on this scene
  119732. */
  119733. probesEnabled: boolean;
  119734. /**
  119735. * Gets or sets the current offline provider to use to store scene data
  119736. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119737. */
  119738. offlineProvider: IOfflineProvider;
  119739. /**
  119740. * Gets or sets the action manager associated with the scene
  119741. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119742. */
  119743. actionManager: AbstractActionManager;
  119744. private _meshesForIntersections;
  119745. /**
  119746. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  119747. */
  119748. proceduralTexturesEnabled: boolean;
  119749. private _engine;
  119750. private _totalVertices;
  119751. /** @hidden */
  119752. _activeIndices: PerfCounter;
  119753. /** @hidden */
  119754. _activeParticles: PerfCounter;
  119755. /** @hidden */
  119756. _activeBones: PerfCounter;
  119757. private _animationRatio;
  119758. /** @hidden */
  119759. _animationTimeLast: number;
  119760. /** @hidden */
  119761. _animationTime: number;
  119762. /**
  119763. * Gets or sets a general scale for animation speed
  119764. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  119765. */
  119766. animationTimeScale: number;
  119767. /** @hidden */
  119768. _cachedMaterial: Nullable<Material>;
  119769. /** @hidden */
  119770. _cachedEffect: Nullable<Effect>;
  119771. /** @hidden */
  119772. _cachedVisibility: Nullable<number>;
  119773. private _renderId;
  119774. private _frameId;
  119775. private _executeWhenReadyTimeoutId;
  119776. private _intermediateRendering;
  119777. private _viewUpdateFlag;
  119778. private _projectionUpdateFlag;
  119779. /** @hidden */
  119780. _toBeDisposed: Nullable<IDisposable>[];
  119781. private _activeRequests;
  119782. /** @hidden */
  119783. _pendingData: any[];
  119784. private _isDisposed;
  119785. /**
  119786. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  119787. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  119788. */
  119789. dispatchAllSubMeshesOfActiveMeshes: boolean;
  119790. private _activeMeshes;
  119791. private _processedMaterials;
  119792. private _renderTargets;
  119793. /** @hidden */
  119794. _activeParticleSystems: SmartArray<IParticleSystem>;
  119795. private _activeSkeletons;
  119796. private _softwareSkinnedMeshes;
  119797. private _renderingManager;
  119798. /** @hidden */
  119799. _activeAnimatables: Animatable[];
  119800. private _transformMatrix;
  119801. private _sceneUbo;
  119802. /** @hidden */
  119803. _viewMatrix: Matrix;
  119804. private _projectionMatrix;
  119805. /** @hidden */
  119806. _forcedViewPosition: Nullable<Vector3>;
  119807. /** @hidden */
  119808. _frustumPlanes: Plane[];
  119809. /**
  119810. * Gets the list of frustum planes (built from the active camera)
  119811. */
  119812. get frustumPlanes(): Plane[];
  119813. /**
  119814. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  119815. * This is useful if there are more lights that the maximum simulteanous authorized
  119816. */
  119817. requireLightSorting: boolean;
  119818. /** @hidden */
  119819. readonly useMaterialMeshMap: boolean;
  119820. /** @hidden */
  119821. readonly useClonedMeshMap: boolean;
  119822. private _externalData;
  119823. private _uid;
  119824. /**
  119825. * @hidden
  119826. * Backing store of defined scene components.
  119827. */
  119828. _components: ISceneComponent[];
  119829. /**
  119830. * @hidden
  119831. * Backing store of defined scene components.
  119832. */
  119833. _serializableComponents: ISceneSerializableComponent[];
  119834. /**
  119835. * List of components to register on the next registration step.
  119836. */
  119837. private _transientComponents;
  119838. /**
  119839. * Registers the transient components if needed.
  119840. */
  119841. private _registerTransientComponents;
  119842. /**
  119843. * @hidden
  119844. * Add a component to the scene.
  119845. * Note that the ccomponent could be registered on th next frame if this is called after
  119846. * the register component stage.
  119847. * @param component Defines the component to add to the scene
  119848. */
  119849. _addComponent(component: ISceneComponent): void;
  119850. /**
  119851. * @hidden
  119852. * Gets a component from the scene.
  119853. * @param name defines the name of the component to retrieve
  119854. * @returns the component or null if not present
  119855. */
  119856. _getComponent(name: string): Nullable<ISceneComponent>;
  119857. /**
  119858. * @hidden
  119859. * Defines the actions happening before camera updates.
  119860. */
  119861. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  119862. /**
  119863. * @hidden
  119864. * Defines the actions happening before clear the canvas.
  119865. */
  119866. _beforeClearStage: Stage<SimpleStageAction>;
  119867. /**
  119868. * @hidden
  119869. * Defines the actions when collecting render targets for the frame.
  119870. */
  119871. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119872. /**
  119873. * @hidden
  119874. * Defines the actions happening for one camera in the frame.
  119875. */
  119876. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119877. /**
  119878. * @hidden
  119879. * Defines the actions happening during the per mesh ready checks.
  119880. */
  119881. _isReadyForMeshStage: Stage<MeshStageAction>;
  119882. /**
  119883. * @hidden
  119884. * Defines the actions happening before evaluate active mesh checks.
  119885. */
  119886. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  119887. /**
  119888. * @hidden
  119889. * Defines the actions happening during the evaluate sub mesh checks.
  119890. */
  119891. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  119892. /**
  119893. * @hidden
  119894. * Defines the actions happening during the active mesh stage.
  119895. */
  119896. _activeMeshStage: Stage<ActiveMeshStageAction>;
  119897. /**
  119898. * @hidden
  119899. * Defines the actions happening during the per camera render target step.
  119900. */
  119901. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  119902. /**
  119903. * @hidden
  119904. * Defines the actions happening just before the active camera is drawing.
  119905. */
  119906. _beforeCameraDrawStage: Stage<CameraStageAction>;
  119907. /**
  119908. * @hidden
  119909. * Defines the actions happening just before a render target is drawing.
  119910. */
  119911. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119912. /**
  119913. * @hidden
  119914. * Defines the actions happening just before a rendering group is drawing.
  119915. */
  119916. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119917. /**
  119918. * @hidden
  119919. * Defines the actions happening just before a mesh is drawing.
  119920. */
  119921. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119922. /**
  119923. * @hidden
  119924. * Defines the actions happening just after a mesh has been drawn.
  119925. */
  119926. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119927. /**
  119928. * @hidden
  119929. * Defines the actions happening just after a rendering group has been drawn.
  119930. */
  119931. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119932. /**
  119933. * @hidden
  119934. * Defines the actions happening just after the active camera has been drawn.
  119935. */
  119936. _afterCameraDrawStage: Stage<CameraStageAction>;
  119937. /**
  119938. * @hidden
  119939. * Defines the actions happening just after a render target has been drawn.
  119940. */
  119941. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119942. /**
  119943. * @hidden
  119944. * Defines the actions happening just after rendering all cameras and computing intersections.
  119945. */
  119946. _afterRenderStage: Stage<SimpleStageAction>;
  119947. /**
  119948. * @hidden
  119949. * Defines the actions happening when a pointer move event happens.
  119950. */
  119951. _pointerMoveStage: Stage<PointerMoveStageAction>;
  119952. /**
  119953. * @hidden
  119954. * Defines the actions happening when a pointer down event happens.
  119955. */
  119956. _pointerDownStage: Stage<PointerUpDownStageAction>;
  119957. /**
  119958. * @hidden
  119959. * Defines the actions happening when a pointer up event happens.
  119960. */
  119961. _pointerUpStage: Stage<PointerUpDownStageAction>;
  119962. /**
  119963. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  119964. */
  119965. private geometriesByUniqueId;
  119966. /**
  119967. * Creates a new Scene
  119968. * @param engine defines the engine to use to render this scene
  119969. * @param options defines the scene options
  119970. */
  119971. constructor(engine: Engine, options?: SceneOptions);
  119972. /**
  119973. * Gets a string identifying the name of the class
  119974. * @returns "Scene" string
  119975. */
  119976. getClassName(): string;
  119977. private _defaultMeshCandidates;
  119978. /**
  119979. * @hidden
  119980. */
  119981. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119982. private _defaultSubMeshCandidates;
  119983. /**
  119984. * @hidden
  119985. */
  119986. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119987. /**
  119988. * Sets the default candidate providers for the scene.
  119989. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  119990. * and getCollidingSubMeshCandidates to their default function
  119991. */
  119992. setDefaultCandidateProviders(): void;
  119993. /**
  119994. * Gets the mesh that is currently under the pointer
  119995. */
  119996. get meshUnderPointer(): Nullable<AbstractMesh>;
  119997. /**
  119998. * Gets or sets the current on-screen X position of the pointer
  119999. */
  120000. get pointerX(): number;
  120001. set pointerX(value: number);
  120002. /**
  120003. * Gets or sets the current on-screen Y position of the pointer
  120004. */
  120005. get pointerY(): number;
  120006. set pointerY(value: number);
  120007. /**
  120008. * Gets the cached material (ie. the latest rendered one)
  120009. * @returns the cached material
  120010. */
  120011. getCachedMaterial(): Nullable<Material>;
  120012. /**
  120013. * Gets the cached effect (ie. the latest rendered one)
  120014. * @returns the cached effect
  120015. */
  120016. getCachedEffect(): Nullable<Effect>;
  120017. /**
  120018. * Gets the cached visibility state (ie. the latest rendered one)
  120019. * @returns the cached visibility state
  120020. */
  120021. getCachedVisibility(): Nullable<number>;
  120022. /**
  120023. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120024. * @param material defines the current material
  120025. * @param effect defines the current effect
  120026. * @param visibility defines the current visibility state
  120027. * @returns true if one parameter is not cached
  120028. */
  120029. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120030. /**
  120031. * Gets the engine associated with the scene
  120032. * @returns an Engine
  120033. */
  120034. getEngine(): Engine;
  120035. /**
  120036. * Gets the total number of vertices rendered per frame
  120037. * @returns the total number of vertices rendered per frame
  120038. */
  120039. getTotalVertices(): number;
  120040. /**
  120041. * Gets the performance counter for total vertices
  120042. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120043. */
  120044. get totalVerticesPerfCounter(): PerfCounter;
  120045. /**
  120046. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120047. * @returns the total number of active indices rendered per frame
  120048. */
  120049. getActiveIndices(): number;
  120050. /**
  120051. * Gets the performance counter for active indices
  120052. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120053. */
  120054. get totalActiveIndicesPerfCounter(): PerfCounter;
  120055. /**
  120056. * Gets the total number of active particles rendered per frame
  120057. * @returns the total number of active particles rendered per frame
  120058. */
  120059. getActiveParticles(): number;
  120060. /**
  120061. * Gets the performance counter for active particles
  120062. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120063. */
  120064. get activeParticlesPerfCounter(): PerfCounter;
  120065. /**
  120066. * Gets the total number of active bones rendered per frame
  120067. * @returns the total number of active bones rendered per frame
  120068. */
  120069. getActiveBones(): number;
  120070. /**
  120071. * Gets the performance counter for active bones
  120072. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120073. */
  120074. get activeBonesPerfCounter(): PerfCounter;
  120075. /**
  120076. * Gets the array of active meshes
  120077. * @returns an array of AbstractMesh
  120078. */
  120079. getActiveMeshes(): SmartArray<AbstractMesh>;
  120080. /**
  120081. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120082. * @returns a number
  120083. */
  120084. getAnimationRatio(): number;
  120085. /**
  120086. * Gets an unique Id for the current render phase
  120087. * @returns a number
  120088. */
  120089. getRenderId(): number;
  120090. /**
  120091. * Gets an unique Id for the current frame
  120092. * @returns a number
  120093. */
  120094. getFrameId(): number;
  120095. /** Call this function if you want to manually increment the render Id*/
  120096. incrementRenderId(): void;
  120097. private _createUbo;
  120098. /**
  120099. * Use this method to simulate a pointer move on a mesh
  120100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120103. * @returns the current scene
  120104. */
  120105. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120106. /**
  120107. * Use this method to simulate a pointer down on a mesh
  120108. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120109. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120110. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120111. * @returns the current scene
  120112. */
  120113. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120114. /**
  120115. * Use this method to simulate a pointer up on a mesh
  120116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120119. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120120. * @returns the current scene
  120121. */
  120122. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120123. /**
  120124. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120125. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120126. * @returns true if the pointer was captured
  120127. */
  120128. isPointerCaptured(pointerId?: number): boolean;
  120129. /**
  120130. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120131. * @param attachUp defines if you want to attach events to pointerup
  120132. * @param attachDown defines if you want to attach events to pointerdown
  120133. * @param attachMove defines if you want to attach events to pointermove
  120134. */
  120135. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120136. /** Detaches all event handlers*/
  120137. detachControl(): void;
  120138. /**
  120139. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120140. * Delay loaded resources are not taking in account
  120141. * @return true if all required resources are ready
  120142. */
  120143. isReady(): boolean;
  120144. /** Resets all cached information relative to material (including effect and visibility) */
  120145. resetCachedMaterial(): void;
  120146. /**
  120147. * Registers a function to be called before every frame render
  120148. * @param func defines the function to register
  120149. */
  120150. registerBeforeRender(func: () => void): void;
  120151. /**
  120152. * Unregisters a function called before every frame render
  120153. * @param func defines the function to unregister
  120154. */
  120155. unregisterBeforeRender(func: () => void): void;
  120156. /**
  120157. * Registers a function to be called after every frame render
  120158. * @param func defines the function to register
  120159. */
  120160. registerAfterRender(func: () => void): void;
  120161. /**
  120162. * Unregisters a function called after every frame render
  120163. * @param func defines the function to unregister
  120164. */
  120165. unregisterAfterRender(func: () => void): void;
  120166. private _executeOnceBeforeRender;
  120167. /**
  120168. * The provided function will run before render once and will be disposed afterwards.
  120169. * A timeout delay can be provided so that the function will be executed in N ms.
  120170. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120171. * @param func The function to be executed.
  120172. * @param timeout optional delay in ms
  120173. */
  120174. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120175. /** @hidden */
  120176. _addPendingData(data: any): void;
  120177. /** @hidden */
  120178. _removePendingData(data: any): void;
  120179. /**
  120180. * Returns the number of items waiting to be loaded
  120181. * @returns the number of items waiting to be loaded
  120182. */
  120183. getWaitingItemsCount(): number;
  120184. /**
  120185. * Returns a boolean indicating if the scene is still loading data
  120186. */
  120187. get isLoading(): boolean;
  120188. /**
  120189. * Registers a function to be executed when the scene is ready
  120190. * @param {Function} func - the function to be executed
  120191. */
  120192. executeWhenReady(func: () => void): void;
  120193. /**
  120194. * Returns a promise that resolves when the scene is ready
  120195. * @returns A promise that resolves when the scene is ready
  120196. */
  120197. whenReadyAsync(): Promise<void>;
  120198. /** @hidden */
  120199. _checkIsReady(): void;
  120200. /**
  120201. * Gets all animatable attached to the scene
  120202. */
  120203. get animatables(): Animatable[];
  120204. /**
  120205. * Resets the last animation time frame.
  120206. * Useful to override when animations start running when loading a scene for the first time.
  120207. */
  120208. resetLastAnimationTimeFrame(): void;
  120209. /**
  120210. * Gets the current view matrix
  120211. * @returns a Matrix
  120212. */
  120213. getViewMatrix(): Matrix;
  120214. /**
  120215. * Gets the current projection matrix
  120216. * @returns a Matrix
  120217. */
  120218. getProjectionMatrix(): Matrix;
  120219. /**
  120220. * Gets the current transform matrix
  120221. * @returns a Matrix made of View * Projection
  120222. */
  120223. getTransformMatrix(): Matrix;
  120224. /**
  120225. * Sets the current transform matrix
  120226. * @param viewL defines the View matrix to use
  120227. * @param projectionL defines the Projection matrix to use
  120228. * @param viewR defines the right View matrix to use (if provided)
  120229. * @param projectionR defines the right Projection matrix to use (if provided)
  120230. */
  120231. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120232. /**
  120233. * Gets the uniform buffer used to store scene data
  120234. * @returns a UniformBuffer
  120235. */
  120236. getSceneUniformBuffer(): UniformBuffer;
  120237. /**
  120238. * Gets an unique (relatively to the current scene) Id
  120239. * @returns an unique number for the scene
  120240. */
  120241. getUniqueId(): number;
  120242. /**
  120243. * Add a mesh to the list of scene's meshes
  120244. * @param newMesh defines the mesh to add
  120245. * @param recursive if all child meshes should also be added to the scene
  120246. */
  120247. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120248. /**
  120249. * Remove a mesh for the list of scene's meshes
  120250. * @param toRemove defines the mesh to remove
  120251. * @param recursive if all child meshes should also be removed from the scene
  120252. * @returns the index where the mesh was in the mesh list
  120253. */
  120254. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120255. /**
  120256. * Add a transform node to the list of scene's transform nodes
  120257. * @param newTransformNode defines the transform node to add
  120258. */
  120259. addTransformNode(newTransformNode: TransformNode): void;
  120260. /**
  120261. * Remove a transform node for the list of scene's transform nodes
  120262. * @param toRemove defines the transform node to remove
  120263. * @returns the index where the transform node was in the transform node list
  120264. */
  120265. removeTransformNode(toRemove: TransformNode): number;
  120266. /**
  120267. * Remove a skeleton for the list of scene's skeletons
  120268. * @param toRemove defines the skeleton to remove
  120269. * @returns the index where the skeleton was in the skeleton list
  120270. */
  120271. removeSkeleton(toRemove: Skeleton): number;
  120272. /**
  120273. * Remove a morph target for the list of scene's morph targets
  120274. * @param toRemove defines the morph target to remove
  120275. * @returns the index where the morph target was in the morph target list
  120276. */
  120277. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120278. /**
  120279. * Remove a light for the list of scene's lights
  120280. * @param toRemove defines the light to remove
  120281. * @returns the index where the light was in the light list
  120282. */
  120283. removeLight(toRemove: Light): number;
  120284. /**
  120285. * Remove a camera for the list of scene's cameras
  120286. * @param toRemove defines the camera to remove
  120287. * @returns the index where the camera was in the camera list
  120288. */
  120289. removeCamera(toRemove: Camera): number;
  120290. /**
  120291. * Remove a particle system for the list of scene's particle systems
  120292. * @param toRemove defines the particle system to remove
  120293. * @returns the index where the particle system was in the particle system list
  120294. */
  120295. removeParticleSystem(toRemove: IParticleSystem): number;
  120296. /**
  120297. * Remove a animation for the list of scene's animations
  120298. * @param toRemove defines the animation to remove
  120299. * @returns the index where the animation was in the animation list
  120300. */
  120301. removeAnimation(toRemove: Animation): number;
  120302. /**
  120303. * Will stop the animation of the given target
  120304. * @param target - the target
  120305. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120306. * @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)
  120307. */
  120308. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120309. /**
  120310. * Removes the given animation group from this scene.
  120311. * @param toRemove The animation group to remove
  120312. * @returns The index of the removed animation group
  120313. */
  120314. removeAnimationGroup(toRemove: AnimationGroup): number;
  120315. /**
  120316. * Removes the given multi-material from this scene.
  120317. * @param toRemove The multi-material to remove
  120318. * @returns The index of the removed multi-material
  120319. */
  120320. removeMultiMaterial(toRemove: MultiMaterial): number;
  120321. /**
  120322. * Removes the given material from this scene.
  120323. * @param toRemove The material to remove
  120324. * @returns The index of the removed material
  120325. */
  120326. removeMaterial(toRemove: Material): number;
  120327. /**
  120328. * Removes the given action manager from this scene.
  120329. * @param toRemove The action manager to remove
  120330. * @returns The index of the removed action manager
  120331. */
  120332. removeActionManager(toRemove: AbstractActionManager): number;
  120333. /**
  120334. * Removes the given texture from this scene.
  120335. * @param toRemove The texture to remove
  120336. * @returns The index of the removed texture
  120337. */
  120338. removeTexture(toRemove: BaseTexture): number;
  120339. /**
  120340. * Adds the given light to this scene
  120341. * @param newLight The light to add
  120342. */
  120343. addLight(newLight: Light): void;
  120344. /**
  120345. * Sorts the list list based on light priorities
  120346. */
  120347. sortLightsByPriority(): void;
  120348. /**
  120349. * Adds the given camera to this scene
  120350. * @param newCamera The camera to add
  120351. */
  120352. addCamera(newCamera: Camera): void;
  120353. /**
  120354. * Adds the given skeleton to this scene
  120355. * @param newSkeleton The skeleton to add
  120356. */
  120357. addSkeleton(newSkeleton: Skeleton): void;
  120358. /**
  120359. * Adds the given particle system to this scene
  120360. * @param newParticleSystem The particle system to add
  120361. */
  120362. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120363. /**
  120364. * Adds the given animation to this scene
  120365. * @param newAnimation The animation to add
  120366. */
  120367. addAnimation(newAnimation: Animation): void;
  120368. /**
  120369. * Adds the given animation group to this scene.
  120370. * @param newAnimationGroup The animation group to add
  120371. */
  120372. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120373. /**
  120374. * Adds the given multi-material to this scene
  120375. * @param newMultiMaterial The multi-material to add
  120376. */
  120377. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120378. /**
  120379. * Adds the given material to this scene
  120380. * @param newMaterial The material to add
  120381. */
  120382. addMaterial(newMaterial: Material): void;
  120383. /**
  120384. * Adds the given morph target to this scene
  120385. * @param newMorphTargetManager The morph target to add
  120386. */
  120387. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120388. /**
  120389. * Adds the given geometry to this scene
  120390. * @param newGeometry The geometry to add
  120391. */
  120392. addGeometry(newGeometry: Geometry): void;
  120393. /**
  120394. * Adds the given action manager to this scene
  120395. * @param newActionManager The action manager to add
  120396. */
  120397. addActionManager(newActionManager: AbstractActionManager): void;
  120398. /**
  120399. * Adds the given texture to this scene.
  120400. * @param newTexture The texture to add
  120401. */
  120402. addTexture(newTexture: BaseTexture): void;
  120403. /**
  120404. * Switch active camera
  120405. * @param newCamera defines the new active camera
  120406. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120407. */
  120408. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120409. /**
  120410. * sets the active camera of the scene using its ID
  120411. * @param id defines the camera's ID
  120412. * @return the new active camera or null if none found.
  120413. */
  120414. setActiveCameraByID(id: string): Nullable<Camera>;
  120415. /**
  120416. * sets the active camera of the scene using its name
  120417. * @param name defines the camera's name
  120418. * @returns the new active camera or null if none found.
  120419. */
  120420. setActiveCameraByName(name: string): Nullable<Camera>;
  120421. /**
  120422. * get an animation group using its name
  120423. * @param name defines the material's name
  120424. * @return the animation group or null if none found.
  120425. */
  120426. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  120427. /**
  120428. * Get a material using its unique id
  120429. * @param uniqueId defines the material's unique id
  120430. * @return the material or null if none found.
  120431. */
  120432. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  120433. /**
  120434. * get a material using its id
  120435. * @param id defines the material's ID
  120436. * @return the material or null if none found.
  120437. */
  120438. getMaterialByID(id: string): Nullable<Material>;
  120439. /**
  120440. * Gets a the last added material using a given id
  120441. * @param id defines the material's ID
  120442. * @return the last material with the given id or null if none found.
  120443. */
  120444. getLastMaterialByID(id: string): Nullable<Material>;
  120445. /**
  120446. * Gets a material using its name
  120447. * @param name defines the material's name
  120448. * @return the material or null if none found.
  120449. */
  120450. getMaterialByName(name: string): Nullable<Material>;
  120451. /**
  120452. * Get a texture using its unique id
  120453. * @param uniqueId defines the texture's unique id
  120454. * @return the texture or null if none found.
  120455. */
  120456. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  120457. /**
  120458. * Gets a camera using its id
  120459. * @param id defines the id to look for
  120460. * @returns the camera or null if not found
  120461. */
  120462. getCameraByID(id: string): Nullable<Camera>;
  120463. /**
  120464. * Gets a camera using its unique id
  120465. * @param uniqueId defines the unique id to look for
  120466. * @returns the camera or null if not found
  120467. */
  120468. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  120469. /**
  120470. * Gets a camera using its name
  120471. * @param name defines the camera's name
  120472. * @return the camera or null if none found.
  120473. */
  120474. getCameraByName(name: string): Nullable<Camera>;
  120475. /**
  120476. * Gets a bone using its id
  120477. * @param id defines the bone's id
  120478. * @return the bone or null if not found
  120479. */
  120480. getBoneByID(id: string): Nullable<Bone>;
  120481. /**
  120482. * Gets a bone using its id
  120483. * @param name defines the bone's name
  120484. * @return the bone or null if not found
  120485. */
  120486. getBoneByName(name: string): Nullable<Bone>;
  120487. /**
  120488. * Gets a light node using its name
  120489. * @param name defines the the light's name
  120490. * @return the light or null if none found.
  120491. */
  120492. getLightByName(name: string): Nullable<Light>;
  120493. /**
  120494. * Gets a light node using its id
  120495. * @param id defines the light's id
  120496. * @return the light or null if none found.
  120497. */
  120498. getLightByID(id: string): Nullable<Light>;
  120499. /**
  120500. * Gets a light node using its scene-generated unique ID
  120501. * @param uniqueId defines the light's unique id
  120502. * @return the light or null if none found.
  120503. */
  120504. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  120505. /**
  120506. * Gets a particle system by id
  120507. * @param id defines the particle system id
  120508. * @return the corresponding system or null if none found
  120509. */
  120510. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  120511. /**
  120512. * Gets a geometry using its ID
  120513. * @param id defines the geometry's id
  120514. * @return the geometry or null if none found.
  120515. */
  120516. getGeometryByID(id: string): Nullable<Geometry>;
  120517. private _getGeometryByUniqueID;
  120518. /**
  120519. * Add a new geometry to this scene
  120520. * @param geometry defines the geometry to be added to the scene.
  120521. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  120522. * @return a boolean defining if the geometry was added or not
  120523. */
  120524. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  120525. /**
  120526. * Removes an existing geometry
  120527. * @param geometry defines the geometry to be removed from the scene
  120528. * @return a boolean defining if the geometry was removed or not
  120529. */
  120530. removeGeometry(geometry: Geometry): boolean;
  120531. /**
  120532. * Gets the list of geometries attached to the scene
  120533. * @returns an array of Geometry
  120534. */
  120535. getGeometries(): Geometry[];
  120536. /**
  120537. * Gets the first added mesh found of a given ID
  120538. * @param id defines the id to search for
  120539. * @return the mesh found or null if not found at all
  120540. */
  120541. getMeshByID(id: string): Nullable<AbstractMesh>;
  120542. /**
  120543. * Gets a list of meshes using their id
  120544. * @param id defines the id to search for
  120545. * @returns a list of meshes
  120546. */
  120547. getMeshesByID(id: string): Array<AbstractMesh>;
  120548. /**
  120549. * Gets the first added transform node found of a given ID
  120550. * @param id defines the id to search for
  120551. * @return the found transform node or null if not found at all.
  120552. */
  120553. getTransformNodeByID(id: string): Nullable<TransformNode>;
  120554. /**
  120555. * Gets a transform node with its auto-generated unique id
  120556. * @param uniqueId efines the unique id to search for
  120557. * @return the found transform node or null if not found at all.
  120558. */
  120559. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  120560. /**
  120561. * Gets a list of transform nodes using their id
  120562. * @param id defines the id to search for
  120563. * @returns a list of transform nodes
  120564. */
  120565. getTransformNodesByID(id: string): Array<TransformNode>;
  120566. /**
  120567. * Gets a mesh with its auto-generated unique id
  120568. * @param uniqueId defines the unique id to search for
  120569. * @return the found mesh or null if not found at all.
  120570. */
  120571. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120572. /**
  120573. * Gets a the last added mesh using a given id
  120574. * @param id defines the id to search for
  120575. * @return the found mesh or null if not found at all.
  120576. */
  120577. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120578. /**
  120579. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120580. * @param id defines the id to search for
  120581. * @return the found node or null if not found at all
  120582. */
  120583. getLastEntryByID(id: string): Nullable<Node>;
  120584. /**
  120585. * Gets a node (Mesh, Camera, Light) using a given id
  120586. * @param id defines the id to search for
  120587. * @return the found node or null if not found at all
  120588. */
  120589. getNodeByID(id: string): Nullable<Node>;
  120590. /**
  120591. * Gets a node (Mesh, Camera, Light) using a given name
  120592. * @param name defines the name to search for
  120593. * @return the found node or null if not found at all.
  120594. */
  120595. getNodeByName(name: string): Nullable<Node>;
  120596. /**
  120597. * Gets a mesh using a given name
  120598. * @param name defines the name to search for
  120599. * @return the found mesh or null if not found at all.
  120600. */
  120601. getMeshByName(name: string): Nullable<AbstractMesh>;
  120602. /**
  120603. * Gets a transform node using a given name
  120604. * @param name defines the name to search for
  120605. * @return the found transform node or null if not found at all.
  120606. */
  120607. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120608. /**
  120609. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120610. * @param id defines the id to search for
  120611. * @return the found skeleton or null if not found at all.
  120612. */
  120613. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120614. /**
  120615. * Gets a skeleton using a given auto generated unique id
  120616. * @param uniqueId defines the unique id to search for
  120617. * @return the found skeleton or null if not found at all.
  120618. */
  120619. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120620. /**
  120621. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120622. * @param id defines the id to search for
  120623. * @return the found skeleton or null if not found at all.
  120624. */
  120625. getSkeletonById(id: string): Nullable<Skeleton>;
  120626. /**
  120627. * Gets a skeleton using a given name
  120628. * @param name defines the name to search for
  120629. * @return the found skeleton or null if not found at all.
  120630. */
  120631. getSkeletonByName(name: string): Nullable<Skeleton>;
  120632. /**
  120633. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120634. * @param id defines the id to search for
  120635. * @return the found morph target manager or null if not found at all.
  120636. */
  120637. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120638. /**
  120639. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120640. * @param id defines the id to search for
  120641. * @return the found morph target or null if not found at all.
  120642. */
  120643. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120644. /**
  120645. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120646. * @param name defines the name to search for
  120647. * @return the found morph target or null if not found at all.
  120648. */
  120649. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120650. /**
  120651. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120652. * @param name defines the name to search for
  120653. * @return the found post process or null if not found at all.
  120654. */
  120655. getPostProcessByName(name: string): Nullable<PostProcess>;
  120656. /**
  120657. * Gets a boolean indicating if the given mesh is active
  120658. * @param mesh defines the mesh to look for
  120659. * @returns true if the mesh is in the active list
  120660. */
  120661. isActiveMesh(mesh: AbstractMesh): boolean;
  120662. /**
  120663. * Return a unique id as a string which can serve as an identifier for the scene
  120664. */
  120665. get uid(): string;
  120666. /**
  120667. * Add an externaly attached data from its key.
  120668. * This method call will fail and return false, if such key already exists.
  120669. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120670. * @param key the unique key that identifies the data
  120671. * @param data the data object to associate to the key for this Engine instance
  120672. * @return true if no such key were already present and the data was added successfully, false otherwise
  120673. */
  120674. addExternalData<T>(key: string, data: T): boolean;
  120675. /**
  120676. * Get an externaly attached data from its key
  120677. * @param key the unique key that identifies the data
  120678. * @return the associated data, if present (can be null), or undefined if not present
  120679. */
  120680. getExternalData<T>(key: string): Nullable<T>;
  120681. /**
  120682. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120683. * @param key the unique key that identifies the data
  120684. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120685. * @return the associated data, can be null if the factory returned null.
  120686. */
  120687. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120688. /**
  120689. * Remove an externaly attached data from the Engine instance
  120690. * @param key the unique key that identifies the data
  120691. * @return true if the data was successfully removed, false if it doesn't exist
  120692. */
  120693. removeExternalData(key: string): boolean;
  120694. private _evaluateSubMesh;
  120695. /**
  120696. * Clear the processed materials smart array preventing retention point in material dispose.
  120697. */
  120698. freeProcessedMaterials(): void;
  120699. private _preventFreeActiveMeshesAndRenderingGroups;
  120700. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120701. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120702. * when disposing several meshes in a row or a hierarchy of meshes.
  120703. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120704. */
  120705. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120706. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120707. /**
  120708. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120709. */
  120710. freeActiveMeshes(): void;
  120711. /**
  120712. * Clear the info related to rendering groups preventing retention points during dispose.
  120713. */
  120714. freeRenderingGroups(): void;
  120715. /** @hidden */
  120716. _isInIntermediateRendering(): boolean;
  120717. /**
  120718. * Lambda returning the list of potentially active meshes.
  120719. */
  120720. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  120721. /**
  120722. * Lambda returning the list of potentially active sub meshes.
  120723. */
  120724. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  120725. /**
  120726. * Lambda returning the list of potentially intersecting sub meshes.
  120727. */
  120728. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  120729. /**
  120730. * Lambda returning the list of potentially colliding sub meshes.
  120731. */
  120732. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  120733. private _activeMeshesFrozen;
  120734. private _skipEvaluateActiveMeshesCompletely;
  120735. /**
  120736. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  120737. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  120738. * @returns the current scene
  120739. */
  120740. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  120741. /**
  120742. * Use this function to restart evaluating active meshes on every frame
  120743. * @returns the current scene
  120744. */
  120745. unfreezeActiveMeshes(): Scene;
  120746. private _evaluateActiveMeshes;
  120747. private _activeMesh;
  120748. /**
  120749. * Update the transform matrix to update from the current active camera
  120750. * @param force defines a boolean used to force the update even if cache is up to date
  120751. */
  120752. updateTransformMatrix(force?: boolean): void;
  120753. private _bindFrameBuffer;
  120754. /** @hidden */
  120755. _allowPostProcessClearColor: boolean;
  120756. /** @hidden */
  120757. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  120758. private _processSubCameras;
  120759. private _checkIntersections;
  120760. /** @hidden */
  120761. _advancePhysicsEngineStep(step: number): void;
  120762. /**
  120763. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  120764. */
  120765. getDeterministicFrameTime: () => number;
  120766. /** @hidden */
  120767. _animate(): void;
  120768. /** Execute all animations (for a frame) */
  120769. animate(): void;
  120770. /**
  120771. * Render the scene
  120772. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  120773. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  120774. */
  120775. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  120776. /**
  120777. * Freeze all materials
  120778. * A frozen material will not be updatable but should be faster to render
  120779. */
  120780. freezeMaterials(): void;
  120781. /**
  120782. * Unfreeze all materials
  120783. * A frozen material will not be updatable but should be faster to render
  120784. */
  120785. unfreezeMaterials(): void;
  120786. /**
  120787. * Releases all held ressources
  120788. */
  120789. dispose(): void;
  120790. /**
  120791. * Gets if the scene is already disposed
  120792. */
  120793. get isDisposed(): boolean;
  120794. /**
  120795. * Call this function to reduce memory footprint of the scene.
  120796. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  120797. */
  120798. clearCachedVertexData(): void;
  120799. /**
  120800. * This function will remove the local cached buffer data from texture.
  120801. * It will save memory but will prevent the texture from being rebuilt
  120802. */
  120803. cleanCachedTextureBuffer(): void;
  120804. /**
  120805. * Get the world extend vectors with an optional filter
  120806. *
  120807. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  120808. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  120809. */
  120810. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  120811. min: Vector3;
  120812. max: Vector3;
  120813. };
  120814. /**
  120815. * Creates a ray that can be used to pick in the scene
  120816. * @param x defines the x coordinate of the origin (on-screen)
  120817. * @param y defines the y coordinate of the origin (on-screen)
  120818. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120819. * @param camera defines the camera to use for the picking
  120820. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120821. * @returns a Ray
  120822. */
  120823. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  120824. /**
  120825. * Creates a ray that can be used to pick in the scene
  120826. * @param x defines the x coordinate of the origin (on-screen)
  120827. * @param y defines the y coordinate of the origin (on-screen)
  120828. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120829. * @param result defines the ray where to store the picking ray
  120830. * @param camera defines the camera to use for the picking
  120831. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120832. * @returns the current scene
  120833. */
  120834. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  120835. /**
  120836. * Creates a ray that can be used to pick in the scene
  120837. * @param x defines the x coordinate of the origin (on-screen)
  120838. * @param y defines the y coordinate of the origin (on-screen)
  120839. * @param camera defines the camera to use for the picking
  120840. * @returns a Ray
  120841. */
  120842. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  120843. /**
  120844. * Creates a ray that can be used to pick in the scene
  120845. * @param x defines the x coordinate of the origin (on-screen)
  120846. * @param y defines the y coordinate of the origin (on-screen)
  120847. * @param result defines the ray where to store the picking ray
  120848. * @param camera defines the camera to use for the picking
  120849. * @returns the current scene
  120850. */
  120851. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  120852. /** Launch a ray to try to pick a mesh in the scene
  120853. * @param x position on screen
  120854. * @param y position on screen
  120855. * @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
  120856. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120857. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120858. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120859. * @returns a PickingInfo
  120860. */
  120861. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120862. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  120863. * @param x position on screen
  120864. * @param y position on screen
  120865. * @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
  120866. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120867. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120868. * @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)
  120869. */
  120870. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  120871. /** Use the given ray to pick a mesh in the scene
  120872. * @param ray The ray to use to pick meshes
  120873. * @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
  120874. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120875. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120876. * @returns a PickingInfo
  120877. */
  120878. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120879. /**
  120880. * Launch a ray to try to pick a mesh in the scene
  120881. * @param x X position on screen
  120882. * @param y Y position on screen
  120883. * @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
  120884. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120885. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120886. * @returns an array of PickingInfo
  120887. */
  120888. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120889. /**
  120890. * Launch a ray to try to pick a mesh in the scene
  120891. * @param ray Ray to use
  120892. * @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
  120893. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120894. * @returns an array of PickingInfo
  120895. */
  120896. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120897. /**
  120898. * Force the value of meshUnderPointer
  120899. * @param mesh defines the mesh to use
  120900. * @param pointerId optional pointer id when using more than one pointer
  120901. */
  120902. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  120903. /**
  120904. * Gets the mesh under the pointer
  120905. * @returns a Mesh or null if no mesh is under the pointer
  120906. */
  120907. getPointerOverMesh(): Nullable<AbstractMesh>;
  120908. /** @hidden */
  120909. _rebuildGeometries(): void;
  120910. /** @hidden */
  120911. _rebuildTextures(): void;
  120912. private _getByTags;
  120913. /**
  120914. * Get a list of meshes by tags
  120915. * @param tagsQuery defines the tags query to use
  120916. * @param forEach defines a predicate used to filter results
  120917. * @returns an array of Mesh
  120918. */
  120919. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  120920. /**
  120921. * Get a list of cameras by tags
  120922. * @param tagsQuery defines the tags query to use
  120923. * @param forEach defines a predicate used to filter results
  120924. * @returns an array of Camera
  120925. */
  120926. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  120927. /**
  120928. * Get a list of lights by tags
  120929. * @param tagsQuery defines the tags query to use
  120930. * @param forEach defines a predicate used to filter results
  120931. * @returns an array of Light
  120932. */
  120933. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  120934. /**
  120935. * Get a list of materials by tags
  120936. * @param tagsQuery defines the tags query to use
  120937. * @param forEach defines a predicate used to filter results
  120938. * @returns an array of Material
  120939. */
  120940. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  120941. /**
  120942. * Get a list of transform nodes by tags
  120943. * @param tagsQuery defines the tags query to use
  120944. * @param forEach defines a predicate used to filter results
  120945. * @returns an array of TransformNode
  120946. */
  120947. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  120948. /**
  120949. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120950. * This allowed control for front to back rendering or reversly depending of the special needs.
  120951. *
  120952. * @param renderingGroupId The rendering group id corresponding to its index
  120953. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120954. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120955. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120956. */
  120957. 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;
  120958. /**
  120959. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120960. *
  120961. * @param renderingGroupId The rendering group id corresponding to its index
  120962. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120963. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120964. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120965. */
  120966. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  120967. /**
  120968. * Gets the current auto clear configuration for one rendering group of the rendering
  120969. * manager.
  120970. * @param index the rendering group index to get the information for
  120971. * @returns The auto clear setup for the requested rendering group
  120972. */
  120973. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  120974. private _blockMaterialDirtyMechanism;
  120975. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  120976. get blockMaterialDirtyMechanism(): boolean;
  120977. set blockMaterialDirtyMechanism(value: boolean);
  120978. /**
  120979. * Will flag all materials as dirty to trigger new shader compilation
  120980. * @param flag defines the flag used to specify which material part must be marked as dirty
  120981. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  120982. */
  120983. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  120984. /** @hidden */
  120985. _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;
  120986. /** @hidden */
  120987. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120988. /** @hidden */
  120989. _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;
  120990. /** @hidden */
  120991. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  120992. /** @hidden */
  120993. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  120994. /** @hidden */
  120995. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120996. }
  120997. }
  120998. declare module BABYLON {
  120999. /**
  121000. * Set of assets to keep when moving a scene into an asset container.
  121001. */
  121002. export class KeepAssets extends AbstractScene {
  121003. }
  121004. /**
  121005. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121006. */
  121007. export class InstantiatedEntries {
  121008. /**
  121009. * List of new root nodes (eg. nodes with no parent)
  121010. */
  121011. rootNodes: TransformNode[];
  121012. /**
  121013. * List of new skeletons
  121014. */
  121015. skeletons: Skeleton[];
  121016. /**
  121017. * List of new animation groups
  121018. */
  121019. animationGroups: AnimationGroup[];
  121020. }
  121021. /**
  121022. * Container with a set of assets that can be added or removed from a scene.
  121023. */
  121024. export class AssetContainer extends AbstractScene {
  121025. private _wasAddedToScene;
  121026. /**
  121027. * The scene the AssetContainer belongs to.
  121028. */
  121029. scene: Scene;
  121030. /**
  121031. * Instantiates an AssetContainer.
  121032. * @param scene The scene the AssetContainer belongs to.
  121033. */
  121034. constructor(scene: Scene);
  121035. /**
  121036. * Instantiate or clone all meshes and add the new ones to the scene.
  121037. * Skeletons and animation groups will all be cloned
  121038. * @param nameFunction defines an optional function used to get new names for clones
  121039. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121040. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121041. */
  121042. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121043. /**
  121044. * Adds all the assets from the container to the scene.
  121045. */
  121046. addAllToScene(): void;
  121047. /**
  121048. * Removes all the assets in the container from the scene
  121049. */
  121050. removeAllFromScene(): void;
  121051. /**
  121052. * Disposes all the assets in the container
  121053. */
  121054. dispose(): void;
  121055. private _moveAssets;
  121056. /**
  121057. * Removes all the assets contained in the scene and adds them to the container.
  121058. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121059. */
  121060. moveAllFromScene(keepAssets?: KeepAssets): void;
  121061. /**
  121062. * 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.
  121063. * @returns the root mesh
  121064. */
  121065. createRootMesh(): Mesh;
  121066. /**
  121067. * Merge animations (direct and animation groups) from this asset container into a scene
  121068. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121069. * @param animatables set of animatables to retarget to a node from the scene
  121070. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121071. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121072. */
  121073. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121074. }
  121075. }
  121076. declare module BABYLON {
  121077. /**
  121078. * Defines how the parser contract is defined.
  121079. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121080. */
  121081. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121082. /**
  121083. * Defines how the individual parser contract is defined.
  121084. * These parser can parse an individual asset
  121085. */
  121086. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121087. /**
  121088. * Base class of the scene acting as a container for the different elements composing a scene.
  121089. * This class is dynamically extended by the different components of the scene increasing
  121090. * flexibility and reducing coupling
  121091. */
  121092. export abstract class AbstractScene {
  121093. /**
  121094. * Stores the list of available parsers in the application.
  121095. */
  121096. private static _BabylonFileParsers;
  121097. /**
  121098. * Stores the list of available individual parsers in the application.
  121099. */
  121100. private static _IndividualBabylonFileParsers;
  121101. /**
  121102. * Adds a parser in the list of available ones
  121103. * @param name Defines the name of the parser
  121104. * @param parser Defines the parser to add
  121105. */
  121106. static AddParser(name: string, parser: BabylonFileParser): void;
  121107. /**
  121108. * Gets a general parser from the list of avaialble ones
  121109. * @param name Defines the name of the parser
  121110. * @returns the requested parser or null
  121111. */
  121112. static GetParser(name: string): Nullable<BabylonFileParser>;
  121113. /**
  121114. * Adds n individual parser in the list of available ones
  121115. * @param name Defines the name of the parser
  121116. * @param parser Defines the parser to add
  121117. */
  121118. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121119. /**
  121120. * Gets an individual parser from the list of avaialble ones
  121121. * @param name Defines the name of the parser
  121122. * @returns the requested parser or null
  121123. */
  121124. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121125. /**
  121126. * Parser json data and populate both a scene and its associated container object
  121127. * @param jsonData Defines the data to parse
  121128. * @param scene Defines the scene to parse the data for
  121129. * @param container Defines the container attached to the parsing sequence
  121130. * @param rootUrl Defines the root url of the data
  121131. */
  121132. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121133. /**
  121134. * Gets the list of root nodes (ie. nodes with no parent)
  121135. */
  121136. rootNodes: Node[];
  121137. /** All of the cameras added to this scene
  121138. * @see https://doc.babylonjs.com/babylon101/cameras
  121139. */
  121140. cameras: Camera[];
  121141. /**
  121142. * All of the lights added to this scene
  121143. * @see https://doc.babylonjs.com/babylon101/lights
  121144. */
  121145. lights: Light[];
  121146. /**
  121147. * All of the (abstract) meshes added to this scene
  121148. */
  121149. meshes: AbstractMesh[];
  121150. /**
  121151. * The list of skeletons added to the scene
  121152. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121153. */
  121154. skeletons: Skeleton[];
  121155. /**
  121156. * All of the particle systems added to this scene
  121157. * @see https://doc.babylonjs.com/babylon101/particles
  121158. */
  121159. particleSystems: IParticleSystem[];
  121160. /**
  121161. * Gets a list of Animations associated with the scene
  121162. */
  121163. animations: Animation[];
  121164. /**
  121165. * All of the animation groups added to this scene
  121166. * @see https://doc.babylonjs.com/how_to/group
  121167. */
  121168. animationGroups: AnimationGroup[];
  121169. /**
  121170. * All of the multi-materials added to this scene
  121171. * @see https://doc.babylonjs.com/how_to/multi_materials
  121172. */
  121173. multiMaterials: MultiMaterial[];
  121174. /**
  121175. * All of the materials added to this scene
  121176. * In the context of a Scene, it is not supposed to be modified manually.
  121177. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121178. * Note also that the order of the Material within the array is not significant and might change.
  121179. * @see https://doc.babylonjs.com/babylon101/materials
  121180. */
  121181. materials: Material[];
  121182. /**
  121183. * The list of morph target managers added to the scene
  121184. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121185. */
  121186. morphTargetManagers: MorphTargetManager[];
  121187. /**
  121188. * The list of geometries used in the scene.
  121189. */
  121190. geometries: Geometry[];
  121191. /**
  121192. * All of the tranform nodes added to this scene
  121193. * In the context of a Scene, it is not supposed to be modified manually.
  121194. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121195. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121196. * @see https://doc.babylonjs.com/how_to/transformnode
  121197. */
  121198. transformNodes: TransformNode[];
  121199. /**
  121200. * ActionManagers available on the scene.
  121201. */
  121202. actionManagers: AbstractActionManager[];
  121203. /**
  121204. * Textures to keep.
  121205. */
  121206. textures: BaseTexture[];
  121207. /** @hidden */
  121208. protected _environmentTexture: Nullable<BaseTexture>;
  121209. /**
  121210. * Texture used in all pbr material as the reflection texture.
  121211. * As in the majority of the scene they are the same (exception for multi room and so on),
  121212. * this is easier to reference from here than from all the materials.
  121213. */
  121214. get environmentTexture(): Nullable<BaseTexture>;
  121215. set environmentTexture(value: Nullable<BaseTexture>);
  121216. /**
  121217. * The list of postprocesses added to the scene
  121218. */
  121219. postProcesses: PostProcess[];
  121220. /**
  121221. * @returns all meshes, lights, cameras, transformNodes and bones
  121222. */
  121223. getNodes(): Array<Node>;
  121224. }
  121225. }
  121226. declare module BABYLON {
  121227. /**
  121228. * Interface used to define options for Sound class
  121229. */
  121230. export interface ISoundOptions {
  121231. /**
  121232. * Does the sound autoplay once loaded.
  121233. */
  121234. autoplay?: boolean;
  121235. /**
  121236. * Does the sound loop after it finishes playing once.
  121237. */
  121238. loop?: boolean;
  121239. /**
  121240. * Sound's volume
  121241. */
  121242. volume?: number;
  121243. /**
  121244. * Is it a spatial sound?
  121245. */
  121246. spatialSound?: boolean;
  121247. /**
  121248. * Maximum distance to hear that sound
  121249. */
  121250. maxDistance?: number;
  121251. /**
  121252. * Uses user defined attenuation function
  121253. */
  121254. useCustomAttenuation?: boolean;
  121255. /**
  121256. * Define the roll off factor of spatial sounds.
  121257. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121258. */
  121259. rolloffFactor?: number;
  121260. /**
  121261. * Define the reference distance the sound should be heard perfectly.
  121262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121263. */
  121264. refDistance?: number;
  121265. /**
  121266. * Define the distance attenuation model the sound will follow.
  121267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121268. */
  121269. distanceModel?: string;
  121270. /**
  121271. * Defines the playback speed (1 by default)
  121272. */
  121273. playbackRate?: number;
  121274. /**
  121275. * Defines if the sound is from a streaming source
  121276. */
  121277. streaming?: boolean;
  121278. /**
  121279. * Defines an optional length (in seconds) inside the sound file
  121280. */
  121281. length?: number;
  121282. /**
  121283. * Defines an optional offset (in seconds) inside the sound file
  121284. */
  121285. offset?: number;
  121286. /**
  121287. * If true, URLs will not be required to state the audio file codec to use.
  121288. */
  121289. skipCodecCheck?: boolean;
  121290. }
  121291. /**
  121292. * Defines a sound that can be played in the application.
  121293. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121294. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121295. */
  121296. export class Sound {
  121297. /**
  121298. * The name of the sound in the scene.
  121299. */
  121300. name: string;
  121301. /**
  121302. * Does the sound autoplay once loaded.
  121303. */
  121304. autoplay: boolean;
  121305. /**
  121306. * Does the sound loop after it finishes playing once.
  121307. */
  121308. loop: boolean;
  121309. /**
  121310. * Does the sound use a custom attenuation curve to simulate the falloff
  121311. * happening when the source gets further away from the camera.
  121312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121313. */
  121314. useCustomAttenuation: boolean;
  121315. /**
  121316. * The sound track id this sound belongs to.
  121317. */
  121318. soundTrackId: number;
  121319. /**
  121320. * Is this sound currently played.
  121321. */
  121322. isPlaying: boolean;
  121323. /**
  121324. * Is this sound currently paused.
  121325. */
  121326. isPaused: boolean;
  121327. /**
  121328. * Does this sound enables spatial sound.
  121329. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121330. */
  121331. spatialSound: boolean;
  121332. /**
  121333. * Define the reference distance the sound should be heard perfectly.
  121334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121335. */
  121336. refDistance: number;
  121337. /**
  121338. * Define the roll off factor of spatial sounds.
  121339. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121340. */
  121341. rolloffFactor: number;
  121342. /**
  121343. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121344. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121345. */
  121346. maxDistance: number;
  121347. /**
  121348. * Define the distance attenuation model the sound will follow.
  121349. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121350. */
  121351. distanceModel: string;
  121352. /**
  121353. * @hidden
  121354. * Back Compat
  121355. **/
  121356. onended: () => any;
  121357. /**
  121358. * Gets or sets an object used to store user defined information for the sound.
  121359. */
  121360. metadata: any;
  121361. /**
  121362. * Observable event when the current playing sound finishes.
  121363. */
  121364. onEndedObservable: Observable<Sound>;
  121365. private _panningModel;
  121366. private _playbackRate;
  121367. private _streaming;
  121368. private _startTime;
  121369. private _startOffset;
  121370. private _position;
  121371. /** @hidden */
  121372. _positionInEmitterSpace: boolean;
  121373. private _localDirection;
  121374. private _volume;
  121375. private _isReadyToPlay;
  121376. private _isDirectional;
  121377. private _readyToPlayCallback;
  121378. private _audioBuffer;
  121379. private _soundSource;
  121380. private _streamingSource;
  121381. private _soundPanner;
  121382. private _soundGain;
  121383. private _inputAudioNode;
  121384. private _outputAudioNode;
  121385. private _coneInnerAngle;
  121386. private _coneOuterAngle;
  121387. private _coneOuterGain;
  121388. private _scene;
  121389. private _connectedTransformNode;
  121390. private _customAttenuationFunction;
  121391. private _registerFunc;
  121392. private _isOutputConnected;
  121393. private _htmlAudioElement;
  121394. private _urlType;
  121395. private _length?;
  121396. private _offset?;
  121397. /** @hidden */
  121398. static _SceneComponentInitialization: (scene: Scene) => void;
  121399. /**
  121400. * Create a sound and attach it to a scene
  121401. * @param name Name of your sound
  121402. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121403. * @param scene defines the scene the sound belongs to
  121404. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121405. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121406. */
  121407. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121408. /**
  121409. * Release the sound and its associated resources
  121410. */
  121411. dispose(): void;
  121412. /**
  121413. * Gets if the sounds is ready to be played or not.
  121414. * @returns true if ready, otherwise false
  121415. */
  121416. isReady(): boolean;
  121417. private _soundLoaded;
  121418. /**
  121419. * Sets the data of the sound from an audiobuffer
  121420. * @param audioBuffer The audioBuffer containing the data
  121421. */
  121422. setAudioBuffer(audioBuffer: AudioBuffer): void;
  121423. /**
  121424. * Updates the current sounds options such as maxdistance, loop...
  121425. * @param options A JSON object containing values named as the object properties
  121426. */
  121427. updateOptions(options: ISoundOptions): void;
  121428. private _createSpatialParameters;
  121429. private _updateSpatialParameters;
  121430. /**
  121431. * Switch the panning model to HRTF:
  121432. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121433. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121434. */
  121435. switchPanningModelToHRTF(): void;
  121436. /**
  121437. * Switch the panning model to Equal Power:
  121438. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121439. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121440. */
  121441. switchPanningModelToEqualPower(): void;
  121442. private _switchPanningModel;
  121443. /**
  121444. * Connect this sound to a sound track audio node like gain...
  121445. * @param soundTrackAudioNode the sound track audio node to connect to
  121446. */
  121447. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  121448. /**
  121449. * Transform this sound into a directional source
  121450. * @param coneInnerAngle Size of the inner cone in degree
  121451. * @param coneOuterAngle Size of the outer cone in degree
  121452. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  121453. */
  121454. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  121455. /**
  121456. * Gets or sets the inner angle for the directional cone.
  121457. */
  121458. get directionalConeInnerAngle(): number;
  121459. /**
  121460. * Gets or sets the inner angle for the directional cone.
  121461. */
  121462. set directionalConeInnerAngle(value: number);
  121463. /**
  121464. * Gets or sets the outer angle for the directional cone.
  121465. */
  121466. get directionalConeOuterAngle(): number;
  121467. /**
  121468. * Gets or sets the outer angle for the directional cone.
  121469. */
  121470. set directionalConeOuterAngle(value: number);
  121471. /**
  121472. * Sets the position of the emitter if spatial sound is enabled
  121473. * @param newPosition Defines the new posisiton
  121474. */
  121475. setPosition(newPosition: Vector3): void;
  121476. /**
  121477. * Sets the local direction of the emitter if spatial sound is enabled
  121478. * @param newLocalDirection Defines the new local direction
  121479. */
  121480. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  121481. private _updateDirection;
  121482. /** @hidden */
  121483. updateDistanceFromListener(): void;
  121484. /**
  121485. * Sets a new custom attenuation function for the sound.
  121486. * @param callback Defines the function used for the attenuation
  121487. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121488. */
  121489. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  121490. /**
  121491. * Play the sound
  121492. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  121493. * @param offset (optional) Start the sound at a specific time in seconds
  121494. * @param length (optional) Sound duration (in seconds)
  121495. */
  121496. play(time?: number, offset?: number, length?: number): void;
  121497. private _onended;
  121498. /**
  121499. * Stop the sound
  121500. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  121501. */
  121502. stop(time?: number): void;
  121503. /**
  121504. * Put the sound in pause
  121505. */
  121506. pause(): void;
  121507. /**
  121508. * Sets a dedicated volume for this sounds
  121509. * @param newVolume Define the new volume of the sound
  121510. * @param time Define time for gradual change to new volume
  121511. */
  121512. setVolume(newVolume: number, time?: number): void;
  121513. /**
  121514. * Set the sound play back rate
  121515. * @param newPlaybackRate Define the playback rate the sound should be played at
  121516. */
  121517. setPlaybackRate(newPlaybackRate: number): void;
  121518. /**
  121519. * Gets the volume of the sound.
  121520. * @returns the volume of the sound
  121521. */
  121522. getVolume(): number;
  121523. /**
  121524. * Attach the sound to a dedicated mesh
  121525. * @param transformNode The transform node to connect the sound with
  121526. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121527. */
  121528. attachToMesh(transformNode: TransformNode): void;
  121529. /**
  121530. * Detach the sound from the previously attached mesh
  121531. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121532. */
  121533. detachFromMesh(): void;
  121534. private _onRegisterAfterWorldMatrixUpdate;
  121535. /**
  121536. * Clone the current sound in the scene.
  121537. * @returns the new sound clone
  121538. */
  121539. clone(): Nullable<Sound>;
  121540. /**
  121541. * Gets the current underlying audio buffer containing the data
  121542. * @returns the audio buffer
  121543. */
  121544. getAudioBuffer(): Nullable<AudioBuffer>;
  121545. /**
  121546. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  121547. * @returns the source node
  121548. */
  121549. getSoundSource(): Nullable<AudioBufferSourceNode>;
  121550. /**
  121551. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  121552. * @returns the gain node
  121553. */
  121554. getSoundGain(): Nullable<GainNode>;
  121555. /**
  121556. * Serializes the Sound in a JSON representation
  121557. * @returns the JSON representation of the sound
  121558. */
  121559. serialize(): any;
  121560. /**
  121561. * Parse a JSON representation of a sound to innstantiate in a given scene
  121562. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  121563. * @param scene Define the scene the new parsed sound should be created in
  121564. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  121565. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  121566. * @returns the newly parsed sound
  121567. */
  121568. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  121569. }
  121570. }
  121571. declare module BABYLON {
  121572. /**
  121573. * This defines an action helpful to play a defined sound on a triggered action.
  121574. */
  121575. export class PlaySoundAction extends Action {
  121576. private _sound;
  121577. /**
  121578. * Instantiate the action
  121579. * @param triggerOptions defines the trigger options
  121580. * @param sound defines the sound to play
  121581. * @param condition defines the trigger related conditions
  121582. */
  121583. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121584. /** @hidden */
  121585. _prepare(): void;
  121586. /**
  121587. * Execute the action and play the sound.
  121588. */
  121589. execute(): void;
  121590. /**
  121591. * Serializes the actions and its related information.
  121592. * @param parent defines the object to serialize in
  121593. * @returns the serialized object
  121594. */
  121595. serialize(parent: any): any;
  121596. }
  121597. /**
  121598. * This defines an action helpful to stop a defined sound on a triggered action.
  121599. */
  121600. export class StopSoundAction extends Action {
  121601. private _sound;
  121602. /**
  121603. * Instantiate the action
  121604. * @param triggerOptions defines the trigger options
  121605. * @param sound defines the sound to stop
  121606. * @param condition defines the trigger related conditions
  121607. */
  121608. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121609. /** @hidden */
  121610. _prepare(): void;
  121611. /**
  121612. * Execute the action and stop the sound.
  121613. */
  121614. execute(): void;
  121615. /**
  121616. * Serializes the actions and its related information.
  121617. * @param parent defines the object to serialize in
  121618. * @returns the serialized object
  121619. */
  121620. serialize(parent: any): any;
  121621. }
  121622. }
  121623. declare module BABYLON {
  121624. /**
  121625. * This defines an action responsible to change the value of a property
  121626. * by interpolating between its current value and the newly set one once triggered.
  121627. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121628. */
  121629. export class InterpolateValueAction extends Action {
  121630. /**
  121631. * Defines the path of the property where the value should be interpolated
  121632. */
  121633. propertyPath: string;
  121634. /**
  121635. * Defines the target value at the end of the interpolation.
  121636. */
  121637. value: any;
  121638. /**
  121639. * Defines the time it will take for the property to interpolate to the value.
  121640. */
  121641. duration: number;
  121642. /**
  121643. * Defines if the other scene animations should be stopped when the action has been triggered
  121644. */
  121645. stopOtherAnimations?: boolean;
  121646. /**
  121647. * Defines a callback raised once the interpolation animation has been done.
  121648. */
  121649. onInterpolationDone?: () => void;
  121650. /**
  121651. * Observable triggered once the interpolation animation has been done.
  121652. */
  121653. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121654. private _target;
  121655. private _effectiveTarget;
  121656. private _property;
  121657. /**
  121658. * Instantiate the action
  121659. * @param triggerOptions defines the trigger options
  121660. * @param target defines the object containing the value to interpolate
  121661. * @param propertyPath defines the path to the property in the target object
  121662. * @param value defines the target value at the end of the interpolation
  121663. * @param duration deines the time it will take for the property to interpolate to the value.
  121664. * @param condition defines the trigger related conditions
  121665. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121666. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121667. */
  121668. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121669. /** @hidden */
  121670. _prepare(): void;
  121671. /**
  121672. * Execute the action starts the value interpolation.
  121673. */
  121674. execute(): void;
  121675. /**
  121676. * Serializes the actions and its related information.
  121677. * @param parent defines the object to serialize in
  121678. * @returns the serialized object
  121679. */
  121680. serialize(parent: any): any;
  121681. }
  121682. }
  121683. declare module BABYLON {
  121684. /**
  121685. * Options allowed during the creation of a sound track.
  121686. */
  121687. export interface ISoundTrackOptions {
  121688. /**
  121689. * The volume the sound track should take during creation
  121690. */
  121691. volume?: number;
  121692. /**
  121693. * Define if the sound track is the main sound track of the scene
  121694. */
  121695. mainTrack?: boolean;
  121696. }
  121697. /**
  121698. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121699. * It will be also used in a future release to apply effects on a specific track.
  121700. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121701. */
  121702. export class SoundTrack {
  121703. /**
  121704. * The unique identifier of the sound track in the scene.
  121705. */
  121706. id: number;
  121707. /**
  121708. * The list of sounds included in the sound track.
  121709. */
  121710. soundCollection: Array<Sound>;
  121711. private _outputAudioNode;
  121712. private _scene;
  121713. private _connectedAnalyser;
  121714. private _options;
  121715. private _isInitialized;
  121716. /**
  121717. * Creates a new sound track.
  121718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121719. * @param scene Define the scene the sound track belongs to
  121720. * @param options
  121721. */
  121722. constructor(scene: Scene, options?: ISoundTrackOptions);
  121723. private _initializeSoundTrackAudioGraph;
  121724. /**
  121725. * Release the sound track and its associated resources
  121726. */
  121727. dispose(): void;
  121728. /**
  121729. * Adds a sound to this sound track
  121730. * @param sound define the cound to add
  121731. * @ignoreNaming
  121732. */
  121733. AddSound(sound: Sound): void;
  121734. /**
  121735. * Removes a sound to this sound track
  121736. * @param sound define the cound to remove
  121737. * @ignoreNaming
  121738. */
  121739. RemoveSound(sound: Sound): void;
  121740. /**
  121741. * Set a global volume for the full sound track.
  121742. * @param newVolume Define the new volume of the sound track
  121743. */
  121744. setVolume(newVolume: number): void;
  121745. /**
  121746. * Switch the panning model to HRTF:
  121747. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121748. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121749. */
  121750. switchPanningModelToHRTF(): void;
  121751. /**
  121752. * Switch the panning model to Equal Power:
  121753. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121754. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121755. */
  121756. switchPanningModelToEqualPower(): void;
  121757. /**
  121758. * Connect the sound track to an audio analyser allowing some amazing
  121759. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121760. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121761. * @param analyser The analyser to connect to the engine
  121762. */
  121763. connectToAnalyser(analyser: Analyser): void;
  121764. }
  121765. }
  121766. declare module BABYLON {
  121767. interface AbstractScene {
  121768. /**
  121769. * The list of sounds used in the scene.
  121770. */
  121771. sounds: Nullable<Array<Sound>>;
  121772. }
  121773. interface Scene {
  121774. /**
  121775. * @hidden
  121776. * Backing field
  121777. */
  121778. _mainSoundTrack: SoundTrack;
  121779. /**
  121780. * The main sound track played by the scene.
  121781. * It cotains your primary collection of sounds.
  121782. */
  121783. mainSoundTrack: SoundTrack;
  121784. /**
  121785. * The list of sound tracks added to the scene
  121786. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121787. */
  121788. soundTracks: Nullable<Array<SoundTrack>>;
  121789. /**
  121790. * Gets a sound using a given name
  121791. * @param name defines the name to search for
  121792. * @return the found sound or null if not found at all.
  121793. */
  121794. getSoundByName(name: string): Nullable<Sound>;
  121795. /**
  121796. * Gets or sets if audio support is enabled
  121797. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121798. */
  121799. audioEnabled: boolean;
  121800. /**
  121801. * Gets or sets if audio will be output to headphones
  121802. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121803. */
  121804. headphone: boolean;
  121805. /**
  121806. * Gets or sets custom audio listener position provider
  121807. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121808. */
  121809. audioListenerPositionProvider: Nullable<() => Vector3>;
  121810. /**
  121811. * Gets or sets a refresh rate when using 3D audio positioning
  121812. */
  121813. audioPositioningRefreshRate: number;
  121814. }
  121815. /**
  121816. * Defines the sound scene component responsible to manage any sounds
  121817. * in a given scene.
  121818. */
  121819. export class AudioSceneComponent implements ISceneSerializableComponent {
  121820. private static _CameraDirectionLH;
  121821. private static _CameraDirectionRH;
  121822. /**
  121823. * The component name helpfull to identify the component in the list of scene components.
  121824. */
  121825. readonly name: string;
  121826. /**
  121827. * The scene the component belongs to.
  121828. */
  121829. scene: Scene;
  121830. private _audioEnabled;
  121831. /**
  121832. * Gets whether audio is enabled or not.
  121833. * Please use related enable/disable method to switch state.
  121834. */
  121835. get audioEnabled(): boolean;
  121836. private _headphone;
  121837. /**
  121838. * Gets whether audio is outputing to headphone or not.
  121839. * Please use the according Switch methods to change output.
  121840. */
  121841. get headphone(): boolean;
  121842. /**
  121843. * Gets or sets a refresh rate when using 3D audio positioning
  121844. */
  121845. audioPositioningRefreshRate: number;
  121846. private _audioListenerPositionProvider;
  121847. /**
  121848. * Gets the current audio listener position provider
  121849. */
  121850. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  121851. /**
  121852. * Sets a custom listener position for all sounds in the scene
  121853. * By default, this is the position of the first active camera
  121854. */
  121855. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  121856. /**
  121857. * Creates a new instance of the component for the given scene
  121858. * @param scene Defines the scene to register the component in
  121859. */
  121860. constructor(scene: Scene);
  121861. /**
  121862. * Registers the component in a given scene
  121863. */
  121864. register(): void;
  121865. /**
  121866. * Rebuilds the elements related to this component in case of
  121867. * context lost for instance.
  121868. */
  121869. rebuild(): void;
  121870. /**
  121871. * Serializes the component data to the specified json object
  121872. * @param serializationObject The object to serialize to
  121873. */
  121874. serialize(serializationObject: any): void;
  121875. /**
  121876. * Adds all the elements from the container to the scene
  121877. * @param container the container holding the elements
  121878. */
  121879. addFromContainer(container: AbstractScene): void;
  121880. /**
  121881. * Removes all the elements in the container from the scene
  121882. * @param container contains the elements to remove
  121883. * @param dispose if the removed element should be disposed (default: false)
  121884. */
  121885. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121886. /**
  121887. * Disposes the component and the associated ressources.
  121888. */
  121889. dispose(): void;
  121890. /**
  121891. * Disables audio in the associated scene.
  121892. */
  121893. disableAudio(): void;
  121894. /**
  121895. * Enables audio in the associated scene.
  121896. */
  121897. enableAudio(): void;
  121898. /**
  121899. * Switch audio to headphone output.
  121900. */
  121901. switchAudioModeForHeadphones(): void;
  121902. /**
  121903. * Switch audio to normal speakers.
  121904. */
  121905. switchAudioModeForNormalSpeakers(): void;
  121906. private _cachedCameraDirection;
  121907. private _cachedCameraPosition;
  121908. private _lastCheck;
  121909. private _afterRender;
  121910. }
  121911. }
  121912. declare module BABYLON {
  121913. /**
  121914. * Wraps one or more Sound objects and selects one with random weight for playback.
  121915. */
  121916. export class WeightedSound {
  121917. /** When true a Sound will be selected and played when the current playing Sound completes. */
  121918. loop: boolean;
  121919. private _coneInnerAngle;
  121920. private _coneOuterAngle;
  121921. private _volume;
  121922. /** A Sound is currently playing. */
  121923. isPlaying: boolean;
  121924. /** A Sound is currently paused. */
  121925. isPaused: boolean;
  121926. private _sounds;
  121927. private _weights;
  121928. private _currentIndex?;
  121929. /**
  121930. * Creates a new WeightedSound from the list of sounds given.
  121931. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  121932. * @param sounds Array of Sounds that will be selected from.
  121933. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  121934. */
  121935. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  121936. /**
  121937. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  121938. */
  121939. get directionalConeInnerAngle(): number;
  121940. /**
  121941. * The size of cone in degress for a directional sound in which there will be no attenuation.
  121942. */
  121943. set directionalConeInnerAngle(value: number);
  121944. /**
  121945. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121946. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121947. */
  121948. get directionalConeOuterAngle(): number;
  121949. /**
  121950. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121951. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121952. */
  121953. set directionalConeOuterAngle(value: number);
  121954. /**
  121955. * Playback volume.
  121956. */
  121957. get volume(): number;
  121958. /**
  121959. * Playback volume.
  121960. */
  121961. set volume(value: number);
  121962. private _onended;
  121963. /**
  121964. * Suspend playback
  121965. */
  121966. pause(): void;
  121967. /**
  121968. * Stop playback
  121969. */
  121970. stop(): void;
  121971. /**
  121972. * Start playback.
  121973. * @param startOffset Position the clip head at a specific time in seconds.
  121974. */
  121975. play(startOffset?: number): void;
  121976. }
  121977. }
  121978. declare module BABYLON {
  121979. /**
  121980. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  121981. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121982. */
  121983. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  121984. /**
  121985. * Gets the name of the behavior.
  121986. */
  121987. get name(): string;
  121988. /**
  121989. * The easing function used by animations
  121990. */
  121991. static EasingFunction: BackEase;
  121992. /**
  121993. * The easing mode used by animations
  121994. */
  121995. static EasingMode: number;
  121996. /**
  121997. * The duration of the animation, in milliseconds
  121998. */
  121999. transitionDuration: number;
  122000. /**
  122001. * Length of the distance animated by the transition when lower radius is reached
  122002. */
  122003. lowerRadiusTransitionRange: number;
  122004. /**
  122005. * Length of the distance animated by the transition when upper radius is reached
  122006. */
  122007. upperRadiusTransitionRange: number;
  122008. private _autoTransitionRange;
  122009. /**
  122010. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122011. */
  122012. get autoTransitionRange(): boolean;
  122013. /**
  122014. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122015. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122016. */
  122017. set autoTransitionRange(value: boolean);
  122018. private _attachedCamera;
  122019. private _onAfterCheckInputsObserver;
  122020. private _onMeshTargetChangedObserver;
  122021. /**
  122022. * Initializes the behavior.
  122023. */
  122024. init(): void;
  122025. /**
  122026. * Attaches the behavior to its arc rotate camera.
  122027. * @param camera Defines the camera to attach the behavior to
  122028. */
  122029. attach(camera: ArcRotateCamera): void;
  122030. /**
  122031. * Detaches the behavior from its current arc rotate camera.
  122032. */
  122033. detach(): void;
  122034. private _radiusIsAnimating;
  122035. private _radiusBounceTransition;
  122036. private _animatables;
  122037. private _cachedWheelPrecision;
  122038. /**
  122039. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122040. * @param radiusLimit The limit to check against.
  122041. * @return Bool to indicate if at limit.
  122042. */
  122043. private _isRadiusAtLimit;
  122044. /**
  122045. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122046. * @param radiusDelta The delta by which to animate to. Can be negative.
  122047. */
  122048. private _applyBoundRadiusAnimation;
  122049. /**
  122050. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122051. */
  122052. protected _clearAnimationLocks(): void;
  122053. /**
  122054. * Stops and removes all animations that have been applied to the camera
  122055. */
  122056. stopAllAnimations(): void;
  122057. }
  122058. }
  122059. declare module BABYLON {
  122060. /**
  122061. * 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.
  122062. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122063. */
  122064. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122065. /**
  122066. * Gets the name of the behavior.
  122067. */
  122068. get name(): string;
  122069. private _mode;
  122070. private _radiusScale;
  122071. private _positionScale;
  122072. private _defaultElevation;
  122073. private _elevationReturnTime;
  122074. private _elevationReturnWaitTime;
  122075. private _zoomStopsAnimation;
  122076. private _framingTime;
  122077. /**
  122078. * The easing function used by animations
  122079. */
  122080. static EasingFunction: ExponentialEase;
  122081. /**
  122082. * The easing mode used by animations
  122083. */
  122084. static EasingMode: number;
  122085. /**
  122086. * Sets the current mode used by the behavior
  122087. */
  122088. set mode(mode: number);
  122089. /**
  122090. * Gets current mode used by the behavior.
  122091. */
  122092. get mode(): number;
  122093. /**
  122094. * Sets the scale applied to the radius (1 by default)
  122095. */
  122096. set radiusScale(radius: number);
  122097. /**
  122098. * Gets the scale applied to the radius
  122099. */
  122100. get radiusScale(): number;
  122101. /**
  122102. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122103. */
  122104. set positionScale(scale: number);
  122105. /**
  122106. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122107. */
  122108. get positionScale(): number;
  122109. /**
  122110. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122111. * behaviour is triggered, in radians.
  122112. */
  122113. set defaultElevation(elevation: number);
  122114. /**
  122115. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122116. * behaviour is triggered, in radians.
  122117. */
  122118. get defaultElevation(): number;
  122119. /**
  122120. * Sets the time (in milliseconds) taken to return to the default beta position.
  122121. * Negative value indicates camera should not return to default.
  122122. */
  122123. set elevationReturnTime(speed: number);
  122124. /**
  122125. * Gets the time (in milliseconds) taken to return to the default beta position.
  122126. * Negative value indicates camera should not return to default.
  122127. */
  122128. get elevationReturnTime(): number;
  122129. /**
  122130. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122131. */
  122132. set elevationReturnWaitTime(time: number);
  122133. /**
  122134. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122135. */
  122136. get elevationReturnWaitTime(): number;
  122137. /**
  122138. * Sets the flag that indicates if user zooming should stop animation.
  122139. */
  122140. set zoomStopsAnimation(flag: boolean);
  122141. /**
  122142. * Gets the flag that indicates if user zooming should stop animation.
  122143. */
  122144. get zoomStopsAnimation(): boolean;
  122145. /**
  122146. * Sets the transition time when framing the mesh, in milliseconds
  122147. */
  122148. set framingTime(time: number);
  122149. /**
  122150. * Gets the transition time when framing the mesh, in milliseconds
  122151. */
  122152. get framingTime(): number;
  122153. /**
  122154. * Define if the behavior should automatically change the configured
  122155. * camera limits and sensibilities.
  122156. */
  122157. autoCorrectCameraLimitsAndSensibility: boolean;
  122158. private _onPrePointerObservableObserver;
  122159. private _onAfterCheckInputsObserver;
  122160. private _onMeshTargetChangedObserver;
  122161. private _attachedCamera;
  122162. private _isPointerDown;
  122163. private _lastInteractionTime;
  122164. /**
  122165. * Initializes the behavior.
  122166. */
  122167. init(): void;
  122168. /**
  122169. * Attaches the behavior to its arc rotate camera.
  122170. * @param camera Defines the camera to attach the behavior to
  122171. */
  122172. attach(camera: ArcRotateCamera): void;
  122173. /**
  122174. * Detaches the behavior from its current arc rotate camera.
  122175. */
  122176. detach(): void;
  122177. private _animatables;
  122178. private _betaIsAnimating;
  122179. private _betaTransition;
  122180. private _radiusTransition;
  122181. private _vectorTransition;
  122182. /**
  122183. * Targets the given mesh and updates zoom level accordingly.
  122184. * @param mesh The mesh to target.
  122185. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122186. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122187. */
  122188. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122189. /**
  122190. * Targets the given mesh with its children and updates zoom level accordingly.
  122191. * @param mesh The mesh to target.
  122192. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122193. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122194. */
  122195. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122196. /**
  122197. * Targets the given meshes with their children and updates zoom level accordingly.
  122198. * @param meshes The mesh to target.
  122199. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122200. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122201. */
  122202. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122203. /**
  122204. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122205. * @param minimumWorld Determines the smaller position of the bounding box extend
  122206. * @param maximumWorld Determines the bigger position of the bounding box extend
  122207. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122208. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122209. */
  122210. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122211. /**
  122212. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122213. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122214. * frustum width.
  122215. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122216. * to fully enclose the mesh in the viewing frustum.
  122217. */
  122218. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122219. /**
  122220. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122221. * is automatically returned to its default position (expected to be above ground plane).
  122222. */
  122223. private _maintainCameraAboveGround;
  122224. /**
  122225. * Returns the frustum slope based on the canvas ratio and camera FOV
  122226. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122227. */
  122228. private _getFrustumSlope;
  122229. /**
  122230. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122231. */
  122232. private _clearAnimationLocks;
  122233. /**
  122234. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122235. */
  122236. private _applyUserInteraction;
  122237. /**
  122238. * Stops and removes all animations that have been applied to the camera
  122239. */
  122240. stopAllAnimations(): void;
  122241. /**
  122242. * Gets a value indicating if the user is moving the camera
  122243. */
  122244. get isUserIsMoving(): boolean;
  122245. /**
  122246. * The camera can move all the way towards the mesh.
  122247. */
  122248. static IgnoreBoundsSizeMode: number;
  122249. /**
  122250. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122251. */
  122252. static FitFrustumSidesMode: number;
  122253. }
  122254. }
  122255. declare module BABYLON {
  122256. /**
  122257. * Base class for Camera Pointer Inputs.
  122258. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122259. * for example usage.
  122260. */
  122261. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122262. /**
  122263. * Defines the camera the input is attached to.
  122264. */
  122265. abstract camera: Camera;
  122266. /**
  122267. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122268. */
  122269. protected _altKey: boolean;
  122270. protected _ctrlKey: boolean;
  122271. protected _metaKey: boolean;
  122272. protected _shiftKey: boolean;
  122273. /**
  122274. * Which mouse buttons were pressed at time of last mouse event.
  122275. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122276. */
  122277. protected _buttonsPressed: number;
  122278. /**
  122279. * Defines the buttons associated with the input to handle camera move.
  122280. */
  122281. buttons: number[];
  122282. /**
  122283. * Attach the input controls to a specific dom element to get the input from.
  122284. * @param element Defines the element the controls should be listened from
  122285. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122286. */
  122287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122288. /**
  122289. * Detach the current controls from the specified dom element.
  122290. * @param element Defines the element to stop listening the inputs from
  122291. */
  122292. detachControl(element: Nullable<HTMLElement>): void;
  122293. /**
  122294. * Gets the class name of the current input.
  122295. * @returns the class name
  122296. */
  122297. getClassName(): string;
  122298. /**
  122299. * Get the friendly name associated with the input class.
  122300. * @returns the input friendly name
  122301. */
  122302. getSimpleName(): string;
  122303. /**
  122304. * Called on pointer POINTERDOUBLETAP event.
  122305. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122306. */
  122307. protected onDoubleTap(type: string): void;
  122308. /**
  122309. * Called on pointer POINTERMOVE event if only a single touch is active.
  122310. * Override this method to provide functionality.
  122311. */
  122312. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122313. /**
  122314. * Called on pointer POINTERMOVE event if multiple touches are active.
  122315. * Override this method to provide functionality.
  122316. */
  122317. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122318. /**
  122319. * Called on JS contextmenu event.
  122320. * Override this method to provide functionality.
  122321. */
  122322. protected onContextMenu(evt: PointerEvent): void;
  122323. /**
  122324. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122325. * press.
  122326. * Override this method to provide functionality.
  122327. */
  122328. protected onButtonDown(evt: PointerEvent): void;
  122329. /**
  122330. * Called each time a new POINTERUP event occurs. Ie, for each button
  122331. * release.
  122332. * Override this method to provide functionality.
  122333. */
  122334. protected onButtonUp(evt: PointerEvent): void;
  122335. /**
  122336. * Called when window becomes inactive.
  122337. * Override this method to provide functionality.
  122338. */
  122339. protected onLostFocus(): void;
  122340. private _pointerInput;
  122341. private _observer;
  122342. private _onLostFocus;
  122343. private pointA;
  122344. private pointB;
  122345. }
  122346. }
  122347. declare module BABYLON {
  122348. /**
  122349. * Manage the pointers inputs to control an arc rotate camera.
  122350. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122351. */
  122352. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122353. /**
  122354. * Defines the camera the input is attached to.
  122355. */
  122356. camera: ArcRotateCamera;
  122357. /**
  122358. * Gets the class name of the current input.
  122359. * @returns the class name
  122360. */
  122361. getClassName(): string;
  122362. /**
  122363. * Defines the buttons associated with the input to handle camera move.
  122364. */
  122365. buttons: number[];
  122366. /**
  122367. * Defines the pointer angular sensibility along the X axis or how fast is
  122368. * the camera rotating.
  122369. */
  122370. angularSensibilityX: number;
  122371. /**
  122372. * Defines the pointer angular sensibility along the Y axis or how fast is
  122373. * the camera rotating.
  122374. */
  122375. angularSensibilityY: number;
  122376. /**
  122377. * Defines the pointer pinch precision or how fast is the camera zooming.
  122378. */
  122379. pinchPrecision: number;
  122380. /**
  122381. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122382. * from 0.
  122383. * It defines the percentage of current camera.radius to use as delta when
  122384. * pinch zoom is used.
  122385. */
  122386. pinchDeltaPercentage: number;
  122387. /**
  122388. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122389. * that any object in the plane at the camera's target point will scale
  122390. * perfectly with finger motion.
  122391. * Overrides pinchDeltaPercentage and pinchPrecision.
  122392. */
  122393. useNaturalPinchZoom: boolean;
  122394. /**
  122395. * Defines the pointer panning sensibility or how fast is the camera moving.
  122396. */
  122397. panningSensibility: number;
  122398. /**
  122399. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122400. */
  122401. multiTouchPanning: boolean;
  122402. /**
  122403. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122404. * zoom (pinch) through multitouch.
  122405. */
  122406. multiTouchPanAndZoom: boolean;
  122407. /**
  122408. * Revers pinch action direction.
  122409. */
  122410. pinchInwards: boolean;
  122411. private _isPanClick;
  122412. private _twoFingerActivityCount;
  122413. private _isPinching;
  122414. /**
  122415. * Called on pointer POINTERMOVE event if only a single touch is active.
  122416. */
  122417. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122418. /**
  122419. * Called on pointer POINTERDOUBLETAP event.
  122420. */
  122421. protected onDoubleTap(type: string): void;
  122422. /**
  122423. * Called on pointer POINTERMOVE event if multiple touches are active.
  122424. */
  122425. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122426. /**
  122427. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122428. * press.
  122429. */
  122430. protected onButtonDown(evt: PointerEvent): void;
  122431. /**
  122432. * Called each time a new POINTERUP event occurs. Ie, for each button
  122433. * release.
  122434. */
  122435. protected onButtonUp(evt: PointerEvent): void;
  122436. /**
  122437. * Called when window becomes inactive.
  122438. */
  122439. protected onLostFocus(): void;
  122440. }
  122441. }
  122442. declare module BABYLON {
  122443. /**
  122444. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  122445. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122446. */
  122447. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  122448. /**
  122449. * Defines the camera the input is attached to.
  122450. */
  122451. camera: ArcRotateCamera;
  122452. /**
  122453. * Defines the list of key codes associated with the up action (increase alpha)
  122454. */
  122455. keysUp: number[];
  122456. /**
  122457. * Defines the list of key codes associated with the down action (decrease alpha)
  122458. */
  122459. keysDown: number[];
  122460. /**
  122461. * Defines the list of key codes associated with the left action (increase beta)
  122462. */
  122463. keysLeft: number[];
  122464. /**
  122465. * Defines the list of key codes associated with the right action (decrease beta)
  122466. */
  122467. keysRight: number[];
  122468. /**
  122469. * Defines the list of key codes associated with the reset action.
  122470. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  122471. */
  122472. keysReset: number[];
  122473. /**
  122474. * Defines the panning sensibility of the inputs.
  122475. * (How fast is the camera panning)
  122476. */
  122477. panningSensibility: number;
  122478. /**
  122479. * Defines the zooming sensibility of the inputs.
  122480. * (How fast is the camera zooming)
  122481. */
  122482. zoomingSensibility: number;
  122483. /**
  122484. * Defines whether maintaining the alt key down switch the movement mode from
  122485. * orientation to zoom.
  122486. */
  122487. useAltToZoom: boolean;
  122488. /**
  122489. * Rotation speed of the camera
  122490. */
  122491. angularSpeed: number;
  122492. private _keys;
  122493. private _ctrlPressed;
  122494. private _altPressed;
  122495. private _onCanvasBlurObserver;
  122496. private _onKeyboardObserver;
  122497. private _engine;
  122498. private _scene;
  122499. /**
  122500. * Attach the input controls to a specific dom element to get the input from.
  122501. * @param element Defines the element the controls should be listened from
  122502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122503. */
  122504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122505. /**
  122506. * Detach the current controls from the specified dom element.
  122507. * @param element Defines the element to stop listening the inputs from
  122508. */
  122509. detachControl(element: Nullable<HTMLElement>): void;
  122510. /**
  122511. * Update the current camera state depending on the inputs that have been used this frame.
  122512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122513. */
  122514. checkInputs(): void;
  122515. /**
  122516. * Gets the class name of the current intput.
  122517. * @returns the class name
  122518. */
  122519. getClassName(): string;
  122520. /**
  122521. * Get the friendly name associated with the input class.
  122522. * @returns the input friendly name
  122523. */
  122524. getSimpleName(): string;
  122525. }
  122526. }
  122527. declare module BABYLON {
  122528. /**
  122529. * Manage the mouse wheel inputs to control an arc rotate camera.
  122530. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122531. */
  122532. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  122533. /**
  122534. * Defines the camera the input is attached to.
  122535. */
  122536. camera: ArcRotateCamera;
  122537. /**
  122538. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122539. */
  122540. wheelPrecision: number;
  122541. /**
  122542. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122543. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122544. */
  122545. wheelDeltaPercentage: number;
  122546. private _wheel;
  122547. private _observer;
  122548. private computeDeltaFromMouseWheelLegacyEvent;
  122549. /**
  122550. * Attach the input controls to a specific dom element to get the input from.
  122551. * @param element Defines the element the controls should be listened from
  122552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122553. */
  122554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122555. /**
  122556. * Detach the current controls from the specified dom element.
  122557. * @param element Defines the element to stop listening the inputs from
  122558. */
  122559. detachControl(element: Nullable<HTMLElement>): void;
  122560. /**
  122561. * Gets the class name of the current intput.
  122562. * @returns the class name
  122563. */
  122564. getClassName(): string;
  122565. /**
  122566. * Get the friendly name associated with the input class.
  122567. * @returns the input friendly name
  122568. */
  122569. getSimpleName(): string;
  122570. }
  122571. }
  122572. declare module BABYLON {
  122573. /**
  122574. * Default Inputs manager for the ArcRotateCamera.
  122575. * It groups all the default supported inputs for ease of use.
  122576. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122577. */
  122578. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122579. /**
  122580. * Instantiates a new ArcRotateCameraInputsManager.
  122581. * @param camera Defines the camera the inputs belong to
  122582. */
  122583. constructor(camera: ArcRotateCamera);
  122584. /**
  122585. * Add mouse wheel input support to the input manager.
  122586. * @returns the current input manager
  122587. */
  122588. addMouseWheel(): ArcRotateCameraInputsManager;
  122589. /**
  122590. * Add pointers input support to the input manager.
  122591. * @returns the current input manager
  122592. */
  122593. addPointers(): ArcRotateCameraInputsManager;
  122594. /**
  122595. * Add keyboard input support to the input manager.
  122596. * @returns the current input manager
  122597. */
  122598. addKeyboard(): ArcRotateCameraInputsManager;
  122599. }
  122600. }
  122601. declare module BABYLON {
  122602. /**
  122603. * This represents an orbital type of camera.
  122604. *
  122605. * 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.
  122606. * 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.
  122607. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122608. */
  122609. export class ArcRotateCamera extends TargetCamera {
  122610. /**
  122611. * Defines the rotation angle of the camera along the longitudinal axis.
  122612. */
  122613. alpha: number;
  122614. /**
  122615. * Defines the rotation angle of the camera along the latitudinal axis.
  122616. */
  122617. beta: number;
  122618. /**
  122619. * Defines the radius of the camera from it s target point.
  122620. */
  122621. radius: number;
  122622. protected _target: Vector3;
  122623. protected _targetHost: Nullable<AbstractMesh>;
  122624. /**
  122625. * Defines the target point of the camera.
  122626. * The camera looks towards it form the radius distance.
  122627. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122628. */
  122629. get target(): Vector3;
  122630. set target(value: Vector3);
  122631. /**
  122632. * Define the current local position of the camera in the scene
  122633. */
  122634. get position(): Vector3;
  122635. set position(newPosition: Vector3);
  122636. protected _upToYMatrix: Matrix;
  122637. protected _YToUpMatrix: Matrix;
  122638. /**
  122639. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122640. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122641. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122642. */
  122643. set upVector(vec: Vector3);
  122644. get upVector(): Vector3;
  122645. /**
  122646. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122647. */
  122648. setMatUp(): void;
  122649. /**
  122650. * Current inertia value on the longitudinal axis.
  122651. * The bigger this number the longer it will take for the camera to stop.
  122652. */
  122653. inertialAlphaOffset: number;
  122654. /**
  122655. * Current inertia value on the latitudinal axis.
  122656. * The bigger this number the longer it will take for the camera to stop.
  122657. */
  122658. inertialBetaOffset: number;
  122659. /**
  122660. * Current inertia value on the radius axis.
  122661. * The bigger this number the longer it will take for the camera to stop.
  122662. */
  122663. inertialRadiusOffset: number;
  122664. /**
  122665. * Minimum allowed angle on the longitudinal axis.
  122666. * This can help limiting how the Camera is able to move in the scene.
  122667. */
  122668. lowerAlphaLimit: Nullable<number>;
  122669. /**
  122670. * Maximum allowed angle on the longitudinal axis.
  122671. * This can help limiting how the Camera is able to move in the scene.
  122672. */
  122673. upperAlphaLimit: Nullable<number>;
  122674. /**
  122675. * Minimum allowed angle on the latitudinal axis.
  122676. * This can help limiting how the Camera is able to move in the scene.
  122677. */
  122678. lowerBetaLimit: number;
  122679. /**
  122680. * Maximum allowed angle on the latitudinal axis.
  122681. * This can help limiting how the Camera is able to move in the scene.
  122682. */
  122683. upperBetaLimit: number;
  122684. /**
  122685. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122686. * This can help limiting how the Camera is able to move in the scene.
  122687. */
  122688. lowerRadiusLimit: Nullable<number>;
  122689. /**
  122690. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122691. * This can help limiting how the Camera is able to move in the scene.
  122692. */
  122693. upperRadiusLimit: Nullable<number>;
  122694. /**
  122695. * Defines the current inertia value used during panning of the camera along the X axis.
  122696. */
  122697. inertialPanningX: number;
  122698. /**
  122699. * Defines the current inertia value used during panning of the camera along the Y axis.
  122700. */
  122701. inertialPanningY: number;
  122702. /**
  122703. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122704. * Basically if your fingers moves away from more than this distance you will be considered
  122705. * in pinch mode.
  122706. */
  122707. pinchToPanMaxDistance: number;
  122708. /**
  122709. * Defines the maximum distance the camera can pan.
  122710. * This could help keeping the cammera always in your scene.
  122711. */
  122712. panningDistanceLimit: Nullable<number>;
  122713. /**
  122714. * Defines the target of the camera before paning.
  122715. */
  122716. panningOriginTarget: Vector3;
  122717. /**
  122718. * Defines the value of the inertia used during panning.
  122719. * 0 would mean stop inertia and one would mean no decelleration at all.
  122720. */
  122721. panningInertia: number;
  122722. /**
  122723. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  122724. */
  122725. get angularSensibilityX(): number;
  122726. set angularSensibilityX(value: number);
  122727. /**
  122728. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  122729. */
  122730. get angularSensibilityY(): number;
  122731. set angularSensibilityY(value: number);
  122732. /**
  122733. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  122734. */
  122735. get pinchPrecision(): number;
  122736. set pinchPrecision(value: number);
  122737. /**
  122738. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  122739. * It will be used instead of pinchDeltaPrecision if different from 0.
  122740. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122741. */
  122742. get pinchDeltaPercentage(): number;
  122743. set pinchDeltaPercentage(value: number);
  122744. /**
  122745. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  122746. * and pinch delta percentage.
  122747. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122748. * that any object in the plane at the camera's target point will scale
  122749. * perfectly with finger motion.
  122750. */
  122751. get useNaturalPinchZoom(): boolean;
  122752. set useNaturalPinchZoom(value: boolean);
  122753. /**
  122754. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  122755. */
  122756. get panningSensibility(): number;
  122757. set panningSensibility(value: number);
  122758. /**
  122759. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  122760. */
  122761. get keysUp(): number[];
  122762. set keysUp(value: number[]);
  122763. /**
  122764. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  122765. */
  122766. get keysDown(): number[];
  122767. set keysDown(value: number[]);
  122768. /**
  122769. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  122770. */
  122771. get keysLeft(): number[];
  122772. set keysLeft(value: number[]);
  122773. /**
  122774. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  122775. */
  122776. get keysRight(): number[];
  122777. set keysRight(value: number[]);
  122778. /**
  122779. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122780. */
  122781. get wheelPrecision(): number;
  122782. set wheelPrecision(value: number);
  122783. /**
  122784. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  122785. * It will be used instead of pinchDeltaPrecision if different from 0.
  122786. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122787. */
  122788. get wheelDeltaPercentage(): number;
  122789. set wheelDeltaPercentage(value: number);
  122790. /**
  122791. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  122792. */
  122793. zoomOnFactor: number;
  122794. /**
  122795. * Defines a screen offset for the camera position.
  122796. */
  122797. targetScreenOffset: Vector2;
  122798. /**
  122799. * Allows the camera to be completely reversed.
  122800. * If false the camera can not arrive upside down.
  122801. */
  122802. allowUpsideDown: boolean;
  122803. /**
  122804. * Define if double tap/click is used to restore the previously saved state of the camera.
  122805. */
  122806. useInputToRestoreState: boolean;
  122807. /** @hidden */
  122808. _viewMatrix: Matrix;
  122809. /** @hidden */
  122810. _useCtrlForPanning: boolean;
  122811. /** @hidden */
  122812. _panningMouseButton: number;
  122813. /**
  122814. * Defines the input associated to the camera.
  122815. */
  122816. inputs: ArcRotateCameraInputsManager;
  122817. /** @hidden */
  122818. _reset: () => void;
  122819. /**
  122820. * Defines the allowed panning axis.
  122821. */
  122822. panningAxis: Vector3;
  122823. protected _localDirection: Vector3;
  122824. protected _transformedDirection: Vector3;
  122825. private _bouncingBehavior;
  122826. /**
  122827. * Gets the bouncing behavior of the camera if it has been enabled.
  122828. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122829. */
  122830. get bouncingBehavior(): Nullable<BouncingBehavior>;
  122831. /**
  122832. * Defines if the bouncing behavior of the camera is enabled on the camera.
  122833. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122834. */
  122835. get useBouncingBehavior(): boolean;
  122836. set useBouncingBehavior(value: boolean);
  122837. private _framingBehavior;
  122838. /**
  122839. * Gets the framing behavior of the camera if it has been enabled.
  122840. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122841. */
  122842. get framingBehavior(): Nullable<FramingBehavior>;
  122843. /**
  122844. * Defines if the framing behavior of the camera is enabled on the camera.
  122845. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122846. */
  122847. get useFramingBehavior(): boolean;
  122848. set useFramingBehavior(value: boolean);
  122849. private _autoRotationBehavior;
  122850. /**
  122851. * Gets the auto rotation behavior of the camera if it has been enabled.
  122852. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122853. */
  122854. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  122855. /**
  122856. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  122857. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122858. */
  122859. get useAutoRotationBehavior(): boolean;
  122860. set useAutoRotationBehavior(value: boolean);
  122861. /**
  122862. * Observable triggered when the mesh target has been changed on the camera.
  122863. */
  122864. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  122865. /**
  122866. * Event raised when the camera is colliding with a mesh.
  122867. */
  122868. onCollide: (collidedMesh: AbstractMesh) => void;
  122869. /**
  122870. * Defines whether the camera should check collision with the objects oh the scene.
  122871. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  122872. */
  122873. checkCollisions: boolean;
  122874. /**
  122875. * Defines the collision radius of the camera.
  122876. * This simulates a sphere around the camera.
  122877. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122878. */
  122879. collisionRadius: Vector3;
  122880. protected _collider: Collider;
  122881. protected _previousPosition: Vector3;
  122882. protected _collisionVelocity: Vector3;
  122883. protected _newPosition: Vector3;
  122884. protected _previousAlpha: number;
  122885. protected _previousBeta: number;
  122886. protected _previousRadius: number;
  122887. protected _collisionTriggered: boolean;
  122888. protected _targetBoundingCenter: Nullable<Vector3>;
  122889. private _computationVector;
  122890. /**
  122891. * Instantiates a new ArcRotateCamera in a given scene
  122892. * @param name Defines the name of the camera
  122893. * @param alpha Defines the camera rotation along the logitudinal axis
  122894. * @param beta Defines the camera rotation along the latitudinal axis
  122895. * @param radius Defines the camera distance from its target
  122896. * @param target Defines the camera target
  122897. * @param scene Defines the scene the camera belongs to
  122898. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  122899. */
  122900. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122901. /** @hidden */
  122902. _initCache(): void;
  122903. /** @hidden */
  122904. _updateCache(ignoreParentClass?: boolean): void;
  122905. protected _getTargetPosition(): Vector3;
  122906. private _storedAlpha;
  122907. private _storedBeta;
  122908. private _storedRadius;
  122909. private _storedTarget;
  122910. private _storedTargetScreenOffset;
  122911. /**
  122912. * Stores the current state of the camera (alpha, beta, radius and target)
  122913. * @returns the camera itself
  122914. */
  122915. storeState(): Camera;
  122916. /**
  122917. * @hidden
  122918. * Restored camera state. You must call storeState() first
  122919. */
  122920. _restoreStateValues(): boolean;
  122921. /** @hidden */
  122922. _isSynchronizedViewMatrix(): boolean;
  122923. /**
  122924. * Attached controls to the current camera.
  122925. * @param element Defines the element the controls should be listened from
  122926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122927. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  122928. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  122929. */
  122930. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  122931. /**
  122932. * Detach the current controls from the camera.
  122933. * The camera will stop reacting to inputs.
  122934. * @param element Defines the element to stop listening the inputs from
  122935. */
  122936. detachControl(element: HTMLElement): void;
  122937. /** @hidden */
  122938. _checkInputs(): void;
  122939. protected _checkLimits(): void;
  122940. /**
  122941. * Rebuilds angles (alpha, beta) and radius from the give position and target
  122942. */
  122943. rebuildAnglesAndRadius(): void;
  122944. /**
  122945. * Use a position to define the current camera related information like alpha, beta and radius
  122946. * @param position Defines the position to set the camera at
  122947. */
  122948. setPosition(position: Vector3): void;
  122949. /**
  122950. * Defines the target the camera should look at.
  122951. * This will automatically adapt alpha beta and radius to fit within the new target.
  122952. * @param target Defines the new target as a Vector or a mesh
  122953. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  122954. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  122955. */
  122956. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  122957. /** @hidden */
  122958. _getViewMatrix(): Matrix;
  122959. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  122960. /**
  122961. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  122962. * @param meshes Defines the mesh to zoom on
  122963. * @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)
  122964. */
  122965. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  122966. /**
  122967. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  122968. * The target will be changed but the radius
  122969. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  122970. * @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)
  122971. */
  122972. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  122973. min: Vector3;
  122974. max: Vector3;
  122975. distance: number;
  122976. }, doNotUpdateMaxZ?: boolean): void;
  122977. /**
  122978. * @override
  122979. * Override Camera.createRigCamera
  122980. */
  122981. createRigCamera(name: string, cameraIndex: number): Camera;
  122982. /**
  122983. * @hidden
  122984. * @override
  122985. * Override Camera._updateRigCameras
  122986. */
  122987. _updateRigCameras(): void;
  122988. /**
  122989. * Destroy the camera and release the current resources hold by it.
  122990. */
  122991. dispose(): void;
  122992. /**
  122993. * Gets the current object class name.
  122994. * @return the class name
  122995. */
  122996. getClassName(): string;
  122997. }
  122998. }
  122999. declare module BABYLON {
  123000. /**
  123001. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123002. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123003. */
  123004. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123005. /**
  123006. * Gets the name of the behavior.
  123007. */
  123008. get name(): string;
  123009. private _zoomStopsAnimation;
  123010. private _idleRotationSpeed;
  123011. private _idleRotationWaitTime;
  123012. private _idleRotationSpinupTime;
  123013. /**
  123014. * Sets the flag that indicates if user zooming should stop animation.
  123015. */
  123016. set zoomStopsAnimation(flag: boolean);
  123017. /**
  123018. * Gets the flag that indicates if user zooming should stop animation.
  123019. */
  123020. get zoomStopsAnimation(): boolean;
  123021. /**
  123022. * Sets the default speed at which the camera rotates around the model.
  123023. */
  123024. set idleRotationSpeed(speed: number);
  123025. /**
  123026. * Gets the default speed at which the camera rotates around the model.
  123027. */
  123028. get idleRotationSpeed(): number;
  123029. /**
  123030. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123031. */
  123032. set idleRotationWaitTime(time: number);
  123033. /**
  123034. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123035. */
  123036. get idleRotationWaitTime(): number;
  123037. /**
  123038. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123039. */
  123040. set idleRotationSpinupTime(time: number);
  123041. /**
  123042. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123043. */
  123044. get idleRotationSpinupTime(): number;
  123045. /**
  123046. * Gets a value indicating if the camera is currently rotating because of this behavior
  123047. */
  123048. get rotationInProgress(): boolean;
  123049. private _onPrePointerObservableObserver;
  123050. private _onAfterCheckInputsObserver;
  123051. private _attachedCamera;
  123052. private _isPointerDown;
  123053. private _lastFrameTime;
  123054. private _lastInteractionTime;
  123055. private _cameraRotationSpeed;
  123056. /**
  123057. * Initializes the behavior.
  123058. */
  123059. init(): void;
  123060. /**
  123061. * Attaches the behavior to its arc rotate camera.
  123062. * @param camera Defines the camera to attach the behavior to
  123063. */
  123064. attach(camera: ArcRotateCamera): void;
  123065. /**
  123066. * Detaches the behavior from its current arc rotate camera.
  123067. */
  123068. detach(): void;
  123069. /**
  123070. * Returns true if user is scrolling.
  123071. * @return true if user is scrolling.
  123072. */
  123073. private _userIsZooming;
  123074. private _lastFrameRadius;
  123075. private _shouldAnimationStopForInteraction;
  123076. /**
  123077. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123078. */
  123079. private _applyUserInteraction;
  123080. private _userIsMoving;
  123081. }
  123082. }
  123083. declare module BABYLON {
  123084. /**
  123085. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123086. */
  123087. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123088. private ui;
  123089. /**
  123090. * The name of the behavior
  123091. */
  123092. name: string;
  123093. /**
  123094. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123095. */
  123096. distanceAwayFromFace: number;
  123097. /**
  123098. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123099. */
  123100. distanceAwayFromBottomOfFace: number;
  123101. private _faceVectors;
  123102. private _target;
  123103. private _scene;
  123104. private _onRenderObserver;
  123105. private _tmpMatrix;
  123106. private _tmpVector;
  123107. /**
  123108. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123109. * @param ui The transform node that should be attched to the mesh
  123110. */
  123111. constructor(ui: TransformNode);
  123112. /**
  123113. * Initializes the behavior
  123114. */
  123115. init(): void;
  123116. private _closestFace;
  123117. private _zeroVector;
  123118. private _lookAtTmpMatrix;
  123119. private _lookAtToRef;
  123120. /**
  123121. * Attaches the AttachToBoxBehavior to the passed in mesh
  123122. * @param target The mesh that the specified node will be attached to
  123123. */
  123124. attach(target: Mesh): void;
  123125. /**
  123126. * Detaches the behavior from the mesh
  123127. */
  123128. detach(): void;
  123129. }
  123130. }
  123131. declare module BABYLON {
  123132. /**
  123133. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123134. */
  123135. export class FadeInOutBehavior implements Behavior<Mesh> {
  123136. /**
  123137. * Time in milliseconds to delay before fading in (Default: 0)
  123138. */
  123139. delay: number;
  123140. /**
  123141. * Time in milliseconds for the mesh to fade in (Default: 300)
  123142. */
  123143. fadeInTime: number;
  123144. private _millisecondsPerFrame;
  123145. private _hovered;
  123146. private _hoverValue;
  123147. private _ownerNode;
  123148. /**
  123149. * Instatiates the FadeInOutBehavior
  123150. */
  123151. constructor();
  123152. /**
  123153. * The name of the behavior
  123154. */
  123155. get name(): string;
  123156. /**
  123157. * Initializes the behavior
  123158. */
  123159. init(): void;
  123160. /**
  123161. * Attaches the fade behavior on the passed in mesh
  123162. * @param ownerNode The mesh that will be faded in/out once attached
  123163. */
  123164. attach(ownerNode: Mesh): void;
  123165. /**
  123166. * Detaches the behavior from the mesh
  123167. */
  123168. detach(): void;
  123169. /**
  123170. * Triggers the mesh to begin fading in or out
  123171. * @param value if the object should fade in or out (true to fade in)
  123172. */
  123173. fadeIn(value: boolean): void;
  123174. private _update;
  123175. private _setAllVisibility;
  123176. }
  123177. }
  123178. declare module BABYLON {
  123179. /**
  123180. * Class containing a set of static utilities functions for managing Pivots
  123181. * @hidden
  123182. */
  123183. export class PivotTools {
  123184. private static _PivotCached;
  123185. private static _OldPivotPoint;
  123186. private static _PivotTranslation;
  123187. private static _PivotTmpVector;
  123188. private static _PivotPostMultiplyPivotMatrix;
  123189. /** @hidden */
  123190. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123191. /** @hidden */
  123192. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123193. }
  123194. }
  123195. declare module BABYLON {
  123196. /**
  123197. * Class containing static functions to help procedurally build meshes
  123198. */
  123199. export class PlaneBuilder {
  123200. /**
  123201. * Creates a plane mesh
  123202. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123203. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123204. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123208. * @param name defines the name of the mesh
  123209. * @param options defines the options used to create the mesh
  123210. * @param scene defines the hosting scene
  123211. * @returns the plane mesh
  123212. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123213. */
  123214. static CreatePlane(name: string, options: {
  123215. size?: number;
  123216. width?: number;
  123217. height?: number;
  123218. sideOrientation?: number;
  123219. frontUVs?: Vector4;
  123220. backUVs?: Vector4;
  123221. updatable?: boolean;
  123222. sourcePlane?: Plane;
  123223. }, scene?: Nullable<Scene>): Mesh;
  123224. }
  123225. }
  123226. declare module BABYLON {
  123227. /**
  123228. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123229. */
  123230. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123231. private static _AnyMouseID;
  123232. /**
  123233. * Abstract mesh the behavior is set on
  123234. */
  123235. attachedNode: AbstractMesh;
  123236. private _dragPlane;
  123237. private _scene;
  123238. private _pointerObserver;
  123239. private _beforeRenderObserver;
  123240. private static _planeScene;
  123241. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123242. /**
  123243. * 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)
  123244. */
  123245. maxDragAngle: number;
  123246. /**
  123247. * @hidden
  123248. */
  123249. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123250. /**
  123251. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123252. */
  123253. currentDraggingPointerID: number;
  123254. /**
  123255. * The last position where the pointer hit the drag plane in world space
  123256. */
  123257. lastDragPosition: Vector3;
  123258. /**
  123259. * If the behavior is currently in a dragging state
  123260. */
  123261. dragging: boolean;
  123262. /**
  123263. * 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)
  123264. */
  123265. dragDeltaRatio: number;
  123266. /**
  123267. * If the drag plane orientation should be updated during the dragging (Default: true)
  123268. */
  123269. updateDragPlane: boolean;
  123270. private _debugMode;
  123271. private _moving;
  123272. /**
  123273. * Fires each time the attached mesh is dragged with the pointer
  123274. * * delta between last drag position and current drag position in world space
  123275. * * dragDistance along the drag axis
  123276. * * dragPlaneNormal normal of the current drag plane used during the drag
  123277. * * dragPlanePoint in world space where the drag intersects the drag plane
  123278. */
  123279. onDragObservable: Observable<{
  123280. delta: Vector3;
  123281. dragPlanePoint: Vector3;
  123282. dragPlaneNormal: Vector3;
  123283. dragDistance: number;
  123284. pointerId: number;
  123285. }>;
  123286. /**
  123287. * Fires each time a drag begins (eg. mouse down on mesh)
  123288. */
  123289. onDragStartObservable: Observable<{
  123290. dragPlanePoint: Vector3;
  123291. pointerId: number;
  123292. }>;
  123293. /**
  123294. * Fires each time a drag ends (eg. mouse release after drag)
  123295. */
  123296. onDragEndObservable: Observable<{
  123297. dragPlanePoint: Vector3;
  123298. pointerId: number;
  123299. }>;
  123300. /**
  123301. * If the attached mesh should be moved when dragged
  123302. */
  123303. moveAttached: boolean;
  123304. /**
  123305. * If the drag behavior will react to drag events (Default: true)
  123306. */
  123307. enabled: boolean;
  123308. /**
  123309. * If pointer events should start and release the drag (Default: true)
  123310. */
  123311. startAndReleaseDragOnPointerEvents: boolean;
  123312. /**
  123313. * If camera controls should be detached during the drag
  123314. */
  123315. detachCameraControls: boolean;
  123316. /**
  123317. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123318. */
  123319. useObjectOrientationForDragging: boolean;
  123320. private _options;
  123321. /**
  123322. * Gets the options used by the behavior
  123323. */
  123324. get options(): {
  123325. dragAxis?: Vector3;
  123326. dragPlaneNormal?: Vector3;
  123327. };
  123328. /**
  123329. * Sets the options used by the behavior
  123330. */
  123331. set options(options: {
  123332. dragAxis?: Vector3;
  123333. dragPlaneNormal?: Vector3;
  123334. });
  123335. /**
  123336. * Creates a pointer drag behavior that can be attached to a mesh
  123337. * @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)
  123338. */
  123339. constructor(options?: {
  123340. dragAxis?: Vector3;
  123341. dragPlaneNormal?: Vector3;
  123342. });
  123343. /**
  123344. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123345. */
  123346. validateDrag: (targetPosition: Vector3) => boolean;
  123347. /**
  123348. * The name of the behavior
  123349. */
  123350. get name(): string;
  123351. /**
  123352. * Initializes the behavior
  123353. */
  123354. init(): void;
  123355. private _tmpVector;
  123356. private _alternatePickedPoint;
  123357. private _worldDragAxis;
  123358. private _targetPosition;
  123359. private _attachedElement;
  123360. /**
  123361. * Attaches the drag behavior the passed in mesh
  123362. * @param ownerNode The mesh that will be dragged around once attached
  123363. * @param predicate Predicate to use for pick filtering
  123364. */
  123365. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123366. /**
  123367. * Force relase the drag action by code.
  123368. */
  123369. releaseDrag(): void;
  123370. private _startDragRay;
  123371. private _lastPointerRay;
  123372. /**
  123373. * Simulates the start of a pointer drag event on the behavior
  123374. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123375. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123376. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123377. */
  123378. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123379. private _startDrag;
  123380. private _dragDelta;
  123381. private _moveDrag;
  123382. private _pickWithRayOnDragPlane;
  123383. private _pointA;
  123384. private _pointC;
  123385. private _localAxis;
  123386. private _lookAt;
  123387. private _updateDragPlanePosition;
  123388. /**
  123389. * Detaches the behavior from the mesh
  123390. */
  123391. detach(): void;
  123392. }
  123393. }
  123394. declare module BABYLON {
  123395. /**
  123396. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123397. */
  123398. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123399. private _dragBehaviorA;
  123400. private _dragBehaviorB;
  123401. private _startDistance;
  123402. private _initialScale;
  123403. private _targetScale;
  123404. private _ownerNode;
  123405. private _sceneRenderObserver;
  123406. /**
  123407. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123408. */
  123409. constructor();
  123410. /**
  123411. * The name of the behavior
  123412. */
  123413. get name(): string;
  123414. /**
  123415. * Initializes the behavior
  123416. */
  123417. init(): void;
  123418. private _getCurrentDistance;
  123419. /**
  123420. * Attaches the scale behavior the passed in mesh
  123421. * @param ownerNode The mesh that will be scaled around once attached
  123422. */
  123423. attach(ownerNode: Mesh): void;
  123424. /**
  123425. * Detaches the behavior from the mesh
  123426. */
  123427. detach(): void;
  123428. }
  123429. }
  123430. declare module BABYLON {
  123431. /**
  123432. * 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
  123433. */
  123434. export class SixDofDragBehavior implements Behavior<Mesh> {
  123435. private static _virtualScene;
  123436. private _ownerNode;
  123437. private _sceneRenderObserver;
  123438. private _scene;
  123439. private _targetPosition;
  123440. private _virtualOriginMesh;
  123441. private _virtualDragMesh;
  123442. private _pointerObserver;
  123443. private _moving;
  123444. private _startingOrientation;
  123445. private _attachedElement;
  123446. /**
  123447. * 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)
  123448. */
  123449. private zDragFactor;
  123450. /**
  123451. * If the object should rotate to face the drag origin
  123452. */
  123453. rotateDraggedObject: boolean;
  123454. /**
  123455. * If the behavior is currently in a dragging state
  123456. */
  123457. dragging: boolean;
  123458. /**
  123459. * 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)
  123460. */
  123461. dragDeltaRatio: number;
  123462. /**
  123463. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123464. */
  123465. currentDraggingPointerID: number;
  123466. /**
  123467. * If camera controls should be detached during the drag
  123468. */
  123469. detachCameraControls: boolean;
  123470. /**
  123471. * Fires each time a drag starts
  123472. */
  123473. onDragStartObservable: Observable<{}>;
  123474. /**
  123475. * Fires each time a drag ends (eg. mouse release after drag)
  123476. */
  123477. onDragEndObservable: Observable<{}>;
  123478. /**
  123479. * 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
  123480. */
  123481. constructor();
  123482. /**
  123483. * The name of the behavior
  123484. */
  123485. get name(): string;
  123486. /**
  123487. * Initializes the behavior
  123488. */
  123489. init(): void;
  123490. /**
  123491. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  123492. */
  123493. private get _pointerCamera();
  123494. /**
  123495. * Attaches the scale behavior the passed in mesh
  123496. * @param ownerNode The mesh that will be scaled around once attached
  123497. */
  123498. attach(ownerNode: Mesh): void;
  123499. /**
  123500. * Detaches the behavior from the mesh
  123501. */
  123502. detach(): void;
  123503. }
  123504. }
  123505. declare module BABYLON {
  123506. /**
  123507. * Class used to apply inverse kinematics to bones
  123508. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  123509. */
  123510. export class BoneIKController {
  123511. private static _tmpVecs;
  123512. private static _tmpQuat;
  123513. private static _tmpMats;
  123514. /**
  123515. * Gets or sets the target mesh
  123516. */
  123517. targetMesh: AbstractMesh;
  123518. /** Gets or sets the mesh used as pole */
  123519. poleTargetMesh: AbstractMesh;
  123520. /**
  123521. * Gets or sets the bone used as pole
  123522. */
  123523. poleTargetBone: Nullable<Bone>;
  123524. /**
  123525. * Gets or sets the target position
  123526. */
  123527. targetPosition: Vector3;
  123528. /**
  123529. * Gets or sets the pole target position
  123530. */
  123531. poleTargetPosition: Vector3;
  123532. /**
  123533. * Gets or sets the pole target local offset
  123534. */
  123535. poleTargetLocalOffset: Vector3;
  123536. /**
  123537. * Gets or sets the pole angle
  123538. */
  123539. poleAngle: number;
  123540. /**
  123541. * Gets or sets the mesh associated with the controller
  123542. */
  123543. mesh: AbstractMesh;
  123544. /**
  123545. * 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)
  123546. */
  123547. slerpAmount: number;
  123548. private _bone1Quat;
  123549. private _bone1Mat;
  123550. private _bone2Ang;
  123551. private _bone1;
  123552. private _bone2;
  123553. private _bone1Length;
  123554. private _bone2Length;
  123555. private _maxAngle;
  123556. private _maxReach;
  123557. private _rightHandedSystem;
  123558. private _bendAxis;
  123559. private _slerping;
  123560. private _adjustRoll;
  123561. /**
  123562. * Gets or sets maximum allowed angle
  123563. */
  123564. get maxAngle(): number;
  123565. set maxAngle(value: number);
  123566. /**
  123567. * Creates a new BoneIKController
  123568. * @param mesh defines the mesh to control
  123569. * @param bone defines the bone to control
  123570. * @param options defines options to set up the controller
  123571. */
  123572. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  123573. targetMesh?: AbstractMesh;
  123574. poleTargetMesh?: AbstractMesh;
  123575. poleTargetBone?: Bone;
  123576. poleTargetLocalOffset?: Vector3;
  123577. poleAngle?: number;
  123578. bendAxis?: Vector3;
  123579. maxAngle?: number;
  123580. slerpAmount?: number;
  123581. });
  123582. private _setMaxAngle;
  123583. /**
  123584. * Force the controller to update the bones
  123585. */
  123586. update(): void;
  123587. }
  123588. }
  123589. declare module BABYLON {
  123590. /**
  123591. * Class used to make a bone look toward a point in space
  123592. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123593. */
  123594. export class BoneLookController {
  123595. private static _tmpVecs;
  123596. private static _tmpQuat;
  123597. private static _tmpMats;
  123598. /**
  123599. * The target Vector3 that the bone will look at
  123600. */
  123601. target: Vector3;
  123602. /**
  123603. * The mesh that the bone is attached to
  123604. */
  123605. mesh: AbstractMesh;
  123606. /**
  123607. * The bone that will be looking to the target
  123608. */
  123609. bone: Bone;
  123610. /**
  123611. * The up axis of the coordinate system that is used when the bone is rotated
  123612. */
  123613. upAxis: Vector3;
  123614. /**
  123615. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123616. */
  123617. upAxisSpace: Space;
  123618. /**
  123619. * Used to make an adjustment to the yaw of the bone
  123620. */
  123621. adjustYaw: number;
  123622. /**
  123623. * Used to make an adjustment to the pitch of the bone
  123624. */
  123625. adjustPitch: number;
  123626. /**
  123627. * Used to make an adjustment to the roll of the bone
  123628. */
  123629. adjustRoll: number;
  123630. /**
  123631. * 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)
  123632. */
  123633. slerpAmount: number;
  123634. private _minYaw;
  123635. private _maxYaw;
  123636. private _minPitch;
  123637. private _maxPitch;
  123638. private _minYawSin;
  123639. private _minYawCos;
  123640. private _maxYawSin;
  123641. private _maxYawCos;
  123642. private _midYawConstraint;
  123643. private _minPitchTan;
  123644. private _maxPitchTan;
  123645. private _boneQuat;
  123646. private _slerping;
  123647. private _transformYawPitch;
  123648. private _transformYawPitchInv;
  123649. private _firstFrameSkipped;
  123650. private _yawRange;
  123651. private _fowardAxis;
  123652. /**
  123653. * Gets or sets the minimum yaw angle that the bone can look to
  123654. */
  123655. get minYaw(): number;
  123656. set minYaw(value: number);
  123657. /**
  123658. * Gets or sets the maximum yaw angle that the bone can look to
  123659. */
  123660. get maxYaw(): number;
  123661. set maxYaw(value: number);
  123662. /**
  123663. * Gets or sets the minimum pitch angle that the bone can look to
  123664. */
  123665. get minPitch(): number;
  123666. set minPitch(value: number);
  123667. /**
  123668. * Gets or sets the maximum pitch angle that the bone can look to
  123669. */
  123670. get maxPitch(): number;
  123671. set maxPitch(value: number);
  123672. /**
  123673. * Create a BoneLookController
  123674. * @param mesh the mesh that the bone belongs to
  123675. * @param bone the bone that will be looking to the target
  123676. * @param target the target Vector3 to look at
  123677. * @param options optional settings:
  123678. * * maxYaw: the maximum angle the bone will yaw to
  123679. * * minYaw: the minimum angle the bone will yaw to
  123680. * * maxPitch: the maximum angle the bone will pitch to
  123681. * * minPitch: the minimum angle the bone will yaw to
  123682. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123683. * * upAxis: the up axis of the coordinate system
  123684. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123685. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123686. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123687. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123688. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123689. * * adjustRoll: used to make an adjustment to the roll of the bone
  123690. **/
  123691. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123692. maxYaw?: number;
  123693. minYaw?: number;
  123694. maxPitch?: number;
  123695. minPitch?: number;
  123696. slerpAmount?: number;
  123697. upAxis?: Vector3;
  123698. upAxisSpace?: Space;
  123699. yawAxis?: Vector3;
  123700. pitchAxis?: Vector3;
  123701. adjustYaw?: number;
  123702. adjustPitch?: number;
  123703. adjustRoll?: number;
  123704. });
  123705. /**
  123706. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123707. */
  123708. update(): void;
  123709. private _getAngleDiff;
  123710. private _getAngleBetween;
  123711. private _isAngleBetween;
  123712. }
  123713. }
  123714. declare module BABYLON {
  123715. /**
  123716. * Manage the gamepad inputs to control an arc rotate camera.
  123717. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123718. */
  123719. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  123720. /**
  123721. * Defines the camera the input is attached to.
  123722. */
  123723. camera: ArcRotateCamera;
  123724. /**
  123725. * Defines the gamepad the input is gathering event from.
  123726. */
  123727. gamepad: Nullable<Gamepad>;
  123728. /**
  123729. * Defines the gamepad rotation sensiblity.
  123730. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123731. */
  123732. gamepadRotationSensibility: number;
  123733. /**
  123734. * Defines the gamepad move sensiblity.
  123735. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123736. */
  123737. gamepadMoveSensibility: number;
  123738. private _yAxisScale;
  123739. /**
  123740. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123741. */
  123742. get invertYAxis(): boolean;
  123743. set invertYAxis(value: boolean);
  123744. private _onGamepadConnectedObserver;
  123745. private _onGamepadDisconnectedObserver;
  123746. /**
  123747. * Attach the input controls to a specific dom element to get the input from.
  123748. * @param element Defines the element the controls should be listened from
  123749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123750. */
  123751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123752. /**
  123753. * Detach the current controls from the specified dom element.
  123754. * @param element Defines the element to stop listening the inputs from
  123755. */
  123756. detachControl(element: Nullable<HTMLElement>): void;
  123757. /**
  123758. * Update the current camera state depending on the inputs that have been used this frame.
  123759. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123760. */
  123761. checkInputs(): void;
  123762. /**
  123763. * Gets the class name of the current intput.
  123764. * @returns the class name
  123765. */
  123766. getClassName(): string;
  123767. /**
  123768. * Get the friendly name associated with the input class.
  123769. * @returns the input friendly name
  123770. */
  123771. getSimpleName(): string;
  123772. }
  123773. }
  123774. declare module BABYLON {
  123775. interface ArcRotateCameraInputsManager {
  123776. /**
  123777. * Add orientation input support to the input manager.
  123778. * @returns the current input manager
  123779. */
  123780. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  123781. }
  123782. /**
  123783. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  123784. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123785. */
  123786. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  123787. /**
  123788. * Defines the camera the input is attached to.
  123789. */
  123790. camera: ArcRotateCamera;
  123791. /**
  123792. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  123793. */
  123794. alphaCorrection: number;
  123795. /**
  123796. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  123797. */
  123798. gammaCorrection: number;
  123799. private _alpha;
  123800. private _gamma;
  123801. private _dirty;
  123802. private _deviceOrientationHandler;
  123803. /**
  123804. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  123805. */
  123806. constructor();
  123807. /**
  123808. * Attach the input controls to a specific dom element to get the input from.
  123809. * @param element Defines the element the controls should be listened from
  123810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123811. */
  123812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123813. /** @hidden */
  123814. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  123815. /**
  123816. * Update the current camera state depending on the inputs that have been used this frame.
  123817. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123818. */
  123819. checkInputs(): void;
  123820. /**
  123821. * Detach the current controls from the specified dom element.
  123822. * @param element Defines the element to stop listening the inputs from
  123823. */
  123824. detachControl(element: Nullable<HTMLElement>): void;
  123825. /**
  123826. * Gets the class name of the current intput.
  123827. * @returns the class name
  123828. */
  123829. getClassName(): string;
  123830. /**
  123831. * Get the friendly name associated with the input class.
  123832. * @returns the input friendly name
  123833. */
  123834. getSimpleName(): string;
  123835. }
  123836. }
  123837. declare module BABYLON {
  123838. /**
  123839. * Listen to mouse events to control the camera.
  123840. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123841. */
  123842. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  123843. /**
  123844. * Defines the camera the input is attached to.
  123845. */
  123846. camera: FlyCamera;
  123847. /**
  123848. * Defines if touch is enabled. (Default is true.)
  123849. */
  123850. touchEnabled: boolean;
  123851. /**
  123852. * Defines the buttons associated with the input to handle camera rotation.
  123853. */
  123854. buttons: number[];
  123855. /**
  123856. * Assign buttons for Yaw control.
  123857. */
  123858. buttonsYaw: number[];
  123859. /**
  123860. * Assign buttons for Pitch control.
  123861. */
  123862. buttonsPitch: number[];
  123863. /**
  123864. * Assign buttons for Roll control.
  123865. */
  123866. buttonsRoll: number[];
  123867. /**
  123868. * Detect if any button is being pressed while mouse is moved.
  123869. * -1 = Mouse locked.
  123870. * 0 = Left button.
  123871. * 1 = Middle Button.
  123872. * 2 = Right Button.
  123873. */
  123874. activeButton: number;
  123875. /**
  123876. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  123877. * Higher values reduce its sensitivity.
  123878. */
  123879. angularSensibility: number;
  123880. private _mousemoveCallback;
  123881. private _observer;
  123882. private _rollObserver;
  123883. private previousPosition;
  123884. private noPreventDefault;
  123885. private element;
  123886. /**
  123887. * Listen to mouse events to control the camera.
  123888. * @param touchEnabled Define if touch is enabled. (Default is true.)
  123889. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123890. */
  123891. constructor(touchEnabled?: boolean);
  123892. /**
  123893. * Attach the mouse control to the HTML DOM element.
  123894. * @param element Defines the element that listens to the input events.
  123895. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  123896. */
  123897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123898. /**
  123899. * Detach the current controls from the specified dom element.
  123900. * @param element Defines the element to stop listening the inputs from
  123901. */
  123902. detachControl(element: Nullable<HTMLElement>): void;
  123903. /**
  123904. * Gets the class name of the current input.
  123905. * @returns the class name.
  123906. */
  123907. getClassName(): string;
  123908. /**
  123909. * Get the friendly name associated with the input class.
  123910. * @returns the input's friendly name.
  123911. */
  123912. getSimpleName(): string;
  123913. private _pointerInput;
  123914. private _onMouseMove;
  123915. /**
  123916. * Rotate camera by mouse offset.
  123917. */
  123918. private rotateCamera;
  123919. }
  123920. }
  123921. declare module BABYLON {
  123922. /**
  123923. * Default Inputs manager for the FlyCamera.
  123924. * It groups all the default supported inputs for ease of use.
  123925. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123926. */
  123927. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  123928. /**
  123929. * Instantiates a new FlyCameraInputsManager.
  123930. * @param camera Defines the camera the inputs belong to.
  123931. */
  123932. constructor(camera: FlyCamera);
  123933. /**
  123934. * Add keyboard input support to the input manager.
  123935. * @returns the new FlyCameraKeyboardMoveInput().
  123936. */
  123937. addKeyboard(): FlyCameraInputsManager;
  123938. /**
  123939. * Add mouse input support to the input manager.
  123940. * @param touchEnabled Enable touch screen support.
  123941. * @returns the new FlyCameraMouseInput().
  123942. */
  123943. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  123944. }
  123945. }
  123946. declare module BABYLON {
  123947. /**
  123948. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123949. * such as in a 3D Space Shooter or a Flight Simulator.
  123950. */
  123951. export class FlyCamera extends TargetCamera {
  123952. /**
  123953. * Define the collision ellipsoid of the camera.
  123954. * This is helpful for simulating a camera body, like a player's body.
  123955. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123956. */
  123957. ellipsoid: Vector3;
  123958. /**
  123959. * Define an offset for the position of the ellipsoid around the camera.
  123960. * This can be helpful if the camera is attached away from the player's body center,
  123961. * such as at its head.
  123962. */
  123963. ellipsoidOffset: Vector3;
  123964. /**
  123965. * Enable or disable collisions of the camera with the rest of the scene objects.
  123966. */
  123967. checkCollisions: boolean;
  123968. /**
  123969. * Enable or disable gravity on the camera.
  123970. */
  123971. applyGravity: boolean;
  123972. /**
  123973. * Define the current direction the camera is moving to.
  123974. */
  123975. cameraDirection: Vector3;
  123976. /**
  123977. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  123978. * This overrides and empties cameraRotation.
  123979. */
  123980. rotationQuaternion: Quaternion;
  123981. /**
  123982. * Track Roll to maintain the wanted Rolling when looking around.
  123983. */
  123984. _trackRoll: number;
  123985. /**
  123986. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  123987. */
  123988. rollCorrect: number;
  123989. /**
  123990. * Mimic a banked turn, Rolling the camera when Yawing.
  123991. * It's recommended to use rollCorrect = 10 for faster banking correction.
  123992. */
  123993. bankedTurn: boolean;
  123994. /**
  123995. * Limit in radians for how much Roll banking will add. (Default: 90°)
  123996. */
  123997. bankedTurnLimit: number;
  123998. /**
  123999. * Value of 0 disables the banked Roll.
  124000. * Value of 1 is equal to the Yaw angle in radians.
  124001. */
  124002. bankedTurnMultiplier: number;
  124003. /**
  124004. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124005. */
  124006. inputs: FlyCameraInputsManager;
  124007. /**
  124008. * Gets the input sensibility for mouse input.
  124009. * Higher values reduce sensitivity.
  124010. */
  124011. get angularSensibility(): number;
  124012. /**
  124013. * Sets the input sensibility for a mouse input.
  124014. * Higher values reduce sensitivity.
  124015. */
  124016. set angularSensibility(value: number);
  124017. /**
  124018. * Get the keys for camera movement forward.
  124019. */
  124020. get keysForward(): number[];
  124021. /**
  124022. * Set the keys for camera movement forward.
  124023. */
  124024. set keysForward(value: number[]);
  124025. /**
  124026. * Get the keys for camera movement backward.
  124027. */
  124028. get keysBackward(): number[];
  124029. set keysBackward(value: number[]);
  124030. /**
  124031. * Get the keys for camera movement up.
  124032. */
  124033. get keysUp(): number[];
  124034. /**
  124035. * Set the keys for camera movement up.
  124036. */
  124037. set keysUp(value: number[]);
  124038. /**
  124039. * Get the keys for camera movement down.
  124040. */
  124041. get keysDown(): number[];
  124042. /**
  124043. * Set the keys for camera movement down.
  124044. */
  124045. set keysDown(value: number[]);
  124046. /**
  124047. * Get the keys for camera movement left.
  124048. */
  124049. get keysLeft(): number[];
  124050. /**
  124051. * Set the keys for camera movement left.
  124052. */
  124053. set keysLeft(value: number[]);
  124054. /**
  124055. * Set the keys for camera movement right.
  124056. */
  124057. get keysRight(): number[];
  124058. /**
  124059. * Set the keys for camera movement right.
  124060. */
  124061. set keysRight(value: number[]);
  124062. /**
  124063. * Event raised when the camera collides with a mesh in the scene.
  124064. */
  124065. onCollide: (collidedMesh: AbstractMesh) => void;
  124066. private _collider;
  124067. private _needMoveForGravity;
  124068. private _oldPosition;
  124069. private _diffPosition;
  124070. private _newPosition;
  124071. /** @hidden */
  124072. _localDirection: Vector3;
  124073. /** @hidden */
  124074. _transformedDirection: Vector3;
  124075. /**
  124076. * Instantiates a FlyCamera.
  124077. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124078. * such as in a 3D Space Shooter or a Flight Simulator.
  124079. * @param name Define the name of the camera in the scene.
  124080. * @param position Define the starting position of the camera in the scene.
  124081. * @param scene Define the scene the camera belongs to.
  124082. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124083. */
  124084. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124085. /**
  124086. * Attach a control to the HTML DOM element.
  124087. * @param element Defines the element that listens to the input events.
  124088. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124089. */
  124090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124091. /**
  124092. * Detach a control from the HTML DOM element.
  124093. * The camera will stop reacting to that input.
  124094. * @param element Defines the element that listens to the input events.
  124095. */
  124096. detachControl(element: HTMLElement): void;
  124097. private _collisionMask;
  124098. /**
  124099. * Get the mask that the camera ignores in collision events.
  124100. */
  124101. get collisionMask(): number;
  124102. /**
  124103. * Set the mask that the camera ignores in collision events.
  124104. */
  124105. set collisionMask(mask: number);
  124106. /** @hidden */
  124107. _collideWithWorld(displacement: Vector3): void;
  124108. /** @hidden */
  124109. private _onCollisionPositionChange;
  124110. /** @hidden */
  124111. _checkInputs(): void;
  124112. /** @hidden */
  124113. _decideIfNeedsToMove(): boolean;
  124114. /** @hidden */
  124115. _updatePosition(): void;
  124116. /**
  124117. * Restore the Roll to its target value at the rate specified.
  124118. * @param rate - Higher means slower restoring.
  124119. * @hidden
  124120. */
  124121. restoreRoll(rate: number): void;
  124122. /**
  124123. * Destroy the camera and release the current resources held by it.
  124124. */
  124125. dispose(): void;
  124126. /**
  124127. * Get the current object class name.
  124128. * @returns the class name.
  124129. */
  124130. getClassName(): string;
  124131. }
  124132. }
  124133. declare module BABYLON {
  124134. /**
  124135. * Listen to keyboard events to control the camera.
  124136. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124137. */
  124138. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124139. /**
  124140. * Defines the camera the input is attached to.
  124141. */
  124142. camera: FlyCamera;
  124143. /**
  124144. * The list of keyboard keys used to control the forward move of the camera.
  124145. */
  124146. keysForward: number[];
  124147. /**
  124148. * The list of keyboard keys used to control the backward move of the camera.
  124149. */
  124150. keysBackward: number[];
  124151. /**
  124152. * The list of keyboard keys used to control the forward move of the camera.
  124153. */
  124154. keysUp: number[];
  124155. /**
  124156. * The list of keyboard keys used to control the backward move of the camera.
  124157. */
  124158. keysDown: number[];
  124159. /**
  124160. * The list of keyboard keys used to control the right strafe move of the camera.
  124161. */
  124162. keysRight: number[];
  124163. /**
  124164. * The list of keyboard keys used to control the left strafe move of the camera.
  124165. */
  124166. keysLeft: number[];
  124167. private _keys;
  124168. private _onCanvasBlurObserver;
  124169. private _onKeyboardObserver;
  124170. private _engine;
  124171. private _scene;
  124172. /**
  124173. * Attach the input controls to a specific dom element to get the input from.
  124174. * @param element Defines the element the controls should be listened from
  124175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124176. */
  124177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124178. /**
  124179. * Detach the current controls from the specified dom element.
  124180. * @param element Defines the element to stop listening the inputs from
  124181. */
  124182. detachControl(element: Nullable<HTMLElement>): void;
  124183. /**
  124184. * Gets the class name of the current intput.
  124185. * @returns the class name
  124186. */
  124187. getClassName(): string;
  124188. /** @hidden */
  124189. _onLostFocus(e: FocusEvent): void;
  124190. /**
  124191. * Get the friendly name associated with the input class.
  124192. * @returns the input friendly name
  124193. */
  124194. getSimpleName(): string;
  124195. /**
  124196. * Update the current camera state depending on the inputs that have been used this frame.
  124197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124198. */
  124199. checkInputs(): void;
  124200. }
  124201. }
  124202. declare module BABYLON {
  124203. /**
  124204. * Manage the mouse wheel inputs to control a follow camera.
  124205. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124206. */
  124207. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124208. /**
  124209. * Defines the camera the input is attached to.
  124210. */
  124211. camera: FollowCamera;
  124212. /**
  124213. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124214. */
  124215. axisControlRadius: boolean;
  124216. /**
  124217. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124218. */
  124219. axisControlHeight: boolean;
  124220. /**
  124221. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124222. */
  124223. axisControlRotation: boolean;
  124224. /**
  124225. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124226. * relation to mouseWheel events.
  124227. */
  124228. wheelPrecision: number;
  124229. /**
  124230. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124231. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124232. */
  124233. wheelDeltaPercentage: number;
  124234. private _wheel;
  124235. private _observer;
  124236. /**
  124237. * Attach the input controls to a specific dom element to get the input from.
  124238. * @param element Defines the element the controls should be listened from
  124239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124240. */
  124241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124242. /**
  124243. * Detach the current controls from the specified dom element.
  124244. * @param element Defines the element to stop listening the inputs from
  124245. */
  124246. detachControl(element: Nullable<HTMLElement>): void;
  124247. /**
  124248. * Gets the class name of the current intput.
  124249. * @returns the class name
  124250. */
  124251. getClassName(): string;
  124252. /**
  124253. * Get the friendly name associated with the input class.
  124254. * @returns the input friendly name
  124255. */
  124256. getSimpleName(): string;
  124257. }
  124258. }
  124259. declare module BABYLON {
  124260. /**
  124261. * Manage the pointers inputs to control an follow camera.
  124262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124263. */
  124264. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124265. /**
  124266. * Defines the camera the input is attached to.
  124267. */
  124268. camera: FollowCamera;
  124269. /**
  124270. * Gets the class name of the current input.
  124271. * @returns the class name
  124272. */
  124273. getClassName(): string;
  124274. /**
  124275. * Defines the pointer angular sensibility along the X axis or how fast is
  124276. * the camera rotating.
  124277. * A negative number will reverse the axis direction.
  124278. */
  124279. angularSensibilityX: number;
  124280. /**
  124281. * Defines the pointer angular sensibility along the Y axis or how fast is
  124282. * the camera rotating.
  124283. * A negative number will reverse the axis direction.
  124284. */
  124285. angularSensibilityY: number;
  124286. /**
  124287. * Defines the pointer pinch precision or how fast is the camera zooming.
  124288. * A negative number will reverse the axis direction.
  124289. */
  124290. pinchPrecision: number;
  124291. /**
  124292. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124293. * from 0.
  124294. * It defines the percentage of current camera.radius to use as delta when
  124295. * pinch zoom is used.
  124296. */
  124297. pinchDeltaPercentage: number;
  124298. /**
  124299. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124300. */
  124301. axisXControlRadius: boolean;
  124302. /**
  124303. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124304. */
  124305. axisXControlHeight: boolean;
  124306. /**
  124307. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124308. */
  124309. axisXControlRotation: boolean;
  124310. /**
  124311. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124312. */
  124313. axisYControlRadius: boolean;
  124314. /**
  124315. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124316. */
  124317. axisYControlHeight: boolean;
  124318. /**
  124319. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124320. */
  124321. axisYControlRotation: boolean;
  124322. /**
  124323. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124324. */
  124325. axisPinchControlRadius: boolean;
  124326. /**
  124327. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124328. */
  124329. axisPinchControlHeight: boolean;
  124330. /**
  124331. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124332. */
  124333. axisPinchControlRotation: boolean;
  124334. /**
  124335. * Log error messages if basic misconfiguration has occurred.
  124336. */
  124337. warningEnable: boolean;
  124338. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124339. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124340. private _warningCounter;
  124341. private _warning;
  124342. }
  124343. }
  124344. declare module BABYLON {
  124345. /**
  124346. * Default Inputs manager for the FollowCamera.
  124347. * It groups all the default supported inputs for ease of use.
  124348. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124349. */
  124350. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124351. /**
  124352. * Instantiates a new FollowCameraInputsManager.
  124353. * @param camera Defines the camera the inputs belong to
  124354. */
  124355. constructor(camera: FollowCamera);
  124356. /**
  124357. * Add keyboard input support to the input manager.
  124358. * @returns the current input manager
  124359. */
  124360. addKeyboard(): FollowCameraInputsManager;
  124361. /**
  124362. * Add mouse wheel input support to the input manager.
  124363. * @returns the current input manager
  124364. */
  124365. addMouseWheel(): FollowCameraInputsManager;
  124366. /**
  124367. * Add pointers input support to the input manager.
  124368. * @returns the current input manager
  124369. */
  124370. addPointers(): FollowCameraInputsManager;
  124371. /**
  124372. * Add orientation input support to the input manager.
  124373. * @returns the current input manager
  124374. */
  124375. addVRDeviceOrientation(): FollowCameraInputsManager;
  124376. }
  124377. }
  124378. declare module BABYLON {
  124379. /**
  124380. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124381. * an arc rotate version arcFollowCamera are available.
  124382. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124383. */
  124384. export class FollowCamera extends TargetCamera {
  124385. /**
  124386. * Distance the follow camera should follow an object at
  124387. */
  124388. radius: number;
  124389. /**
  124390. * Minimum allowed distance of the camera to the axis of rotation
  124391. * (The camera can not get closer).
  124392. * This can help limiting how the Camera is able to move in the scene.
  124393. */
  124394. lowerRadiusLimit: Nullable<number>;
  124395. /**
  124396. * Maximum allowed distance of the camera to the axis of rotation
  124397. * (The camera can not get further).
  124398. * This can help limiting how the Camera is able to move in the scene.
  124399. */
  124400. upperRadiusLimit: Nullable<number>;
  124401. /**
  124402. * Define a rotation offset between the camera and the object it follows
  124403. */
  124404. rotationOffset: number;
  124405. /**
  124406. * Minimum allowed angle to camera position relative to target object.
  124407. * This can help limiting how the Camera is able to move in the scene.
  124408. */
  124409. lowerRotationOffsetLimit: Nullable<number>;
  124410. /**
  124411. * Maximum allowed angle to camera position relative to target object.
  124412. * This can help limiting how the Camera is able to move in the scene.
  124413. */
  124414. upperRotationOffsetLimit: Nullable<number>;
  124415. /**
  124416. * Define a height offset between the camera and the object it follows.
  124417. * It can help following an object from the top (like a car chaing a plane)
  124418. */
  124419. heightOffset: number;
  124420. /**
  124421. * Minimum allowed height of camera position relative to target object.
  124422. * This can help limiting how the Camera is able to move in the scene.
  124423. */
  124424. lowerHeightOffsetLimit: Nullable<number>;
  124425. /**
  124426. * Maximum allowed height of camera position relative to target object.
  124427. * This can help limiting how the Camera is able to move in the scene.
  124428. */
  124429. upperHeightOffsetLimit: Nullable<number>;
  124430. /**
  124431. * Define how fast the camera can accelerate to follow it s target.
  124432. */
  124433. cameraAcceleration: number;
  124434. /**
  124435. * Define the speed limit of the camera following an object.
  124436. */
  124437. maxCameraSpeed: number;
  124438. /**
  124439. * Define the target of the camera.
  124440. */
  124441. lockedTarget: Nullable<AbstractMesh>;
  124442. /**
  124443. * Defines the input associated with the camera.
  124444. */
  124445. inputs: FollowCameraInputsManager;
  124446. /**
  124447. * Instantiates the follow camera.
  124448. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124449. * @param name Define the name of the camera in the scene
  124450. * @param position Define the position of the camera
  124451. * @param scene Define the scene the camera belong to
  124452. * @param lockedTarget Define the target of the camera
  124453. */
  124454. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  124455. private _follow;
  124456. /**
  124457. * Attached controls to the current camera.
  124458. * @param element Defines the element the controls should be listened from
  124459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124460. */
  124461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124462. /**
  124463. * Detach the current controls from the camera.
  124464. * The camera will stop reacting to inputs.
  124465. * @param element Defines the element to stop listening the inputs from
  124466. */
  124467. detachControl(element: HTMLElement): void;
  124468. /** @hidden */
  124469. _checkInputs(): void;
  124470. private _checkLimits;
  124471. /**
  124472. * Gets the camera class name.
  124473. * @returns the class name
  124474. */
  124475. getClassName(): string;
  124476. }
  124477. /**
  124478. * Arc Rotate version of the follow camera.
  124479. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  124480. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124481. */
  124482. export class ArcFollowCamera extends TargetCamera {
  124483. /** The longitudinal angle of the camera */
  124484. alpha: number;
  124485. /** The latitudinal angle of the camera */
  124486. beta: number;
  124487. /** The radius of the camera from its target */
  124488. radius: number;
  124489. private _cartesianCoordinates;
  124490. /** Define the camera target (the mesh it should follow) */
  124491. private _meshTarget;
  124492. /**
  124493. * Instantiates a new ArcFollowCamera
  124494. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124495. * @param name Define the name of the camera
  124496. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  124497. * @param beta Define the rotation angle of the camera around the elevation axis
  124498. * @param radius Define the radius of the camera from its target point
  124499. * @param target Define the target of the camera
  124500. * @param scene Define the scene the camera belongs to
  124501. */
  124502. constructor(name: string,
  124503. /** The longitudinal angle of the camera */
  124504. alpha: number,
  124505. /** The latitudinal angle of the camera */
  124506. beta: number,
  124507. /** The radius of the camera from its target */
  124508. radius: number,
  124509. /** Define the camera target (the mesh it should follow) */
  124510. target: Nullable<AbstractMesh>, scene: Scene);
  124511. private _follow;
  124512. /** @hidden */
  124513. _checkInputs(): void;
  124514. /**
  124515. * Returns the class name of the object.
  124516. * It is mostly used internally for serialization purposes.
  124517. */
  124518. getClassName(): string;
  124519. }
  124520. }
  124521. declare module BABYLON {
  124522. /**
  124523. * Manage the keyboard inputs to control the movement of a follow camera.
  124524. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124525. */
  124526. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  124527. /**
  124528. * Defines the camera the input is attached to.
  124529. */
  124530. camera: FollowCamera;
  124531. /**
  124532. * Defines the list of key codes associated with the up action (increase heightOffset)
  124533. */
  124534. keysHeightOffsetIncr: number[];
  124535. /**
  124536. * Defines the list of key codes associated with the down action (decrease heightOffset)
  124537. */
  124538. keysHeightOffsetDecr: number[];
  124539. /**
  124540. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  124541. */
  124542. keysHeightOffsetModifierAlt: boolean;
  124543. /**
  124544. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  124545. */
  124546. keysHeightOffsetModifierCtrl: boolean;
  124547. /**
  124548. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  124549. */
  124550. keysHeightOffsetModifierShift: boolean;
  124551. /**
  124552. * Defines the list of key codes associated with the left action (increase rotationOffset)
  124553. */
  124554. keysRotationOffsetIncr: number[];
  124555. /**
  124556. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  124557. */
  124558. keysRotationOffsetDecr: number[];
  124559. /**
  124560. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  124561. */
  124562. keysRotationOffsetModifierAlt: boolean;
  124563. /**
  124564. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  124565. */
  124566. keysRotationOffsetModifierCtrl: boolean;
  124567. /**
  124568. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  124569. */
  124570. keysRotationOffsetModifierShift: boolean;
  124571. /**
  124572. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  124573. */
  124574. keysRadiusIncr: number[];
  124575. /**
  124576. * Defines the list of key codes associated with the zoom-out action (increase radius)
  124577. */
  124578. keysRadiusDecr: number[];
  124579. /**
  124580. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124581. */
  124582. keysRadiusModifierAlt: boolean;
  124583. /**
  124584. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124585. */
  124586. keysRadiusModifierCtrl: boolean;
  124587. /**
  124588. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124589. */
  124590. keysRadiusModifierShift: boolean;
  124591. /**
  124592. * Defines the rate of change of heightOffset.
  124593. */
  124594. heightSensibility: number;
  124595. /**
  124596. * Defines the rate of change of rotationOffset.
  124597. */
  124598. rotationSensibility: number;
  124599. /**
  124600. * Defines the rate of change of radius.
  124601. */
  124602. radiusSensibility: number;
  124603. private _keys;
  124604. private _ctrlPressed;
  124605. private _altPressed;
  124606. private _shiftPressed;
  124607. private _onCanvasBlurObserver;
  124608. private _onKeyboardObserver;
  124609. private _engine;
  124610. private _scene;
  124611. /**
  124612. * Attach the input controls to a specific dom element to get the input from.
  124613. * @param element Defines the element the controls should be listened from
  124614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124615. */
  124616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124617. /**
  124618. * Detach the current controls from the specified dom element.
  124619. * @param element Defines the element to stop listening the inputs from
  124620. */
  124621. detachControl(element: Nullable<HTMLElement>): void;
  124622. /**
  124623. * Update the current camera state depending on the inputs that have been used this frame.
  124624. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124625. */
  124626. checkInputs(): void;
  124627. /**
  124628. * Gets the class name of the current input.
  124629. * @returns the class name
  124630. */
  124631. getClassName(): string;
  124632. /**
  124633. * Get the friendly name associated with the input class.
  124634. * @returns the input friendly name
  124635. */
  124636. getSimpleName(): string;
  124637. /**
  124638. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124639. * allow modification of the heightOffset value.
  124640. */
  124641. private _modifierHeightOffset;
  124642. /**
  124643. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124644. * allow modification of the rotationOffset value.
  124645. */
  124646. private _modifierRotationOffset;
  124647. /**
  124648. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124649. * allow modification of the radius value.
  124650. */
  124651. private _modifierRadius;
  124652. }
  124653. }
  124654. declare module BABYLON {
  124655. interface FreeCameraInputsManager {
  124656. /**
  124657. * @hidden
  124658. */
  124659. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124660. /**
  124661. * Add orientation input support to the input manager.
  124662. * @returns the current input manager
  124663. */
  124664. addDeviceOrientation(): FreeCameraInputsManager;
  124665. }
  124666. /**
  124667. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124668. * Screen rotation is taken into account.
  124669. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124670. */
  124671. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124672. private _camera;
  124673. private _screenOrientationAngle;
  124674. private _constantTranform;
  124675. private _screenQuaternion;
  124676. private _alpha;
  124677. private _beta;
  124678. private _gamma;
  124679. /**
  124680. * Can be used to detect if a device orientation sensor is available on a device
  124681. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124682. * @returns a promise that will resolve on orientation change
  124683. */
  124684. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124685. /**
  124686. * @hidden
  124687. */
  124688. _onDeviceOrientationChangedObservable: Observable<void>;
  124689. /**
  124690. * Instantiates a new input
  124691. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124692. */
  124693. constructor();
  124694. /**
  124695. * Define the camera controlled by the input.
  124696. */
  124697. get camera(): FreeCamera;
  124698. set camera(camera: FreeCamera);
  124699. /**
  124700. * Attach the input controls to a specific dom element to get the input from.
  124701. * @param element Defines the element the controls should be listened from
  124702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124703. */
  124704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124705. private _orientationChanged;
  124706. private _deviceOrientation;
  124707. /**
  124708. * Detach the current controls from the specified dom element.
  124709. * @param element Defines the element to stop listening the inputs from
  124710. */
  124711. detachControl(element: Nullable<HTMLElement>): void;
  124712. /**
  124713. * Update the current camera state depending on the inputs that have been used this frame.
  124714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124715. */
  124716. checkInputs(): void;
  124717. /**
  124718. * Gets the class name of the current intput.
  124719. * @returns the class name
  124720. */
  124721. getClassName(): string;
  124722. /**
  124723. * Get the friendly name associated with the input class.
  124724. * @returns the input friendly name
  124725. */
  124726. getSimpleName(): string;
  124727. }
  124728. }
  124729. declare module BABYLON {
  124730. /**
  124731. * Manage the gamepad inputs to control a free camera.
  124732. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124733. */
  124734. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  124735. /**
  124736. * Define the camera the input is attached to.
  124737. */
  124738. camera: FreeCamera;
  124739. /**
  124740. * Define the Gamepad controlling the input
  124741. */
  124742. gamepad: Nullable<Gamepad>;
  124743. /**
  124744. * Defines the gamepad rotation sensiblity.
  124745. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124746. */
  124747. gamepadAngularSensibility: number;
  124748. /**
  124749. * Defines the gamepad move sensiblity.
  124750. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124751. */
  124752. gamepadMoveSensibility: number;
  124753. private _yAxisScale;
  124754. /**
  124755. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124756. */
  124757. get invertYAxis(): boolean;
  124758. set invertYAxis(value: boolean);
  124759. private _onGamepadConnectedObserver;
  124760. private _onGamepadDisconnectedObserver;
  124761. private _cameraTransform;
  124762. private _deltaTransform;
  124763. private _vector3;
  124764. private _vector2;
  124765. /**
  124766. * Attach the input controls to a specific dom element to get the input from.
  124767. * @param element Defines the element the controls should be listened from
  124768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124769. */
  124770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124771. /**
  124772. * Detach the current controls from the specified dom element.
  124773. * @param element Defines the element to stop listening the inputs from
  124774. */
  124775. detachControl(element: Nullable<HTMLElement>): void;
  124776. /**
  124777. * Update the current camera state depending on the inputs that have been used this frame.
  124778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124779. */
  124780. checkInputs(): void;
  124781. /**
  124782. * Gets the class name of the current intput.
  124783. * @returns the class name
  124784. */
  124785. getClassName(): string;
  124786. /**
  124787. * Get the friendly name associated with the input class.
  124788. * @returns the input friendly name
  124789. */
  124790. getSimpleName(): string;
  124791. }
  124792. }
  124793. declare module BABYLON {
  124794. /**
  124795. * Defines the potential axis of a Joystick
  124796. */
  124797. export enum JoystickAxis {
  124798. /** X axis */
  124799. X = 0,
  124800. /** Y axis */
  124801. Y = 1,
  124802. /** Z axis */
  124803. Z = 2
  124804. }
  124805. /**
  124806. * Represents the different customization options available
  124807. * for VirtualJoystick
  124808. */
  124809. interface VirtualJoystickCustomizations {
  124810. /**
  124811. * Size of the joystick's puck
  124812. */
  124813. puckSize: number;
  124814. /**
  124815. * Size of the joystick's container
  124816. */
  124817. containerSize: number;
  124818. /**
  124819. * Color of the joystick && puck
  124820. */
  124821. color: string;
  124822. /**
  124823. * Image URL for the joystick's puck
  124824. */
  124825. puckImage?: string;
  124826. /**
  124827. * Image URL for the joystick's container
  124828. */
  124829. containerImage?: string;
  124830. /**
  124831. * Defines the unmoving position of the joystick container
  124832. */
  124833. position?: {
  124834. x: number;
  124835. y: number;
  124836. };
  124837. /**
  124838. * Defines whether or not the joystick container is always visible
  124839. */
  124840. alwaysVisible: boolean;
  124841. /**
  124842. * Defines whether or not to limit the movement of the puck to the joystick's container
  124843. */
  124844. limitToContainer: boolean;
  124845. }
  124846. /**
  124847. * Class used to define virtual joystick (used in touch mode)
  124848. */
  124849. export class VirtualJoystick {
  124850. /**
  124851. * Gets or sets a boolean indicating that left and right values must be inverted
  124852. */
  124853. reverseLeftRight: boolean;
  124854. /**
  124855. * Gets or sets a boolean indicating that up and down values must be inverted
  124856. */
  124857. reverseUpDown: boolean;
  124858. /**
  124859. * Gets the offset value for the position (ie. the change of the position value)
  124860. */
  124861. deltaPosition: Vector3;
  124862. /**
  124863. * Gets a boolean indicating if the virtual joystick was pressed
  124864. */
  124865. pressed: boolean;
  124866. /**
  124867. * Canvas the virtual joystick will render onto, default z-index of this is 5
  124868. */
  124869. static Canvas: Nullable<HTMLCanvasElement>;
  124870. /**
  124871. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  124872. */
  124873. limitToContainer: boolean;
  124874. private static _globalJoystickIndex;
  124875. private static _alwaysVisibleSticks;
  124876. private static vjCanvasContext;
  124877. private static vjCanvasWidth;
  124878. private static vjCanvasHeight;
  124879. private static halfWidth;
  124880. private static _GetDefaultOptions;
  124881. private _action;
  124882. private _axisTargetedByLeftAndRight;
  124883. private _axisTargetedByUpAndDown;
  124884. private _joystickSensibility;
  124885. private _inversedSensibility;
  124886. private _joystickPointerID;
  124887. private _joystickColor;
  124888. private _joystickPointerPos;
  124889. private _joystickPreviousPointerPos;
  124890. private _joystickPointerStartPos;
  124891. private _deltaJoystickVector;
  124892. private _leftJoystick;
  124893. private _touches;
  124894. private _joystickPosition;
  124895. private _alwaysVisible;
  124896. private _puckImage;
  124897. private _containerImage;
  124898. private _joystickPuckSize;
  124899. private _joystickContainerSize;
  124900. private _clearPuckSize;
  124901. private _clearContainerSize;
  124902. private _clearPuckSizeOffset;
  124903. private _clearContainerSizeOffset;
  124904. private _onPointerDownHandlerRef;
  124905. private _onPointerMoveHandlerRef;
  124906. private _onPointerUpHandlerRef;
  124907. private _onResize;
  124908. /**
  124909. * Creates a new virtual joystick
  124910. * @param leftJoystick defines that the joystick is for left hand (false by default)
  124911. * @param customizations Defines the options we want to customize the VirtualJoystick
  124912. */
  124913. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  124914. /**
  124915. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  124916. * @param newJoystickSensibility defines the new sensibility
  124917. */
  124918. setJoystickSensibility(newJoystickSensibility: number): void;
  124919. private _onPointerDown;
  124920. private _onPointerMove;
  124921. private _onPointerUp;
  124922. /**
  124923. * Change the color of the virtual joystick
  124924. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  124925. */
  124926. setJoystickColor(newColor: string): void;
  124927. /**
  124928. * Size of the joystick's container
  124929. */
  124930. set containerSize(newSize: number);
  124931. get containerSize(): number;
  124932. /**
  124933. * Size of the joystick's puck
  124934. */
  124935. set puckSize(newSize: number);
  124936. get puckSize(): number;
  124937. /**
  124938. * Clears the set position of the joystick
  124939. */
  124940. clearPosition(): void;
  124941. /**
  124942. * Defines whether or not the joystick container is always visible
  124943. */
  124944. set alwaysVisible(value: boolean);
  124945. get alwaysVisible(): boolean;
  124946. /**
  124947. * Sets the constant position of the Joystick container
  124948. * @param x X axis coordinate
  124949. * @param y Y axis coordinate
  124950. */
  124951. setPosition(x: number, y: number): void;
  124952. /**
  124953. * Defines a callback to call when the joystick is touched
  124954. * @param action defines the callback
  124955. */
  124956. setActionOnTouch(action: () => any): void;
  124957. /**
  124958. * Defines which axis you'd like to control for left & right
  124959. * @param axis defines the axis to use
  124960. */
  124961. setAxisForLeftRight(axis: JoystickAxis): void;
  124962. /**
  124963. * Defines which axis you'd like to control for up & down
  124964. * @param axis defines the axis to use
  124965. */
  124966. setAxisForUpDown(axis: JoystickAxis): void;
  124967. /**
  124968. * Clears the canvas from the previous puck / container draw
  124969. */
  124970. private _clearPreviousDraw;
  124971. /**
  124972. * Loads `urlPath` to be used for the container's image
  124973. * @param urlPath defines the urlPath of an image to use
  124974. */
  124975. setContainerImage(urlPath: string): void;
  124976. /**
  124977. * Loads `urlPath` to be used for the puck's image
  124978. * @param urlPath defines the urlPath of an image to use
  124979. */
  124980. setPuckImage(urlPath: string): void;
  124981. /**
  124982. * Draws the Virtual Joystick's container
  124983. */
  124984. private _drawContainer;
  124985. /**
  124986. * Draws the Virtual Joystick's puck
  124987. */
  124988. private _drawPuck;
  124989. private _drawVirtualJoystick;
  124990. /**
  124991. * Release internal HTML canvas
  124992. */
  124993. releaseCanvas(): void;
  124994. }
  124995. }
  124996. declare module BABYLON {
  124997. interface FreeCameraInputsManager {
  124998. /**
  124999. * Add virtual joystick input support to the input manager.
  125000. * @returns the current input manager
  125001. */
  125002. addVirtualJoystick(): FreeCameraInputsManager;
  125003. }
  125004. /**
  125005. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125006. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125007. */
  125008. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125009. /**
  125010. * Defines the camera the input is attached to.
  125011. */
  125012. camera: FreeCamera;
  125013. private _leftjoystick;
  125014. private _rightjoystick;
  125015. /**
  125016. * Gets the left stick of the virtual joystick.
  125017. * @returns The virtual Joystick
  125018. */
  125019. getLeftJoystick(): VirtualJoystick;
  125020. /**
  125021. * Gets the right stick of the virtual joystick.
  125022. * @returns The virtual Joystick
  125023. */
  125024. getRightJoystick(): VirtualJoystick;
  125025. /**
  125026. * Update the current camera state depending on the inputs that have been used this frame.
  125027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125028. */
  125029. checkInputs(): void;
  125030. /**
  125031. * Attach the input controls to a specific dom element to get the input from.
  125032. * @param element Defines the element the controls should be listened from
  125033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125034. */
  125035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125036. /**
  125037. * Detach the current controls from the specified dom element.
  125038. * @param element Defines the element to stop listening the inputs from
  125039. */
  125040. detachControl(element: Nullable<HTMLElement>): void;
  125041. /**
  125042. * Gets the class name of the current intput.
  125043. * @returns the class name
  125044. */
  125045. getClassName(): string;
  125046. /**
  125047. * Get the friendly name associated with the input class.
  125048. * @returns the input friendly name
  125049. */
  125050. getSimpleName(): string;
  125051. }
  125052. }
  125053. declare module BABYLON {
  125054. /**
  125055. * This represents a FPS type of camera controlled by touch.
  125056. * This is like a universal camera minus the Gamepad controls.
  125057. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125058. */
  125059. export class TouchCamera extends FreeCamera {
  125060. /**
  125061. * Defines the touch sensibility for rotation.
  125062. * The higher the faster.
  125063. */
  125064. get touchAngularSensibility(): number;
  125065. set touchAngularSensibility(value: number);
  125066. /**
  125067. * Defines the touch sensibility for move.
  125068. * The higher the faster.
  125069. */
  125070. get touchMoveSensibility(): number;
  125071. set touchMoveSensibility(value: number);
  125072. /**
  125073. * Instantiates a new touch camera.
  125074. * This represents a FPS type of camera controlled by touch.
  125075. * This is like a universal camera minus the Gamepad controls.
  125076. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125077. * @param name Define the name of the camera in the scene
  125078. * @param position Define the start position of the camera in the scene
  125079. * @param scene Define the scene the camera belongs to
  125080. */
  125081. constructor(name: string, position: Vector3, scene: Scene);
  125082. /**
  125083. * Gets the current object class name.
  125084. * @return the class name
  125085. */
  125086. getClassName(): string;
  125087. /** @hidden */
  125088. _setupInputs(): void;
  125089. }
  125090. }
  125091. declare module BABYLON {
  125092. /**
  125093. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125094. * being tilted forward or back and left or right.
  125095. */
  125096. export class DeviceOrientationCamera extends FreeCamera {
  125097. private _initialQuaternion;
  125098. private _quaternionCache;
  125099. private _tmpDragQuaternion;
  125100. private _disablePointerInputWhenUsingDeviceOrientation;
  125101. /**
  125102. * Creates a new device orientation camera
  125103. * @param name The name of the camera
  125104. * @param position The start position camera
  125105. * @param scene The scene the camera belongs to
  125106. */
  125107. constructor(name: string, position: Vector3, scene: Scene);
  125108. /**
  125109. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125110. */
  125111. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125112. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125113. private _dragFactor;
  125114. /**
  125115. * Enabled turning on the y axis when the orientation sensor is active
  125116. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125117. */
  125118. enableHorizontalDragging(dragFactor?: number): void;
  125119. /**
  125120. * Gets the current instance class name ("DeviceOrientationCamera").
  125121. * This helps avoiding instanceof at run time.
  125122. * @returns the class name
  125123. */
  125124. getClassName(): string;
  125125. /**
  125126. * @hidden
  125127. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125128. */
  125129. _checkInputs(): void;
  125130. /**
  125131. * Reset the camera to its default orientation on the specified axis only.
  125132. * @param axis The axis to reset
  125133. */
  125134. resetToCurrentRotation(axis?: Axis): void;
  125135. }
  125136. }
  125137. declare module BABYLON {
  125138. /**
  125139. * Defines supported buttons for XBox360 compatible gamepads
  125140. */
  125141. export enum Xbox360Button {
  125142. /** A */
  125143. A = 0,
  125144. /** B */
  125145. B = 1,
  125146. /** X */
  125147. X = 2,
  125148. /** Y */
  125149. Y = 3,
  125150. /** Left button */
  125151. LB = 4,
  125152. /** Right button */
  125153. RB = 5,
  125154. /** Back */
  125155. Back = 8,
  125156. /** Start */
  125157. Start = 9,
  125158. /** Left stick */
  125159. LeftStick = 10,
  125160. /** Right stick */
  125161. RightStick = 11
  125162. }
  125163. /** Defines values for XBox360 DPad */
  125164. export enum Xbox360Dpad {
  125165. /** Up */
  125166. Up = 12,
  125167. /** Down */
  125168. Down = 13,
  125169. /** Left */
  125170. Left = 14,
  125171. /** Right */
  125172. Right = 15
  125173. }
  125174. /**
  125175. * Defines a XBox360 gamepad
  125176. */
  125177. export class Xbox360Pad extends Gamepad {
  125178. private _leftTrigger;
  125179. private _rightTrigger;
  125180. private _onlefttriggerchanged;
  125181. private _onrighttriggerchanged;
  125182. private _onbuttondown;
  125183. private _onbuttonup;
  125184. private _ondpaddown;
  125185. private _ondpadup;
  125186. /** Observable raised when a button is pressed */
  125187. onButtonDownObservable: Observable<Xbox360Button>;
  125188. /** Observable raised when a button is released */
  125189. onButtonUpObservable: Observable<Xbox360Button>;
  125190. /** Observable raised when a pad is pressed */
  125191. onPadDownObservable: Observable<Xbox360Dpad>;
  125192. /** Observable raised when a pad is released */
  125193. onPadUpObservable: Observable<Xbox360Dpad>;
  125194. private _buttonA;
  125195. private _buttonB;
  125196. private _buttonX;
  125197. private _buttonY;
  125198. private _buttonBack;
  125199. private _buttonStart;
  125200. private _buttonLB;
  125201. private _buttonRB;
  125202. private _buttonLeftStick;
  125203. private _buttonRightStick;
  125204. private _dPadUp;
  125205. private _dPadDown;
  125206. private _dPadLeft;
  125207. private _dPadRight;
  125208. private _isXboxOnePad;
  125209. /**
  125210. * Creates a new XBox360 gamepad object
  125211. * @param id defines the id of this gamepad
  125212. * @param index defines its index
  125213. * @param gamepad defines the internal HTML gamepad object
  125214. * @param xboxOne defines if it is a XBox One gamepad
  125215. */
  125216. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125217. /**
  125218. * Defines the callback to call when left trigger is pressed
  125219. * @param callback defines the callback to use
  125220. */
  125221. onlefttriggerchanged(callback: (value: number) => void): void;
  125222. /**
  125223. * Defines the callback to call when right trigger is pressed
  125224. * @param callback defines the callback to use
  125225. */
  125226. onrighttriggerchanged(callback: (value: number) => void): void;
  125227. /**
  125228. * Gets the left trigger value
  125229. */
  125230. get leftTrigger(): number;
  125231. /**
  125232. * Sets the left trigger value
  125233. */
  125234. set leftTrigger(newValue: number);
  125235. /**
  125236. * Gets the right trigger value
  125237. */
  125238. get rightTrigger(): number;
  125239. /**
  125240. * Sets the right trigger value
  125241. */
  125242. set rightTrigger(newValue: number);
  125243. /**
  125244. * Defines the callback to call when a button is pressed
  125245. * @param callback defines the callback to use
  125246. */
  125247. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125248. /**
  125249. * Defines the callback to call when a button is released
  125250. * @param callback defines the callback to use
  125251. */
  125252. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125253. /**
  125254. * Defines the callback to call when a pad is pressed
  125255. * @param callback defines the callback to use
  125256. */
  125257. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125258. /**
  125259. * Defines the callback to call when a pad is released
  125260. * @param callback defines the callback to use
  125261. */
  125262. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125263. private _setButtonValue;
  125264. private _setDPadValue;
  125265. /**
  125266. * Gets the value of the `A` button
  125267. */
  125268. get buttonA(): number;
  125269. /**
  125270. * Sets the value of the `A` button
  125271. */
  125272. set buttonA(value: number);
  125273. /**
  125274. * Gets the value of the `B` button
  125275. */
  125276. get buttonB(): number;
  125277. /**
  125278. * Sets the value of the `B` button
  125279. */
  125280. set buttonB(value: number);
  125281. /**
  125282. * Gets the value of the `X` button
  125283. */
  125284. get buttonX(): number;
  125285. /**
  125286. * Sets the value of the `X` button
  125287. */
  125288. set buttonX(value: number);
  125289. /**
  125290. * Gets the value of the `Y` button
  125291. */
  125292. get buttonY(): number;
  125293. /**
  125294. * Sets the value of the `Y` button
  125295. */
  125296. set buttonY(value: number);
  125297. /**
  125298. * Gets the value of the `Start` button
  125299. */
  125300. get buttonStart(): number;
  125301. /**
  125302. * Sets the value of the `Start` button
  125303. */
  125304. set buttonStart(value: number);
  125305. /**
  125306. * Gets the value of the `Back` button
  125307. */
  125308. get buttonBack(): number;
  125309. /**
  125310. * Sets the value of the `Back` button
  125311. */
  125312. set buttonBack(value: number);
  125313. /**
  125314. * Gets the value of the `Left` button
  125315. */
  125316. get buttonLB(): number;
  125317. /**
  125318. * Sets the value of the `Left` button
  125319. */
  125320. set buttonLB(value: number);
  125321. /**
  125322. * Gets the value of the `Right` button
  125323. */
  125324. get buttonRB(): number;
  125325. /**
  125326. * Sets the value of the `Right` button
  125327. */
  125328. set buttonRB(value: number);
  125329. /**
  125330. * Gets the value of the Left joystick
  125331. */
  125332. get buttonLeftStick(): number;
  125333. /**
  125334. * Sets the value of the Left joystick
  125335. */
  125336. set buttonLeftStick(value: number);
  125337. /**
  125338. * Gets the value of the Right joystick
  125339. */
  125340. get buttonRightStick(): number;
  125341. /**
  125342. * Sets the value of the Right joystick
  125343. */
  125344. set buttonRightStick(value: number);
  125345. /**
  125346. * Gets the value of D-pad up
  125347. */
  125348. get dPadUp(): number;
  125349. /**
  125350. * Sets the value of D-pad up
  125351. */
  125352. set dPadUp(value: number);
  125353. /**
  125354. * Gets the value of D-pad down
  125355. */
  125356. get dPadDown(): number;
  125357. /**
  125358. * Sets the value of D-pad down
  125359. */
  125360. set dPadDown(value: number);
  125361. /**
  125362. * Gets the value of D-pad left
  125363. */
  125364. get dPadLeft(): number;
  125365. /**
  125366. * Sets the value of D-pad left
  125367. */
  125368. set dPadLeft(value: number);
  125369. /**
  125370. * Gets the value of D-pad right
  125371. */
  125372. get dPadRight(): number;
  125373. /**
  125374. * Sets the value of D-pad right
  125375. */
  125376. set dPadRight(value: number);
  125377. /**
  125378. * Force the gamepad to synchronize with device values
  125379. */
  125380. update(): void;
  125381. /**
  125382. * Disposes the gamepad
  125383. */
  125384. dispose(): void;
  125385. }
  125386. }
  125387. declare module BABYLON {
  125388. /**
  125389. * Defines supported buttons for DualShock compatible gamepads
  125390. */
  125391. export enum DualShockButton {
  125392. /** Cross */
  125393. Cross = 0,
  125394. /** Circle */
  125395. Circle = 1,
  125396. /** Square */
  125397. Square = 2,
  125398. /** Triangle */
  125399. Triangle = 3,
  125400. /** L1 */
  125401. L1 = 4,
  125402. /** R1 */
  125403. R1 = 5,
  125404. /** Share */
  125405. Share = 8,
  125406. /** Options */
  125407. Options = 9,
  125408. /** Left stick */
  125409. LeftStick = 10,
  125410. /** Right stick */
  125411. RightStick = 11
  125412. }
  125413. /** Defines values for DualShock DPad */
  125414. export enum DualShockDpad {
  125415. /** Up */
  125416. Up = 12,
  125417. /** Down */
  125418. Down = 13,
  125419. /** Left */
  125420. Left = 14,
  125421. /** Right */
  125422. Right = 15
  125423. }
  125424. /**
  125425. * Defines a DualShock gamepad
  125426. */
  125427. export class DualShockPad extends Gamepad {
  125428. private _leftTrigger;
  125429. private _rightTrigger;
  125430. private _onlefttriggerchanged;
  125431. private _onrighttriggerchanged;
  125432. private _onbuttondown;
  125433. private _onbuttonup;
  125434. private _ondpaddown;
  125435. private _ondpadup;
  125436. /** Observable raised when a button is pressed */
  125437. onButtonDownObservable: Observable<DualShockButton>;
  125438. /** Observable raised when a button is released */
  125439. onButtonUpObservable: Observable<DualShockButton>;
  125440. /** Observable raised when a pad is pressed */
  125441. onPadDownObservable: Observable<DualShockDpad>;
  125442. /** Observable raised when a pad is released */
  125443. onPadUpObservable: Observable<DualShockDpad>;
  125444. private _buttonCross;
  125445. private _buttonCircle;
  125446. private _buttonSquare;
  125447. private _buttonTriangle;
  125448. private _buttonShare;
  125449. private _buttonOptions;
  125450. private _buttonL1;
  125451. private _buttonR1;
  125452. private _buttonLeftStick;
  125453. private _buttonRightStick;
  125454. private _dPadUp;
  125455. private _dPadDown;
  125456. private _dPadLeft;
  125457. private _dPadRight;
  125458. /**
  125459. * Creates a new DualShock gamepad object
  125460. * @param id defines the id of this gamepad
  125461. * @param index defines its index
  125462. * @param gamepad defines the internal HTML gamepad object
  125463. */
  125464. constructor(id: string, index: number, gamepad: any);
  125465. /**
  125466. * Defines the callback to call when left trigger is pressed
  125467. * @param callback defines the callback to use
  125468. */
  125469. onlefttriggerchanged(callback: (value: number) => void): void;
  125470. /**
  125471. * Defines the callback to call when right trigger is pressed
  125472. * @param callback defines the callback to use
  125473. */
  125474. onrighttriggerchanged(callback: (value: number) => void): void;
  125475. /**
  125476. * Gets the left trigger value
  125477. */
  125478. get leftTrigger(): number;
  125479. /**
  125480. * Sets the left trigger value
  125481. */
  125482. set leftTrigger(newValue: number);
  125483. /**
  125484. * Gets the right trigger value
  125485. */
  125486. get rightTrigger(): number;
  125487. /**
  125488. * Sets the right trigger value
  125489. */
  125490. set rightTrigger(newValue: number);
  125491. /**
  125492. * Defines the callback to call when a button is pressed
  125493. * @param callback defines the callback to use
  125494. */
  125495. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  125496. /**
  125497. * Defines the callback to call when a button is released
  125498. * @param callback defines the callback to use
  125499. */
  125500. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  125501. /**
  125502. * Defines the callback to call when a pad is pressed
  125503. * @param callback defines the callback to use
  125504. */
  125505. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  125506. /**
  125507. * Defines the callback to call when a pad is released
  125508. * @param callback defines the callback to use
  125509. */
  125510. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  125511. private _setButtonValue;
  125512. private _setDPadValue;
  125513. /**
  125514. * Gets the value of the `Cross` button
  125515. */
  125516. get buttonCross(): number;
  125517. /**
  125518. * Sets the value of the `Cross` button
  125519. */
  125520. set buttonCross(value: number);
  125521. /**
  125522. * Gets the value of the `Circle` button
  125523. */
  125524. get buttonCircle(): number;
  125525. /**
  125526. * Sets the value of the `Circle` button
  125527. */
  125528. set buttonCircle(value: number);
  125529. /**
  125530. * Gets the value of the `Square` button
  125531. */
  125532. get buttonSquare(): number;
  125533. /**
  125534. * Sets the value of the `Square` button
  125535. */
  125536. set buttonSquare(value: number);
  125537. /**
  125538. * Gets the value of the `Triangle` button
  125539. */
  125540. get buttonTriangle(): number;
  125541. /**
  125542. * Sets the value of the `Triangle` button
  125543. */
  125544. set buttonTriangle(value: number);
  125545. /**
  125546. * Gets the value of the `Options` button
  125547. */
  125548. get buttonOptions(): number;
  125549. /**
  125550. * Sets the value of the `Options` button
  125551. */
  125552. set buttonOptions(value: number);
  125553. /**
  125554. * Gets the value of the `Share` button
  125555. */
  125556. get buttonShare(): number;
  125557. /**
  125558. * Sets the value of the `Share` button
  125559. */
  125560. set buttonShare(value: number);
  125561. /**
  125562. * Gets the value of the `L1` button
  125563. */
  125564. get buttonL1(): number;
  125565. /**
  125566. * Sets the value of the `L1` button
  125567. */
  125568. set buttonL1(value: number);
  125569. /**
  125570. * Gets the value of the `R1` button
  125571. */
  125572. get buttonR1(): number;
  125573. /**
  125574. * Sets the value of the `R1` button
  125575. */
  125576. set buttonR1(value: number);
  125577. /**
  125578. * Gets the value of the Left joystick
  125579. */
  125580. get buttonLeftStick(): number;
  125581. /**
  125582. * Sets the value of the Left joystick
  125583. */
  125584. set buttonLeftStick(value: number);
  125585. /**
  125586. * Gets the value of the Right joystick
  125587. */
  125588. get buttonRightStick(): number;
  125589. /**
  125590. * Sets the value of the Right joystick
  125591. */
  125592. set buttonRightStick(value: number);
  125593. /**
  125594. * Gets the value of D-pad up
  125595. */
  125596. get dPadUp(): number;
  125597. /**
  125598. * Sets the value of D-pad up
  125599. */
  125600. set dPadUp(value: number);
  125601. /**
  125602. * Gets the value of D-pad down
  125603. */
  125604. get dPadDown(): number;
  125605. /**
  125606. * Sets the value of D-pad down
  125607. */
  125608. set dPadDown(value: number);
  125609. /**
  125610. * Gets the value of D-pad left
  125611. */
  125612. get dPadLeft(): number;
  125613. /**
  125614. * Sets the value of D-pad left
  125615. */
  125616. set dPadLeft(value: number);
  125617. /**
  125618. * Gets the value of D-pad right
  125619. */
  125620. get dPadRight(): number;
  125621. /**
  125622. * Sets the value of D-pad right
  125623. */
  125624. set dPadRight(value: number);
  125625. /**
  125626. * Force the gamepad to synchronize with device values
  125627. */
  125628. update(): void;
  125629. /**
  125630. * Disposes the gamepad
  125631. */
  125632. dispose(): void;
  125633. }
  125634. }
  125635. declare module BABYLON {
  125636. /**
  125637. * Manager for handling gamepads
  125638. */
  125639. export class GamepadManager {
  125640. private _scene?;
  125641. private _babylonGamepads;
  125642. private _oneGamepadConnected;
  125643. /** @hidden */
  125644. _isMonitoring: boolean;
  125645. private _gamepadEventSupported;
  125646. private _gamepadSupport?;
  125647. /**
  125648. * observable to be triggered when the gamepad controller has been connected
  125649. */
  125650. onGamepadConnectedObservable: Observable<Gamepad>;
  125651. /**
  125652. * observable to be triggered when the gamepad controller has been disconnected
  125653. */
  125654. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125655. private _onGamepadConnectedEvent;
  125656. private _onGamepadDisconnectedEvent;
  125657. /**
  125658. * Initializes the gamepad manager
  125659. * @param _scene BabylonJS scene
  125660. */
  125661. constructor(_scene?: Scene | undefined);
  125662. /**
  125663. * The gamepads in the game pad manager
  125664. */
  125665. get gamepads(): Gamepad[];
  125666. /**
  125667. * Get the gamepad controllers based on type
  125668. * @param type The type of gamepad controller
  125669. * @returns Nullable gamepad
  125670. */
  125671. getGamepadByType(type?: number): Nullable<Gamepad>;
  125672. /**
  125673. * Disposes the gamepad manager
  125674. */
  125675. dispose(): void;
  125676. private _addNewGamepad;
  125677. private _startMonitoringGamepads;
  125678. private _stopMonitoringGamepads;
  125679. /** @hidden */
  125680. _checkGamepadsStatus(): void;
  125681. private _updateGamepadObjects;
  125682. }
  125683. }
  125684. declare module BABYLON {
  125685. interface Scene {
  125686. /** @hidden */
  125687. _gamepadManager: Nullable<GamepadManager>;
  125688. /**
  125689. * Gets the gamepad manager associated with the scene
  125690. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125691. */
  125692. gamepadManager: GamepadManager;
  125693. }
  125694. /**
  125695. * Interface representing a free camera inputs manager
  125696. */
  125697. interface FreeCameraInputsManager {
  125698. /**
  125699. * Adds gamepad input support to the FreeCameraInputsManager.
  125700. * @returns the FreeCameraInputsManager
  125701. */
  125702. addGamepad(): FreeCameraInputsManager;
  125703. }
  125704. /**
  125705. * Interface representing an arc rotate camera inputs manager
  125706. */
  125707. interface ArcRotateCameraInputsManager {
  125708. /**
  125709. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125710. * @returns the camera inputs manager
  125711. */
  125712. addGamepad(): ArcRotateCameraInputsManager;
  125713. }
  125714. /**
  125715. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  125716. */
  125717. export class GamepadSystemSceneComponent implements ISceneComponent {
  125718. /**
  125719. * The component name helpfull to identify the component in the list of scene components.
  125720. */
  125721. readonly name: string;
  125722. /**
  125723. * The scene the component belongs to.
  125724. */
  125725. scene: Scene;
  125726. /**
  125727. * Creates a new instance of the component for the given scene
  125728. * @param scene Defines the scene to register the component in
  125729. */
  125730. constructor(scene: Scene);
  125731. /**
  125732. * Registers the component in a given scene
  125733. */
  125734. register(): void;
  125735. /**
  125736. * Rebuilds the elements related to this component in case of
  125737. * context lost for instance.
  125738. */
  125739. rebuild(): void;
  125740. /**
  125741. * Disposes the component and the associated ressources
  125742. */
  125743. dispose(): void;
  125744. private _beforeCameraUpdate;
  125745. }
  125746. }
  125747. declare module BABYLON {
  125748. /**
  125749. * 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,
  125750. * which still works and will still be found in many Playgrounds.
  125751. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125752. */
  125753. export class UniversalCamera extends TouchCamera {
  125754. /**
  125755. * Defines the gamepad rotation sensiblity.
  125756. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125757. */
  125758. get gamepadAngularSensibility(): number;
  125759. set gamepadAngularSensibility(value: number);
  125760. /**
  125761. * Defines the gamepad move sensiblity.
  125762. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125763. */
  125764. get gamepadMoveSensibility(): number;
  125765. set gamepadMoveSensibility(value: number);
  125766. /**
  125767. * 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,
  125768. * which still works and will still be found in many Playgrounds.
  125769. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125770. * @param name Define the name of the camera in the scene
  125771. * @param position Define the start position of the camera in the scene
  125772. * @param scene Define the scene the camera belongs to
  125773. */
  125774. constructor(name: string, position: Vector3, scene: Scene);
  125775. /**
  125776. * Gets the current object class name.
  125777. * @return the class name
  125778. */
  125779. getClassName(): string;
  125780. }
  125781. }
  125782. declare module BABYLON {
  125783. /**
  125784. * This represents a FPS type of camera. This is only here for back compat purpose.
  125785. * Please use the UniversalCamera instead as both are identical.
  125786. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125787. */
  125788. export class GamepadCamera extends UniversalCamera {
  125789. /**
  125790. * Instantiates a new Gamepad Camera
  125791. * This represents a FPS type of camera. This is only here for back compat purpose.
  125792. * Please use the UniversalCamera instead as both are identical.
  125793. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125794. * @param name Define the name of the camera in the scene
  125795. * @param position Define the start position of the camera in the scene
  125796. * @param scene Define the scene the camera belongs to
  125797. */
  125798. constructor(name: string, position: Vector3, scene: Scene);
  125799. /**
  125800. * Gets the current object class name.
  125801. * @return the class name
  125802. */
  125803. getClassName(): string;
  125804. }
  125805. }
  125806. declare module BABYLON {
  125807. /** @hidden */
  125808. export var passPixelShader: {
  125809. name: string;
  125810. shader: string;
  125811. };
  125812. }
  125813. declare module BABYLON {
  125814. /** @hidden */
  125815. export var passCubePixelShader: {
  125816. name: string;
  125817. shader: string;
  125818. };
  125819. }
  125820. declare module BABYLON {
  125821. /**
  125822. * PassPostProcess which produces an output the same as it's input
  125823. */
  125824. export class PassPostProcess extends PostProcess {
  125825. /**
  125826. * Gets a string identifying the name of the class
  125827. * @returns "PassPostProcess" string
  125828. */
  125829. getClassName(): string;
  125830. /**
  125831. * Creates the PassPostProcess
  125832. * @param name The name of the effect.
  125833. * @param options The required width/height ratio to downsize to before computing the render pass.
  125834. * @param camera The camera to apply the render pass to.
  125835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125836. * @param engine The engine which the post process will be applied. (default: current engine)
  125837. * @param reusable If the post process can be reused on the same frame. (default: false)
  125838. * @param textureType The type of texture to be used when performing the post processing.
  125839. * @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)
  125840. */
  125841. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125842. /** @hidden */
  125843. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  125844. }
  125845. /**
  125846. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  125847. */
  125848. export class PassCubePostProcess extends PostProcess {
  125849. private _face;
  125850. /**
  125851. * Gets or sets the cube face to display.
  125852. * * 0 is +X
  125853. * * 1 is -X
  125854. * * 2 is +Y
  125855. * * 3 is -Y
  125856. * * 4 is +Z
  125857. * * 5 is -Z
  125858. */
  125859. get face(): number;
  125860. set face(value: number);
  125861. /**
  125862. * Gets a string identifying the name of the class
  125863. * @returns "PassCubePostProcess" string
  125864. */
  125865. getClassName(): string;
  125866. /**
  125867. * Creates the PassCubePostProcess
  125868. * @param name The name of the effect.
  125869. * @param options The required width/height ratio to downsize to before computing the render pass.
  125870. * @param camera The camera to apply the render pass to.
  125871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125872. * @param engine The engine which the post process will be applied. (default: current engine)
  125873. * @param reusable If the post process can be reused on the same frame. (default: false)
  125874. * @param textureType The type of texture to be used when performing the post processing.
  125875. * @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)
  125876. */
  125877. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125878. /** @hidden */
  125879. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  125880. }
  125881. }
  125882. declare module BABYLON {
  125883. /** @hidden */
  125884. export var anaglyphPixelShader: {
  125885. name: string;
  125886. shader: string;
  125887. };
  125888. }
  125889. declare module BABYLON {
  125890. /**
  125891. * Postprocess used to generate anaglyphic rendering
  125892. */
  125893. export class AnaglyphPostProcess extends PostProcess {
  125894. private _passedProcess;
  125895. /**
  125896. * Gets a string identifying the name of the class
  125897. * @returns "AnaglyphPostProcess" string
  125898. */
  125899. getClassName(): string;
  125900. /**
  125901. * Creates a new AnaglyphPostProcess
  125902. * @param name defines postprocess name
  125903. * @param options defines creation options or target ratio scale
  125904. * @param rigCameras defines cameras using this postprocess
  125905. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  125906. * @param engine defines hosting engine
  125907. * @param reusable defines if the postprocess will be reused multiple times per frame
  125908. */
  125909. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  125910. }
  125911. }
  125912. declare module BABYLON {
  125913. /**
  125914. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  125915. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125916. */
  125917. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  125918. /**
  125919. * Creates a new AnaglyphArcRotateCamera
  125920. * @param name defines camera name
  125921. * @param alpha defines alpha angle (in radians)
  125922. * @param beta defines beta angle (in radians)
  125923. * @param radius defines radius
  125924. * @param target defines camera target
  125925. * @param interaxialDistance defines distance between each color axis
  125926. * @param scene defines the hosting scene
  125927. */
  125928. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  125929. /**
  125930. * Gets camera class name
  125931. * @returns AnaglyphArcRotateCamera
  125932. */
  125933. getClassName(): string;
  125934. }
  125935. }
  125936. declare module BABYLON {
  125937. /**
  125938. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  125939. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125940. */
  125941. export class AnaglyphFreeCamera extends FreeCamera {
  125942. /**
  125943. * Creates a new AnaglyphFreeCamera
  125944. * @param name defines camera name
  125945. * @param position defines initial position
  125946. * @param interaxialDistance defines distance between each color axis
  125947. * @param scene defines the hosting scene
  125948. */
  125949. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125950. /**
  125951. * Gets camera class name
  125952. * @returns AnaglyphFreeCamera
  125953. */
  125954. getClassName(): string;
  125955. }
  125956. }
  125957. declare module BABYLON {
  125958. /**
  125959. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  125960. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125961. */
  125962. export class AnaglyphGamepadCamera extends GamepadCamera {
  125963. /**
  125964. * Creates a new AnaglyphGamepadCamera
  125965. * @param name defines camera name
  125966. * @param position defines initial position
  125967. * @param interaxialDistance defines distance between each color axis
  125968. * @param scene defines the hosting scene
  125969. */
  125970. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125971. /**
  125972. * Gets camera class name
  125973. * @returns AnaglyphGamepadCamera
  125974. */
  125975. getClassName(): string;
  125976. }
  125977. }
  125978. declare module BABYLON {
  125979. /**
  125980. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  125981. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125982. */
  125983. export class AnaglyphUniversalCamera extends UniversalCamera {
  125984. /**
  125985. * Creates a new AnaglyphUniversalCamera
  125986. * @param name defines camera name
  125987. * @param position defines initial position
  125988. * @param interaxialDistance defines distance between each color axis
  125989. * @param scene defines the hosting scene
  125990. */
  125991. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125992. /**
  125993. * Gets camera class name
  125994. * @returns AnaglyphUniversalCamera
  125995. */
  125996. getClassName(): string;
  125997. }
  125998. }
  125999. declare module BABYLON {
  126000. /**
  126001. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126002. * @see https://doc.babylonjs.com/features/cameras
  126003. */
  126004. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126005. /**
  126006. * Creates a new StereoscopicArcRotateCamera
  126007. * @param name defines camera name
  126008. * @param alpha defines alpha angle (in radians)
  126009. * @param beta defines beta angle (in radians)
  126010. * @param radius defines radius
  126011. * @param target defines camera target
  126012. * @param interaxialDistance defines distance between each color axis
  126013. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126014. * @param scene defines the hosting scene
  126015. */
  126016. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126017. /**
  126018. * Gets camera class name
  126019. * @returns StereoscopicArcRotateCamera
  126020. */
  126021. getClassName(): string;
  126022. }
  126023. }
  126024. declare module BABYLON {
  126025. /**
  126026. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126027. * @see https://doc.babylonjs.com/features/cameras
  126028. */
  126029. export class StereoscopicFreeCamera extends FreeCamera {
  126030. /**
  126031. * Creates a new StereoscopicFreeCamera
  126032. * @param name defines camera name
  126033. * @param position defines initial position
  126034. * @param interaxialDistance defines distance between each color axis
  126035. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126036. * @param scene defines the hosting scene
  126037. */
  126038. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126039. /**
  126040. * Gets camera class name
  126041. * @returns StereoscopicFreeCamera
  126042. */
  126043. getClassName(): string;
  126044. }
  126045. }
  126046. declare module BABYLON {
  126047. /**
  126048. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126049. * @see https://doc.babylonjs.com/features/cameras
  126050. */
  126051. export class StereoscopicGamepadCamera extends GamepadCamera {
  126052. /**
  126053. * Creates a new StereoscopicGamepadCamera
  126054. * @param name defines camera name
  126055. * @param position defines initial position
  126056. * @param interaxialDistance defines distance between each color axis
  126057. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126058. * @param scene defines the hosting scene
  126059. */
  126060. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126061. /**
  126062. * Gets camera class name
  126063. * @returns StereoscopicGamepadCamera
  126064. */
  126065. getClassName(): string;
  126066. }
  126067. }
  126068. declare module BABYLON {
  126069. /**
  126070. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126071. * @see https://doc.babylonjs.com/features/cameras
  126072. */
  126073. export class StereoscopicUniversalCamera extends UniversalCamera {
  126074. /**
  126075. * Creates a new StereoscopicUniversalCamera
  126076. * @param name defines camera name
  126077. * @param position defines initial position
  126078. * @param interaxialDistance defines distance between each color axis
  126079. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126080. * @param scene defines the hosting scene
  126081. */
  126082. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126083. /**
  126084. * Gets camera class name
  126085. * @returns StereoscopicUniversalCamera
  126086. */
  126087. getClassName(): string;
  126088. }
  126089. }
  126090. declare module BABYLON {
  126091. /**
  126092. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126093. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126094. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126095. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126096. */
  126097. export class VirtualJoysticksCamera extends FreeCamera {
  126098. /**
  126099. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126100. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126101. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126102. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126103. * @param name Define the name of the camera in the scene
  126104. * @param position Define the start position of the camera in the scene
  126105. * @param scene Define the scene the camera belongs to
  126106. */
  126107. constructor(name: string, position: Vector3, scene: Scene);
  126108. /**
  126109. * Gets the current object class name.
  126110. * @return the class name
  126111. */
  126112. getClassName(): string;
  126113. }
  126114. }
  126115. declare module BABYLON {
  126116. /**
  126117. * This represents all the required metrics to create a VR camera.
  126118. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126119. */
  126120. export class VRCameraMetrics {
  126121. /**
  126122. * Define the horizontal resolution off the screen.
  126123. */
  126124. hResolution: number;
  126125. /**
  126126. * Define the vertical resolution off the screen.
  126127. */
  126128. vResolution: number;
  126129. /**
  126130. * Define the horizontal screen size.
  126131. */
  126132. hScreenSize: number;
  126133. /**
  126134. * Define the vertical screen size.
  126135. */
  126136. vScreenSize: number;
  126137. /**
  126138. * Define the vertical screen center position.
  126139. */
  126140. vScreenCenter: number;
  126141. /**
  126142. * Define the distance of the eyes to the screen.
  126143. */
  126144. eyeToScreenDistance: number;
  126145. /**
  126146. * Define the distance between both lenses
  126147. */
  126148. lensSeparationDistance: number;
  126149. /**
  126150. * Define the distance between both viewer's eyes.
  126151. */
  126152. interpupillaryDistance: number;
  126153. /**
  126154. * Define the distortion factor of the VR postprocess.
  126155. * Please, touch with care.
  126156. */
  126157. distortionK: number[];
  126158. /**
  126159. * Define the chromatic aberration correction factors for the VR post process.
  126160. */
  126161. chromaAbCorrection: number[];
  126162. /**
  126163. * Define the scale factor of the post process.
  126164. * The smaller the better but the slower.
  126165. */
  126166. postProcessScaleFactor: number;
  126167. /**
  126168. * Define an offset for the lens center.
  126169. */
  126170. lensCenterOffset: number;
  126171. /**
  126172. * Define if the current vr camera should compensate the distortion of the lense or not.
  126173. */
  126174. compensateDistortion: boolean;
  126175. /**
  126176. * Defines if multiview should be enabled when rendering (Default: false)
  126177. */
  126178. multiviewEnabled: boolean;
  126179. /**
  126180. * Gets the rendering aspect ratio based on the provided resolutions.
  126181. */
  126182. get aspectRatio(): number;
  126183. /**
  126184. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126185. */
  126186. get aspectRatioFov(): number;
  126187. /**
  126188. * @hidden
  126189. */
  126190. get leftHMatrix(): Matrix;
  126191. /**
  126192. * @hidden
  126193. */
  126194. get rightHMatrix(): Matrix;
  126195. /**
  126196. * @hidden
  126197. */
  126198. get leftPreViewMatrix(): Matrix;
  126199. /**
  126200. * @hidden
  126201. */
  126202. get rightPreViewMatrix(): Matrix;
  126203. /**
  126204. * Get the default VRMetrics based on the most generic setup.
  126205. * @returns the default vr metrics
  126206. */
  126207. static GetDefault(): VRCameraMetrics;
  126208. }
  126209. }
  126210. declare module BABYLON {
  126211. /** @hidden */
  126212. export var vrDistortionCorrectionPixelShader: {
  126213. name: string;
  126214. shader: string;
  126215. };
  126216. }
  126217. declare module BABYLON {
  126218. /**
  126219. * VRDistortionCorrectionPostProcess used for mobile VR
  126220. */
  126221. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126222. private _isRightEye;
  126223. private _distortionFactors;
  126224. private _postProcessScaleFactor;
  126225. private _lensCenterOffset;
  126226. private _scaleIn;
  126227. private _scaleFactor;
  126228. private _lensCenter;
  126229. /**
  126230. * Gets a string identifying the name of the class
  126231. * @returns "VRDistortionCorrectionPostProcess" string
  126232. */
  126233. getClassName(): string;
  126234. /**
  126235. * Initializes the VRDistortionCorrectionPostProcess
  126236. * @param name The name of the effect.
  126237. * @param camera The camera to apply the render pass to.
  126238. * @param isRightEye If this is for the right eye distortion
  126239. * @param vrMetrics All the required metrics for the VR camera
  126240. */
  126241. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126242. }
  126243. }
  126244. declare module BABYLON {
  126245. /**
  126246. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126247. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126248. */
  126249. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126250. /**
  126251. * Creates a new VRDeviceOrientationArcRotateCamera
  126252. * @param name defines camera name
  126253. * @param alpha defines the camera rotation along the logitudinal axis
  126254. * @param beta defines the camera rotation along the latitudinal axis
  126255. * @param radius defines the camera distance from its target
  126256. * @param target defines the camera target
  126257. * @param scene defines the scene the camera belongs to
  126258. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126259. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126260. */
  126261. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126262. /**
  126263. * Gets camera class name
  126264. * @returns VRDeviceOrientationArcRotateCamera
  126265. */
  126266. getClassName(): string;
  126267. }
  126268. }
  126269. declare module BABYLON {
  126270. /**
  126271. * Camera used to simulate VR rendering (based on FreeCamera)
  126272. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126273. */
  126274. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126275. /**
  126276. * Creates a new VRDeviceOrientationFreeCamera
  126277. * @param name defines camera name
  126278. * @param position defines the start position of the camera
  126279. * @param scene defines the scene the camera belongs to
  126280. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126281. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126282. */
  126283. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126284. /**
  126285. * Gets camera class name
  126286. * @returns VRDeviceOrientationFreeCamera
  126287. */
  126288. getClassName(): string;
  126289. }
  126290. }
  126291. declare module BABYLON {
  126292. /**
  126293. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126294. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126295. */
  126296. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126297. /**
  126298. * Creates a new VRDeviceOrientationGamepadCamera
  126299. * @param name defines camera name
  126300. * @param position defines the start position of the camera
  126301. * @param scene defines the scene the camera belongs to
  126302. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126303. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126304. */
  126305. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126306. /**
  126307. * Gets camera class name
  126308. * @returns VRDeviceOrientationGamepadCamera
  126309. */
  126310. getClassName(): string;
  126311. }
  126312. }
  126313. declare module BABYLON {
  126314. /**
  126315. * A class extending Texture allowing drawing on a texture
  126316. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126317. */
  126318. export class DynamicTexture extends Texture {
  126319. private _generateMipMaps;
  126320. private _canvas;
  126321. private _context;
  126322. /**
  126323. * Creates a DynamicTexture
  126324. * @param name defines the name of the texture
  126325. * @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
  126326. * @param scene defines the scene where you want the texture
  126327. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126328. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126329. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126330. */
  126331. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126332. /**
  126333. * Get the current class name of the texture useful for serialization or dynamic coding.
  126334. * @returns "DynamicTexture"
  126335. */
  126336. getClassName(): string;
  126337. /**
  126338. * Gets the current state of canRescale
  126339. */
  126340. get canRescale(): boolean;
  126341. private _recreate;
  126342. /**
  126343. * Scales the texture
  126344. * @param ratio the scale factor to apply to both width and height
  126345. */
  126346. scale(ratio: number): void;
  126347. /**
  126348. * Resizes the texture
  126349. * @param width the new width
  126350. * @param height the new height
  126351. */
  126352. scaleTo(width: number, height: number): void;
  126353. /**
  126354. * Gets the context of the canvas used by the texture
  126355. * @returns the canvas context of the dynamic texture
  126356. */
  126357. getContext(): CanvasRenderingContext2D;
  126358. /**
  126359. * Clears the texture
  126360. */
  126361. clear(): void;
  126362. /**
  126363. * Updates the texture
  126364. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126365. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126366. */
  126367. update(invertY?: boolean, premulAlpha?: boolean): void;
  126368. /**
  126369. * Draws text onto the texture
  126370. * @param text defines the text to be drawn
  126371. * @param x defines the placement of the text from the left
  126372. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126373. * @param font defines the font to be used with font-style, font-size, font-name
  126374. * @param color defines the color used for the text
  126375. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126376. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126377. * @param update defines whether texture is immediately update (default is true)
  126378. */
  126379. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126380. /**
  126381. * Clones the texture
  126382. * @returns the clone of the texture.
  126383. */
  126384. clone(): DynamicTexture;
  126385. /**
  126386. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126387. * @returns a serialized dynamic texture object
  126388. */
  126389. serialize(): any;
  126390. private _IsCanvasElement;
  126391. /** @hidden */
  126392. _rebuild(): void;
  126393. }
  126394. }
  126395. declare module BABYLON {
  126396. /**
  126397. * Class containing static functions to help procedurally build meshes
  126398. */
  126399. export class GroundBuilder {
  126400. /**
  126401. * Creates a ground mesh
  126402. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126403. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126405. * @param name defines the name of the mesh
  126406. * @param options defines the options used to create the mesh
  126407. * @param scene defines the hosting scene
  126408. * @returns the ground mesh
  126409. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126410. */
  126411. static CreateGround(name: string, options: {
  126412. width?: number;
  126413. height?: number;
  126414. subdivisions?: number;
  126415. subdivisionsX?: number;
  126416. subdivisionsY?: number;
  126417. updatable?: boolean;
  126418. }, scene: any): Mesh;
  126419. /**
  126420. * Creates a tiled ground mesh
  126421. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126422. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126423. * * 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
  126424. * * 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
  126425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126426. * @param name defines the name of the mesh
  126427. * @param options defines the options used to create the mesh
  126428. * @param scene defines the hosting scene
  126429. * @returns the tiled ground mesh
  126430. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126431. */
  126432. static CreateTiledGround(name: string, options: {
  126433. xmin: number;
  126434. zmin: number;
  126435. xmax: number;
  126436. zmax: number;
  126437. subdivisions?: {
  126438. w: number;
  126439. h: number;
  126440. };
  126441. precision?: {
  126442. w: number;
  126443. h: number;
  126444. };
  126445. updatable?: boolean;
  126446. }, scene?: Nullable<Scene>): Mesh;
  126447. /**
  126448. * Creates a ground mesh from a height map
  126449. * * The parameter `url` sets the URL of the height map image resource.
  126450. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126451. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126452. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126453. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126454. * * 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.
  126455. * * 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).
  126456. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126458. * @param name defines the name of the mesh
  126459. * @param url defines the url to the height map
  126460. * @param options defines the options used to create the mesh
  126461. * @param scene defines the hosting scene
  126462. * @returns the ground mesh
  126463. * @see https://doc.babylonjs.com/babylon101/height_map
  126464. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126465. */
  126466. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126467. width?: number;
  126468. height?: number;
  126469. subdivisions?: number;
  126470. minHeight?: number;
  126471. maxHeight?: number;
  126472. colorFilter?: Color3;
  126473. alphaFilter?: number;
  126474. updatable?: boolean;
  126475. onReady?: (mesh: GroundMesh) => void;
  126476. }, scene?: Nullable<Scene>): GroundMesh;
  126477. }
  126478. }
  126479. declare module BABYLON {
  126480. /**
  126481. * Class containing static functions to help procedurally build meshes
  126482. */
  126483. export class TorusBuilder {
  126484. /**
  126485. * Creates a torus mesh
  126486. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126487. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126488. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126492. * @param name defines the name of the mesh
  126493. * @param options defines the options used to create the mesh
  126494. * @param scene defines the hosting scene
  126495. * @returns the torus mesh
  126496. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126497. */
  126498. static CreateTorus(name: string, options: {
  126499. diameter?: number;
  126500. thickness?: number;
  126501. tessellation?: number;
  126502. updatable?: boolean;
  126503. sideOrientation?: number;
  126504. frontUVs?: Vector4;
  126505. backUVs?: Vector4;
  126506. }, scene: any): Mesh;
  126507. }
  126508. }
  126509. declare module BABYLON {
  126510. /**
  126511. * Class containing static functions to help procedurally build meshes
  126512. */
  126513. export class CylinderBuilder {
  126514. /**
  126515. * Creates a cylinder or a cone mesh
  126516. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126517. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126518. * * 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.
  126519. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126520. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126521. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126522. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126523. * * 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).
  126524. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126525. * * 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).
  126526. * * 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
  126527. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126528. * * 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
  126529. * * 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.
  126530. * * If `enclose` is false, a ring surface is one element.
  126531. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126532. * * 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
  126533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126536. * @param name defines the name of the mesh
  126537. * @param options defines the options used to create the mesh
  126538. * @param scene defines the hosting scene
  126539. * @returns the cylinder mesh
  126540. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126541. */
  126542. static CreateCylinder(name: string, options: {
  126543. height?: number;
  126544. diameterTop?: number;
  126545. diameterBottom?: number;
  126546. diameter?: number;
  126547. tessellation?: number;
  126548. subdivisions?: number;
  126549. arc?: number;
  126550. faceColors?: Color4[];
  126551. faceUV?: Vector4[];
  126552. updatable?: boolean;
  126553. hasRings?: boolean;
  126554. enclose?: boolean;
  126555. cap?: number;
  126556. sideOrientation?: number;
  126557. frontUVs?: Vector4;
  126558. backUVs?: Vector4;
  126559. }, scene: any): Mesh;
  126560. }
  126561. }
  126562. declare module BABYLON {
  126563. /**
  126564. * States of the webXR experience
  126565. */
  126566. export enum WebXRState {
  126567. /**
  126568. * Transitioning to being in XR mode
  126569. */
  126570. ENTERING_XR = 0,
  126571. /**
  126572. * Transitioning to non XR mode
  126573. */
  126574. EXITING_XR = 1,
  126575. /**
  126576. * In XR mode and presenting
  126577. */
  126578. IN_XR = 2,
  126579. /**
  126580. * Not entered XR mode
  126581. */
  126582. NOT_IN_XR = 3
  126583. }
  126584. /**
  126585. * Abstraction of the XR render target
  126586. */
  126587. export interface WebXRRenderTarget extends IDisposable {
  126588. /**
  126589. * xrpresent context of the canvas which can be used to display/mirror xr content
  126590. */
  126591. canvasContext: WebGLRenderingContext;
  126592. /**
  126593. * xr layer for the canvas
  126594. */
  126595. xrLayer: Nullable<XRWebGLLayer>;
  126596. /**
  126597. * Initializes the xr layer for the session
  126598. * @param xrSession xr session
  126599. * @returns a promise that will resolve once the XR Layer has been created
  126600. */
  126601. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126602. }
  126603. }
  126604. declare module BABYLON {
  126605. /**
  126606. * COnfiguration object for WebXR output canvas
  126607. */
  126608. export class WebXRManagedOutputCanvasOptions {
  126609. /**
  126610. * An optional canvas in case you wish to create it yourself and provide it here.
  126611. * If not provided, a new canvas will be created
  126612. */
  126613. canvasElement?: HTMLCanvasElement;
  126614. /**
  126615. * Options for this XR Layer output
  126616. */
  126617. canvasOptions?: XRWebGLLayerOptions;
  126618. /**
  126619. * CSS styling for a newly created canvas (if not provided)
  126620. */
  126621. newCanvasCssStyle?: string;
  126622. /**
  126623. * Get the default values of the configuration object
  126624. * @param engine defines the engine to use (can be null)
  126625. * @returns default values of this configuration object
  126626. */
  126627. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  126628. }
  126629. /**
  126630. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126631. */
  126632. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126633. private _options;
  126634. private _canvas;
  126635. private _engine;
  126636. private _originalCanvasSize;
  126637. /**
  126638. * Rendering context of the canvas which can be used to display/mirror xr content
  126639. */
  126640. canvasContext: WebGLRenderingContext;
  126641. /**
  126642. * xr layer for the canvas
  126643. */
  126644. xrLayer: Nullable<XRWebGLLayer>;
  126645. /**
  126646. * Obseervers registered here will be triggered when the xr layer was initialized
  126647. */
  126648. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126649. /**
  126650. * Initializes the canvas to be added/removed upon entering/exiting xr
  126651. * @param _xrSessionManager The XR Session manager
  126652. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126653. */
  126654. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126655. /**
  126656. * Disposes of the object
  126657. */
  126658. dispose(): void;
  126659. /**
  126660. * Initializes the xr layer for the session
  126661. * @param xrSession xr session
  126662. * @returns a promise that will resolve once the XR Layer has been created
  126663. */
  126664. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126665. private _addCanvas;
  126666. private _removeCanvas;
  126667. private _setCanvasSize;
  126668. private _setManagedOutputCanvas;
  126669. }
  126670. }
  126671. declare module BABYLON {
  126672. /**
  126673. * Manages an XRSession to work with Babylon's engine
  126674. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126675. */
  126676. export class WebXRSessionManager implements IDisposable {
  126677. /** The scene which the session should be created for */
  126678. scene: Scene;
  126679. private _referenceSpace;
  126680. private _rttProvider;
  126681. private _sessionEnded;
  126682. private _xrNavigator;
  126683. private baseLayer;
  126684. /**
  126685. * The base reference space from which the session started. good if you want to reset your
  126686. * reference space
  126687. */
  126688. baseReferenceSpace: XRReferenceSpace;
  126689. /**
  126690. * Current XR frame
  126691. */
  126692. currentFrame: Nullable<XRFrame>;
  126693. /** WebXR timestamp updated every frame */
  126694. currentTimestamp: number;
  126695. /**
  126696. * Used just in case of a failure to initialize an immersive session.
  126697. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126698. */
  126699. defaultHeightCompensation: number;
  126700. /**
  126701. * Fires every time a new xrFrame arrives which can be used to update the camera
  126702. */
  126703. onXRFrameObservable: Observable<XRFrame>;
  126704. /**
  126705. * Fires when the reference space changed
  126706. */
  126707. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126708. /**
  126709. * Fires when the xr session is ended either by the device or manually done
  126710. */
  126711. onXRSessionEnded: Observable<any>;
  126712. /**
  126713. * Fires when the xr session is ended either by the device or manually done
  126714. */
  126715. onXRSessionInit: Observable<XRSession>;
  126716. /**
  126717. * Underlying xr session
  126718. */
  126719. session: XRSession;
  126720. /**
  126721. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  126722. * or get the offset the player is currently at.
  126723. */
  126724. viewerReferenceSpace: XRReferenceSpace;
  126725. /**
  126726. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  126727. * @param scene The scene which the session should be created for
  126728. */
  126729. constructor(
  126730. /** The scene which the session should be created for */
  126731. scene: Scene);
  126732. /**
  126733. * The current reference space used in this session. This reference space can constantly change!
  126734. * It is mainly used to offset the camera's position.
  126735. */
  126736. get referenceSpace(): XRReferenceSpace;
  126737. /**
  126738. * Set a new reference space and triggers the observable
  126739. */
  126740. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  126741. /**
  126742. * Disposes of the session manager
  126743. */
  126744. dispose(): void;
  126745. /**
  126746. * Stops the xrSession and restores the render loop
  126747. * @returns Promise which resolves after it exits XR
  126748. */
  126749. exitXRAsync(): Promise<void>;
  126750. /**
  126751. * Gets the correct render target texture to be rendered this frame for this eye
  126752. * @param eye the eye for which to get the render target
  126753. * @returns the render target for the specified eye
  126754. */
  126755. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  126756. /**
  126757. * Creates a WebXRRenderTarget object for the XR session
  126758. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  126759. * @param options optional options to provide when creating a new render target
  126760. * @returns a WebXR render target to which the session can render
  126761. */
  126762. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  126763. /**
  126764. * Initializes the manager
  126765. * After initialization enterXR can be called to start an XR session
  126766. * @returns Promise which resolves after it is initialized
  126767. */
  126768. initializeAsync(): Promise<void>;
  126769. /**
  126770. * Initializes an xr session
  126771. * @param xrSessionMode mode to initialize
  126772. * @param xrSessionInit defines optional and required values to pass to the session builder
  126773. * @returns a promise which will resolve once the session has been initialized
  126774. */
  126775. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  126776. /**
  126777. * Checks if a session would be supported for the creation options specified
  126778. * @param sessionMode session mode to check if supported eg. immersive-vr
  126779. * @returns A Promise that resolves to true if supported and false if not
  126780. */
  126781. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126782. /**
  126783. * Resets the reference space to the one started the session
  126784. */
  126785. resetReferenceSpace(): void;
  126786. /**
  126787. * Starts rendering to the xr layer
  126788. */
  126789. runXRRenderLoop(): void;
  126790. /**
  126791. * Sets the reference space on the xr session
  126792. * @param referenceSpaceType space to set
  126793. * @returns a promise that will resolve once the reference space has been set
  126794. */
  126795. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126796. /**
  126797. * Updates the render state of the session
  126798. * @param state state to set
  126799. * @returns a promise that resolves once the render state has been updated
  126800. */
  126801. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  126802. /**
  126803. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  126804. * @param sessionMode defines the session to test
  126805. * @returns a promise with boolean as final value
  126806. */
  126807. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126808. private _createRenderTargetTexture;
  126809. }
  126810. }
  126811. declare module BABYLON {
  126812. /**
  126813. * WebXR Camera which holds the views for the xrSession
  126814. * @see https://doc.babylonjs.com/how_to/webxr_camera
  126815. */
  126816. export class WebXRCamera extends FreeCamera {
  126817. private _xrSessionManager;
  126818. private _firstFrame;
  126819. private _referenceQuaternion;
  126820. private _referencedPosition;
  126821. private _xrInvPositionCache;
  126822. private _xrInvQuaternionCache;
  126823. /**
  126824. * Observable raised before camera teleportation
  126825. */
  126826. onBeforeCameraTeleport: Observable<Vector3>;
  126827. /**
  126828. * Observable raised after camera teleportation
  126829. */
  126830. onAfterCameraTeleport: Observable<Vector3>;
  126831. /**
  126832. * Should position compensation execute on first frame.
  126833. * This is used when copying the position from a native (non XR) camera
  126834. */
  126835. compensateOnFirstFrame: boolean;
  126836. /**
  126837. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  126838. * @param name the name of the camera
  126839. * @param scene the scene to add the camera to
  126840. * @param _xrSessionManager a constructed xr session manager
  126841. */
  126842. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  126843. /**
  126844. * Return the user's height, unrelated to the current ground.
  126845. * This will be the y position of this camera, when ground level is 0.
  126846. */
  126847. get realWorldHeight(): number;
  126848. /** @hidden */
  126849. _updateForDualEyeDebugging(): void;
  126850. /**
  126851. * Sets this camera's transformation based on a non-vr camera
  126852. * @param otherCamera the non-vr camera to copy the transformation from
  126853. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  126854. */
  126855. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  126856. /**
  126857. * Gets the current instance class name ("WebXRCamera").
  126858. * @returns the class name
  126859. */
  126860. getClassName(): string;
  126861. private _rotate180;
  126862. private _updateFromXRSession;
  126863. private _updateNumberOfRigCameras;
  126864. private _updateReferenceSpace;
  126865. private _updateReferenceSpaceOffset;
  126866. }
  126867. }
  126868. declare module BABYLON {
  126869. /**
  126870. * Defining the interface required for a (webxr) feature
  126871. */
  126872. export interface IWebXRFeature extends IDisposable {
  126873. /**
  126874. * Is this feature attached
  126875. */
  126876. attached: boolean;
  126877. /**
  126878. * Should auto-attach be disabled?
  126879. */
  126880. disableAutoAttach: boolean;
  126881. /**
  126882. * Attach the feature to the session
  126883. * Will usually be called by the features manager
  126884. *
  126885. * @param force should attachment be forced (even when already attached)
  126886. * @returns true if successful.
  126887. */
  126888. attach(force?: boolean): boolean;
  126889. /**
  126890. * Detach the feature from the session
  126891. * Will usually be called by the features manager
  126892. *
  126893. * @returns true if successful.
  126894. */
  126895. detach(): boolean;
  126896. /**
  126897. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  126898. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  126899. *
  126900. * @returns whether or not the feature is compatible in this environment
  126901. */
  126902. isCompatible(): boolean;
  126903. /**
  126904. * Was this feature disposed;
  126905. */
  126906. isDisposed: boolean;
  126907. /**
  126908. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  126909. */
  126910. xrNativeFeatureName?: string;
  126911. /**
  126912. * A list of (Babylon WebXR) features this feature depends on
  126913. */
  126914. dependsOn?: string[];
  126915. }
  126916. /**
  126917. * A list of the currently available features without referencing them
  126918. */
  126919. export class WebXRFeatureName {
  126920. /**
  126921. * The name of the anchor system feature
  126922. */
  126923. static readonly ANCHOR_SYSTEM: string;
  126924. /**
  126925. * The name of the background remover feature
  126926. */
  126927. static readonly BACKGROUND_REMOVER: string;
  126928. /**
  126929. * The name of the hit test feature
  126930. */
  126931. static readonly HIT_TEST: string;
  126932. /**
  126933. * physics impostors for xr controllers feature
  126934. */
  126935. static readonly PHYSICS_CONTROLLERS: string;
  126936. /**
  126937. * The name of the plane detection feature
  126938. */
  126939. static readonly PLANE_DETECTION: string;
  126940. /**
  126941. * The name of the pointer selection feature
  126942. */
  126943. static readonly POINTER_SELECTION: string;
  126944. /**
  126945. * The name of the teleportation feature
  126946. */
  126947. static readonly TELEPORTATION: string;
  126948. /**
  126949. * The name of the feature points feature.
  126950. */
  126951. static readonly FEATURE_POINTS: string;
  126952. /**
  126953. * The name of the hand tracking feature.
  126954. */
  126955. static readonly HAND_TRACKING: string;
  126956. }
  126957. /**
  126958. * Defining the constructor of a feature. Used to register the modules.
  126959. */
  126960. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  126961. /**
  126962. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  126963. * It is mainly used in AR sessions.
  126964. *
  126965. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  126966. */
  126967. export class WebXRFeaturesManager implements IDisposable {
  126968. private _xrSessionManager;
  126969. private static readonly _AvailableFeatures;
  126970. private _features;
  126971. /**
  126972. * constructs a new features manages.
  126973. *
  126974. * @param _xrSessionManager an instance of WebXRSessionManager
  126975. */
  126976. constructor(_xrSessionManager: WebXRSessionManager);
  126977. /**
  126978. * Used to register a module. After calling this function a developer can use this feature in the scene.
  126979. * Mainly used internally.
  126980. *
  126981. * @param featureName the name of the feature to register
  126982. * @param constructorFunction the function used to construct the module
  126983. * @param version the (babylon) version of the module
  126984. * @param stable is that a stable version of this module
  126985. */
  126986. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  126987. /**
  126988. * Returns a constructor of a specific feature.
  126989. *
  126990. * @param featureName the name of the feature to construct
  126991. * @param version the version of the feature to load
  126992. * @param xrSessionManager the xrSessionManager. Used to construct the module
  126993. * @param options optional options provided to the module.
  126994. * @returns a function that, when called, will return a new instance of this feature
  126995. */
  126996. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  126997. /**
  126998. * Can be used to return the list of features currently registered
  126999. *
  127000. * @returns an Array of available features
  127001. */
  127002. static GetAvailableFeatures(): string[];
  127003. /**
  127004. * Gets the versions available for a specific feature
  127005. * @param featureName the name of the feature
  127006. * @returns an array with the available versions
  127007. */
  127008. static GetAvailableVersions(featureName: string): string[];
  127009. /**
  127010. * Return the latest unstable version of this feature
  127011. * @param featureName the name of the feature to search
  127012. * @returns the version number. if not found will return -1
  127013. */
  127014. static GetLatestVersionOfFeature(featureName: string): number;
  127015. /**
  127016. * Return the latest stable version of this feature
  127017. * @param featureName the name of the feature to search
  127018. * @returns the version number. if not found will return -1
  127019. */
  127020. static GetStableVersionOfFeature(featureName: string): number;
  127021. /**
  127022. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127023. * Can be used during a session to start a feature
  127024. * @param featureName the name of feature to attach
  127025. */
  127026. attachFeature(featureName: string): void;
  127027. /**
  127028. * Can be used inside a session or when the session ends to detach a specific feature
  127029. * @param featureName the name of the feature to detach
  127030. */
  127031. detachFeature(featureName: string): void;
  127032. /**
  127033. * Used to disable an already-enabled feature
  127034. * The feature will be disposed and will be recreated once enabled.
  127035. * @param featureName the feature to disable
  127036. * @returns true if disable was successful
  127037. */
  127038. disableFeature(featureName: string | {
  127039. Name: string;
  127040. }): boolean;
  127041. /**
  127042. * dispose this features manager
  127043. */
  127044. dispose(): void;
  127045. /**
  127046. * 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.
  127047. * 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.
  127048. *
  127049. * @param featureName the name of the feature to load or the class of the feature
  127050. * @param version optional version to load. if not provided the latest version will be enabled
  127051. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127052. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127053. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127054. * @returns a new constructed feature or throws an error if feature not found.
  127055. */
  127056. enableFeature(featureName: string | {
  127057. Name: string;
  127058. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127059. /**
  127060. * get the implementation of an enabled feature.
  127061. * @param featureName the name of the feature to load
  127062. * @returns the feature class, if found
  127063. */
  127064. getEnabledFeature(featureName: string): IWebXRFeature;
  127065. /**
  127066. * Get the list of enabled features
  127067. * @returns an array of enabled features
  127068. */
  127069. getEnabledFeatures(): string[];
  127070. /**
  127071. * This function will exten the session creation configuration object with enabled features.
  127072. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127073. * according to the defined "required" variable, provided during enableFeature call
  127074. * @param xrSessionInit the xr Session init object to extend
  127075. *
  127076. * @returns an extended XRSessionInit object
  127077. */
  127078. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127079. }
  127080. }
  127081. declare module BABYLON {
  127082. /**
  127083. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127084. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127085. */
  127086. export class WebXRExperienceHelper implements IDisposable {
  127087. private scene;
  127088. private _nonVRCamera;
  127089. private _originalSceneAutoClear;
  127090. private _supported;
  127091. /**
  127092. * Camera used to render xr content
  127093. */
  127094. camera: WebXRCamera;
  127095. /** A features manager for this xr session */
  127096. featuresManager: WebXRFeaturesManager;
  127097. /**
  127098. * Observers registered here will be triggered after the camera's initial transformation is set
  127099. * This can be used to set a different ground level or an extra rotation.
  127100. *
  127101. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127102. * to the position set after this observable is done executing.
  127103. */
  127104. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127105. /**
  127106. * Fires when the state of the experience helper has changed
  127107. */
  127108. onStateChangedObservable: Observable<WebXRState>;
  127109. /** Session manager used to keep track of xr session */
  127110. sessionManager: WebXRSessionManager;
  127111. /**
  127112. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127113. */
  127114. state: WebXRState;
  127115. /**
  127116. * Creates a WebXRExperienceHelper
  127117. * @param scene The scene the helper should be created in
  127118. */
  127119. private constructor();
  127120. /**
  127121. * Creates the experience helper
  127122. * @param scene the scene to attach the experience helper to
  127123. * @returns a promise for the experience helper
  127124. */
  127125. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127126. /**
  127127. * Disposes of the experience helper
  127128. */
  127129. dispose(): void;
  127130. /**
  127131. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127132. * @param sessionMode options for the XR session
  127133. * @param referenceSpaceType frame of reference of the XR session
  127134. * @param renderTarget the output canvas that will be used to enter XR mode
  127135. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127136. * @returns promise that resolves after xr mode has entered
  127137. */
  127138. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127139. /**
  127140. * Exits XR mode and returns the scene to its original state
  127141. * @returns promise that resolves after xr mode has exited
  127142. */
  127143. exitXRAsync(): Promise<void>;
  127144. private _nonXRToXRCamera;
  127145. private _setState;
  127146. }
  127147. }
  127148. declare module BABYLON {
  127149. /**
  127150. * X-Y values for axes in WebXR
  127151. */
  127152. export interface IWebXRMotionControllerAxesValue {
  127153. /**
  127154. * The value of the x axis
  127155. */
  127156. x: number;
  127157. /**
  127158. * The value of the y-axis
  127159. */
  127160. y: number;
  127161. }
  127162. /**
  127163. * changed / previous values for the values of this component
  127164. */
  127165. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127166. /**
  127167. * current (this frame) value
  127168. */
  127169. current: T;
  127170. /**
  127171. * previous (last change) value
  127172. */
  127173. previous: T;
  127174. }
  127175. /**
  127176. * Represents changes in the component between current frame and last values recorded
  127177. */
  127178. export interface IWebXRMotionControllerComponentChanges {
  127179. /**
  127180. * will be populated with previous and current values if axes changed
  127181. */
  127182. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127183. /**
  127184. * will be populated with previous and current values if pressed changed
  127185. */
  127186. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127187. /**
  127188. * will be populated with previous and current values if touched changed
  127189. */
  127190. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127191. /**
  127192. * will be populated with previous and current values if value changed
  127193. */
  127194. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127195. }
  127196. /**
  127197. * This class represents a single component (for example button or thumbstick) of a motion controller
  127198. */
  127199. export class WebXRControllerComponent implements IDisposable {
  127200. /**
  127201. * the id of this component
  127202. */
  127203. id: string;
  127204. /**
  127205. * the type of the component
  127206. */
  127207. type: MotionControllerComponentType;
  127208. private _buttonIndex;
  127209. private _axesIndices;
  127210. private _axes;
  127211. private _changes;
  127212. private _currentValue;
  127213. private _hasChanges;
  127214. private _pressed;
  127215. private _touched;
  127216. /**
  127217. * button component type
  127218. */
  127219. static BUTTON_TYPE: MotionControllerComponentType;
  127220. /**
  127221. * squeeze component type
  127222. */
  127223. static SQUEEZE_TYPE: MotionControllerComponentType;
  127224. /**
  127225. * Thumbstick component type
  127226. */
  127227. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127228. /**
  127229. * Touchpad component type
  127230. */
  127231. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127232. /**
  127233. * trigger component type
  127234. */
  127235. static TRIGGER_TYPE: MotionControllerComponentType;
  127236. /**
  127237. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127238. * the axes data changes
  127239. */
  127240. onAxisValueChangedObservable: Observable<{
  127241. x: number;
  127242. y: number;
  127243. }>;
  127244. /**
  127245. * Observers registered here will be triggered when the state of a button changes
  127246. * State change is either pressed / touched / value
  127247. */
  127248. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127249. /**
  127250. * Creates a new component for a motion controller.
  127251. * It is created by the motion controller itself
  127252. *
  127253. * @param id the id of this component
  127254. * @param type the type of the component
  127255. * @param _buttonIndex index in the buttons array of the gamepad
  127256. * @param _axesIndices indices of the values in the axes array of the gamepad
  127257. */
  127258. constructor(
  127259. /**
  127260. * the id of this component
  127261. */
  127262. id: string,
  127263. /**
  127264. * the type of the component
  127265. */
  127266. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127267. /**
  127268. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127269. */
  127270. get axes(): IWebXRMotionControllerAxesValue;
  127271. /**
  127272. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127273. */
  127274. get changes(): IWebXRMotionControllerComponentChanges;
  127275. /**
  127276. * Return whether or not the component changed the last frame
  127277. */
  127278. get hasChanges(): boolean;
  127279. /**
  127280. * is the button currently pressed
  127281. */
  127282. get pressed(): boolean;
  127283. /**
  127284. * is the button currently touched
  127285. */
  127286. get touched(): boolean;
  127287. /**
  127288. * Get the current value of this component
  127289. */
  127290. get value(): number;
  127291. /**
  127292. * Dispose this component
  127293. */
  127294. dispose(): void;
  127295. /**
  127296. * Are there axes correlating to this component
  127297. * @return true is axes data is available
  127298. */
  127299. isAxes(): boolean;
  127300. /**
  127301. * Is this component a button (hence - pressable)
  127302. * @returns true if can be pressed
  127303. */
  127304. isButton(): boolean;
  127305. /**
  127306. * update this component using the gamepad object it is in. Called on every frame
  127307. * @param nativeController the native gamepad controller object
  127308. */
  127309. update(nativeController: IMinimalMotionControllerObject): void;
  127310. }
  127311. }
  127312. declare module BABYLON {
  127313. /**
  127314. * Interface used to represent data loading progression
  127315. */
  127316. export interface ISceneLoaderProgressEvent {
  127317. /**
  127318. * Defines if data length to load can be evaluated
  127319. */
  127320. readonly lengthComputable: boolean;
  127321. /**
  127322. * Defines the loaded data length
  127323. */
  127324. readonly loaded: number;
  127325. /**
  127326. * Defines the data length to load
  127327. */
  127328. readonly total: number;
  127329. }
  127330. /**
  127331. * Interface used by SceneLoader plugins to define supported file extensions
  127332. */
  127333. export interface ISceneLoaderPluginExtensions {
  127334. /**
  127335. * Defines the list of supported extensions
  127336. */
  127337. [extension: string]: {
  127338. isBinary: boolean;
  127339. };
  127340. }
  127341. /**
  127342. * Interface used by SceneLoader plugin factory
  127343. */
  127344. export interface ISceneLoaderPluginFactory {
  127345. /**
  127346. * Defines the name of the factory
  127347. */
  127348. name: string;
  127349. /**
  127350. * Function called to create a new plugin
  127351. * @return the new plugin
  127352. */
  127353. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127354. /**
  127355. * The callback that returns true if the data can be directly loaded.
  127356. * @param data string containing the file data
  127357. * @returns if the data can be loaded directly
  127358. */
  127359. canDirectLoad?(data: string): boolean;
  127360. }
  127361. /**
  127362. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127363. */
  127364. export interface ISceneLoaderPluginBase {
  127365. /**
  127366. * The friendly name of this plugin.
  127367. */
  127368. name: string;
  127369. /**
  127370. * The file extensions supported by this plugin.
  127371. */
  127372. extensions: string | ISceneLoaderPluginExtensions;
  127373. /**
  127374. * The callback called when loading from a url.
  127375. * @param scene scene loading this url
  127376. * @param url url to load
  127377. * @param onSuccess callback called when the file successfully loads
  127378. * @param onProgress callback called while file is loading (if the server supports this mode)
  127379. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127380. * @param onError callback called when the file fails to load
  127381. * @returns a file request object
  127382. */
  127383. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127384. /**
  127385. * The callback called when loading from a file object.
  127386. * @param scene scene loading this file
  127387. * @param file defines the file to load
  127388. * @param onSuccess defines the callback to call when data is loaded
  127389. * @param onProgress defines the callback to call during loading process
  127390. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127391. * @param onError defines the callback to call when an error occurs
  127392. * @returns a file request object
  127393. */
  127394. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127395. /**
  127396. * The callback that returns true if the data can be directly loaded.
  127397. * @param data string containing the file data
  127398. * @returns if the data can be loaded directly
  127399. */
  127400. canDirectLoad?(data: string): boolean;
  127401. /**
  127402. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127403. * @param scene scene loading this data
  127404. * @param data string containing the data
  127405. * @returns data to pass to the plugin
  127406. */
  127407. directLoad?(scene: Scene, data: string): any;
  127408. /**
  127409. * The callback that allows custom handling of the root url based on the response url.
  127410. * @param rootUrl the original root url
  127411. * @param responseURL the response url if available
  127412. * @returns the new root url
  127413. */
  127414. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  127415. }
  127416. /**
  127417. * Interface used to define a SceneLoader plugin
  127418. */
  127419. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  127420. /**
  127421. * Import meshes into a scene.
  127422. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127423. * @param scene The scene to import into
  127424. * @param data The data to import
  127425. * @param rootUrl The root url for scene and resources
  127426. * @param meshes The meshes array to import into
  127427. * @param particleSystems The particle systems array to import into
  127428. * @param skeletons The skeletons array to import into
  127429. * @param onError The callback when import fails
  127430. * @returns True if successful or false otherwise
  127431. */
  127432. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  127433. /**
  127434. * Load into a scene.
  127435. * @param scene The scene to load into
  127436. * @param data The data to import
  127437. * @param rootUrl The root url for scene and resources
  127438. * @param onError The callback when import fails
  127439. * @returns True if successful or false otherwise
  127440. */
  127441. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  127442. /**
  127443. * Load into an asset container.
  127444. * @param scene The scene to load into
  127445. * @param data The data to import
  127446. * @param rootUrl The root url for scene and resources
  127447. * @param onError The callback when import fails
  127448. * @returns The loaded asset container
  127449. */
  127450. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  127451. }
  127452. /**
  127453. * Interface used to define an async SceneLoader plugin
  127454. */
  127455. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  127456. /**
  127457. * Import meshes into a scene.
  127458. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127459. * @param scene The scene to import into
  127460. * @param data The data to import
  127461. * @param rootUrl The root url for scene and resources
  127462. * @param onProgress The callback when the load progresses
  127463. * @param fileName Defines the name of the file to load
  127464. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  127465. */
  127466. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  127467. meshes: AbstractMesh[];
  127468. particleSystems: IParticleSystem[];
  127469. skeletons: Skeleton[];
  127470. animationGroups: AnimationGroup[];
  127471. }>;
  127472. /**
  127473. * Load into a scene.
  127474. * @param scene The scene to load into
  127475. * @param data The data to import
  127476. * @param rootUrl The root url for scene and resources
  127477. * @param onProgress The callback when the load progresses
  127478. * @param fileName Defines the name of the file to load
  127479. * @returns Nothing
  127480. */
  127481. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  127482. /**
  127483. * Load into an asset container.
  127484. * @param scene The scene to load into
  127485. * @param data The data to import
  127486. * @param rootUrl The root url for scene and resources
  127487. * @param onProgress The callback when the load progresses
  127488. * @param fileName Defines the name of the file to load
  127489. * @returns The loaded asset container
  127490. */
  127491. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  127492. }
  127493. /**
  127494. * Mode that determines how to handle old animation groups before loading new ones.
  127495. */
  127496. export enum SceneLoaderAnimationGroupLoadingMode {
  127497. /**
  127498. * Reset all old animations to initial state then dispose them.
  127499. */
  127500. Clean = 0,
  127501. /**
  127502. * Stop all old animations.
  127503. */
  127504. Stop = 1,
  127505. /**
  127506. * Restart old animations from first frame.
  127507. */
  127508. Sync = 2,
  127509. /**
  127510. * Old animations remains untouched.
  127511. */
  127512. NoSync = 3
  127513. }
  127514. /**
  127515. * Defines a plugin registered by the SceneLoader
  127516. */
  127517. interface IRegisteredPlugin {
  127518. /**
  127519. * Defines the plugin to use
  127520. */
  127521. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127522. /**
  127523. * Defines if the plugin supports binary data
  127524. */
  127525. isBinary: boolean;
  127526. }
  127527. /**
  127528. * Class used to load scene from various file formats using registered plugins
  127529. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  127530. */
  127531. export class SceneLoader {
  127532. /**
  127533. * No logging while loading
  127534. */
  127535. static readonly NO_LOGGING: number;
  127536. /**
  127537. * Minimal logging while loading
  127538. */
  127539. static readonly MINIMAL_LOGGING: number;
  127540. /**
  127541. * Summary logging while loading
  127542. */
  127543. static readonly SUMMARY_LOGGING: number;
  127544. /**
  127545. * Detailled logging while loading
  127546. */
  127547. static readonly DETAILED_LOGGING: number;
  127548. /**
  127549. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  127550. */
  127551. static get ForceFullSceneLoadingForIncremental(): boolean;
  127552. static set ForceFullSceneLoadingForIncremental(value: boolean);
  127553. /**
  127554. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  127555. */
  127556. static get ShowLoadingScreen(): boolean;
  127557. static set ShowLoadingScreen(value: boolean);
  127558. /**
  127559. * Defines the current logging level (while loading the scene)
  127560. * @ignorenaming
  127561. */
  127562. static get loggingLevel(): number;
  127563. static set loggingLevel(value: number);
  127564. /**
  127565. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  127566. */
  127567. static get CleanBoneMatrixWeights(): boolean;
  127568. static set CleanBoneMatrixWeights(value: boolean);
  127569. /**
  127570. * Event raised when a plugin is used to load a scene
  127571. */
  127572. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127573. private static _registeredPlugins;
  127574. private static _showingLoadingScreen;
  127575. /**
  127576. * Gets the default plugin (used to load Babylon files)
  127577. * @returns the .babylon plugin
  127578. */
  127579. static GetDefaultPlugin(): IRegisteredPlugin;
  127580. private static _GetPluginForExtension;
  127581. private static _GetPluginForDirectLoad;
  127582. private static _GetPluginForFilename;
  127583. private static _GetDirectLoad;
  127584. private static _LoadData;
  127585. private static _GetFileInfo;
  127586. /**
  127587. * Gets a plugin that can load the given extension
  127588. * @param extension defines the extension to load
  127589. * @returns a plugin or null if none works
  127590. */
  127591. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127592. /**
  127593. * Gets a boolean indicating that the given extension can be loaded
  127594. * @param extension defines the extension to load
  127595. * @returns true if the extension is supported
  127596. */
  127597. static IsPluginForExtensionAvailable(extension: string): boolean;
  127598. /**
  127599. * Adds a new plugin to the list of registered plugins
  127600. * @param plugin defines the plugin to add
  127601. */
  127602. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127603. /**
  127604. * Import meshes into a scene
  127605. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127606. * @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)
  127607. * @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)
  127608. * @param scene the instance of BABYLON.Scene to append to
  127609. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  127610. * @param onProgress a callback with a progress event for each file being loaded
  127611. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127612. * @param pluginExtension the extension used to determine the plugin
  127613. * @returns The loaded plugin
  127614. */
  127615. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127616. /**
  127617. * Import meshes into a scene
  127618. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127619. * @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)
  127620. * @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)
  127621. * @param scene the instance of BABYLON.Scene to append to
  127622. * @param onProgress a callback with a progress event for each file being loaded
  127623. * @param pluginExtension the extension used to determine the plugin
  127624. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127625. */
  127626. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127627. meshes: AbstractMesh[];
  127628. particleSystems: IParticleSystem[];
  127629. skeletons: Skeleton[];
  127630. animationGroups: AnimationGroup[];
  127631. }>;
  127632. /**
  127633. * Load a scene
  127634. * @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)
  127635. * @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)
  127636. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127637. * @param onSuccess a callback with the scene when import succeeds
  127638. * @param onProgress a callback with a progress event for each file being loaded
  127639. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127640. * @param pluginExtension the extension used to determine the plugin
  127641. * @returns The loaded plugin
  127642. */
  127643. 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>;
  127644. /**
  127645. * Load a scene
  127646. * @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)
  127647. * @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)
  127648. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127649. * @param onProgress a callback with a progress event for each file being loaded
  127650. * @param pluginExtension the extension used to determine the plugin
  127651. * @returns The loaded scene
  127652. */
  127653. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127654. /**
  127655. * Append a scene
  127656. * @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)
  127657. * @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)
  127658. * @param scene is the instance of BABYLON.Scene to append to
  127659. * @param onSuccess a callback with the scene when import succeeds
  127660. * @param onProgress a callback with a progress event for each file being loaded
  127661. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127662. * @param pluginExtension the extension used to determine the plugin
  127663. * @returns The loaded plugin
  127664. */
  127665. 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>;
  127666. /**
  127667. * Append a scene
  127668. * @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)
  127669. * @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)
  127670. * @param scene is the instance of BABYLON.Scene to append to
  127671. * @param onProgress a callback with a progress event for each file being loaded
  127672. * @param pluginExtension the extension used to determine the plugin
  127673. * @returns The given scene
  127674. */
  127675. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127676. /**
  127677. * Load a scene into an asset container
  127678. * @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)
  127679. * @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)
  127680. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127681. * @param onSuccess a callback with the scene when import succeeds
  127682. * @param onProgress a callback with a progress event for each file being loaded
  127683. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127684. * @param pluginExtension the extension used to determine the plugin
  127685. * @returns The loaded plugin
  127686. */
  127687. 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>;
  127688. /**
  127689. * Load a scene into an asset container
  127690. * @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)
  127691. * @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)
  127692. * @param scene is the instance of Scene to append to
  127693. * @param onProgress a callback with a progress event for each file being loaded
  127694. * @param pluginExtension the extension used to determine the plugin
  127695. * @returns The loaded asset container
  127696. */
  127697. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127698. /**
  127699. * Import animations from a file into a scene
  127700. * @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)
  127701. * @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)
  127702. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127703. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127704. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127705. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127706. * @param onSuccess a callback with the scene when import succeeds
  127707. * @param onProgress a callback with a progress event for each file being loaded
  127708. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127709. * @param pluginExtension the extension used to determine the plugin
  127710. */
  127711. 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;
  127712. /**
  127713. * Import animations from a file into a scene
  127714. * @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)
  127715. * @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)
  127716. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127717. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127718. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127719. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127720. * @param onSuccess a callback with the scene when import succeeds
  127721. * @param onProgress a callback with a progress event for each file being loaded
  127722. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127723. * @param pluginExtension the extension used to determine the plugin
  127724. * @returns the updated scene with imported animations
  127725. */
  127726. 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>;
  127727. }
  127728. }
  127729. declare module BABYLON {
  127730. /**
  127731. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  127732. */
  127733. export type MotionControllerHandedness = "none" | "left" | "right";
  127734. /**
  127735. * The type of components available in motion controllers.
  127736. * This is not the name of the component.
  127737. */
  127738. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  127739. /**
  127740. * The state of a controller component
  127741. */
  127742. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  127743. /**
  127744. * The schema of motion controller layout.
  127745. * No object will be initialized using this interface
  127746. * This is used just to define the profile.
  127747. */
  127748. export interface IMotionControllerLayout {
  127749. /**
  127750. * Path to load the assets. Usually relative to the base path
  127751. */
  127752. assetPath: string;
  127753. /**
  127754. * Available components (unsorted)
  127755. */
  127756. components: {
  127757. /**
  127758. * A map of component Ids
  127759. */
  127760. [componentId: string]: {
  127761. /**
  127762. * The type of input the component outputs
  127763. */
  127764. type: MotionControllerComponentType;
  127765. /**
  127766. * The indices of this component in the gamepad object
  127767. */
  127768. gamepadIndices: {
  127769. /**
  127770. * Index of button
  127771. */
  127772. button?: number;
  127773. /**
  127774. * If available, index of x-axis
  127775. */
  127776. xAxis?: number;
  127777. /**
  127778. * If available, index of y-axis
  127779. */
  127780. yAxis?: number;
  127781. };
  127782. /**
  127783. * The mesh's root node name
  127784. */
  127785. rootNodeName: string;
  127786. /**
  127787. * Animation definitions for this model
  127788. */
  127789. visualResponses: {
  127790. [stateKey: string]: {
  127791. /**
  127792. * What property will be animated
  127793. */
  127794. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  127795. /**
  127796. * What states influence this visual response
  127797. */
  127798. states: MotionControllerComponentStateType[];
  127799. /**
  127800. * Type of animation - movement or visibility
  127801. */
  127802. valueNodeProperty: "transform" | "visibility";
  127803. /**
  127804. * Base node name to move. Its position will be calculated according to the min and max nodes
  127805. */
  127806. valueNodeName?: string;
  127807. /**
  127808. * Minimum movement node
  127809. */
  127810. minNodeName?: string;
  127811. /**
  127812. * Max movement node
  127813. */
  127814. maxNodeName?: string;
  127815. };
  127816. };
  127817. /**
  127818. * If touch enabled, what is the name of node to display user feedback
  127819. */
  127820. touchPointNodeName?: string;
  127821. };
  127822. };
  127823. /**
  127824. * Is it xr standard mapping or not
  127825. */
  127826. gamepadMapping: "" | "xr-standard";
  127827. /**
  127828. * Base root node of this entire model
  127829. */
  127830. rootNodeName: string;
  127831. /**
  127832. * Defines the main button component id
  127833. */
  127834. selectComponentId: string;
  127835. }
  127836. /**
  127837. * A definition for the layout map in the input profile
  127838. */
  127839. export interface IMotionControllerLayoutMap {
  127840. /**
  127841. * Layouts with handedness type as a key
  127842. */
  127843. [handedness: string]: IMotionControllerLayout;
  127844. }
  127845. /**
  127846. * The XR Input profile schema
  127847. * Profiles can be found here:
  127848. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  127849. */
  127850. export interface IMotionControllerProfile {
  127851. /**
  127852. * fallback profiles for this profileId
  127853. */
  127854. fallbackProfileIds: string[];
  127855. /**
  127856. * The layout map, with handedness as key
  127857. */
  127858. layouts: IMotionControllerLayoutMap;
  127859. /**
  127860. * The id of this profile
  127861. * correlates to the profile(s) in the xrInput.profiles array
  127862. */
  127863. profileId: string;
  127864. }
  127865. /**
  127866. * A helper-interface for the 3 meshes needed for controller button animation
  127867. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  127868. */
  127869. export interface IMotionControllerButtonMeshMap {
  127870. /**
  127871. * the mesh that defines the pressed value mesh position.
  127872. * This is used to find the max-position of this button
  127873. */
  127874. pressedMesh: AbstractMesh;
  127875. /**
  127876. * the mesh that defines the unpressed value mesh position.
  127877. * This is used to find the min (or initial) position of this button
  127878. */
  127879. unpressedMesh: AbstractMesh;
  127880. /**
  127881. * The mesh that will be changed when value changes
  127882. */
  127883. valueMesh: AbstractMesh;
  127884. }
  127885. /**
  127886. * A helper-interface for the 3 meshes needed for controller axis animation.
  127887. * This will be expanded when touchpad animations are fully supported
  127888. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  127889. */
  127890. export interface IMotionControllerMeshMap {
  127891. /**
  127892. * the mesh that defines the maximum value mesh position.
  127893. */
  127894. maxMesh?: AbstractMesh;
  127895. /**
  127896. * the mesh that defines the minimum value mesh position.
  127897. */
  127898. minMesh?: AbstractMesh;
  127899. /**
  127900. * The mesh that will be changed when axis value changes
  127901. */
  127902. valueMesh?: AbstractMesh;
  127903. }
  127904. /**
  127905. * The elements needed for change-detection of the gamepad objects in motion controllers
  127906. */
  127907. export interface IMinimalMotionControllerObject {
  127908. /**
  127909. * Available axes of this controller
  127910. */
  127911. axes: number[];
  127912. /**
  127913. * An array of available buttons
  127914. */
  127915. buttons: Array<{
  127916. /**
  127917. * Value of the button/trigger
  127918. */
  127919. value: number;
  127920. /**
  127921. * If the button/trigger is currently touched
  127922. */
  127923. touched: boolean;
  127924. /**
  127925. * If the button/trigger is currently pressed
  127926. */
  127927. pressed: boolean;
  127928. }>;
  127929. /**
  127930. * EXPERIMENTAL haptic support.
  127931. */
  127932. hapticActuators?: Array<{
  127933. pulse: (value: number, duration: number) => Promise<boolean>;
  127934. }>;
  127935. }
  127936. /**
  127937. * An Abstract Motion controller
  127938. * This class receives an xrInput and a profile layout and uses those to initialize the components
  127939. * Each component has an observable to check for changes in value and state
  127940. */
  127941. export abstract class WebXRAbstractMotionController implements IDisposable {
  127942. protected scene: Scene;
  127943. protected layout: IMotionControllerLayout;
  127944. /**
  127945. * The gamepad object correlating to this controller
  127946. */
  127947. gamepadObject: IMinimalMotionControllerObject;
  127948. /**
  127949. * handedness (left/right/none) of this controller
  127950. */
  127951. handedness: MotionControllerHandedness;
  127952. private _initComponent;
  127953. private _modelReady;
  127954. /**
  127955. * A map of components (WebXRControllerComponent) in this motion controller
  127956. * Components have a ComponentType and can also have both button and axis definitions
  127957. */
  127958. readonly components: {
  127959. [id: string]: WebXRControllerComponent;
  127960. };
  127961. /**
  127962. * Disable the model's animation. Can be set at any time.
  127963. */
  127964. disableAnimation: boolean;
  127965. /**
  127966. * Observers registered here will be triggered when the model of this controller is done loading
  127967. */
  127968. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  127969. /**
  127970. * The profile id of this motion controller
  127971. */
  127972. abstract profileId: string;
  127973. /**
  127974. * The root mesh of the model. It is null if the model was not yet initialized
  127975. */
  127976. rootMesh: Nullable<AbstractMesh>;
  127977. /**
  127978. * constructs a new abstract motion controller
  127979. * @param scene the scene to which the model of the controller will be added
  127980. * @param layout The profile layout to load
  127981. * @param gamepadObject The gamepad object correlating to this controller
  127982. * @param handedness handedness (left/right/none) of this controller
  127983. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  127984. */
  127985. constructor(scene: Scene, layout: IMotionControllerLayout,
  127986. /**
  127987. * The gamepad object correlating to this controller
  127988. */
  127989. gamepadObject: IMinimalMotionControllerObject,
  127990. /**
  127991. * handedness (left/right/none) of this controller
  127992. */
  127993. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  127994. /**
  127995. * Dispose this controller, the model mesh and all its components
  127996. */
  127997. dispose(): void;
  127998. /**
  127999. * Returns all components of specific type
  128000. * @param type the type to search for
  128001. * @return an array of components with this type
  128002. */
  128003. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128004. /**
  128005. * get a component based an its component id as defined in layout.components
  128006. * @param id the id of the component
  128007. * @returns the component correlates to the id or undefined if not found
  128008. */
  128009. getComponent(id: string): WebXRControllerComponent;
  128010. /**
  128011. * Get the list of components available in this motion controller
  128012. * @returns an array of strings correlating to available components
  128013. */
  128014. getComponentIds(): string[];
  128015. /**
  128016. * Get the first component of specific type
  128017. * @param type type of component to find
  128018. * @return a controller component or null if not found
  128019. */
  128020. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128021. /**
  128022. * Get the main (Select) component of this controller as defined in the layout
  128023. * @returns the main component of this controller
  128024. */
  128025. getMainComponent(): WebXRControllerComponent;
  128026. /**
  128027. * Loads the model correlating to this controller
  128028. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128029. * @returns A promise fulfilled with the result of the model loading
  128030. */
  128031. loadModel(): Promise<boolean>;
  128032. /**
  128033. * Update this model using the current XRFrame
  128034. * @param xrFrame the current xr frame to use and update the model
  128035. */
  128036. updateFromXRFrame(xrFrame: XRFrame): void;
  128037. /**
  128038. * Backwards compatibility due to a deeply-integrated typo
  128039. */
  128040. get handness(): XREye;
  128041. /**
  128042. * Pulse (vibrate) this controller
  128043. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128044. * Consecutive calls to this function will cancel the last pulse call
  128045. *
  128046. * @param value the strength of the pulse in 0.0...1.0 range
  128047. * @param duration Duration of the pulse in milliseconds
  128048. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128049. * @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
  128050. */
  128051. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128052. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128053. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128054. /**
  128055. * Moves the axis on the controller mesh based on its current state
  128056. * @param axis the index of the axis
  128057. * @param axisValue the value of the axis which determines the meshes new position
  128058. * @hidden
  128059. */
  128060. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128061. /**
  128062. * Update the model itself with the current frame data
  128063. * @param xrFrame the frame to use for updating the model mesh
  128064. */
  128065. protected updateModel(xrFrame: XRFrame): void;
  128066. /**
  128067. * Get the filename and path for this controller's model
  128068. * @returns a map of filename and path
  128069. */
  128070. protected abstract _getFilenameAndPath(): {
  128071. filename: string;
  128072. path: string;
  128073. };
  128074. /**
  128075. * This function is called before the mesh is loaded. It checks for loading constraints.
  128076. * For example, this function can check if the GLB loader is available
  128077. * If this function returns false, the generic controller will be loaded instead
  128078. * @returns Is the client ready to load the mesh
  128079. */
  128080. protected abstract _getModelLoadingConstraints(): boolean;
  128081. /**
  128082. * This function will be called after the model was successfully loaded and can be used
  128083. * for mesh transformations before it is available for the user
  128084. * @param meshes the loaded meshes
  128085. */
  128086. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128087. /**
  128088. * Set the root mesh for this controller. Important for the WebXR controller class
  128089. * @param meshes the loaded meshes
  128090. */
  128091. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128092. /**
  128093. * A function executed each frame that updates the mesh (if needed)
  128094. * @param xrFrame the current xrFrame
  128095. */
  128096. protected abstract _updateModel(xrFrame: XRFrame): void;
  128097. private _getGenericFilenameAndPath;
  128098. private _getGenericParentMesh;
  128099. }
  128100. }
  128101. declare module BABYLON {
  128102. /**
  128103. * A generic trigger-only motion controller for WebXR
  128104. */
  128105. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128106. /**
  128107. * Static version of the profile id of this controller
  128108. */
  128109. static ProfileId: string;
  128110. profileId: string;
  128111. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128112. protected _getFilenameAndPath(): {
  128113. filename: string;
  128114. path: string;
  128115. };
  128116. protected _getModelLoadingConstraints(): boolean;
  128117. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128118. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128119. protected _updateModel(): void;
  128120. }
  128121. }
  128122. declare module BABYLON {
  128123. /**
  128124. * Class containing static functions to help procedurally build meshes
  128125. */
  128126. export class SphereBuilder {
  128127. /**
  128128. * Creates a sphere mesh
  128129. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128130. * * 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`)
  128131. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128132. * * 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
  128133. * * 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)
  128134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128137. * @param name defines the name of the mesh
  128138. * @param options defines the options used to create the mesh
  128139. * @param scene defines the hosting scene
  128140. * @returns the sphere mesh
  128141. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128142. */
  128143. static CreateSphere(name: string, options: {
  128144. segments?: number;
  128145. diameter?: number;
  128146. diameterX?: number;
  128147. diameterY?: number;
  128148. diameterZ?: number;
  128149. arc?: number;
  128150. slice?: number;
  128151. sideOrientation?: number;
  128152. frontUVs?: Vector4;
  128153. backUVs?: Vector4;
  128154. updatable?: boolean;
  128155. }, scene?: Nullable<Scene>): Mesh;
  128156. }
  128157. }
  128158. declare module BABYLON {
  128159. /**
  128160. * A profiled motion controller has its profile loaded from an online repository.
  128161. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128162. */
  128163. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128164. private _repositoryUrl;
  128165. private _buttonMeshMapping;
  128166. private _touchDots;
  128167. /**
  128168. * The profile ID of this controller. Will be populated when the controller initializes.
  128169. */
  128170. profileId: string;
  128171. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128172. dispose(): void;
  128173. protected _getFilenameAndPath(): {
  128174. filename: string;
  128175. path: string;
  128176. };
  128177. protected _getModelLoadingConstraints(): boolean;
  128178. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128179. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128180. protected _updateModel(_xrFrame: XRFrame): void;
  128181. }
  128182. }
  128183. declare module BABYLON {
  128184. /**
  128185. * A construction function type to create a new controller based on an xrInput object
  128186. */
  128187. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128188. /**
  128189. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128190. *
  128191. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128192. * it should be replaced with auto-loaded controllers.
  128193. *
  128194. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128195. */
  128196. export class WebXRMotionControllerManager {
  128197. private static _AvailableControllers;
  128198. private static _Fallbacks;
  128199. private static _ProfileLoadingPromises;
  128200. private static _ProfilesList;
  128201. /**
  128202. * The base URL of the online controller repository. Can be changed at any time.
  128203. */
  128204. static BaseRepositoryUrl: string;
  128205. /**
  128206. * Which repository gets priority - local or online
  128207. */
  128208. static PrioritizeOnlineRepository: boolean;
  128209. /**
  128210. * Use the online repository, or use only locally-defined controllers
  128211. */
  128212. static UseOnlineRepository: boolean;
  128213. /**
  128214. * Clear the cache used for profile loading and reload when requested again
  128215. */
  128216. static ClearProfilesCache(): void;
  128217. /**
  128218. * Register the default fallbacks.
  128219. * This function is called automatically when this file is imported.
  128220. */
  128221. static DefaultFallbacks(): void;
  128222. /**
  128223. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128224. * @param profileId the profile to which a fallback needs to be found
  128225. * @return an array with corresponding fallback profiles
  128226. */
  128227. static FindFallbackWithProfileId(profileId: string): string[];
  128228. /**
  128229. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128230. * The order of search:
  128231. *
  128232. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128233. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128234. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128235. * 4) return the generic trigger controller if none were found
  128236. *
  128237. * @param xrInput the xrInput to which a new controller is initialized
  128238. * @param scene the scene to which the model will be added
  128239. * @param forceProfile force a certain profile for this controller
  128240. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128241. */
  128242. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128243. /**
  128244. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128245. *
  128246. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128247. *
  128248. * @param type the profile type to register
  128249. * @param constructFunction the function to be called when loading this profile
  128250. */
  128251. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128252. /**
  128253. * Register a fallback to a specific profile.
  128254. * @param profileId the profileId that will receive the fallbacks
  128255. * @param fallbacks A list of fallback profiles
  128256. */
  128257. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128258. /**
  128259. * Will update the list of profiles available in the repository
  128260. * @return a promise that resolves to a map of profiles available online
  128261. */
  128262. static UpdateProfilesList(): Promise<{
  128263. [profile: string]: string;
  128264. }>;
  128265. private static _LoadProfileFromRepository;
  128266. private static _LoadProfilesFromAvailableControllers;
  128267. }
  128268. }
  128269. declare module BABYLON {
  128270. /**
  128271. * Configuration options for the WebXR controller creation
  128272. */
  128273. export interface IWebXRControllerOptions {
  128274. /**
  128275. * Should the controller mesh be animated when a user interacts with it
  128276. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128277. */
  128278. disableMotionControllerAnimation?: boolean;
  128279. /**
  128280. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128281. */
  128282. doNotLoadControllerMesh?: boolean;
  128283. /**
  128284. * Force a specific controller type for this controller.
  128285. * This can be used when creating your own profile or when testing different controllers
  128286. */
  128287. forceControllerProfile?: string;
  128288. /**
  128289. * Defines a rendering group ID for meshes that will be loaded.
  128290. * This is for the default controllers only.
  128291. */
  128292. renderingGroupId?: number;
  128293. }
  128294. /**
  128295. * Represents an XR controller
  128296. */
  128297. export class WebXRInputSource {
  128298. private _scene;
  128299. /** The underlying input source for the controller */
  128300. inputSource: XRInputSource;
  128301. private _options;
  128302. private _tmpVector;
  128303. private _uniqueId;
  128304. private _disposed;
  128305. /**
  128306. * 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
  128307. */
  128308. grip?: AbstractMesh;
  128309. /**
  128310. * If available, this is the gamepad object related to this controller.
  128311. * Using this object it is possible to get click events and trackpad changes of the
  128312. * webxr controller that is currently being used.
  128313. */
  128314. motionController?: WebXRAbstractMotionController;
  128315. /**
  128316. * Event that fires when the controller is removed/disposed.
  128317. * The object provided as event data is this controller, after associated assets were disposed.
  128318. * uniqueId is still available.
  128319. */
  128320. onDisposeObservable: Observable<WebXRInputSource>;
  128321. /**
  128322. * Will be triggered when the mesh associated with the motion controller is done loading.
  128323. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128324. * A shortened version of controller -> motion controller -> on mesh loaded.
  128325. */
  128326. onMeshLoadedObservable: Observable<AbstractMesh>;
  128327. /**
  128328. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128329. */
  128330. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128331. /**
  128332. * Pointer which can be used to select objects or attach a visible laser to
  128333. */
  128334. pointer: AbstractMesh;
  128335. /**
  128336. * Creates the input source object
  128337. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128338. * @param _scene the scene which the controller should be associated to
  128339. * @param inputSource the underlying input source for the controller
  128340. * @param _options options for this controller creation
  128341. */
  128342. constructor(_scene: Scene,
  128343. /** The underlying input source for the controller */
  128344. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128345. /**
  128346. * Get this controllers unique id
  128347. */
  128348. get uniqueId(): string;
  128349. /**
  128350. * Disposes of the object
  128351. */
  128352. dispose(): void;
  128353. /**
  128354. * Gets a world space ray coming from the pointer or grip
  128355. * @param result the resulting ray
  128356. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128357. */
  128358. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128359. /**
  128360. * Updates the controller pose based on the given XRFrame
  128361. * @param xrFrame xr frame to update the pose with
  128362. * @param referenceSpace reference space to use
  128363. */
  128364. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128365. }
  128366. }
  128367. declare module BABYLON {
  128368. /**
  128369. * The schema for initialization options of the XR Input class
  128370. */
  128371. export interface IWebXRInputOptions {
  128372. /**
  128373. * If set to true no model will be automatically loaded
  128374. */
  128375. doNotLoadControllerMeshes?: boolean;
  128376. /**
  128377. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128378. * If not found, the xr input profile data will be used.
  128379. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128380. */
  128381. forceInputProfile?: string;
  128382. /**
  128383. * Do not send a request to the controller repository to load the profile.
  128384. *
  128385. * Instead, use the controllers available in babylon itself.
  128386. */
  128387. disableOnlineControllerRepository?: boolean;
  128388. /**
  128389. * A custom URL for the controllers repository
  128390. */
  128391. customControllersRepositoryURL?: string;
  128392. /**
  128393. * Should the controller model's components not move according to the user input
  128394. */
  128395. disableControllerAnimation?: boolean;
  128396. /**
  128397. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128398. */
  128399. controllerOptions?: IWebXRControllerOptions;
  128400. }
  128401. /**
  128402. * XR input used to track XR inputs such as controllers/rays
  128403. */
  128404. export class WebXRInput implements IDisposable {
  128405. /**
  128406. * the xr session manager for this session
  128407. */
  128408. xrSessionManager: WebXRSessionManager;
  128409. /**
  128410. * the WebXR camera for this session. Mainly used for teleportation
  128411. */
  128412. xrCamera: WebXRCamera;
  128413. private readonly options;
  128414. /**
  128415. * XR controllers being tracked
  128416. */
  128417. controllers: Array<WebXRInputSource>;
  128418. private _frameObserver;
  128419. private _sessionEndedObserver;
  128420. private _sessionInitObserver;
  128421. /**
  128422. * Event when a controller has been connected/added
  128423. */
  128424. onControllerAddedObservable: Observable<WebXRInputSource>;
  128425. /**
  128426. * Event when a controller has been removed/disconnected
  128427. */
  128428. onControllerRemovedObservable: Observable<WebXRInputSource>;
  128429. /**
  128430. * Initializes the WebXRInput
  128431. * @param xrSessionManager the xr session manager for this session
  128432. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  128433. * @param options = initialization options for this xr input
  128434. */
  128435. constructor(
  128436. /**
  128437. * the xr session manager for this session
  128438. */
  128439. xrSessionManager: WebXRSessionManager,
  128440. /**
  128441. * the WebXR camera for this session. Mainly used for teleportation
  128442. */
  128443. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  128444. private _onInputSourcesChange;
  128445. private _addAndRemoveControllers;
  128446. /**
  128447. * Disposes of the object
  128448. */
  128449. dispose(): void;
  128450. }
  128451. }
  128452. declare module BABYLON {
  128453. /**
  128454. * This is the base class for all WebXR features.
  128455. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  128456. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  128457. */
  128458. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  128459. protected _xrSessionManager: WebXRSessionManager;
  128460. private _attached;
  128461. private _removeOnDetach;
  128462. /**
  128463. * Is this feature disposed?
  128464. */
  128465. isDisposed: boolean;
  128466. /**
  128467. * Should auto-attach be disabled?
  128468. */
  128469. disableAutoAttach: boolean;
  128470. /**
  128471. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  128472. */
  128473. xrNativeFeatureName: string;
  128474. /**
  128475. * Construct a new (abstract) WebXR feature
  128476. * @param _xrSessionManager the xr session manager for this feature
  128477. */
  128478. constructor(_xrSessionManager: WebXRSessionManager);
  128479. /**
  128480. * Is this feature attached
  128481. */
  128482. get attached(): boolean;
  128483. /**
  128484. * attach this feature
  128485. *
  128486. * @param force should attachment be forced (even when already attached)
  128487. * @returns true if successful, false is failed or already attached
  128488. */
  128489. attach(force?: boolean): boolean;
  128490. /**
  128491. * detach this feature.
  128492. *
  128493. * @returns true if successful, false if failed or already detached
  128494. */
  128495. detach(): boolean;
  128496. /**
  128497. * Dispose this feature and all of the resources attached
  128498. */
  128499. dispose(): void;
  128500. /**
  128501. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  128502. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  128503. *
  128504. * @returns whether or not the feature is compatible in this environment
  128505. */
  128506. isCompatible(): boolean;
  128507. /**
  128508. * This is used to register callbacks that will automatically be removed when detach is called.
  128509. * @param observable the observable to which the observer will be attached
  128510. * @param callback the callback to register
  128511. */
  128512. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  128513. /**
  128514. * Code in this function will be executed on each xrFrame received from the browser.
  128515. * This function will not execute after the feature is detached.
  128516. * @param _xrFrame the current frame
  128517. */
  128518. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  128519. }
  128520. }
  128521. declare module BABYLON {
  128522. /**
  128523. * Renders a layer on top of an existing scene
  128524. */
  128525. export class UtilityLayerRenderer implements IDisposable {
  128526. /** the original scene that will be rendered on top of */
  128527. originalScene: Scene;
  128528. private _pointerCaptures;
  128529. private _lastPointerEvents;
  128530. private static _DefaultUtilityLayer;
  128531. private static _DefaultKeepDepthUtilityLayer;
  128532. private _sharedGizmoLight;
  128533. private _renderCamera;
  128534. /**
  128535. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  128536. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  128537. * @returns the camera that is used when rendering the utility layer
  128538. */
  128539. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  128540. /**
  128541. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  128542. * @param cam the camera that should be used when rendering the utility layer
  128543. */
  128544. setRenderCamera(cam: Nullable<Camera>): void;
  128545. /**
  128546. * @hidden
  128547. * Light which used by gizmos to get light shading
  128548. */
  128549. _getSharedGizmoLight(): HemisphericLight;
  128550. /**
  128551. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128552. */
  128553. pickUtilitySceneFirst: boolean;
  128554. /**
  128555. * 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)
  128556. */
  128557. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  128558. /**
  128559. * 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)
  128560. */
  128561. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  128562. /**
  128563. * The scene that is rendered on top of the original scene
  128564. */
  128565. utilityLayerScene: Scene;
  128566. /**
  128567. * If the utility layer should automatically be rendered on top of existing scene
  128568. */
  128569. shouldRender: boolean;
  128570. /**
  128571. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128572. */
  128573. onlyCheckPointerDownEvents: boolean;
  128574. /**
  128575. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128576. */
  128577. processAllEvents: boolean;
  128578. /**
  128579. * Observable raised when the pointer move from the utility layer scene to the main scene
  128580. */
  128581. onPointerOutObservable: Observable<number>;
  128582. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  128583. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  128584. private _afterRenderObserver;
  128585. private _sceneDisposeObserver;
  128586. private _originalPointerObserver;
  128587. /**
  128588. * Instantiates a UtilityLayerRenderer
  128589. * @param originalScene the original scene that will be rendered on top of
  128590. * @param handleEvents boolean indicating if the utility layer should handle events
  128591. */
  128592. constructor(
  128593. /** the original scene that will be rendered on top of */
  128594. originalScene: Scene, handleEvents?: boolean);
  128595. private _notifyObservers;
  128596. /**
  128597. * Renders the utility layers scene on top of the original scene
  128598. */
  128599. render(): void;
  128600. /**
  128601. * Disposes of the renderer
  128602. */
  128603. dispose(): void;
  128604. private _updateCamera;
  128605. }
  128606. }
  128607. declare module BABYLON {
  128608. /**
  128609. * Options interface for the pointer selection module
  128610. */
  128611. export interface IWebXRControllerPointerSelectionOptions {
  128612. /**
  128613. * if provided, this scene will be used to render meshes.
  128614. */
  128615. customUtilityLayerScene?: Scene;
  128616. /**
  128617. * 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)
  128618. * If not disabled, the last picked point will be used to execute a pointer up event
  128619. * If disabled, pointer up event will be triggered right after the pointer down event.
  128620. * Used in screen and gaze target ray mode only
  128621. */
  128622. disablePointerUpOnTouchOut: boolean;
  128623. /**
  128624. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128625. */
  128626. forceGazeMode: boolean;
  128627. /**
  128628. * 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
  128629. * to start a new countdown to the pointer down event.
  128630. * Defaults to 1.
  128631. */
  128632. gazeModePointerMovedFactor?: number;
  128633. /**
  128634. * Different button type to use instead of the main component
  128635. */
  128636. overrideButtonId?: string;
  128637. /**
  128638. * use this rendering group id for the meshes (optional)
  128639. */
  128640. renderingGroupId?: number;
  128641. /**
  128642. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128643. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128644. * 3000 means 3 seconds between pointing at something and selecting it
  128645. */
  128646. timeToSelect?: number;
  128647. /**
  128648. * Should meshes created here be added to a utility layer or the main scene
  128649. */
  128650. useUtilityLayer?: boolean;
  128651. /**
  128652. * Optional WebXR camera to be used for gaze selection
  128653. */
  128654. gazeCamera?: WebXRCamera;
  128655. /**
  128656. * the xr input to use with this pointer selection
  128657. */
  128658. xrInput: WebXRInput;
  128659. }
  128660. /**
  128661. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128662. */
  128663. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128664. private readonly _options;
  128665. private static _idCounter;
  128666. private _attachController;
  128667. private _controllers;
  128668. private _scene;
  128669. private _tmpVectorForPickCompare;
  128670. /**
  128671. * The module's name
  128672. */
  128673. static readonly Name: string;
  128674. /**
  128675. * The (Babylon) version of this module.
  128676. * This is an integer representing the implementation version.
  128677. * This number does not correspond to the WebXR specs version
  128678. */
  128679. static readonly Version: number;
  128680. /**
  128681. * Disable lighting on the laser pointer (so it will always be visible)
  128682. */
  128683. disablePointerLighting: boolean;
  128684. /**
  128685. * Disable lighting on the selection mesh (so it will always be visible)
  128686. */
  128687. disableSelectionMeshLighting: boolean;
  128688. /**
  128689. * Should the laser pointer be displayed
  128690. */
  128691. displayLaserPointer: boolean;
  128692. /**
  128693. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128694. */
  128695. displaySelectionMesh: boolean;
  128696. /**
  128697. * This color will be set to the laser pointer when selection is triggered
  128698. */
  128699. laserPointerPickedColor: Color3;
  128700. /**
  128701. * Default color of the laser pointer
  128702. */
  128703. laserPointerDefaultColor: Color3;
  128704. /**
  128705. * default color of the selection ring
  128706. */
  128707. selectionMeshDefaultColor: Color3;
  128708. /**
  128709. * This color will be applied to the selection ring when selection is triggered
  128710. */
  128711. selectionMeshPickedColor: Color3;
  128712. /**
  128713. * Optional filter to be used for ray selection. This predicate shares behavior with
  128714. * scene.pointerMovePredicate which takes priority if it is also assigned.
  128715. */
  128716. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128717. /**
  128718. * constructs a new background remover module
  128719. * @param _xrSessionManager the session manager for this module
  128720. * @param _options read-only options to be used in this module
  128721. */
  128722. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  128723. /**
  128724. * attach this feature
  128725. * Will usually be called by the features manager
  128726. *
  128727. * @returns true if successful.
  128728. */
  128729. attach(): boolean;
  128730. /**
  128731. * detach this feature.
  128732. * Will usually be called by the features manager
  128733. *
  128734. * @returns true if successful.
  128735. */
  128736. detach(): boolean;
  128737. /**
  128738. * Will get the mesh under a specific pointer.
  128739. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  128740. * @param controllerId the controllerId to check
  128741. * @returns The mesh under pointer or null if no mesh is under the pointer
  128742. */
  128743. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  128744. /**
  128745. * Get the xr controller that correlates to the pointer id in the pointer event
  128746. *
  128747. * @param id the pointer id to search for
  128748. * @returns the controller that correlates to this id or null if not found
  128749. */
  128750. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  128751. protected _onXRFrame(_xrFrame: XRFrame): void;
  128752. private _attachGazeMode;
  128753. private _attachScreenRayMode;
  128754. private _attachTrackedPointerRayMode;
  128755. private _convertNormalToDirectionOfRay;
  128756. private _detachController;
  128757. private _generateNewMeshPair;
  128758. private _pickingMoved;
  128759. private _updatePointerDistance;
  128760. /** @hidden */
  128761. get lasterPointerDefaultColor(): Color3;
  128762. }
  128763. }
  128764. declare module BABYLON {
  128765. /**
  128766. * Button which can be used to enter a different mode of XR
  128767. */
  128768. export class WebXREnterExitUIButton {
  128769. /** button element */
  128770. element: HTMLElement;
  128771. /** XR initialization options for the button */
  128772. sessionMode: XRSessionMode;
  128773. /** Reference space type */
  128774. referenceSpaceType: XRReferenceSpaceType;
  128775. /**
  128776. * Creates a WebXREnterExitUIButton
  128777. * @param element button element
  128778. * @param sessionMode XR initialization session mode
  128779. * @param referenceSpaceType the type of reference space to be used
  128780. */
  128781. constructor(
  128782. /** button element */
  128783. element: HTMLElement,
  128784. /** XR initialization options for the button */
  128785. sessionMode: XRSessionMode,
  128786. /** Reference space type */
  128787. referenceSpaceType: XRReferenceSpaceType);
  128788. /**
  128789. * Extendable function which can be used to update the button's visuals when the state changes
  128790. * @param activeButton the current active button in the UI
  128791. */
  128792. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  128793. }
  128794. /**
  128795. * Options to create the webXR UI
  128796. */
  128797. export class WebXREnterExitUIOptions {
  128798. /**
  128799. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  128800. */
  128801. customButtons?: Array<WebXREnterExitUIButton>;
  128802. /**
  128803. * A reference space type to use when creating the default button.
  128804. * Default is local-floor
  128805. */
  128806. referenceSpaceType?: XRReferenceSpaceType;
  128807. /**
  128808. * Context to enter xr with
  128809. */
  128810. renderTarget?: Nullable<WebXRRenderTarget>;
  128811. /**
  128812. * A session mode to use when creating the default button.
  128813. * Default is immersive-vr
  128814. */
  128815. sessionMode?: XRSessionMode;
  128816. /**
  128817. * A list of optional features to init the session with
  128818. */
  128819. optionalFeatures?: string[];
  128820. /**
  128821. * A list of optional features to init the session with
  128822. */
  128823. requiredFeatures?: string[];
  128824. }
  128825. /**
  128826. * UI to allow the user to enter/exit XR mode
  128827. */
  128828. export class WebXREnterExitUI implements IDisposable {
  128829. private scene;
  128830. /** version of the options passed to this UI */
  128831. options: WebXREnterExitUIOptions;
  128832. private _activeButton;
  128833. private _buttons;
  128834. /**
  128835. * The HTML Div Element to which buttons are added.
  128836. */
  128837. readonly overlay: HTMLDivElement;
  128838. /**
  128839. * Fired every time the active button is changed.
  128840. *
  128841. * When xr is entered via a button that launches xr that button will be the callback parameter
  128842. *
  128843. * When exiting xr the callback parameter will be null)
  128844. */
  128845. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  128846. /**
  128847. *
  128848. * @param scene babylon scene object to use
  128849. * @param options (read-only) version of the options passed to this UI
  128850. */
  128851. private constructor();
  128852. /**
  128853. * Creates UI to allow the user to enter/exit XR mode
  128854. * @param scene the scene to add the ui to
  128855. * @param helper the xr experience helper to enter/exit xr with
  128856. * @param options options to configure the UI
  128857. * @returns the created ui
  128858. */
  128859. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  128860. /**
  128861. * Disposes of the XR UI component
  128862. */
  128863. dispose(): void;
  128864. private _updateButtons;
  128865. }
  128866. }
  128867. declare module BABYLON {
  128868. /**
  128869. * Class containing static functions to help procedurally build meshes
  128870. */
  128871. export class LinesBuilder {
  128872. /**
  128873. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  128874. * * 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
  128875. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  128876. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  128877. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  128878. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  128879. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128880. * * 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
  128881. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  128882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  128884. * @param name defines the name of the new line system
  128885. * @param options defines the options used to create the line system
  128886. * @param scene defines the hosting scene
  128887. * @returns a new line system mesh
  128888. */
  128889. static CreateLineSystem(name: string, options: {
  128890. lines: Vector3[][];
  128891. updatable?: boolean;
  128892. instance?: Nullable<LinesMesh>;
  128893. colors?: Nullable<Color4[][]>;
  128894. useVertexAlpha?: boolean;
  128895. }, scene: Nullable<Scene>): LinesMesh;
  128896. /**
  128897. * Creates a line mesh
  128898. * 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
  128899. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128900. * * The parameter `points` is an array successive Vector3
  128901. * * 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
  128902. * * The optional parameter `colors` is an array of successive Color4, one per line point
  128903. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  128904. * * When updating an instance, remember that only point positions can change, not the number of points
  128905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  128907. * @param name defines the name of the new line system
  128908. * @param options defines the options used to create the line system
  128909. * @param scene defines the hosting scene
  128910. * @returns a new line mesh
  128911. */
  128912. static CreateLines(name: string, options: {
  128913. points: Vector3[];
  128914. updatable?: boolean;
  128915. instance?: Nullable<LinesMesh>;
  128916. colors?: Color4[];
  128917. useVertexAlpha?: boolean;
  128918. }, scene?: Nullable<Scene>): LinesMesh;
  128919. /**
  128920. * Creates a dashed line mesh
  128921. * * 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
  128922. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128923. * * The parameter `points` is an array successive Vector3
  128924. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  128925. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  128926. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  128927. * * 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
  128928. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128929. * * When updating an instance, remember that only point positions can change, not the number of points
  128930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128931. * @param name defines the name of the mesh
  128932. * @param options defines the options used to create the mesh
  128933. * @param scene defines the hosting scene
  128934. * @returns the dashed line mesh
  128935. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  128936. */
  128937. static CreateDashedLines(name: string, options: {
  128938. points: Vector3[];
  128939. dashSize?: number;
  128940. gapSize?: number;
  128941. dashNb?: number;
  128942. updatable?: boolean;
  128943. instance?: LinesMesh;
  128944. useVertexAlpha?: boolean;
  128945. }, scene?: Nullable<Scene>): LinesMesh;
  128946. }
  128947. }
  128948. declare module BABYLON {
  128949. /**
  128950. * Construction options for a timer
  128951. */
  128952. export interface ITimerOptions<T> {
  128953. /**
  128954. * Time-to-end
  128955. */
  128956. timeout: number;
  128957. /**
  128958. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  128959. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  128960. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  128961. */
  128962. contextObservable: Observable<T>;
  128963. /**
  128964. * Optional parameters when adding an observer to the observable
  128965. */
  128966. observableParameters?: {
  128967. mask?: number;
  128968. insertFirst?: boolean;
  128969. scope?: any;
  128970. };
  128971. /**
  128972. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  128973. */
  128974. breakCondition?: (data?: ITimerData<T>) => boolean;
  128975. /**
  128976. * Will be triggered when the time condition has met
  128977. */
  128978. onEnded?: (data: ITimerData<any>) => void;
  128979. /**
  128980. * Will be triggered when the break condition has met (prematurely ended)
  128981. */
  128982. onAborted?: (data: ITimerData<any>) => void;
  128983. /**
  128984. * Optional function to execute on each tick (or count)
  128985. */
  128986. onTick?: (data: ITimerData<any>) => void;
  128987. }
  128988. /**
  128989. * An interface defining the data sent by the timer
  128990. */
  128991. export interface ITimerData<T> {
  128992. /**
  128993. * When did it start
  128994. */
  128995. startTime: number;
  128996. /**
  128997. * Time now
  128998. */
  128999. currentTime: number;
  129000. /**
  129001. * Time passed since started
  129002. */
  129003. deltaTime: number;
  129004. /**
  129005. * How much is completed, in [0.0...1.0].
  129006. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129007. */
  129008. completeRate: number;
  129009. /**
  129010. * What the registered observable sent in the last count
  129011. */
  129012. payload: T;
  129013. }
  129014. /**
  129015. * The current state of the timer
  129016. */
  129017. export enum TimerState {
  129018. /**
  129019. * Timer initialized, not yet started
  129020. */
  129021. INIT = 0,
  129022. /**
  129023. * Timer started and counting
  129024. */
  129025. STARTED = 1,
  129026. /**
  129027. * Timer ended (whether aborted or time reached)
  129028. */
  129029. ENDED = 2
  129030. }
  129031. /**
  129032. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129033. *
  129034. * @param options options with which to initialize this timer
  129035. */
  129036. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129037. /**
  129038. * An advanced implementation of a timer class
  129039. */
  129040. export class AdvancedTimer<T = any> implements IDisposable {
  129041. /**
  129042. * Will notify each time the timer calculates the remaining time
  129043. */
  129044. onEachCountObservable: Observable<ITimerData<T>>;
  129045. /**
  129046. * Will trigger when the timer was aborted due to the break condition
  129047. */
  129048. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129049. /**
  129050. * Will trigger when the timer ended successfully
  129051. */
  129052. onTimerEndedObservable: Observable<ITimerData<T>>;
  129053. /**
  129054. * Will trigger when the timer state has changed
  129055. */
  129056. onStateChangedObservable: Observable<TimerState>;
  129057. private _observer;
  129058. private _contextObservable;
  129059. private _observableParameters;
  129060. private _startTime;
  129061. private _timer;
  129062. private _state;
  129063. private _breakCondition;
  129064. private _timeToEnd;
  129065. private _breakOnNextTick;
  129066. /**
  129067. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129068. * @param options construction options for this advanced timer
  129069. */
  129070. constructor(options: ITimerOptions<T>);
  129071. /**
  129072. * set a breaking condition for this timer. Default is to never break during count
  129073. * @param predicate the new break condition. Returns true to break, false otherwise
  129074. */
  129075. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129076. /**
  129077. * Reset ALL associated observables in this advanced timer
  129078. */
  129079. clearObservables(): void;
  129080. /**
  129081. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129082. *
  129083. * @param timeToEnd how much time to measure until timer ended
  129084. */
  129085. start(timeToEnd?: number): void;
  129086. /**
  129087. * Will force a stop on the next tick.
  129088. */
  129089. stop(): void;
  129090. /**
  129091. * Dispose this timer, clearing all resources
  129092. */
  129093. dispose(): void;
  129094. private _setState;
  129095. private _tick;
  129096. private _stop;
  129097. }
  129098. }
  129099. declare module BABYLON {
  129100. /**
  129101. * The options container for the teleportation module
  129102. */
  129103. export interface IWebXRTeleportationOptions {
  129104. /**
  129105. * if provided, this scene will be used to render meshes.
  129106. */
  129107. customUtilityLayerScene?: Scene;
  129108. /**
  129109. * Values to configure the default target mesh
  129110. */
  129111. defaultTargetMeshOptions?: {
  129112. /**
  129113. * Fill color of the teleportation area
  129114. */
  129115. teleportationFillColor?: string;
  129116. /**
  129117. * Border color for the teleportation area
  129118. */
  129119. teleportationBorderColor?: string;
  129120. /**
  129121. * Disable the mesh's animation sequence
  129122. */
  129123. disableAnimation?: boolean;
  129124. /**
  129125. * Disable lighting on the material or the ring and arrow
  129126. */
  129127. disableLighting?: boolean;
  129128. /**
  129129. * Override the default material of the torus and arrow
  129130. */
  129131. torusArrowMaterial?: Material;
  129132. };
  129133. /**
  129134. * A list of meshes to use as floor meshes.
  129135. * Meshes can be added and removed after initializing the feature using the
  129136. * addFloorMesh and removeFloorMesh functions
  129137. * If empty, rotation will still work
  129138. */
  129139. floorMeshes?: AbstractMesh[];
  129140. /**
  129141. * use this rendering group id for the meshes (optional)
  129142. */
  129143. renderingGroupId?: number;
  129144. /**
  129145. * Should teleportation move only to snap points
  129146. */
  129147. snapPointsOnly?: boolean;
  129148. /**
  129149. * An array of points to which the teleportation will snap to.
  129150. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129151. */
  129152. snapPositions?: Vector3[];
  129153. /**
  129154. * How close should the teleportation ray be in order to snap to position.
  129155. * Default to 0.8 units (meters)
  129156. */
  129157. snapToPositionRadius?: number;
  129158. /**
  129159. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129160. * If you want to support rotation, make sure your mesh has a direction indicator.
  129161. *
  129162. * When left untouched, the default mesh will be initialized.
  129163. */
  129164. teleportationTargetMesh?: AbstractMesh;
  129165. /**
  129166. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129167. */
  129168. timeToTeleport?: number;
  129169. /**
  129170. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129171. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129172. */
  129173. useMainComponentOnly?: boolean;
  129174. /**
  129175. * Should meshes created here be added to a utility layer or the main scene
  129176. */
  129177. useUtilityLayer?: boolean;
  129178. /**
  129179. * Babylon XR Input class for controller
  129180. */
  129181. xrInput: WebXRInput;
  129182. /**
  129183. * Meshes that the teleportation ray cannot go through
  129184. */
  129185. pickBlockerMeshes?: AbstractMesh[];
  129186. }
  129187. /**
  129188. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129189. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129190. * the input of the attached controllers.
  129191. */
  129192. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129193. private _options;
  129194. private _controllers;
  129195. private _currentTeleportationControllerId;
  129196. private _floorMeshes;
  129197. private _quadraticBezierCurve;
  129198. private _selectionFeature;
  129199. private _snapToPositions;
  129200. private _snappedToPoint;
  129201. private _teleportationRingMaterial?;
  129202. private _tmpRay;
  129203. private _tmpVector;
  129204. private _tmpQuaternion;
  129205. /**
  129206. * The module's name
  129207. */
  129208. static readonly Name: string;
  129209. /**
  129210. * The (Babylon) version of this module.
  129211. * This is an integer representing the implementation version.
  129212. * This number does not correspond to the webxr specs version
  129213. */
  129214. static readonly Version: number;
  129215. /**
  129216. * Is movement backwards enabled
  129217. */
  129218. backwardsMovementEnabled: boolean;
  129219. /**
  129220. * Distance to travel when moving backwards
  129221. */
  129222. backwardsTeleportationDistance: number;
  129223. /**
  129224. * The distance from the user to the inspection point in the direction of the controller
  129225. * A higher number will allow the user to move further
  129226. * defaults to 5 (meters, in xr units)
  129227. */
  129228. parabolicCheckRadius: number;
  129229. /**
  129230. * Should the module support parabolic ray on top of direct ray
  129231. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129232. * Very helpful when moving between floors / different heights
  129233. */
  129234. parabolicRayEnabled: boolean;
  129235. /**
  129236. * How much rotation should be applied when rotating right and left
  129237. */
  129238. rotationAngle: number;
  129239. /**
  129240. * Is rotation enabled when moving forward?
  129241. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129242. */
  129243. rotationEnabled: boolean;
  129244. /**
  129245. * constructs a new anchor system
  129246. * @param _xrSessionManager an instance of WebXRSessionManager
  129247. * @param _options configuration object for this feature
  129248. */
  129249. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129250. /**
  129251. * Get the snapPointsOnly flag
  129252. */
  129253. get snapPointsOnly(): boolean;
  129254. /**
  129255. * Sets the snapPointsOnly flag
  129256. * @param snapToPoints should teleportation be exclusively to snap points
  129257. */
  129258. set snapPointsOnly(snapToPoints: boolean);
  129259. /**
  129260. * Add a new mesh to the floor meshes array
  129261. * @param mesh the mesh to use as floor mesh
  129262. */
  129263. addFloorMesh(mesh: AbstractMesh): void;
  129264. /**
  129265. * Add a new snap-to point to fix teleportation to this position
  129266. * @param newSnapPoint The new Snap-To point
  129267. */
  129268. addSnapPoint(newSnapPoint: Vector3): void;
  129269. attach(): boolean;
  129270. detach(): boolean;
  129271. dispose(): void;
  129272. /**
  129273. * Remove a mesh from the floor meshes array
  129274. * @param mesh the mesh to remove
  129275. */
  129276. removeFloorMesh(mesh: AbstractMesh): void;
  129277. /**
  129278. * Remove a mesh from the floor meshes array using its name
  129279. * @param name the mesh name to remove
  129280. */
  129281. removeFloorMeshByName(name: string): void;
  129282. /**
  129283. * 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
  129284. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129285. * @returns was the point found and removed or not
  129286. */
  129287. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129288. /**
  129289. * This function sets a selection feature that will be disabled when
  129290. * the forward ray is shown and will be reattached when hidden.
  129291. * This is used to remove the selection rays when moving.
  129292. * @param selectionFeature the feature to disable when forward movement is enabled
  129293. */
  129294. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129295. protected _onXRFrame(_xrFrame: XRFrame): void;
  129296. private _attachController;
  129297. private _createDefaultTargetMesh;
  129298. private _detachController;
  129299. private _findClosestSnapPointWithRadius;
  129300. private _setTargetMeshPosition;
  129301. private _setTargetMeshVisibility;
  129302. private _showParabolicPath;
  129303. private _teleportForward;
  129304. }
  129305. }
  129306. declare module BABYLON {
  129307. /**
  129308. * Options for the default xr helper
  129309. */
  129310. export class WebXRDefaultExperienceOptions {
  129311. /**
  129312. * Enable or disable default UI to enter XR
  129313. */
  129314. disableDefaultUI?: boolean;
  129315. /**
  129316. * Should teleportation not initialize. defaults to false.
  129317. */
  129318. disableTeleportation?: boolean;
  129319. /**
  129320. * Floor meshes that will be used for teleport
  129321. */
  129322. floorMeshes?: Array<AbstractMesh>;
  129323. /**
  129324. * If set to true, the first frame will not be used to reset position
  129325. * The first frame is mainly used when copying transformation from the old camera
  129326. * Mainly used in AR
  129327. */
  129328. ignoreNativeCameraTransformation?: boolean;
  129329. /**
  129330. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129331. */
  129332. inputOptions?: IWebXRInputOptions;
  129333. /**
  129334. * optional configuration for the output canvas
  129335. */
  129336. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129337. /**
  129338. * optional UI options. This can be used among other to change session mode and reference space type
  129339. */
  129340. uiOptions?: WebXREnterExitUIOptions;
  129341. /**
  129342. * When loading teleportation and pointer select, use stable versions instead of latest.
  129343. */
  129344. useStablePlugins?: boolean;
  129345. /**
  129346. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129347. */
  129348. renderingGroupId?: number;
  129349. /**
  129350. * A list of optional features to init the session with
  129351. * If set to true, all features we support will be added
  129352. */
  129353. optionalFeatures?: boolean | string[];
  129354. }
  129355. /**
  129356. * Default experience which provides a similar setup to the previous webVRExperience
  129357. */
  129358. export class WebXRDefaultExperience {
  129359. /**
  129360. * Base experience
  129361. */
  129362. baseExperience: WebXRExperienceHelper;
  129363. /**
  129364. * Enables ui for entering/exiting xr
  129365. */
  129366. enterExitUI: WebXREnterExitUI;
  129367. /**
  129368. * Input experience extension
  129369. */
  129370. input: WebXRInput;
  129371. /**
  129372. * Enables laser pointer and selection
  129373. */
  129374. pointerSelection: WebXRControllerPointerSelection;
  129375. /**
  129376. * Default target xr should render to
  129377. */
  129378. renderTarget: WebXRRenderTarget;
  129379. /**
  129380. * Enables teleportation
  129381. */
  129382. teleportation: WebXRMotionControllerTeleportation;
  129383. private constructor();
  129384. /**
  129385. * Creates the default xr experience
  129386. * @param scene scene
  129387. * @param options options for basic configuration
  129388. * @returns resulting WebXRDefaultExperience
  129389. */
  129390. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129391. /**
  129392. * DIsposes of the experience helper
  129393. */
  129394. dispose(): void;
  129395. }
  129396. }
  129397. declare module BABYLON {
  129398. /**
  129399. * Options to modify the vr teleportation behavior.
  129400. */
  129401. export interface VRTeleportationOptions {
  129402. /**
  129403. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129404. */
  129405. floorMeshName?: string;
  129406. /**
  129407. * A list of meshes to be used as the teleportation floor. (default: empty)
  129408. */
  129409. floorMeshes?: Mesh[];
  129410. /**
  129411. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  129412. */
  129413. teleportationMode?: number;
  129414. /**
  129415. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  129416. */
  129417. teleportationTime?: number;
  129418. /**
  129419. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  129420. */
  129421. teleportationSpeed?: number;
  129422. /**
  129423. * The easing function used in the animation or null for Linear. (default CircleEase)
  129424. */
  129425. easingFunction?: EasingFunction;
  129426. }
  129427. /**
  129428. * Options to modify the vr experience helper's behavior.
  129429. */
  129430. export interface VRExperienceHelperOptions extends WebVROptions {
  129431. /**
  129432. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  129433. */
  129434. createDeviceOrientationCamera?: boolean;
  129435. /**
  129436. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  129437. */
  129438. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  129439. /**
  129440. * Uses the main button on the controller to toggle the laser casted. (default: true)
  129441. */
  129442. laserToggle?: boolean;
  129443. /**
  129444. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  129445. */
  129446. floorMeshes?: Mesh[];
  129447. /**
  129448. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  129449. */
  129450. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  129451. /**
  129452. * Defines if WebXR should be used instead of WebVR (if available)
  129453. */
  129454. useXR?: boolean;
  129455. }
  129456. /**
  129457. * Event containing information after VR has been entered
  129458. */
  129459. export class OnAfterEnteringVRObservableEvent {
  129460. /**
  129461. * If entering vr was successful
  129462. */
  129463. success: boolean;
  129464. }
  129465. /**
  129466. * Helps to quickly add VR support to an existing scene.
  129467. * See https://doc.babylonjs.com/how_to/webvr_helper
  129468. */
  129469. export class VRExperienceHelper {
  129470. /** Options to modify the vr experience helper's behavior. */
  129471. webVROptions: VRExperienceHelperOptions;
  129472. private _scene;
  129473. private _position;
  129474. private _btnVR;
  129475. private _btnVRDisplayed;
  129476. private _webVRsupported;
  129477. private _webVRready;
  129478. private _webVRrequesting;
  129479. private _webVRpresenting;
  129480. private _hasEnteredVR;
  129481. private _fullscreenVRpresenting;
  129482. private _inputElement;
  129483. private _webVRCamera;
  129484. private _vrDeviceOrientationCamera;
  129485. private _deviceOrientationCamera;
  129486. private _existingCamera;
  129487. private _onKeyDown;
  129488. private _onVrDisplayPresentChange;
  129489. private _onVRDisplayChanged;
  129490. private _onVRRequestPresentStart;
  129491. private _onVRRequestPresentComplete;
  129492. /**
  129493. * 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)
  129494. */
  129495. enableGazeEvenWhenNoPointerLock: boolean;
  129496. /**
  129497. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  129498. */
  129499. exitVROnDoubleTap: boolean;
  129500. /**
  129501. * Observable raised right before entering VR.
  129502. */
  129503. onEnteringVRObservable: Observable<VRExperienceHelper>;
  129504. /**
  129505. * Observable raised when entering VR has completed.
  129506. */
  129507. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  129508. /**
  129509. * Observable raised when exiting VR.
  129510. */
  129511. onExitingVRObservable: Observable<VRExperienceHelper>;
  129512. /**
  129513. * Observable raised when controller mesh is loaded.
  129514. */
  129515. onControllerMeshLoadedObservable: Observable<WebVRController>;
  129516. /** Return this.onEnteringVRObservable
  129517. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  129518. */
  129519. get onEnteringVR(): Observable<VRExperienceHelper>;
  129520. /** Return this.onExitingVRObservable
  129521. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  129522. */
  129523. get onExitingVR(): Observable<VRExperienceHelper>;
  129524. /** Return this.onControllerMeshLoadedObservable
  129525. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  129526. */
  129527. get onControllerMeshLoaded(): Observable<WebVRController>;
  129528. private _rayLength;
  129529. private _useCustomVRButton;
  129530. private _teleportationRequested;
  129531. private _teleportActive;
  129532. private _floorMeshName;
  129533. private _floorMeshesCollection;
  129534. private _teleportationMode;
  129535. private _teleportationTime;
  129536. private _teleportationSpeed;
  129537. private _teleportationEasing;
  129538. private _rotationAllowed;
  129539. private _teleportBackwardsVector;
  129540. private _teleportationTarget;
  129541. private _isDefaultTeleportationTarget;
  129542. private _postProcessMove;
  129543. private _teleportationFillColor;
  129544. private _teleportationBorderColor;
  129545. private _rotationAngle;
  129546. private _haloCenter;
  129547. private _cameraGazer;
  129548. private _padSensibilityUp;
  129549. private _padSensibilityDown;
  129550. private _leftController;
  129551. private _rightController;
  129552. private _gazeColor;
  129553. private _laserColor;
  129554. private _pickedLaserColor;
  129555. private _pickedGazeColor;
  129556. /**
  129557. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  129558. */
  129559. onNewMeshSelected: Observable<AbstractMesh>;
  129560. /**
  129561. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  129562. * This observable will provide the mesh and the controller used to select the mesh
  129563. */
  129564. onMeshSelectedWithController: Observable<{
  129565. mesh: AbstractMesh;
  129566. controller: WebVRController;
  129567. }>;
  129568. /**
  129569. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  129570. */
  129571. onNewMeshPicked: Observable<PickingInfo>;
  129572. private _circleEase;
  129573. /**
  129574. * Observable raised before camera teleportation
  129575. */
  129576. onBeforeCameraTeleport: Observable<Vector3>;
  129577. /**
  129578. * Observable raised after camera teleportation
  129579. */
  129580. onAfterCameraTeleport: Observable<Vector3>;
  129581. /**
  129582. * Observable raised when current selected mesh gets unselected
  129583. */
  129584. onSelectedMeshUnselected: Observable<AbstractMesh>;
  129585. private _raySelectionPredicate;
  129586. /**
  129587. * To be optionaly changed by user to define custom ray selection
  129588. */
  129589. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129590. /**
  129591. * To be optionaly changed by user to define custom selection logic (after ray selection)
  129592. */
  129593. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129594. /**
  129595. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  129596. */
  129597. teleportationEnabled: boolean;
  129598. private _defaultHeight;
  129599. private _teleportationInitialized;
  129600. private _interactionsEnabled;
  129601. private _interactionsRequested;
  129602. private _displayGaze;
  129603. private _displayLaserPointer;
  129604. /**
  129605. * The mesh used to display where the user is going to teleport.
  129606. */
  129607. get teleportationTarget(): Mesh;
  129608. /**
  129609. * Sets the mesh to be used to display where the user is going to teleport.
  129610. */
  129611. set teleportationTarget(value: Mesh);
  129612. /**
  129613. * 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
  129614. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129615. * See https://doc.babylonjs.com/resources/baking_transformations
  129616. */
  129617. get gazeTrackerMesh(): Mesh;
  129618. set gazeTrackerMesh(value: Mesh);
  129619. /**
  129620. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129621. */
  129622. updateGazeTrackerScale: boolean;
  129623. /**
  129624. * If the gaze trackers color should be updated when selecting meshes
  129625. */
  129626. updateGazeTrackerColor: boolean;
  129627. /**
  129628. * If the controller laser color should be updated when selecting meshes
  129629. */
  129630. updateControllerLaserColor: boolean;
  129631. /**
  129632. * The gaze tracking mesh corresponding to the left controller
  129633. */
  129634. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129635. /**
  129636. * The gaze tracking mesh corresponding to the right controller
  129637. */
  129638. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129639. /**
  129640. * If the ray of the gaze should be displayed.
  129641. */
  129642. get displayGaze(): boolean;
  129643. /**
  129644. * Sets if the ray of the gaze should be displayed.
  129645. */
  129646. set displayGaze(value: boolean);
  129647. /**
  129648. * If the ray of the LaserPointer should be displayed.
  129649. */
  129650. get displayLaserPointer(): boolean;
  129651. /**
  129652. * Sets if the ray of the LaserPointer should be displayed.
  129653. */
  129654. set displayLaserPointer(value: boolean);
  129655. /**
  129656. * The deviceOrientationCamera used as the camera when not in VR.
  129657. */
  129658. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129659. /**
  129660. * Based on the current WebVR support, returns the current VR camera used.
  129661. */
  129662. get currentVRCamera(): Nullable<Camera>;
  129663. /**
  129664. * The webVRCamera which is used when in VR.
  129665. */
  129666. get webVRCamera(): WebVRFreeCamera;
  129667. /**
  129668. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129669. */
  129670. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129671. /**
  129672. * The html button that is used to trigger entering into VR.
  129673. */
  129674. get vrButton(): Nullable<HTMLButtonElement>;
  129675. private get _teleportationRequestInitiated();
  129676. /**
  129677. * Defines whether or not Pointer lock should be requested when switching to
  129678. * full screen.
  129679. */
  129680. requestPointerLockOnFullScreen: boolean;
  129681. /**
  129682. * If asking to force XR, this will be populated with the default xr experience
  129683. */
  129684. xr: WebXRDefaultExperience;
  129685. /**
  129686. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129687. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129688. */
  129689. xrTestDone: boolean;
  129690. /**
  129691. * Instantiates a VRExperienceHelper.
  129692. * Helps to quickly add VR support to an existing scene.
  129693. * @param scene The scene the VRExperienceHelper belongs to.
  129694. * @param webVROptions Options to modify the vr experience helper's behavior.
  129695. */
  129696. constructor(scene: Scene,
  129697. /** Options to modify the vr experience helper's behavior. */
  129698. webVROptions?: VRExperienceHelperOptions);
  129699. private completeVRInit;
  129700. private _onDefaultMeshLoaded;
  129701. private _onResize;
  129702. private _onFullscreenChange;
  129703. /**
  129704. * Gets a value indicating if we are currently in VR mode.
  129705. */
  129706. get isInVRMode(): boolean;
  129707. private onVrDisplayPresentChange;
  129708. private onVRDisplayChanged;
  129709. private moveButtonToBottomRight;
  129710. private displayVRButton;
  129711. private updateButtonVisibility;
  129712. private _cachedAngularSensibility;
  129713. /**
  129714. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  129715. * Otherwise, will use the fullscreen API.
  129716. */
  129717. enterVR(): void;
  129718. /**
  129719. * Attempt to exit VR, or fullscreen.
  129720. */
  129721. exitVR(): void;
  129722. /**
  129723. * The position of the vr experience helper.
  129724. */
  129725. get position(): Vector3;
  129726. /**
  129727. * Sets the position of the vr experience helper.
  129728. */
  129729. set position(value: Vector3);
  129730. /**
  129731. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  129732. */
  129733. enableInteractions(): void;
  129734. private get _noControllerIsActive();
  129735. private beforeRender;
  129736. private _isTeleportationFloor;
  129737. /**
  129738. * Adds a floor mesh to be used for teleportation.
  129739. * @param floorMesh the mesh to be used for teleportation.
  129740. */
  129741. addFloorMesh(floorMesh: Mesh): void;
  129742. /**
  129743. * Removes a floor mesh from being used for teleportation.
  129744. * @param floorMesh the mesh to be removed.
  129745. */
  129746. removeFloorMesh(floorMesh: Mesh): void;
  129747. /**
  129748. * Enables interactions and teleportation using the VR controllers and gaze.
  129749. * @param vrTeleportationOptions options to modify teleportation behavior.
  129750. */
  129751. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  129752. private _onNewGamepadConnected;
  129753. private _tryEnableInteractionOnController;
  129754. private _onNewGamepadDisconnected;
  129755. private _enableInteractionOnController;
  129756. private _checkTeleportWithRay;
  129757. private _checkRotate;
  129758. private _checkTeleportBackwards;
  129759. private _enableTeleportationOnController;
  129760. private _createTeleportationCircles;
  129761. private _displayTeleportationTarget;
  129762. private _hideTeleportationTarget;
  129763. private _rotateCamera;
  129764. private _moveTeleportationSelectorTo;
  129765. private _workingVector;
  129766. private _workingQuaternion;
  129767. private _workingMatrix;
  129768. /**
  129769. * Time Constant Teleportation Mode
  129770. */
  129771. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  129772. /**
  129773. * Speed Constant Teleportation Mode
  129774. */
  129775. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  129776. /**
  129777. * Teleports the users feet to the desired location
  129778. * @param location The location where the user's feet should be placed
  129779. */
  129780. teleportCamera(location: Vector3): void;
  129781. private _convertNormalToDirectionOfRay;
  129782. private _castRayAndSelectObject;
  129783. private _notifySelectedMeshUnselected;
  129784. /**
  129785. * Permanently set new colors for the laser pointer
  129786. * @param color the new laser color
  129787. * @param pickedColor the new laser color when picked mesh detected
  129788. */
  129789. setLaserColor(color: Color3, pickedColor?: Color3): void;
  129790. /**
  129791. * Set lighting enabled / disabled on the laser pointer of both controllers
  129792. * @param enabled should the lighting be enabled on the laser pointer
  129793. */
  129794. setLaserLightingState(enabled?: boolean): void;
  129795. /**
  129796. * Permanently set new colors for the gaze pointer
  129797. * @param color the new gaze color
  129798. * @param pickedColor the new gaze color when picked mesh detected
  129799. */
  129800. setGazeColor(color: Color3, pickedColor?: Color3): void;
  129801. /**
  129802. * Sets the color of the laser ray from the vr controllers.
  129803. * @param color new color for the ray.
  129804. */
  129805. changeLaserColor(color: Color3): void;
  129806. /**
  129807. * Sets the color of the ray from the vr headsets gaze.
  129808. * @param color new color for the ray.
  129809. */
  129810. changeGazeColor(color: Color3): void;
  129811. /**
  129812. * Exits VR and disposes of the vr experience helper
  129813. */
  129814. dispose(): void;
  129815. /**
  129816. * Gets the name of the VRExperienceHelper class
  129817. * @returns "VRExperienceHelper"
  129818. */
  129819. getClassName(): string;
  129820. }
  129821. }
  129822. declare module BABYLON {
  129823. /**
  129824. * Contains an array of blocks representing the octree
  129825. */
  129826. export interface IOctreeContainer<T> {
  129827. /**
  129828. * Blocks within the octree
  129829. */
  129830. blocks: Array<OctreeBlock<T>>;
  129831. }
  129832. /**
  129833. * Class used to store a cell in an octree
  129834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129835. */
  129836. export class OctreeBlock<T> {
  129837. /**
  129838. * Gets the content of the current block
  129839. */
  129840. entries: T[];
  129841. /**
  129842. * Gets the list of block children
  129843. */
  129844. blocks: Array<OctreeBlock<T>>;
  129845. private _depth;
  129846. private _maxDepth;
  129847. private _capacity;
  129848. private _minPoint;
  129849. private _maxPoint;
  129850. private _boundingVectors;
  129851. private _creationFunc;
  129852. /**
  129853. * Creates a new block
  129854. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  129855. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  129856. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129857. * @param depth defines the current depth of this block in the octree
  129858. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  129859. * @param creationFunc defines a callback to call when an element is added to the block
  129860. */
  129861. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  129862. /**
  129863. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129864. */
  129865. get capacity(): number;
  129866. /**
  129867. * Gets the minimum vector (in world space) of the block's bounding box
  129868. */
  129869. get minPoint(): Vector3;
  129870. /**
  129871. * Gets the maximum vector (in world space) of the block's bounding box
  129872. */
  129873. get maxPoint(): Vector3;
  129874. /**
  129875. * Add a new element to this block
  129876. * @param entry defines the element to add
  129877. */
  129878. addEntry(entry: T): void;
  129879. /**
  129880. * Remove an element from this block
  129881. * @param entry defines the element to remove
  129882. */
  129883. removeEntry(entry: T): void;
  129884. /**
  129885. * Add an array of elements to this block
  129886. * @param entries defines the array of elements to add
  129887. */
  129888. addEntries(entries: T[]): void;
  129889. /**
  129890. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  129891. * @param frustumPlanes defines the frustum planes to test
  129892. * @param selection defines the array to store current content if selection is positive
  129893. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129894. */
  129895. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129896. /**
  129897. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  129898. * @param sphereCenter defines the bounding sphere center
  129899. * @param sphereRadius defines the bounding sphere radius
  129900. * @param selection defines the array to store current content if selection is positive
  129901. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129902. */
  129903. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129904. /**
  129905. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  129906. * @param ray defines the ray to test with
  129907. * @param selection defines the array to store current content if selection is positive
  129908. */
  129909. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  129910. /**
  129911. * Subdivide the content into child blocks (this block will then be empty)
  129912. */
  129913. createInnerBlocks(): void;
  129914. /**
  129915. * @hidden
  129916. */
  129917. 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;
  129918. }
  129919. }
  129920. declare module BABYLON {
  129921. /**
  129922. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  129923. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129924. */
  129925. export class Octree<T> {
  129926. /** 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.) */
  129927. maxDepth: number;
  129928. /**
  129929. * Blocks within the octree containing objects
  129930. */
  129931. blocks: Array<OctreeBlock<T>>;
  129932. /**
  129933. * Content stored in the octree
  129934. */
  129935. dynamicContent: T[];
  129936. private _maxBlockCapacity;
  129937. private _selectionContent;
  129938. private _creationFunc;
  129939. /**
  129940. * Creates a octree
  129941. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129942. * @param creationFunc function to be used to instatiate the octree
  129943. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  129944. * @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.)
  129945. */
  129946. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  129947. /** 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.) */
  129948. maxDepth?: number);
  129949. /**
  129950. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  129951. * @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);
  129952. * @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);
  129953. * @param entries meshes to be added to the octree blocks
  129954. */
  129955. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  129956. /**
  129957. * Adds a mesh to the octree
  129958. * @param entry Mesh to add to the octree
  129959. */
  129960. addMesh(entry: T): void;
  129961. /**
  129962. * Remove an element from the octree
  129963. * @param entry defines the element to remove
  129964. */
  129965. removeMesh(entry: T): void;
  129966. /**
  129967. * Selects an array of meshes within the frustum
  129968. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  129969. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  129970. * @returns array of meshes within the frustum
  129971. */
  129972. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  129973. /**
  129974. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  129975. * @param sphereCenter defines the bounding sphere center
  129976. * @param sphereRadius defines the bounding sphere radius
  129977. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129978. * @returns an array of objects that intersect the sphere
  129979. */
  129980. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  129981. /**
  129982. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  129983. * @param ray defines the ray to test with
  129984. * @returns array of intersected objects
  129985. */
  129986. intersectsRay(ray: Ray): SmartArray<T>;
  129987. /**
  129988. * Adds a mesh into the octree block if it intersects the block
  129989. */
  129990. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  129991. /**
  129992. * Adds a submesh into the octree block if it intersects the block
  129993. */
  129994. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  129995. }
  129996. }
  129997. declare module BABYLON {
  129998. interface Scene {
  129999. /**
  130000. * @hidden
  130001. * Backing Filed
  130002. */
  130003. _selectionOctree: Octree<AbstractMesh>;
  130004. /**
  130005. * Gets the octree used to boost mesh selection (picking)
  130006. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130007. */
  130008. selectionOctree: Octree<AbstractMesh>;
  130009. /**
  130010. * Creates or updates the octree used to boost selection (picking)
  130011. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130012. * @param maxCapacity defines the maximum capacity per leaf
  130013. * @param maxDepth defines the maximum depth of the octree
  130014. * @returns an octree of AbstractMesh
  130015. */
  130016. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130017. }
  130018. interface AbstractMesh {
  130019. /**
  130020. * @hidden
  130021. * Backing Field
  130022. */
  130023. _submeshesOctree: Octree<SubMesh>;
  130024. /**
  130025. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130026. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130027. * @param maxCapacity defines the maximum size of each block (64 by default)
  130028. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130029. * @returns the new octree
  130030. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130031. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130032. */
  130033. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130034. }
  130035. /**
  130036. * Defines the octree scene component responsible to manage any octrees
  130037. * in a given scene.
  130038. */
  130039. export class OctreeSceneComponent {
  130040. /**
  130041. * The component name help to identify the component in the list of scene components.
  130042. */
  130043. readonly name: string;
  130044. /**
  130045. * The scene the component belongs to.
  130046. */
  130047. scene: Scene;
  130048. /**
  130049. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130050. */
  130051. readonly checksIsEnabled: boolean;
  130052. /**
  130053. * Creates a new instance of the component for the given scene
  130054. * @param scene Defines the scene to register the component in
  130055. */
  130056. constructor(scene: Scene);
  130057. /**
  130058. * Registers the component in a given scene
  130059. */
  130060. register(): void;
  130061. /**
  130062. * Return the list of active meshes
  130063. * @returns the list of active meshes
  130064. */
  130065. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130066. /**
  130067. * Return the list of active sub meshes
  130068. * @param mesh The mesh to get the candidates sub meshes from
  130069. * @returns the list of active sub meshes
  130070. */
  130071. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130072. private _tempRay;
  130073. /**
  130074. * Return the list of sub meshes intersecting with a given local ray
  130075. * @param mesh defines the mesh to find the submesh for
  130076. * @param localRay defines the ray in local space
  130077. * @returns the list of intersecting sub meshes
  130078. */
  130079. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130080. /**
  130081. * Return the list of sub meshes colliding with a collider
  130082. * @param mesh defines the mesh to find the submesh for
  130083. * @param collider defines the collider to evaluate the collision against
  130084. * @returns the list of colliding sub meshes
  130085. */
  130086. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130087. /**
  130088. * Rebuilds the elements related to this component in case of
  130089. * context lost for instance.
  130090. */
  130091. rebuild(): void;
  130092. /**
  130093. * Disposes the component and the associated ressources.
  130094. */
  130095. dispose(): void;
  130096. }
  130097. }
  130098. declare module BABYLON {
  130099. /**
  130100. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130101. */
  130102. export class Gizmo implements IDisposable {
  130103. /** The utility layer the gizmo will be added to */
  130104. gizmoLayer: UtilityLayerRenderer;
  130105. /**
  130106. * The root mesh of the gizmo
  130107. */
  130108. _rootMesh: Mesh;
  130109. private _attachedMesh;
  130110. private _attachedNode;
  130111. /**
  130112. * Ratio for the scale of the gizmo (Default: 1)
  130113. */
  130114. protected _scaleRatio: number;
  130115. /**
  130116. * Ratio for the scale of the gizmo (Default: 1)
  130117. */
  130118. set scaleRatio(value: number);
  130119. get scaleRatio(): number;
  130120. /**
  130121. * If a custom mesh has been set (Default: false)
  130122. */
  130123. protected _customMeshSet: boolean;
  130124. /**
  130125. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130126. * * When set, interactions will be enabled
  130127. */
  130128. get attachedMesh(): Nullable<AbstractMesh>;
  130129. set attachedMesh(value: Nullable<AbstractMesh>);
  130130. /**
  130131. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130132. * * When set, interactions will be enabled
  130133. */
  130134. get attachedNode(): Nullable<Node>;
  130135. set attachedNode(value: Nullable<Node>);
  130136. /**
  130137. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130138. * @param mesh The mesh to replace the default mesh of the gizmo
  130139. */
  130140. setCustomMesh(mesh: Mesh): void;
  130141. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130142. /**
  130143. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130144. */
  130145. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130146. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130147. /**
  130148. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130149. */
  130150. updateGizmoPositionToMatchAttachedMesh: boolean;
  130151. /**
  130152. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130153. */
  130154. updateScale: boolean;
  130155. protected _interactionsEnabled: boolean;
  130156. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130157. private _beforeRenderObserver;
  130158. private _tempQuaternion;
  130159. private _tempVector;
  130160. private _tempVector2;
  130161. private _tempMatrix1;
  130162. private _tempMatrix2;
  130163. private _rightHandtoLeftHandMatrix;
  130164. /**
  130165. * Creates a gizmo
  130166. * @param gizmoLayer The utility layer the gizmo will be added to
  130167. */
  130168. constructor(
  130169. /** The utility layer the gizmo will be added to */
  130170. gizmoLayer?: UtilityLayerRenderer);
  130171. /**
  130172. * Updates the gizmo to match the attached mesh's position/rotation
  130173. */
  130174. protected _update(): void;
  130175. /**
  130176. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130177. * @param value Node, TransformNode or mesh
  130178. */
  130179. protected _matrixChanged(): void;
  130180. /**
  130181. * Disposes of the gizmo
  130182. */
  130183. dispose(): void;
  130184. }
  130185. }
  130186. declare module BABYLON {
  130187. /**
  130188. * Single plane drag gizmo
  130189. */
  130190. export class PlaneDragGizmo extends Gizmo {
  130191. /**
  130192. * Drag behavior responsible for the gizmos dragging interactions
  130193. */
  130194. dragBehavior: PointerDragBehavior;
  130195. private _pointerObserver;
  130196. /**
  130197. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130198. */
  130199. snapDistance: number;
  130200. /**
  130201. * Event that fires each time the gizmo snaps to a new location.
  130202. * * snapDistance is the the change in distance
  130203. */
  130204. onSnapObservable: Observable<{
  130205. snapDistance: number;
  130206. }>;
  130207. private _plane;
  130208. private _coloredMaterial;
  130209. private _hoverMaterial;
  130210. private _isEnabled;
  130211. private _parent;
  130212. /** @hidden */
  130213. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130214. /** @hidden */
  130215. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130216. /**
  130217. * Creates a PlaneDragGizmo
  130218. * @param gizmoLayer The utility layer the gizmo will be added to
  130219. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130220. * @param color The color of the gizmo
  130221. */
  130222. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130223. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130224. /**
  130225. * If the gizmo is enabled
  130226. */
  130227. set isEnabled(value: boolean);
  130228. get isEnabled(): boolean;
  130229. /**
  130230. * Disposes of the gizmo
  130231. */
  130232. dispose(): void;
  130233. }
  130234. }
  130235. declare module BABYLON {
  130236. /**
  130237. * Gizmo that enables dragging a mesh along 3 axis
  130238. */
  130239. export class PositionGizmo extends Gizmo {
  130240. /**
  130241. * Internal gizmo used for interactions on the x axis
  130242. */
  130243. xGizmo: AxisDragGizmo;
  130244. /**
  130245. * Internal gizmo used for interactions on the y axis
  130246. */
  130247. yGizmo: AxisDragGizmo;
  130248. /**
  130249. * Internal gizmo used for interactions on the z axis
  130250. */
  130251. zGizmo: AxisDragGizmo;
  130252. /**
  130253. * Internal gizmo used for interactions on the yz plane
  130254. */
  130255. xPlaneGizmo: PlaneDragGizmo;
  130256. /**
  130257. * Internal gizmo used for interactions on the xz plane
  130258. */
  130259. yPlaneGizmo: PlaneDragGizmo;
  130260. /**
  130261. * Internal gizmo used for interactions on the xy plane
  130262. */
  130263. zPlaneGizmo: PlaneDragGizmo;
  130264. /**
  130265. * private variables
  130266. */
  130267. private _meshAttached;
  130268. private _nodeAttached;
  130269. private _snapDistance;
  130270. /** Fires an event when any of it's sub gizmos are dragged */
  130271. onDragStartObservable: Observable<unknown>;
  130272. /** Fires an event when any of it's sub gizmos are released from dragging */
  130273. onDragEndObservable: Observable<unknown>;
  130274. /**
  130275. * If set to true, planar drag is enabled
  130276. */
  130277. private _planarGizmoEnabled;
  130278. get attachedMesh(): Nullable<AbstractMesh>;
  130279. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130280. get attachedNode(): Nullable<Node>;
  130281. set attachedNode(node: Nullable<Node>);
  130282. /**
  130283. * Creates a PositionGizmo
  130284. * @param gizmoLayer The utility layer the gizmo will be added to
  130285. @param thickness display gizmo axis thickness
  130286. */
  130287. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130288. /**
  130289. * If the planar drag gizmo is enabled
  130290. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130291. */
  130292. set planarGizmoEnabled(value: boolean);
  130293. get planarGizmoEnabled(): boolean;
  130294. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130295. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130296. /**
  130297. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130298. */
  130299. set snapDistance(value: number);
  130300. get snapDistance(): number;
  130301. /**
  130302. * Ratio for the scale of the gizmo (Default: 1)
  130303. */
  130304. set scaleRatio(value: number);
  130305. get scaleRatio(): number;
  130306. /**
  130307. * Disposes of the gizmo
  130308. */
  130309. dispose(): void;
  130310. /**
  130311. * CustomMeshes are not supported by this gizmo
  130312. * @param mesh The mesh to replace the default mesh of the gizmo
  130313. */
  130314. setCustomMesh(mesh: Mesh): void;
  130315. }
  130316. }
  130317. declare module BABYLON {
  130318. /**
  130319. * Single axis drag gizmo
  130320. */
  130321. export class AxisDragGizmo extends Gizmo {
  130322. /**
  130323. * Drag behavior responsible for the gizmos dragging interactions
  130324. */
  130325. dragBehavior: PointerDragBehavior;
  130326. private _pointerObserver;
  130327. /**
  130328. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130329. */
  130330. snapDistance: number;
  130331. /**
  130332. * Event that fires each time the gizmo snaps to a new location.
  130333. * * snapDistance is the the change in distance
  130334. */
  130335. onSnapObservable: Observable<{
  130336. snapDistance: number;
  130337. }>;
  130338. private _isEnabled;
  130339. private _parent;
  130340. private _arrow;
  130341. private _coloredMaterial;
  130342. private _hoverMaterial;
  130343. /** @hidden */
  130344. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130345. /** @hidden */
  130346. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130347. /**
  130348. * Creates an AxisDragGizmo
  130349. * @param gizmoLayer The utility layer the gizmo will be added to
  130350. * @param dragAxis The axis which the gizmo will be able to drag on
  130351. * @param color The color of the gizmo
  130352. * @param thickness display gizmo axis thickness
  130353. */
  130354. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130355. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130356. /**
  130357. * If the gizmo is enabled
  130358. */
  130359. set isEnabled(value: boolean);
  130360. get isEnabled(): boolean;
  130361. /**
  130362. * Disposes of the gizmo
  130363. */
  130364. dispose(): void;
  130365. }
  130366. }
  130367. declare module BABYLON.Debug {
  130368. /**
  130369. * The Axes viewer will show 3 axes in a specific point in space
  130370. */
  130371. export class AxesViewer {
  130372. private _xAxis;
  130373. private _yAxis;
  130374. private _zAxis;
  130375. private _scaleLinesFactor;
  130376. private _instanced;
  130377. /**
  130378. * Gets the hosting scene
  130379. */
  130380. scene: Nullable<Scene>;
  130381. /**
  130382. * Gets or sets a number used to scale line length
  130383. */
  130384. scaleLines: number;
  130385. /** Gets the node hierarchy used to render x-axis */
  130386. get xAxis(): TransformNode;
  130387. /** Gets the node hierarchy used to render y-axis */
  130388. get yAxis(): TransformNode;
  130389. /** Gets the node hierarchy used to render z-axis */
  130390. get zAxis(): TransformNode;
  130391. /**
  130392. * Creates a new AxesViewer
  130393. * @param scene defines the hosting scene
  130394. * @param scaleLines defines a number used to scale line length (1 by default)
  130395. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130396. * @param xAxis defines the node hierarchy used to render the x-axis
  130397. * @param yAxis defines the node hierarchy used to render the y-axis
  130398. * @param zAxis defines the node hierarchy used to render the z-axis
  130399. */
  130400. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130401. /**
  130402. * Force the viewer to update
  130403. * @param position defines the position of the viewer
  130404. * @param xaxis defines the x axis of the viewer
  130405. * @param yaxis defines the y axis of the viewer
  130406. * @param zaxis defines the z axis of the viewer
  130407. */
  130408. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130409. /**
  130410. * Creates an instance of this axes viewer.
  130411. * @returns a new axes viewer with instanced meshes
  130412. */
  130413. createInstance(): AxesViewer;
  130414. /** Releases resources */
  130415. dispose(): void;
  130416. private static _SetRenderingGroupId;
  130417. }
  130418. }
  130419. declare module BABYLON.Debug {
  130420. /**
  130421. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  130422. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  130423. */
  130424. export class BoneAxesViewer extends AxesViewer {
  130425. /**
  130426. * Gets or sets the target mesh where to display the axes viewer
  130427. */
  130428. mesh: Nullable<Mesh>;
  130429. /**
  130430. * Gets or sets the target bone where to display the axes viewer
  130431. */
  130432. bone: Nullable<Bone>;
  130433. /** Gets current position */
  130434. pos: Vector3;
  130435. /** Gets direction of X axis */
  130436. xaxis: Vector3;
  130437. /** Gets direction of Y axis */
  130438. yaxis: Vector3;
  130439. /** Gets direction of Z axis */
  130440. zaxis: Vector3;
  130441. /**
  130442. * Creates a new BoneAxesViewer
  130443. * @param scene defines the hosting scene
  130444. * @param bone defines the target bone
  130445. * @param mesh defines the target mesh
  130446. * @param scaleLines defines a scaling factor for line length (1 by default)
  130447. */
  130448. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  130449. /**
  130450. * Force the viewer to update
  130451. */
  130452. update(): void;
  130453. /** Releases resources */
  130454. dispose(): void;
  130455. }
  130456. }
  130457. declare module BABYLON {
  130458. /**
  130459. * Interface used to define scene explorer extensibility option
  130460. */
  130461. export interface IExplorerExtensibilityOption {
  130462. /**
  130463. * Define the option label
  130464. */
  130465. label: string;
  130466. /**
  130467. * Defines the action to execute on click
  130468. */
  130469. action: (entity: any) => void;
  130470. }
  130471. /**
  130472. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  130473. */
  130474. export interface IExplorerExtensibilityGroup {
  130475. /**
  130476. * Defines a predicate to test if a given type mut be extended
  130477. */
  130478. predicate: (entity: any) => boolean;
  130479. /**
  130480. * Gets the list of options added to a type
  130481. */
  130482. entries: IExplorerExtensibilityOption[];
  130483. }
  130484. /**
  130485. * Interface used to define the options to use to create the Inspector
  130486. */
  130487. export interface IInspectorOptions {
  130488. /**
  130489. * Display in overlay mode (default: false)
  130490. */
  130491. overlay?: boolean;
  130492. /**
  130493. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  130494. */
  130495. globalRoot?: HTMLElement;
  130496. /**
  130497. * Display the Scene explorer
  130498. */
  130499. showExplorer?: boolean;
  130500. /**
  130501. * Display the property inspector
  130502. */
  130503. showInspector?: boolean;
  130504. /**
  130505. * Display in embed mode (both panes on the right)
  130506. */
  130507. embedMode?: boolean;
  130508. /**
  130509. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  130510. */
  130511. handleResize?: boolean;
  130512. /**
  130513. * Allow the panes to popup (default: true)
  130514. */
  130515. enablePopup?: boolean;
  130516. /**
  130517. * Allow the panes to be closed by users (default: true)
  130518. */
  130519. enableClose?: boolean;
  130520. /**
  130521. * Optional list of extensibility entries
  130522. */
  130523. explorerExtensibility?: IExplorerExtensibilityGroup[];
  130524. /**
  130525. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  130526. */
  130527. inspectorURL?: string;
  130528. /**
  130529. * Optional initial tab (default to DebugLayerTab.Properties)
  130530. */
  130531. initialTab?: DebugLayerTab;
  130532. }
  130533. interface Scene {
  130534. /**
  130535. * @hidden
  130536. * Backing field
  130537. */
  130538. _debugLayer: DebugLayer;
  130539. /**
  130540. * Gets the debug layer (aka Inspector) associated with the scene
  130541. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130542. */
  130543. debugLayer: DebugLayer;
  130544. }
  130545. /**
  130546. * Enum of inspector action tab
  130547. */
  130548. export enum DebugLayerTab {
  130549. /**
  130550. * Properties tag (default)
  130551. */
  130552. Properties = 0,
  130553. /**
  130554. * Debug tab
  130555. */
  130556. Debug = 1,
  130557. /**
  130558. * Statistics tab
  130559. */
  130560. Statistics = 2,
  130561. /**
  130562. * Tools tab
  130563. */
  130564. Tools = 3,
  130565. /**
  130566. * Settings tab
  130567. */
  130568. Settings = 4
  130569. }
  130570. /**
  130571. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130572. * what is happening in your scene
  130573. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130574. */
  130575. export class DebugLayer {
  130576. /**
  130577. * Define the url to get the inspector script from.
  130578. * By default it uses the babylonjs CDN.
  130579. * @ignoreNaming
  130580. */
  130581. static InspectorURL: string;
  130582. private _scene;
  130583. private BJSINSPECTOR;
  130584. private _onPropertyChangedObservable?;
  130585. /**
  130586. * Observable triggered when a property is changed through the inspector.
  130587. */
  130588. get onPropertyChangedObservable(): any;
  130589. /**
  130590. * Instantiates a new debug layer.
  130591. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130592. * what is happening in your scene
  130593. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130594. * @param scene Defines the scene to inspect
  130595. */
  130596. constructor(scene: Scene);
  130597. /** Creates the inspector window. */
  130598. private _createInspector;
  130599. /**
  130600. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  130601. * @param entity defines the entity to select
  130602. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  130603. */
  130604. select(entity: any, lineContainerTitles?: string | string[]): void;
  130605. /** Get the inspector from bundle or global */
  130606. private _getGlobalInspector;
  130607. /**
  130608. * Get if the inspector is visible or not.
  130609. * @returns true if visible otherwise, false
  130610. */
  130611. isVisible(): boolean;
  130612. /**
  130613. * Hide the inspector and close its window.
  130614. */
  130615. hide(): void;
  130616. /**
  130617. * Update the scene in the inspector
  130618. */
  130619. setAsActiveScene(): void;
  130620. /**
  130621. * Launch the debugLayer.
  130622. * @param config Define the configuration of the inspector
  130623. * @return a promise fulfilled when the debug layer is visible
  130624. */
  130625. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130626. }
  130627. }
  130628. declare module BABYLON {
  130629. /**
  130630. * Class containing static functions to help procedurally build meshes
  130631. */
  130632. export class BoxBuilder {
  130633. /**
  130634. * Creates a box mesh
  130635. * * The parameter `size` sets the size (float) of each box side (default 1)
  130636. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130637. * * 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)
  130638. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130642. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130643. * @param name defines the name of the mesh
  130644. * @param options defines the options used to create the mesh
  130645. * @param scene defines the hosting scene
  130646. * @returns the box mesh
  130647. */
  130648. static CreateBox(name: string, options: {
  130649. size?: number;
  130650. width?: number;
  130651. height?: number;
  130652. depth?: number;
  130653. faceUV?: Vector4[];
  130654. faceColors?: Color4[];
  130655. sideOrientation?: number;
  130656. frontUVs?: Vector4;
  130657. backUVs?: Vector4;
  130658. wrap?: boolean;
  130659. topBaseAt?: number;
  130660. bottomBaseAt?: number;
  130661. updatable?: boolean;
  130662. }, scene?: Nullable<Scene>): Mesh;
  130663. }
  130664. }
  130665. declare module BABYLON.Debug {
  130666. /**
  130667. * Used to show the physics impostor around the specific mesh
  130668. */
  130669. export class PhysicsViewer {
  130670. /** @hidden */
  130671. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130672. /** @hidden */
  130673. protected _meshes: Array<Nullable<AbstractMesh>>;
  130674. /** @hidden */
  130675. protected _scene: Nullable<Scene>;
  130676. /** @hidden */
  130677. protected _numMeshes: number;
  130678. /** @hidden */
  130679. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130680. private _renderFunction;
  130681. private _utilityLayer;
  130682. private _debugBoxMesh;
  130683. private _debugSphereMesh;
  130684. private _debugCylinderMesh;
  130685. private _debugMaterial;
  130686. private _debugMeshMeshes;
  130687. /**
  130688. * Creates a new PhysicsViewer
  130689. * @param scene defines the hosting scene
  130690. */
  130691. constructor(scene: Scene);
  130692. /** @hidden */
  130693. protected _updateDebugMeshes(): void;
  130694. /**
  130695. * Renders a specified physic impostor
  130696. * @param impostor defines the impostor to render
  130697. * @param targetMesh defines the mesh represented by the impostor
  130698. * @returns the new debug mesh used to render the impostor
  130699. */
  130700. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130701. /**
  130702. * Hides a specified physic impostor
  130703. * @param impostor defines the impostor to hide
  130704. */
  130705. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130706. private _getDebugMaterial;
  130707. private _getDebugBoxMesh;
  130708. private _getDebugSphereMesh;
  130709. private _getDebugCylinderMesh;
  130710. private _getDebugMeshMesh;
  130711. private _getDebugMesh;
  130712. /** Releases all resources */
  130713. dispose(): void;
  130714. }
  130715. }
  130716. declare module BABYLON {
  130717. /**
  130718. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130719. * in order to better appreciate the issue one might have.
  130720. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130721. */
  130722. export class RayHelper {
  130723. /**
  130724. * Defines the ray we are currently tryin to visualize.
  130725. */
  130726. ray: Nullable<Ray>;
  130727. private _renderPoints;
  130728. private _renderLine;
  130729. private _renderFunction;
  130730. private _scene;
  130731. private _onAfterRenderObserver;
  130732. private _onAfterStepObserver;
  130733. private _attachedToMesh;
  130734. private _meshSpaceDirection;
  130735. private _meshSpaceOrigin;
  130736. /**
  130737. * Helper function to create a colored helper in a scene in one line.
  130738. * @param ray Defines the ray we are currently tryin to visualize
  130739. * @param scene Defines the scene the ray is used in
  130740. * @param color Defines the color we want to see the ray in
  130741. * @returns The newly created ray helper.
  130742. */
  130743. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  130744. /**
  130745. * Instantiate a new ray helper.
  130746. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130747. * in order to better appreciate the issue one might have.
  130748. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130749. * @param ray Defines the ray we are currently tryin to visualize
  130750. */
  130751. constructor(ray: Ray);
  130752. /**
  130753. * Shows the ray we are willing to debug.
  130754. * @param scene Defines the scene the ray needs to be rendered in
  130755. * @param color Defines the color the ray needs to be rendered in
  130756. */
  130757. show(scene: Scene, color?: Color3): void;
  130758. /**
  130759. * Hides the ray we are debugging.
  130760. */
  130761. hide(): void;
  130762. private _render;
  130763. /**
  130764. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  130765. * @param mesh Defines the mesh we want the helper attached to
  130766. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  130767. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  130768. * @param length Defines the length of the ray
  130769. */
  130770. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  130771. /**
  130772. * Detach the ray helper from the mesh it has previously been attached to.
  130773. */
  130774. detachFromMesh(): void;
  130775. private _updateToMesh;
  130776. /**
  130777. * Dispose the helper and release its associated resources.
  130778. */
  130779. dispose(): void;
  130780. }
  130781. }
  130782. declare module BABYLON {
  130783. /**
  130784. * Defines the options associated with the creation of a SkeletonViewer.
  130785. */
  130786. export interface ISkeletonViewerOptions {
  130787. /** Should the system pause animations before building the Viewer? */
  130788. pauseAnimations: boolean;
  130789. /** Should the system return the skeleton to rest before building? */
  130790. returnToRest: boolean;
  130791. /** public Display Mode of the Viewer */
  130792. displayMode: number;
  130793. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130794. displayOptions: ISkeletonViewerDisplayOptions;
  130795. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130796. computeBonesUsingShaders: boolean;
  130797. /** Flag ignore non weighted bones */
  130798. useAllBones: boolean;
  130799. }
  130800. /**
  130801. * Defines how to display the various bone meshes for the viewer.
  130802. */
  130803. export interface ISkeletonViewerDisplayOptions {
  130804. /** How far down to start tapering the bone spurs */
  130805. midStep?: number;
  130806. /** How big is the midStep? */
  130807. midStepFactor?: number;
  130808. /** Base for the Sphere Size */
  130809. sphereBaseSize?: number;
  130810. /** The ratio of the sphere to the longest bone in units */
  130811. sphereScaleUnit?: number;
  130812. /** Ratio for the Sphere Size */
  130813. sphereFactor?: number;
  130814. }
  130815. /**
  130816. * Defines the constructor options for the BoneWeight Shader.
  130817. */
  130818. export interface IBoneWeightShaderOptions {
  130819. /** Skeleton to Map */
  130820. skeleton: Skeleton;
  130821. /** Colors for Uninfluenced bones */
  130822. colorBase?: Color3;
  130823. /** Colors for 0.0-0.25 Weight bones */
  130824. colorZero?: Color3;
  130825. /** Color for 0.25-0.5 Weight Influence */
  130826. colorQuarter?: Color3;
  130827. /** Color for 0.5-0.75 Weight Influence */
  130828. colorHalf?: Color3;
  130829. /** Color for 0.75-1 Weight Influence */
  130830. colorFull?: Color3;
  130831. /** Color for Zero Weight Influence */
  130832. targetBoneIndex?: number;
  130833. }
  130834. /**
  130835. * Simple structure of the gradient steps for the Color Map.
  130836. */
  130837. export interface ISkeletonMapShaderColorMapKnot {
  130838. /** Color of the Knot */
  130839. color: Color3;
  130840. /** Location of the Knot */
  130841. location: number;
  130842. }
  130843. /**
  130844. * Defines the constructor options for the SkeletonMap Shader.
  130845. */
  130846. export interface ISkeletonMapShaderOptions {
  130847. /** Skeleton to Map */
  130848. skeleton: Skeleton;
  130849. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  130850. colorMap?: ISkeletonMapShaderColorMapKnot[];
  130851. }
  130852. }
  130853. declare module BABYLON {
  130854. /**
  130855. * Class containing static functions to help procedurally build meshes
  130856. */
  130857. export class RibbonBuilder {
  130858. /**
  130859. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130860. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130861. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130862. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130863. * * 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
  130864. * * 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
  130865. * * 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
  130866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130868. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130869. * * 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
  130870. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130871. * * 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
  130872. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130874. * @param name defines the name of the mesh
  130875. * @param options defines the options used to create the mesh
  130876. * @param scene defines the hosting scene
  130877. * @returns the ribbon mesh
  130878. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130879. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130880. */
  130881. static CreateRibbon(name: string, options: {
  130882. pathArray: Vector3[][];
  130883. closeArray?: boolean;
  130884. closePath?: boolean;
  130885. offset?: number;
  130886. updatable?: boolean;
  130887. sideOrientation?: number;
  130888. frontUVs?: Vector4;
  130889. backUVs?: Vector4;
  130890. instance?: Mesh;
  130891. invertUV?: boolean;
  130892. uvs?: Vector2[];
  130893. colors?: Color4[];
  130894. }, scene?: Nullable<Scene>): Mesh;
  130895. }
  130896. }
  130897. declare module BABYLON {
  130898. /**
  130899. * Class containing static functions to help procedurally build meshes
  130900. */
  130901. export class ShapeBuilder {
  130902. /**
  130903. * 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.
  130904. * * 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.
  130905. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130906. * * 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.
  130907. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130908. * * 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
  130909. * * 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
  130910. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130913. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130915. * @param name defines the name of the mesh
  130916. * @param options defines the options used to create the mesh
  130917. * @param scene defines the hosting scene
  130918. * @returns the extruded shape mesh
  130919. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130921. */
  130922. static ExtrudeShape(name: string, options: {
  130923. shape: Vector3[];
  130924. path: Vector3[];
  130925. scale?: number;
  130926. rotation?: number;
  130927. cap?: number;
  130928. updatable?: boolean;
  130929. sideOrientation?: number;
  130930. frontUVs?: Vector4;
  130931. backUVs?: Vector4;
  130932. instance?: Mesh;
  130933. invertUV?: boolean;
  130934. }, scene?: Nullable<Scene>): Mesh;
  130935. /**
  130936. * Creates an custom extruded shape mesh.
  130937. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130938. * * 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.
  130939. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130940. * * 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
  130941. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130942. * * 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
  130943. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130944. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130945. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130946. * * 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
  130947. * * 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
  130948. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130953. * @param name defines the name of the mesh
  130954. * @param options defines the options used to create the mesh
  130955. * @param scene defines the hosting scene
  130956. * @returns the custom extruded shape mesh
  130957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130958. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130960. */
  130961. static ExtrudeShapeCustom(name: string, options: {
  130962. shape: Vector3[];
  130963. path: Vector3[];
  130964. scaleFunction?: any;
  130965. rotationFunction?: any;
  130966. ribbonCloseArray?: boolean;
  130967. ribbonClosePath?: boolean;
  130968. cap?: number;
  130969. updatable?: boolean;
  130970. sideOrientation?: number;
  130971. frontUVs?: Vector4;
  130972. backUVs?: Vector4;
  130973. instance?: Mesh;
  130974. invertUV?: boolean;
  130975. }, scene?: Nullable<Scene>): Mesh;
  130976. private static _ExtrudeShapeGeneric;
  130977. }
  130978. }
  130979. declare module BABYLON.Debug {
  130980. /**
  130981. * Class used to render a debug view of a given skeleton
  130982. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  130983. */
  130984. export class SkeletonViewer {
  130985. /** defines the skeleton to render */
  130986. skeleton: Skeleton;
  130987. /** defines the mesh attached to the skeleton */
  130988. mesh: AbstractMesh;
  130989. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130990. autoUpdateBonesMatrices: boolean;
  130991. /** defines the rendering group id to use with the viewer */
  130992. renderingGroupId: number;
  130993. /** is the options for the viewer */
  130994. options: Partial<ISkeletonViewerOptions>;
  130995. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  130996. static readonly DISPLAY_LINES: number;
  130997. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  130998. static readonly DISPLAY_SPHERES: number;
  130999. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131000. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131001. /** public static method to create a BoneWeight Shader
  131002. * @param options The constructor options
  131003. * @param scene The scene that the shader is scoped to
  131004. * @returns The created ShaderMaterial
  131005. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131006. */
  131007. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131008. /** public static method to create a BoneWeight Shader
  131009. * @param options The constructor options
  131010. * @param scene The scene that the shader is scoped to
  131011. * @returns The created ShaderMaterial
  131012. */
  131013. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131014. /** private static method to create a BoneWeight Shader
  131015. * @param size The size of the buffer to create (usually the bone count)
  131016. * @param colorMap The gradient data to generate
  131017. * @param scene The scene that the shader is scoped to
  131018. * @returns an Array of floats from the color gradient values
  131019. */
  131020. private static _CreateBoneMapColorBuffer;
  131021. /** If SkeletonViewer scene scope. */
  131022. private _scene;
  131023. /** Gets or sets the color used to render the skeleton */
  131024. color: Color3;
  131025. /** Array of the points of the skeleton fo the line view. */
  131026. private _debugLines;
  131027. /** The SkeletonViewers Mesh. */
  131028. private _debugMesh;
  131029. /** If SkeletonViewer is enabled. */
  131030. private _isEnabled;
  131031. /** If SkeletonViewer is ready. */
  131032. private _ready;
  131033. /** SkeletonViewer render observable. */
  131034. private _obs;
  131035. /** The Utility Layer to render the gizmos in. */
  131036. private _utilityLayer;
  131037. private _boneIndices;
  131038. /** Gets the Scene. */
  131039. get scene(): Scene;
  131040. /** Gets the utilityLayer. */
  131041. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131042. /** Checks Ready Status. */
  131043. get isReady(): Boolean;
  131044. /** Sets Ready Status. */
  131045. set ready(value: boolean);
  131046. /** Gets the debugMesh */
  131047. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131048. /** Sets the debugMesh */
  131049. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131050. /** Gets the material */
  131051. get material(): StandardMaterial;
  131052. /** Sets the material */
  131053. set material(value: StandardMaterial);
  131054. /** Gets the material */
  131055. get displayMode(): number;
  131056. /** Sets the material */
  131057. set displayMode(value: number);
  131058. /**
  131059. * Creates a new SkeletonViewer
  131060. * @param skeleton defines the skeleton to render
  131061. * @param mesh defines the mesh attached to the skeleton
  131062. * @param scene defines the hosting scene
  131063. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131064. * @param renderingGroupId defines the rendering group id to use with the viewer
  131065. * @param options All of the extra constructor options for the SkeletonViewer
  131066. */
  131067. constructor(
  131068. /** defines the skeleton to render */
  131069. skeleton: Skeleton,
  131070. /** defines the mesh attached to the skeleton */
  131071. mesh: AbstractMesh,
  131072. /** The Scene scope*/
  131073. scene: Scene,
  131074. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131075. autoUpdateBonesMatrices?: boolean,
  131076. /** defines the rendering group id to use with the viewer */
  131077. renderingGroupId?: number,
  131078. /** is the options for the viewer */
  131079. options?: Partial<ISkeletonViewerOptions>);
  131080. /** The Dynamic bindings for the update functions */
  131081. private _bindObs;
  131082. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131083. update(): void;
  131084. /** Gets or sets a boolean indicating if the viewer is enabled */
  131085. set isEnabled(value: boolean);
  131086. get isEnabled(): boolean;
  131087. private _getBonePosition;
  131088. private _getLinesForBonesWithLength;
  131089. private _getLinesForBonesNoLength;
  131090. /** function to revert the mesh and scene back to the initial state. */
  131091. private _revert;
  131092. /** function to build and bind sphere joint points and spur bone representations. */
  131093. private _buildSpheresAndSpurs;
  131094. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131095. private _displayLinesUpdate;
  131096. /** Changes the displayMode of the skeleton viewer
  131097. * @param mode The displayMode numerical value
  131098. */
  131099. changeDisplayMode(mode: number): void;
  131100. /** Changes the displayMode of the skeleton viewer
  131101. * @param option String of the option name
  131102. * @param value The numerical option value
  131103. */
  131104. changeDisplayOptions(option: string, value: number): void;
  131105. /** Release associated resources */
  131106. dispose(): void;
  131107. }
  131108. }
  131109. declare module BABYLON {
  131110. /**
  131111. * Enum for Device Types
  131112. */
  131113. export enum DeviceType {
  131114. /** Generic */
  131115. Generic = 0,
  131116. /** Keyboard */
  131117. Keyboard = 1,
  131118. /** Mouse */
  131119. Mouse = 2,
  131120. /** Touch Pointers */
  131121. Touch = 3,
  131122. /** PS4 Dual Shock */
  131123. DualShock = 4,
  131124. /** Xbox */
  131125. Xbox = 5,
  131126. /** Switch Controller */
  131127. Switch = 6
  131128. }
  131129. /**
  131130. * Enum for All Pointers (Touch/Mouse)
  131131. */
  131132. export enum PointerInput {
  131133. /** Horizontal Axis */
  131134. Horizontal = 0,
  131135. /** Vertical Axis */
  131136. Vertical = 1,
  131137. /** Left Click or Touch */
  131138. LeftClick = 2,
  131139. /** Middle Click */
  131140. MiddleClick = 3,
  131141. /** Right Click */
  131142. RightClick = 4,
  131143. /** Browser Back */
  131144. BrowserBack = 5,
  131145. /** Browser Forward */
  131146. BrowserForward = 6
  131147. }
  131148. /**
  131149. * Enum for Dual Shock Gamepad
  131150. */
  131151. export enum DualShockInput {
  131152. /** Cross */
  131153. Cross = 0,
  131154. /** Circle */
  131155. Circle = 1,
  131156. /** Square */
  131157. Square = 2,
  131158. /** Triangle */
  131159. Triangle = 3,
  131160. /** L1 */
  131161. L1 = 4,
  131162. /** R1 */
  131163. R1 = 5,
  131164. /** L2 */
  131165. L2 = 6,
  131166. /** R2 */
  131167. R2 = 7,
  131168. /** Share */
  131169. Share = 8,
  131170. /** Options */
  131171. Options = 9,
  131172. /** L3 */
  131173. L3 = 10,
  131174. /** R3 */
  131175. R3 = 11,
  131176. /** DPadUp */
  131177. DPadUp = 12,
  131178. /** DPadDown */
  131179. DPadDown = 13,
  131180. /** DPadLeft */
  131181. DPadLeft = 14,
  131182. /** DRight */
  131183. DPadRight = 15,
  131184. /** Home */
  131185. Home = 16,
  131186. /** TouchPad */
  131187. TouchPad = 17,
  131188. /** LStickXAxis */
  131189. LStickXAxis = 18,
  131190. /** LStickYAxis */
  131191. LStickYAxis = 19,
  131192. /** RStickXAxis */
  131193. RStickXAxis = 20,
  131194. /** RStickYAxis */
  131195. RStickYAxis = 21
  131196. }
  131197. /**
  131198. * Enum for Xbox Gamepad
  131199. */
  131200. export enum XboxInput {
  131201. /** A */
  131202. A = 0,
  131203. /** B */
  131204. B = 1,
  131205. /** X */
  131206. X = 2,
  131207. /** Y */
  131208. Y = 3,
  131209. /** LB */
  131210. LB = 4,
  131211. /** RB */
  131212. RB = 5,
  131213. /** LT */
  131214. LT = 6,
  131215. /** RT */
  131216. RT = 7,
  131217. /** Back */
  131218. Back = 8,
  131219. /** Start */
  131220. Start = 9,
  131221. /** LS */
  131222. LS = 10,
  131223. /** RS */
  131224. RS = 11,
  131225. /** DPadUp */
  131226. DPadUp = 12,
  131227. /** DPadDown */
  131228. DPadDown = 13,
  131229. /** DPadLeft */
  131230. DPadLeft = 14,
  131231. /** DRight */
  131232. DPadRight = 15,
  131233. /** Home */
  131234. Home = 16,
  131235. /** LStickXAxis */
  131236. LStickXAxis = 17,
  131237. /** LStickYAxis */
  131238. LStickYAxis = 18,
  131239. /** RStickXAxis */
  131240. RStickXAxis = 19,
  131241. /** RStickYAxis */
  131242. RStickYAxis = 20
  131243. }
  131244. /**
  131245. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131246. */
  131247. export enum SwitchInput {
  131248. /** B */
  131249. B = 0,
  131250. /** A */
  131251. A = 1,
  131252. /** Y */
  131253. Y = 2,
  131254. /** X */
  131255. X = 3,
  131256. /** L */
  131257. L = 4,
  131258. /** R */
  131259. R = 5,
  131260. /** ZL */
  131261. ZL = 6,
  131262. /** ZR */
  131263. ZR = 7,
  131264. /** Minus */
  131265. Minus = 8,
  131266. /** Plus */
  131267. Plus = 9,
  131268. /** LS */
  131269. LS = 10,
  131270. /** RS */
  131271. RS = 11,
  131272. /** DPadUp */
  131273. DPadUp = 12,
  131274. /** DPadDown */
  131275. DPadDown = 13,
  131276. /** DPadLeft */
  131277. DPadLeft = 14,
  131278. /** DRight */
  131279. DPadRight = 15,
  131280. /** Home */
  131281. Home = 16,
  131282. /** Capture */
  131283. Capture = 17,
  131284. /** LStickXAxis */
  131285. LStickXAxis = 18,
  131286. /** LStickYAxis */
  131287. LStickYAxis = 19,
  131288. /** RStickXAxis */
  131289. RStickXAxis = 20,
  131290. /** RStickYAxis */
  131291. RStickYAxis = 21
  131292. }
  131293. }
  131294. declare module BABYLON {
  131295. /**
  131296. * This class will take all inputs from Keyboard, Pointer, and
  131297. * any Gamepads and provide a polling system that all devices
  131298. * will use. This class assumes that there will only be one
  131299. * pointer device and one keyboard.
  131300. */
  131301. export class DeviceInputSystem implements IDisposable {
  131302. /**
  131303. * Callback to be triggered when a device is connected
  131304. */
  131305. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131306. /**
  131307. * Callback to be triggered when a device is disconnected
  131308. */
  131309. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131310. /**
  131311. * Callback to be triggered when event driven input is updated
  131312. */
  131313. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131314. private _inputs;
  131315. private _gamepads;
  131316. private _keyboardActive;
  131317. private _pointerActive;
  131318. private _elementToAttachTo;
  131319. private _keyboardDownEvent;
  131320. private _keyboardUpEvent;
  131321. private _pointerMoveEvent;
  131322. private _pointerDownEvent;
  131323. private _pointerUpEvent;
  131324. private _gamepadConnectedEvent;
  131325. private _gamepadDisconnectedEvent;
  131326. private static _MAX_KEYCODES;
  131327. private static _MAX_POINTER_INPUTS;
  131328. private constructor();
  131329. /**
  131330. * Creates a new DeviceInputSystem instance
  131331. * @param engine Engine to pull input element from
  131332. * @returns The new instance
  131333. */
  131334. static Create(engine: Engine): DeviceInputSystem;
  131335. /**
  131336. * Checks for current device input value, given an id and input index
  131337. * @param deviceName Id of connected device
  131338. * @param inputIndex Index of device input
  131339. * @returns Current value of input
  131340. */
  131341. /**
  131342. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131343. * @param deviceType Enum specifiying device type
  131344. * @param deviceSlot "Slot" or index that device is referenced in
  131345. * @param inputIndex Id of input to be checked
  131346. * @returns Current value of input
  131347. */
  131348. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131349. /**
  131350. * Dispose of all the eventlisteners
  131351. */
  131352. dispose(): void;
  131353. /**
  131354. * Add device and inputs to device array
  131355. * @param deviceType Enum specifiying device type
  131356. * @param deviceSlot "Slot" or index that device is referenced in
  131357. * @param numberOfInputs Number of input entries to create for given device
  131358. */
  131359. private _registerDevice;
  131360. /**
  131361. * Given a specific device name, remove that device from the device map
  131362. * @param deviceType Enum specifiying device type
  131363. * @param deviceSlot "Slot" or index that device is referenced in
  131364. */
  131365. private _unregisterDevice;
  131366. /**
  131367. * Handle all actions that come from keyboard interaction
  131368. */
  131369. private _handleKeyActions;
  131370. /**
  131371. * Handle all actions that come from pointer interaction
  131372. */
  131373. private _handlePointerActions;
  131374. /**
  131375. * Handle all actions that come from gamepad interaction
  131376. */
  131377. private _handleGamepadActions;
  131378. /**
  131379. * Update all non-event based devices with each frame
  131380. * @param deviceType Enum specifiying device type
  131381. * @param deviceSlot "Slot" or index that device is referenced in
  131382. * @param inputIndex Id of input to be checked
  131383. */
  131384. private _updateDevice;
  131385. /**
  131386. * Gets DeviceType from the device name
  131387. * @param deviceName Name of Device from DeviceInputSystem
  131388. * @returns DeviceType enum value
  131389. */
  131390. private _getGamepadDeviceType;
  131391. }
  131392. }
  131393. declare module BABYLON {
  131394. /**
  131395. * Type to handle enforcement of inputs
  131396. */
  131397. 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;
  131398. }
  131399. declare module BABYLON {
  131400. /**
  131401. * Class that handles all input for a specific device
  131402. */
  131403. export class DeviceSource<T extends DeviceType> {
  131404. /** Type of device */
  131405. readonly deviceType: DeviceType;
  131406. /** "Slot" or index that device is referenced in */
  131407. readonly deviceSlot: number;
  131408. /**
  131409. * Observable to handle device input changes per device
  131410. */
  131411. readonly onInputChangedObservable: Observable<{
  131412. inputIndex: DeviceInput<T>;
  131413. previousState: Nullable<number>;
  131414. currentState: Nullable<number>;
  131415. }>;
  131416. private readonly _deviceInputSystem;
  131417. /**
  131418. * Default Constructor
  131419. * @param deviceInputSystem Reference to DeviceInputSystem
  131420. * @param deviceType Type of device
  131421. * @param deviceSlot "Slot" or index that device is referenced in
  131422. */
  131423. constructor(deviceInputSystem: DeviceInputSystem,
  131424. /** Type of device */
  131425. deviceType: DeviceType,
  131426. /** "Slot" or index that device is referenced in */
  131427. deviceSlot?: number);
  131428. /**
  131429. * Get input for specific input
  131430. * @param inputIndex index of specific input on device
  131431. * @returns Input value from DeviceInputSystem
  131432. */
  131433. getInput(inputIndex: DeviceInput<T>): number;
  131434. }
  131435. /**
  131436. * Class to keep track of devices
  131437. */
  131438. export class DeviceSourceManager implements IDisposable {
  131439. /**
  131440. * Observable to be triggered when before a device is connected
  131441. */
  131442. readonly onBeforeDeviceConnectedObservable: Observable<{
  131443. deviceType: DeviceType;
  131444. deviceSlot: number;
  131445. }>;
  131446. /**
  131447. * Observable to be triggered when before a device is disconnected
  131448. */
  131449. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  131450. deviceType: DeviceType;
  131451. deviceSlot: number;
  131452. }>;
  131453. /**
  131454. * Observable to be triggered when after a device is connected
  131455. */
  131456. readonly onAfterDeviceConnectedObservable: Observable<{
  131457. deviceType: DeviceType;
  131458. deviceSlot: number;
  131459. }>;
  131460. /**
  131461. * Observable to be triggered when after a device is disconnected
  131462. */
  131463. readonly onAfterDeviceDisconnectedObservable: Observable<{
  131464. deviceType: DeviceType;
  131465. deviceSlot: number;
  131466. }>;
  131467. private readonly _devices;
  131468. private readonly _firstDevice;
  131469. private readonly _deviceInputSystem;
  131470. /**
  131471. * Default Constructor
  131472. * @param engine engine to pull input element from
  131473. */
  131474. constructor(engine: Engine);
  131475. /**
  131476. * Gets a DeviceSource, given a type and slot
  131477. * @param deviceType Enum specifying device type
  131478. * @param deviceSlot "Slot" or index that device is referenced in
  131479. * @returns DeviceSource object
  131480. */
  131481. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  131482. /**
  131483. * Gets an array of DeviceSource objects for a given device type
  131484. * @param deviceType Enum specifying device type
  131485. * @returns Array of DeviceSource objects
  131486. */
  131487. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  131488. /**
  131489. * Dispose of DeviceInputSystem and other parts
  131490. */
  131491. dispose(): void;
  131492. /**
  131493. * Function to add device name to device list
  131494. * @param deviceType Enum specifying device type
  131495. * @param deviceSlot "Slot" or index that device is referenced in
  131496. */
  131497. private _addDevice;
  131498. /**
  131499. * Function to remove device name to device list
  131500. * @param deviceType Enum specifying device type
  131501. * @param deviceSlot "Slot" or index that device is referenced in
  131502. */
  131503. private _removeDevice;
  131504. /**
  131505. * Updates array storing first connected device of each type
  131506. * @param type Type of Device
  131507. */
  131508. private _updateFirstDevices;
  131509. }
  131510. }
  131511. declare module BABYLON {
  131512. /**
  131513. * Options to create the null engine
  131514. */
  131515. export class NullEngineOptions {
  131516. /**
  131517. * Render width (Default: 512)
  131518. */
  131519. renderWidth: number;
  131520. /**
  131521. * Render height (Default: 256)
  131522. */
  131523. renderHeight: number;
  131524. /**
  131525. * Texture size (Default: 512)
  131526. */
  131527. textureSize: number;
  131528. /**
  131529. * If delta time between frames should be constant
  131530. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131531. */
  131532. deterministicLockstep: boolean;
  131533. /**
  131534. * Maximum about of steps between frames (Default: 4)
  131535. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131536. */
  131537. lockstepMaxSteps: number;
  131538. /**
  131539. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  131540. */
  131541. useHighPrecisionMatrix?: boolean;
  131542. }
  131543. /**
  131544. * The null engine class provides support for headless version of babylon.js.
  131545. * This can be used in server side scenario or for testing purposes
  131546. */
  131547. export class NullEngine extends Engine {
  131548. private _options;
  131549. /**
  131550. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  131551. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131552. * @returns true if engine is in deterministic lock step mode
  131553. */
  131554. isDeterministicLockStep(): boolean;
  131555. /**
  131556. * Gets the max steps when engine is running in deterministic lock step
  131557. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131558. * @returns the max steps
  131559. */
  131560. getLockstepMaxSteps(): number;
  131561. /**
  131562. * Gets the current hardware scaling level.
  131563. * By default the hardware scaling level is computed from the window device ratio.
  131564. * 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.
  131565. * @returns a number indicating the current hardware scaling level
  131566. */
  131567. getHardwareScalingLevel(): number;
  131568. constructor(options?: NullEngineOptions);
  131569. /**
  131570. * Creates a vertex buffer
  131571. * @param vertices the data for the vertex buffer
  131572. * @returns the new WebGL static buffer
  131573. */
  131574. createVertexBuffer(vertices: FloatArray): DataBuffer;
  131575. /**
  131576. * Creates a new index buffer
  131577. * @param indices defines the content of the index buffer
  131578. * @param updatable defines if the index buffer must be updatable
  131579. * @returns a new webGL buffer
  131580. */
  131581. createIndexBuffer(indices: IndicesArray): DataBuffer;
  131582. /**
  131583. * Clear the current render buffer or the current render target (if any is set up)
  131584. * @param color defines the color to use
  131585. * @param backBuffer defines if the back buffer must be cleared
  131586. * @param depth defines if the depth buffer must be cleared
  131587. * @param stencil defines if the stencil buffer must be cleared
  131588. */
  131589. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131590. /**
  131591. * Gets the current render width
  131592. * @param useScreen defines if screen size must be used (or the current render target if any)
  131593. * @returns a number defining the current render width
  131594. */
  131595. getRenderWidth(useScreen?: boolean): number;
  131596. /**
  131597. * Gets the current render height
  131598. * @param useScreen defines if screen size must be used (or the current render target if any)
  131599. * @returns a number defining the current render height
  131600. */
  131601. getRenderHeight(useScreen?: boolean): number;
  131602. /**
  131603. * Set the WebGL's viewport
  131604. * @param viewport defines the viewport element to be used
  131605. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  131606. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  131607. */
  131608. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  131609. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  131610. /**
  131611. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  131612. * @param pipelineContext defines the pipeline context to use
  131613. * @param uniformsNames defines the list of uniform names
  131614. * @returns an array of webGL uniform locations
  131615. */
  131616. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  131617. /**
  131618. * Gets the lsit of active attributes for a given webGL program
  131619. * @param pipelineContext defines the pipeline context to use
  131620. * @param attributesNames defines the list of attribute names to get
  131621. * @returns an array of indices indicating the offset of each attribute
  131622. */
  131623. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131624. /**
  131625. * Binds an effect to the webGL context
  131626. * @param effect defines the effect to bind
  131627. */
  131628. bindSamplers(effect: Effect): void;
  131629. /**
  131630. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  131631. * @param effect defines the effect to activate
  131632. */
  131633. enableEffect(effect: Effect): void;
  131634. /**
  131635. * Set various states to the webGL context
  131636. * @param culling defines backface culling state
  131637. * @param zOffset defines the value to apply to zOffset (0 by default)
  131638. * @param force defines if states must be applied even if cache is up to date
  131639. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  131640. */
  131641. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131642. /**
  131643. * Set the value of an uniform to an array of int32
  131644. * @param uniform defines the webGL uniform location where to store the value
  131645. * @param array defines the array of int32 to store
  131646. */
  131647. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131648. /**
  131649. * Set the value of an uniform to an array of int32 (stored as vec2)
  131650. * @param uniform defines the webGL uniform location where to store the value
  131651. * @param array defines the array of int32 to store
  131652. */
  131653. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131654. /**
  131655. * Set the value of an uniform to an array of int32 (stored as vec3)
  131656. * @param uniform defines the webGL uniform location where to store the value
  131657. * @param array defines the array of int32 to store
  131658. */
  131659. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131660. /**
  131661. * Set the value of an uniform to an array of int32 (stored as vec4)
  131662. * @param uniform defines the webGL uniform location where to store the value
  131663. * @param array defines the array of int32 to store
  131664. */
  131665. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131666. /**
  131667. * Set the value of an uniform to an array of float32
  131668. * @param uniform defines the webGL uniform location where to store the value
  131669. * @param array defines the array of float32 to store
  131670. */
  131671. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131672. /**
  131673. * Set the value of an uniform to an array of float32 (stored as vec2)
  131674. * @param uniform defines the webGL uniform location where to store the value
  131675. * @param array defines the array of float32 to store
  131676. */
  131677. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131678. /**
  131679. * Set the value of an uniform to an array of float32 (stored as vec3)
  131680. * @param uniform defines the webGL uniform location where to store the value
  131681. * @param array defines the array of float32 to store
  131682. */
  131683. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131684. /**
  131685. * Set the value of an uniform to an array of float32 (stored as vec4)
  131686. * @param uniform defines the webGL uniform location where to store the value
  131687. * @param array defines the array of float32 to store
  131688. */
  131689. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131690. /**
  131691. * Set the value of an uniform to an array of number
  131692. * @param uniform defines the webGL uniform location where to store the value
  131693. * @param array defines the array of number to store
  131694. */
  131695. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131696. /**
  131697. * Set the value of an uniform to an array of number (stored as vec2)
  131698. * @param uniform defines the webGL uniform location where to store the value
  131699. * @param array defines the array of number to store
  131700. */
  131701. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131702. /**
  131703. * Set the value of an uniform to an array of number (stored as vec3)
  131704. * @param uniform defines the webGL uniform location where to store the value
  131705. * @param array defines the array of number to store
  131706. */
  131707. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131708. /**
  131709. * Set the value of an uniform to an array of number (stored as vec4)
  131710. * @param uniform defines the webGL uniform location where to store the value
  131711. * @param array defines the array of number to store
  131712. */
  131713. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131714. /**
  131715. * Set the value of an uniform to an array of float32 (stored as matrices)
  131716. * @param uniform defines the webGL uniform location where to store the value
  131717. * @param matrices defines the array of float32 to store
  131718. */
  131719. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131720. /**
  131721. * Set the value of an uniform to a matrix (3x3)
  131722. * @param uniform defines the webGL uniform location where to store the value
  131723. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  131724. */
  131725. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131726. /**
  131727. * Set the value of an uniform to a matrix (2x2)
  131728. * @param uniform defines the webGL uniform location where to store the value
  131729. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  131730. */
  131731. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131732. /**
  131733. * Set the value of an uniform to a number (float)
  131734. * @param uniform defines the webGL uniform location where to store the value
  131735. * @param value defines the float number to store
  131736. */
  131737. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131738. /**
  131739. * Set the value of an uniform to a vec2
  131740. * @param uniform defines the webGL uniform location where to store the value
  131741. * @param x defines the 1st component of the value
  131742. * @param y defines the 2nd component of the value
  131743. */
  131744. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131745. /**
  131746. * Set the value of an uniform to a vec3
  131747. * @param uniform defines the webGL uniform location where to store the value
  131748. * @param x defines the 1st component of the value
  131749. * @param y defines the 2nd component of the value
  131750. * @param z defines the 3rd component of the value
  131751. */
  131752. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131753. /**
  131754. * Set the value of an uniform to a boolean
  131755. * @param uniform defines the webGL uniform location where to store the value
  131756. * @param bool defines the boolean to store
  131757. */
  131758. setBool(uniform: WebGLUniformLocation, bool: number): void;
  131759. /**
  131760. * Set the value of an uniform to a vec4
  131761. * @param uniform defines the webGL uniform location where to store the value
  131762. * @param x defines the 1st component of the value
  131763. * @param y defines the 2nd component of the value
  131764. * @param z defines the 3rd component of the value
  131765. * @param w defines the 4th component of the value
  131766. */
  131767. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131768. /**
  131769. * Sets the current alpha mode
  131770. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  131771. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131772. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131773. */
  131774. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131775. /**
  131776. * Bind webGl buffers directly to the webGL context
  131777. * @param vertexBuffers defines the vertex buffer to bind
  131778. * @param indexBuffer defines the index buffer to bind
  131779. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  131780. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  131781. * @param effect defines the effect associated with the vertex buffer
  131782. */
  131783. bindBuffers(vertexBuffers: {
  131784. [key: string]: VertexBuffer;
  131785. }, indexBuffer: DataBuffer, effect: Effect): void;
  131786. /**
  131787. * Force the entire cache to be cleared
  131788. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  131789. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  131790. */
  131791. wipeCaches(bruteForce?: boolean): void;
  131792. /**
  131793. * Send a draw order
  131794. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  131795. * @param indexStart defines the starting index
  131796. * @param indexCount defines the number of index to draw
  131797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131798. */
  131799. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  131800. /**
  131801. * Draw a list of indexed primitives
  131802. * @param fillMode defines the primitive to use
  131803. * @param indexStart defines the starting index
  131804. * @param indexCount defines the number of index to draw
  131805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131806. */
  131807. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131808. /**
  131809. * Draw a list of unindexed primitives
  131810. * @param fillMode defines the primitive to use
  131811. * @param verticesStart defines the index of first vertex to draw
  131812. * @param verticesCount defines the count of vertices to draw
  131813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131814. */
  131815. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131816. /** @hidden */
  131817. _createTexture(): WebGLTexture;
  131818. /** @hidden */
  131819. _releaseTexture(texture: InternalTexture): void;
  131820. /**
  131821. * Usually called from Texture.ts.
  131822. * Passed information to create a WebGLTexture
  131823. * @param urlArg defines a value which contains one of the following:
  131824. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131825. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131826. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131827. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131828. * @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)
  131829. * @param scene needed for loading to the correct scene
  131830. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131831. * @param onLoad optional callback to be called upon successful completion
  131832. * @param onError optional callback to be called upon failure
  131833. * @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
  131834. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131835. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131836. * @param forcedExtension defines the extension to use to pick the right loader
  131837. * @param mimeType defines an optional mime type
  131838. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131839. */
  131840. 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;
  131841. /**
  131842. * Creates a new render target texture
  131843. * @param size defines the size of the texture
  131844. * @param options defines the options used to create the texture
  131845. * @returns a new render target texture stored in an InternalTexture
  131846. */
  131847. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  131848. /**
  131849. * Update the sampling mode of a given texture
  131850. * @param samplingMode defines the required sampling mode
  131851. * @param texture defines the texture to update
  131852. */
  131853. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131854. /**
  131855. * Binds the frame buffer to the specified texture.
  131856. * @param texture The texture to render to or null for the default canvas
  131857. * @param faceIndex The face of the texture to render to in case of cube texture
  131858. * @param requiredWidth The width of the target to render to
  131859. * @param requiredHeight The height of the target to render to
  131860. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  131861. * @param lodLevel defines le lod level to bind to the frame buffer
  131862. */
  131863. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131864. /**
  131865. * Unbind the current render target texture from the webGL context
  131866. * @param texture defines the render target texture to unbind
  131867. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  131868. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  131869. */
  131870. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131871. /**
  131872. * Creates a dynamic vertex buffer
  131873. * @param vertices the data for the dynamic vertex buffer
  131874. * @returns the new WebGL dynamic buffer
  131875. */
  131876. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  131877. /**
  131878. * Update the content of a dynamic texture
  131879. * @param texture defines the texture to update
  131880. * @param canvas defines the canvas containing the source
  131881. * @param invertY defines if data must be stored with Y axis inverted
  131882. * @param premulAlpha defines if alpha is stored as premultiplied
  131883. * @param format defines the format of the data
  131884. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  131885. */
  131886. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  131887. /**
  131888. * Gets a boolean indicating if all created effects are ready
  131889. * @returns true if all effects are ready
  131890. */
  131891. areAllEffectsReady(): boolean;
  131892. /**
  131893. * @hidden
  131894. * Get the current error code of the webGL context
  131895. * @returns the error code
  131896. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  131897. */
  131898. getError(): number;
  131899. /** @hidden */
  131900. _getUnpackAlignement(): number;
  131901. /** @hidden */
  131902. _unpackFlipY(value: boolean): void;
  131903. /**
  131904. * Update a dynamic index buffer
  131905. * @param indexBuffer defines the target index buffer
  131906. * @param indices defines the data to update
  131907. * @param offset defines the offset in the target index buffer where update should start
  131908. */
  131909. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  131910. /**
  131911. * Updates a dynamic vertex buffer.
  131912. * @param vertexBuffer the vertex buffer to update
  131913. * @param vertices the data used to update the vertex buffer
  131914. * @param byteOffset the byte offset of the data (optional)
  131915. * @param byteLength the byte length of the data (optional)
  131916. */
  131917. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  131918. /** @hidden */
  131919. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  131920. /** @hidden */
  131921. _bindTexture(channel: number, texture: InternalTexture): void;
  131922. protected _deleteBuffer(buffer: WebGLBuffer): void;
  131923. /**
  131924. * 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
  131925. */
  131926. releaseEffects(): void;
  131927. displayLoadingUI(): void;
  131928. hideLoadingUI(): void;
  131929. /** @hidden */
  131930. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131931. /** @hidden */
  131932. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131933. /** @hidden */
  131934. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131935. /** @hidden */
  131936. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131937. }
  131938. }
  131939. declare module BABYLON {
  131940. /**
  131941. * @hidden
  131942. **/
  131943. export class _TimeToken {
  131944. _startTimeQuery: Nullable<WebGLQuery>;
  131945. _endTimeQuery: Nullable<WebGLQuery>;
  131946. _timeElapsedQuery: Nullable<WebGLQuery>;
  131947. _timeElapsedQueryEnded: boolean;
  131948. }
  131949. }
  131950. declare module BABYLON {
  131951. /** @hidden */
  131952. export class _OcclusionDataStorage {
  131953. /** @hidden */
  131954. occlusionInternalRetryCounter: number;
  131955. /** @hidden */
  131956. isOcclusionQueryInProgress: boolean;
  131957. /** @hidden */
  131958. isOccluded: boolean;
  131959. /** @hidden */
  131960. occlusionRetryCount: number;
  131961. /** @hidden */
  131962. occlusionType: number;
  131963. /** @hidden */
  131964. occlusionQueryAlgorithmType: number;
  131965. }
  131966. interface Engine {
  131967. /**
  131968. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  131969. * @return the new query
  131970. */
  131971. createQuery(): WebGLQuery;
  131972. /**
  131973. * Delete and release a webGL query
  131974. * @param query defines the query to delete
  131975. * @return the current engine
  131976. */
  131977. deleteQuery(query: WebGLQuery): Engine;
  131978. /**
  131979. * Check if a given query has resolved and got its value
  131980. * @param query defines the query to check
  131981. * @returns true if the query got its value
  131982. */
  131983. isQueryResultAvailable(query: WebGLQuery): boolean;
  131984. /**
  131985. * Gets the value of a given query
  131986. * @param query defines the query to check
  131987. * @returns the value of the query
  131988. */
  131989. getQueryResult(query: WebGLQuery): number;
  131990. /**
  131991. * Initiates an occlusion query
  131992. * @param algorithmType defines the algorithm to use
  131993. * @param query defines the query to use
  131994. * @returns the current engine
  131995. * @see https://doc.babylonjs.com/features/occlusionquery
  131996. */
  131997. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  131998. /**
  131999. * Ends an occlusion query
  132000. * @see https://doc.babylonjs.com/features/occlusionquery
  132001. * @param algorithmType defines the algorithm to use
  132002. * @returns the current engine
  132003. */
  132004. endOcclusionQuery(algorithmType: number): Engine;
  132005. /**
  132006. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132007. * Please note that only one query can be issued at a time
  132008. * @returns a time token used to track the time span
  132009. */
  132010. startTimeQuery(): Nullable<_TimeToken>;
  132011. /**
  132012. * Ends a time query
  132013. * @param token defines the token used to measure the time span
  132014. * @returns the time spent (in ns)
  132015. */
  132016. endTimeQuery(token: _TimeToken): int;
  132017. /** @hidden */
  132018. _currentNonTimestampToken: Nullable<_TimeToken>;
  132019. /** @hidden */
  132020. _createTimeQuery(): WebGLQuery;
  132021. /** @hidden */
  132022. _deleteTimeQuery(query: WebGLQuery): void;
  132023. /** @hidden */
  132024. _getGlAlgorithmType(algorithmType: number): number;
  132025. /** @hidden */
  132026. _getTimeQueryResult(query: WebGLQuery): any;
  132027. /** @hidden */
  132028. _getTimeQueryAvailability(query: WebGLQuery): any;
  132029. }
  132030. interface AbstractMesh {
  132031. /**
  132032. * Backing filed
  132033. * @hidden
  132034. */
  132035. __occlusionDataStorage: _OcclusionDataStorage;
  132036. /**
  132037. * Access property
  132038. * @hidden
  132039. */
  132040. _occlusionDataStorage: _OcclusionDataStorage;
  132041. /**
  132042. * 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.
  132043. * The default value is -1 which means don't break the query and wait till the result
  132044. * @see https://doc.babylonjs.com/features/occlusionquery
  132045. */
  132046. occlusionRetryCount: number;
  132047. /**
  132048. * 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:
  132049. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132050. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132051. * * 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.
  132052. * @see https://doc.babylonjs.com/features/occlusionquery
  132053. */
  132054. occlusionType: number;
  132055. /**
  132056. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132057. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132058. * * 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.
  132059. * @see https://doc.babylonjs.com/features/occlusionquery
  132060. */
  132061. occlusionQueryAlgorithmType: number;
  132062. /**
  132063. * 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
  132064. * @see https://doc.babylonjs.com/features/occlusionquery
  132065. */
  132066. isOccluded: boolean;
  132067. /**
  132068. * Flag to check the progress status of the query
  132069. * @see https://doc.babylonjs.com/features/occlusionquery
  132070. */
  132071. isOcclusionQueryInProgress: boolean;
  132072. }
  132073. }
  132074. declare module BABYLON {
  132075. /** @hidden */
  132076. export var _forceTransformFeedbackToBundle: boolean;
  132077. interface Engine {
  132078. /**
  132079. * Creates a webGL transform feedback object
  132080. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132081. * @returns the webGL transform feedback object
  132082. */
  132083. createTransformFeedback(): WebGLTransformFeedback;
  132084. /**
  132085. * Delete a webGL transform feedback object
  132086. * @param value defines the webGL transform feedback object to delete
  132087. */
  132088. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132089. /**
  132090. * Bind a webGL transform feedback object to the webgl context
  132091. * @param value defines the webGL transform feedback object to bind
  132092. */
  132093. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132094. /**
  132095. * Begins a transform feedback operation
  132096. * @param usePoints defines if points or triangles must be used
  132097. */
  132098. beginTransformFeedback(usePoints: boolean): void;
  132099. /**
  132100. * Ends a transform feedback operation
  132101. */
  132102. endTransformFeedback(): void;
  132103. /**
  132104. * Specify the varyings to use with transform feedback
  132105. * @param program defines the associated webGL program
  132106. * @param value defines the list of strings representing the varying names
  132107. */
  132108. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132109. /**
  132110. * Bind a webGL buffer for a transform feedback operation
  132111. * @param value defines the webGL buffer to bind
  132112. */
  132113. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132114. }
  132115. }
  132116. declare module BABYLON {
  132117. /**
  132118. * Class used to define an additional view for the engine
  132119. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132120. */
  132121. export class EngineView {
  132122. /** Defines the canvas where to render the view */
  132123. target: HTMLCanvasElement;
  132124. /** Defines an optional camera used to render the view (will use active camera else) */
  132125. camera?: Camera;
  132126. }
  132127. interface Engine {
  132128. /**
  132129. * Gets or sets the HTML element to use for attaching events
  132130. */
  132131. inputElement: Nullable<HTMLElement>;
  132132. /**
  132133. * Gets the current engine view
  132134. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132135. */
  132136. activeView: Nullable<EngineView>;
  132137. /** Gets or sets the list of views */
  132138. views: EngineView[];
  132139. /**
  132140. * Register a new child canvas
  132141. * @param canvas defines the canvas to register
  132142. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132143. * @returns the associated view
  132144. */
  132145. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132146. /**
  132147. * Remove a registered child canvas
  132148. * @param canvas defines the canvas to remove
  132149. * @returns the current engine
  132150. */
  132151. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132152. }
  132153. }
  132154. declare module BABYLON {
  132155. interface Engine {
  132156. /** @hidden */
  132157. _excludedCompressedTextures: string[];
  132158. /** @hidden */
  132159. _textureFormatInUse: string;
  132160. /**
  132161. * Gets the list of texture formats supported
  132162. */
  132163. readonly texturesSupported: Array<string>;
  132164. /**
  132165. * Gets the texture format in use
  132166. */
  132167. readonly textureFormatInUse: Nullable<string>;
  132168. /**
  132169. * Set the compressed texture extensions or file names to skip.
  132170. *
  132171. * @param skippedFiles defines the list of those texture files you want to skip
  132172. * Example: [".dds", ".env", "myfile.png"]
  132173. */
  132174. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132175. /**
  132176. * Set the compressed texture format to use, based on the formats you have, and the formats
  132177. * supported by the hardware / browser.
  132178. *
  132179. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132180. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132181. * to API arguments needed to compressed textures. This puts the burden on the container
  132182. * generator to house the arcane code for determining these for current & future formats.
  132183. *
  132184. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132185. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132186. *
  132187. * Note: The result of this call is not taken into account when a texture is base64.
  132188. *
  132189. * @param formatsAvailable defines the list of those format families you have created
  132190. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132191. *
  132192. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132193. * @returns The extension selected.
  132194. */
  132195. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132196. }
  132197. }
  132198. declare module BABYLON {
  132199. /**
  132200. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132201. */
  132202. export interface CubeMapInfo {
  132203. /**
  132204. * The pixel array for the front face.
  132205. * This is stored in format, left to right, up to down format.
  132206. */
  132207. front: Nullable<ArrayBufferView>;
  132208. /**
  132209. * The pixel array for the back face.
  132210. * This is stored in format, left to right, up to down format.
  132211. */
  132212. back: Nullable<ArrayBufferView>;
  132213. /**
  132214. * The pixel array for the left face.
  132215. * This is stored in format, left to right, up to down format.
  132216. */
  132217. left: Nullable<ArrayBufferView>;
  132218. /**
  132219. * The pixel array for the right face.
  132220. * This is stored in format, left to right, up to down format.
  132221. */
  132222. right: Nullable<ArrayBufferView>;
  132223. /**
  132224. * The pixel array for the up face.
  132225. * This is stored in format, left to right, up to down format.
  132226. */
  132227. up: Nullable<ArrayBufferView>;
  132228. /**
  132229. * The pixel array for the down face.
  132230. * This is stored in format, left to right, up to down format.
  132231. */
  132232. down: Nullable<ArrayBufferView>;
  132233. /**
  132234. * The size of the cubemap stored.
  132235. *
  132236. * Each faces will be size * size pixels.
  132237. */
  132238. size: number;
  132239. /**
  132240. * The format of the texture.
  132241. *
  132242. * RGBA, RGB.
  132243. */
  132244. format: number;
  132245. /**
  132246. * The type of the texture data.
  132247. *
  132248. * UNSIGNED_INT, FLOAT.
  132249. */
  132250. type: number;
  132251. /**
  132252. * Specifies whether the texture is in gamma space.
  132253. */
  132254. gammaSpace: boolean;
  132255. }
  132256. /**
  132257. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132258. */
  132259. export class PanoramaToCubeMapTools {
  132260. private static FACE_LEFT;
  132261. private static FACE_RIGHT;
  132262. private static FACE_FRONT;
  132263. private static FACE_BACK;
  132264. private static FACE_DOWN;
  132265. private static FACE_UP;
  132266. /**
  132267. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132268. *
  132269. * @param float32Array The source data.
  132270. * @param inputWidth The width of the input panorama.
  132271. * @param inputHeight The height of the input panorama.
  132272. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132273. * @return The cubemap data
  132274. */
  132275. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132276. private static CreateCubemapTexture;
  132277. private static CalcProjectionSpherical;
  132278. }
  132279. }
  132280. declare module BABYLON {
  132281. /**
  132282. * Helper class dealing with the extraction of spherical polynomial dataArray
  132283. * from a cube map.
  132284. */
  132285. export class CubeMapToSphericalPolynomialTools {
  132286. private static FileFaces;
  132287. /**
  132288. * Converts a texture to the according Spherical Polynomial data.
  132289. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132290. *
  132291. * @param texture The texture to extract the information from.
  132292. * @return The Spherical Polynomial data.
  132293. */
  132294. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132295. /**
  132296. * Converts a cubemap to the according Spherical Polynomial data.
  132297. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132298. *
  132299. * @param cubeInfo The Cube map to extract the information from.
  132300. * @return The Spherical Polynomial data.
  132301. */
  132302. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132303. }
  132304. }
  132305. declare module BABYLON {
  132306. interface BaseTexture {
  132307. /**
  132308. * Get the polynomial representation of the texture data.
  132309. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132310. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132311. */
  132312. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132313. }
  132314. }
  132315. declare module BABYLON {
  132316. /** @hidden */
  132317. export var rgbdEncodePixelShader: {
  132318. name: string;
  132319. shader: string;
  132320. };
  132321. }
  132322. declare module BABYLON {
  132323. /** @hidden */
  132324. export var rgbdDecodePixelShader: {
  132325. name: string;
  132326. shader: string;
  132327. };
  132328. }
  132329. declare module BABYLON {
  132330. /**
  132331. * Raw texture data and descriptor sufficient for WebGL texture upload
  132332. */
  132333. export interface EnvironmentTextureInfo {
  132334. /**
  132335. * Version of the environment map
  132336. */
  132337. version: number;
  132338. /**
  132339. * Width of image
  132340. */
  132341. width: number;
  132342. /**
  132343. * Irradiance information stored in the file.
  132344. */
  132345. irradiance: any;
  132346. /**
  132347. * Specular information stored in the file.
  132348. */
  132349. specular: any;
  132350. }
  132351. /**
  132352. * Defines One Image in the file. It requires only the position in the file
  132353. * as well as the length.
  132354. */
  132355. interface BufferImageData {
  132356. /**
  132357. * Length of the image data.
  132358. */
  132359. length: number;
  132360. /**
  132361. * Position of the data from the null terminator delimiting the end of the JSON.
  132362. */
  132363. position: number;
  132364. }
  132365. /**
  132366. * Defines the specular data enclosed in the file.
  132367. * This corresponds to the version 1 of the data.
  132368. */
  132369. export interface EnvironmentTextureSpecularInfoV1 {
  132370. /**
  132371. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132372. */
  132373. specularDataPosition?: number;
  132374. /**
  132375. * This contains all the images data needed to reconstruct the cubemap.
  132376. */
  132377. mipmaps: Array<BufferImageData>;
  132378. /**
  132379. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132380. */
  132381. lodGenerationScale: number;
  132382. }
  132383. /**
  132384. * Sets of helpers addressing the serialization and deserialization of environment texture
  132385. * stored in a BabylonJS env file.
  132386. * Those files are usually stored as .env files.
  132387. */
  132388. export class EnvironmentTextureTools {
  132389. /**
  132390. * Magic number identifying the env file.
  132391. */
  132392. private static _MagicBytes;
  132393. /**
  132394. * Gets the environment info from an env file.
  132395. * @param data The array buffer containing the .env bytes.
  132396. * @returns the environment file info (the json header) if successfully parsed.
  132397. */
  132398. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  132399. /**
  132400. * Creates an environment texture from a loaded cube texture.
  132401. * @param texture defines the cube texture to convert in env file
  132402. * @return a promise containing the environment data if succesfull.
  132403. */
  132404. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  132405. /**
  132406. * Creates a JSON representation of the spherical data.
  132407. * @param texture defines the texture containing the polynomials
  132408. * @return the JSON representation of the spherical info
  132409. */
  132410. private static _CreateEnvTextureIrradiance;
  132411. /**
  132412. * Creates the ArrayBufferViews used for initializing environment texture image data.
  132413. * @param data the image data
  132414. * @param info parameters that determine what views will be created for accessing the underlying buffer
  132415. * @return the views described by info providing access to the underlying buffer
  132416. */
  132417. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  132418. /**
  132419. * Uploads the texture info contained in the env file to the GPU.
  132420. * @param texture defines the internal texture to upload to
  132421. * @param data defines the data to load
  132422. * @param info defines the texture info retrieved through the GetEnvInfo method
  132423. * @returns a promise
  132424. */
  132425. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  132426. private static _OnImageReadyAsync;
  132427. /**
  132428. * Uploads the levels of image data to the GPU.
  132429. * @param texture defines the internal texture to upload to
  132430. * @param imageData defines the array buffer views of image data [mipmap][face]
  132431. * @returns a promise
  132432. */
  132433. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  132434. /**
  132435. * Uploads spherical polynomials information to the texture.
  132436. * @param texture defines the texture we are trying to upload the information to
  132437. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  132438. */
  132439. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  132440. /** @hidden */
  132441. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132442. }
  132443. }
  132444. declare module BABYLON {
  132445. /**
  132446. * Class used to inline functions in shader code
  132447. */
  132448. export class ShaderCodeInliner {
  132449. private static readonly _RegexpFindFunctionNameAndType;
  132450. private _sourceCode;
  132451. private _functionDescr;
  132452. private _numMaxIterations;
  132453. /** Gets or sets the token used to mark the functions to inline */
  132454. inlineToken: string;
  132455. /** Gets or sets the debug mode */
  132456. debug: boolean;
  132457. /** Gets the code after the inlining process */
  132458. get code(): string;
  132459. /**
  132460. * Initializes the inliner
  132461. * @param sourceCode shader code source to inline
  132462. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  132463. */
  132464. constructor(sourceCode: string, numMaxIterations?: number);
  132465. /**
  132466. * Start the processing of the shader code
  132467. */
  132468. processCode(): void;
  132469. private _collectFunctions;
  132470. private _processInlining;
  132471. private _extractBetweenMarkers;
  132472. private _skipWhitespaces;
  132473. private _removeComments;
  132474. private _replaceFunctionCallsByCode;
  132475. private _findBackward;
  132476. private _escapeRegExp;
  132477. private _replaceNames;
  132478. }
  132479. }
  132480. declare module BABYLON {
  132481. /**
  132482. * Container for accessors for natively-stored mesh data buffers.
  132483. */
  132484. class NativeDataBuffer extends DataBuffer {
  132485. /**
  132486. * Accessor value used to identify/retrieve a natively-stored index buffer.
  132487. */
  132488. nativeIndexBuffer?: any;
  132489. /**
  132490. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  132491. */
  132492. nativeVertexBuffer?: any;
  132493. }
  132494. /** @hidden */
  132495. class NativeTexture extends InternalTexture {
  132496. getInternalTexture(): InternalTexture;
  132497. getViewCount(): number;
  132498. }
  132499. /** @hidden */
  132500. export class NativeEngine extends Engine {
  132501. private readonly _native;
  132502. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  132503. private readonly INVALID_HANDLE;
  132504. private _boundBuffersVertexArray;
  132505. getHardwareScalingLevel(): number;
  132506. constructor();
  132507. dispose(): void;
  132508. /**
  132509. * Can be used to override the current requestAnimationFrame requester.
  132510. * @hidden
  132511. */
  132512. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  132513. /**
  132514. * Override default engine behavior.
  132515. * @param color
  132516. * @param backBuffer
  132517. * @param depth
  132518. * @param stencil
  132519. */
  132520. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  132521. /**
  132522. * Gets host document
  132523. * @returns the host document object
  132524. */
  132525. getHostDocument(): Nullable<Document>;
  132526. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132527. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  132528. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  132529. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  132530. [key: string]: VertexBuffer;
  132531. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132532. bindBuffers(vertexBuffers: {
  132533. [key: string]: VertexBuffer;
  132534. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132535. recordVertexArrayObject(vertexBuffers: {
  132536. [key: string]: VertexBuffer;
  132537. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  132538. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132539. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132540. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132541. /**
  132542. * Draw a list of indexed primitives
  132543. * @param fillMode defines the primitive to use
  132544. * @param indexStart defines the starting index
  132545. * @param indexCount defines the number of index to draw
  132546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132547. */
  132548. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132549. /**
  132550. * Draw a list of unindexed primitives
  132551. * @param fillMode defines the primitive to use
  132552. * @param verticesStart defines the index of first vertex to draw
  132553. * @param verticesCount defines the count of vertices to draw
  132554. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132555. */
  132556. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132557. createPipelineContext(): IPipelineContext;
  132558. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  132559. /** @hidden */
  132560. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  132561. /** @hidden */
  132562. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  132563. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132564. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132565. protected _setProgram(program: WebGLProgram): void;
  132566. _releaseEffect(effect: Effect): void;
  132567. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  132568. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  132569. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  132570. bindSamplers(effect: Effect): void;
  132571. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  132572. getRenderWidth(useScreen?: boolean): number;
  132573. getRenderHeight(useScreen?: boolean): number;
  132574. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  132575. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132576. /**
  132577. * Set the z offset to apply to current rendering
  132578. * @param value defines the offset to apply
  132579. */
  132580. setZOffset(value: number): void;
  132581. /**
  132582. * Gets the current value of the zOffset
  132583. * @returns the current zOffset state
  132584. */
  132585. getZOffset(): number;
  132586. /**
  132587. * Enable or disable depth buffering
  132588. * @param enable defines the state to set
  132589. */
  132590. setDepthBuffer(enable: boolean): void;
  132591. /**
  132592. * Gets a boolean indicating if depth writing is enabled
  132593. * @returns the current depth writing state
  132594. */
  132595. getDepthWrite(): boolean;
  132596. /**
  132597. * Enable or disable depth writing
  132598. * @param enable defines the state to set
  132599. */
  132600. setDepthWrite(enable: boolean): void;
  132601. /**
  132602. * Enable or disable color writing
  132603. * @param enable defines the state to set
  132604. */
  132605. setColorWrite(enable: boolean): void;
  132606. /**
  132607. * Gets a boolean indicating if color writing is enabled
  132608. * @returns the current color writing state
  132609. */
  132610. getColorWrite(): boolean;
  132611. /**
  132612. * Sets alpha constants used by some alpha blending modes
  132613. * @param r defines the red component
  132614. * @param g defines the green component
  132615. * @param b defines the blue component
  132616. * @param a defines the alpha component
  132617. */
  132618. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  132619. /**
  132620. * Sets the current alpha mode
  132621. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  132622. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132623. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132624. */
  132625. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132626. /**
  132627. * Gets the current alpha mode
  132628. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132629. * @returns the current alpha mode
  132630. */
  132631. getAlphaMode(): number;
  132632. setInt(uniform: WebGLUniformLocation, int: number): void;
  132633. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  132634. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  132635. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  132636. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  132637. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  132638. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  132639. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  132640. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  132641. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  132642. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  132643. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  132644. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  132645. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  132646. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132647. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132648. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132649. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132650. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132651. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132652. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  132653. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  132654. wipeCaches(bruteForce?: boolean): void;
  132655. _createTexture(): WebGLTexture;
  132656. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  132657. /**
  132658. * Usually called from Texture.ts.
  132659. * Passed information to create a WebGLTexture
  132660. * @param url defines a value which contains one of the following:
  132661. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132662. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132663. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132665. * @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)
  132666. * @param scene needed for loading to the correct scene
  132667. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132668. * @param onLoad optional callback to be called upon successful completion
  132669. * @param onError optional callback to be called upon failure
  132670. * @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
  132671. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132672. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132673. * @param forcedExtension defines the extension to use to pick the right loader
  132674. * @param mimeType defines an optional mime type
  132675. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132676. */
  132677. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  132678. /**
  132679. * Creates a cube texture
  132680. * @param rootUrl defines the url where the files to load is located
  132681. * @param scene defines the current scene
  132682. * @param files defines the list of files to load (1 per face)
  132683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132684. * @param onLoad defines an optional callback raised when the texture is loaded
  132685. * @param onError defines an optional callback raised if there is an issue to load the texture
  132686. * @param format defines the format of the data
  132687. * @param forcedExtension defines the extension to use to pick the right loader
  132688. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132691. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132692. * @returns the cube texture as an InternalTexture
  132693. */
  132694. 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;
  132695. private _getSamplingFilter;
  132696. private static _GetNativeTextureFormat;
  132697. createRenderTargetTexture(size: number | {
  132698. width: number;
  132699. height: number;
  132700. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132701. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132702. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132703. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132704. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132705. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132706. /**
  132707. * Updates a dynamic vertex buffer.
  132708. * @param vertexBuffer the vertex buffer to update
  132709. * @param data the data used to update the vertex buffer
  132710. * @param byteOffset the byte offset of the data (optional)
  132711. * @param byteLength the byte length of the data (optional)
  132712. */
  132713. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132714. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132715. private _updateAnisotropicLevel;
  132716. private _getAddressMode;
  132717. /** @hidden */
  132718. _bindTexture(channel: number, texture: InternalTexture): void;
  132719. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  132720. releaseEffects(): void;
  132721. /** @hidden */
  132722. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132723. /** @hidden */
  132724. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132725. /** @hidden */
  132726. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132727. /** @hidden */
  132728. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132729. }
  132730. }
  132731. declare module BABYLON {
  132732. /**
  132733. * Gather the list of clipboard event types as constants.
  132734. */
  132735. export class ClipboardEventTypes {
  132736. /**
  132737. * The clipboard event is fired when a copy command is active (pressed).
  132738. */
  132739. static readonly COPY: number;
  132740. /**
  132741. * The clipboard event is fired when a cut command is active (pressed).
  132742. */
  132743. static readonly CUT: number;
  132744. /**
  132745. * The clipboard event is fired when a paste command is active (pressed).
  132746. */
  132747. static readonly PASTE: number;
  132748. }
  132749. /**
  132750. * This class is used to store clipboard related info for the onClipboardObservable event.
  132751. */
  132752. export class ClipboardInfo {
  132753. /**
  132754. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132755. */
  132756. type: number;
  132757. /**
  132758. * Defines the related dom event
  132759. */
  132760. event: ClipboardEvent;
  132761. /**
  132762. *Creates an instance of ClipboardInfo.
  132763. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  132764. * @param event Defines the related dom event
  132765. */
  132766. constructor(
  132767. /**
  132768. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132769. */
  132770. type: number,
  132771. /**
  132772. * Defines the related dom event
  132773. */
  132774. event: ClipboardEvent);
  132775. /**
  132776. * Get the clipboard event's type from the keycode.
  132777. * @param keyCode Defines the keyCode for the current keyboard event.
  132778. * @return {number}
  132779. */
  132780. static GetTypeFromCharacter(keyCode: number): number;
  132781. }
  132782. }
  132783. declare module BABYLON {
  132784. /**
  132785. * Google Daydream controller
  132786. */
  132787. export class DaydreamController extends WebVRController {
  132788. /**
  132789. * Base Url for the controller model.
  132790. */
  132791. static MODEL_BASE_URL: string;
  132792. /**
  132793. * File name for the controller model.
  132794. */
  132795. static MODEL_FILENAME: string;
  132796. /**
  132797. * Gamepad Id prefix used to identify Daydream Controller.
  132798. */
  132799. static readonly GAMEPAD_ID_PREFIX: string;
  132800. /**
  132801. * Creates a new DaydreamController from a gamepad
  132802. * @param vrGamepad the gamepad that the controller should be created from
  132803. */
  132804. constructor(vrGamepad: any);
  132805. /**
  132806. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132807. * @param scene scene in which to add meshes
  132808. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132809. */
  132810. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132811. /**
  132812. * Called once for each button that changed state since the last frame
  132813. * @param buttonIdx Which button index changed
  132814. * @param state New state of the button
  132815. * @param changes Which properties on the state changed since last frame
  132816. */
  132817. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132818. }
  132819. }
  132820. declare module BABYLON {
  132821. /**
  132822. * Gear VR Controller
  132823. */
  132824. export class GearVRController extends WebVRController {
  132825. /**
  132826. * Base Url for the controller model.
  132827. */
  132828. static MODEL_BASE_URL: string;
  132829. /**
  132830. * File name for the controller model.
  132831. */
  132832. static MODEL_FILENAME: string;
  132833. /**
  132834. * Gamepad Id prefix used to identify this controller.
  132835. */
  132836. static readonly GAMEPAD_ID_PREFIX: string;
  132837. private readonly _buttonIndexToObservableNameMap;
  132838. /**
  132839. * Creates a new GearVRController from a gamepad
  132840. * @param vrGamepad the gamepad that the controller should be created from
  132841. */
  132842. constructor(vrGamepad: any);
  132843. /**
  132844. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132845. * @param scene scene in which to add meshes
  132846. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132847. */
  132848. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132849. /**
  132850. * Called once for each button that changed state since the last frame
  132851. * @param buttonIdx Which button index changed
  132852. * @param state New state of the button
  132853. * @param changes Which properties on the state changed since last frame
  132854. */
  132855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132856. }
  132857. }
  132858. declare module BABYLON {
  132859. /**
  132860. * Generic Controller
  132861. */
  132862. export class GenericController extends WebVRController {
  132863. /**
  132864. * Base Url for the controller model.
  132865. */
  132866. static readonly MODEL_BASE_URL: string;
  132867. /**
  132868. * File name for the controller model.
  132869. */
  132870. static readonly MODEL_FILENAME: string;
  132871. /**
  132872. * Creates a new GenericController from a gamepad
  132873. * @param vrGamepad the gamepad that the controller should be created from
  132874. */
  132875. constructor(vrGamepad: any);
  132876. /**
  132877. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132878. * @param scene scene in which to add meshes
  132879. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132880. */
  132881. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132882. /**
  132883. * Called once for each button that changed state since the last frame
  132884. * @param buttonIdx Which button index changed
  132885. * @param state New state of the button
  132886. * @param changes Which properties on the state changed since last frame
  132887. */
  132888. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132889. }
  132890. }
  132891. declare module BABYLON {
  132892. /**
  132893. * Oculus Touch Controller
  132894. */
  132895. export class OculusTouchController extends WebVRController {
  132896. /**
  132897. * Base Url for the controller model.
  132898. */
  132899. static MODEL_BASE_URL: string;
  132900. /**
  132901. * File name for the left controller model.
  132902. */
  132903. static MODEL_LEFT_FILENAME: string;
  132904. /**
  132905. * File name for the right controller model.
  132906. */
  132907. static MODEL_RIGHT_FILENAME: string;
  132908. /**
  132909. * Base Url for the Quest controller model.
  132910. */
  132911. static QUEST_MODEL_BASE_URL: string;
  132912. /**
  132913. * @hidden
  132914. * If the controllers are running on a device that needs the updated Quest controller models
  132915. */
  132916. static _IsQuest: boolean;
  132917. /**
  132918. * Fired when the secondary trigger on this controller is modified
  132919. */
  132920. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  132921. /**
  132922. * Fired when the thumb rest on this controller is modified
  132923. */
  132924. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  132925. /**
  132926. * Creates a new OculusTouchController from a gamepad
  132927. * @param vrGamepad the gamepad that the controller should be created from
  132928. */
  132929. constructor(vrGamepad: any);
  132930. /**
  132931. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132932. * @param scene scene in which to add meshes
  132933. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132934. */
  132935. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132936. /**
  132937. * Fired when the A button on this controller is modified
  132938. */
  132939. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132940. /**
  132941. * Fired when the B button on this controller is modified
  132942. */
  132943. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132944. /**
  132945. * Fired when the X button on this controller is modified
  132946. */
  132947. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132948. /**
  132949. * Fired when the Y button on this controller is modified
  132950. */
  132951. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132952. /**
  132953. * Called once for each button that changed state since the last frame
  132954. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  132955. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  132956. * 2) secondary trigger (same)
  132957. * 3) A (right) X (left), touch, pressed = value
  132958. * 4) B / Y
  132959. * 5) thumb rest
  132960. * @param buttonIdx Which button index changed
  132961. * @param state New state of the button
  132962. * @param changes Which properties on the state changed since last frame
  132963. */
  132964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132965. }
  132966. }
  132967. declare module BABYLON {
  132968. /**
  132969. * Vive Controller
  132970. */
  132971. export class ViveController extends WebVRController {
  132972. /**
  132973. * Base Url for the controller model.
  132974. */
  132975. static MODEL_BASE_URL: string;
  132976. /**
  132977. * File name for the controller model.
  132978. */
  132979. static MODEL_FILENAME: string;
  132980. /**
  132981. * Creates a new ViveController from a gamepad
  132982. * @param vrGamepad the gamepad that the controller should be created from
  132983. */
  132984. constructor(vrGamepad: any);
  132985. /**
  132986. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132987. * @param scene scene in which to add meshes
  132988. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132989. */
  132990. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132991. /**
  132992. * Fired when the left button on this controller is modified
  132993. */
  132994. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132995. /**
  132996. * Fired when the right button on this controller is modified
  132997. */
  132998. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132999. /**
  133000. * Fired when the menu button on this controller is modified
  133001. */
  133002. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133003. /**
  133004. * Called once for each button that changed state since the last frame
  133005. * Vive mapping:
  133006. * 0: touchpad
  133007. * 1: trigger
  133008. * 2: left AND right buttons
  133009. * 3: menu button
  133010. * @param buttonIdx Which button index changed
  133011. * @param state New state of the button
  133012. * @param changes Which properties on the state changed since last frame
  133013. */
  133014. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133015. }
  133016. }
  133017. declare module BABYLON {
  133018. /**
  133019. * Defines the WindowsMotionController object that the state of the windows motion controller
  133020. */
  133021. export class WindowsMotionController extends WebVRController {
  133022. /**
  133023. * The base url used to load the left and right controller models
  133024. */
  133025. static MODEL_BASE_URL: string;
  133026. /**
  133027. * The name of the left controller model file
  133028. */
  133029. static MODEL_LEFT_FILENAME: string;
  133030. /**
  133031. * The name of the right controller model file
  133032. */
  133033. static MODEL_RIGHT_FILENAME: string;
  133034. /**
  133035. * The controller name prefix for this controller type
  133036. */
  133037. static readonly GAMEPAD_ID_PREFIX: string;
  133038. /**
  133039. * The controller id pattern for this controller type
  133040. */
  133041. private static readonly GAMEPAD_ID_PATTERN;
  133042. private _loadedMeshInfo;
  133043. protected readonly _mapping: {
  133044. buttons: string[];
  133045. buttonMeshNames: {
  133046. trigger: string;
  133047. menu: string;
  133048. grip: string;
  133049. thumbstick: string;
  133050. trackpad: string;
  133051. };
  133052. buttonObservableNames: {
  133053. trigger: string;
  133054. menu: string;
  133055. grip: string;
  133056. thumbstick: string;
  133057. trackpad: string;
  133058. };
  133059. axisMeshNames: string[];
  133060. pointingPoseMeshName: string;
  133061. };
  133062. /**
  133063. * Fired when the trackpad on this controller is clicked
  133064. */
  133065. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133066. /**
  133067. * Fired when the trackpad on this controller is modified
  133068. */
  133069. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133070. /**
  133071. * The current x and y values of this controller's trackpad
  133072. */
  133073. trackpad: StickValues;
  133074. /**
  133075. * Creates a new WindowsMotionController from a gamepad
  133076. * @param vrGamepad the gamepad that the controller should be created from
  133077. */
  133078. constructor(vrGamepad: any);
  133079. /**
  133080. * Fired when the trigger on this controller is modified
  133081. */
  133082. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133083. /**
  133084. * Fired when the menu button on this controller is modified
  133085. */
  133086. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133087. /**
  133088. * Fired when the grip button on this controller is modified
  133089. */
  133090. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133091. /**
  133092. * Fired when the thumbstick button on this controller is modified
  133093. */
  133094. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133095. /**
  133096. * Fired when the touchpad button on this controller is modified
  133097. */
  133098. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133099. /**
  133100. * Fired when the touchpad values on this controller are modified
  133101. */
  133102. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133103. protected _updateTrackpad(): void;
  133104. /**
  133105. * Called once per frame by the engine.
  133106. */
  133107. update(): void;
  133108. /**
  133109. * Called once for each button that changed state since the last frame
  133110. * @param buttonIdx Which button index changed
  133111. * @param state New state of the button
  133112. * @param changes Which properties on the state changed since last frame
  133113. */
  133114. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133115. /**
  133116. * Moves the buttons on the controller mesh based on their current state
  133117. * @param buttonName the name of the button to move
  133118. * @param buttonValue the value of the button which determines the buttons new position
  133119. */
  133120. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133121. /**
  133122. * Moves the axis on the controller mesh based on its current state
  133123. * @param axis the index of the axis
  133124. * @param axisValue the value of the axis which determines the meshes new position
  133125. * @hidden
  133126. */
  133127. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133128. /**
  133129. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133130. * @param scene scene in which to add meshes
  133131. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133132. */
  133133. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133134. /**
  133135. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133136. * can be transformed by button presses and axes values, based on this._mapping.
  133137. *
  133138. * @param scene scene in which the meshes exist
  133139. * @param meshes list of meshes that make up the controller model to process
  133140. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133141. */
  133142. private processModel;
  133143. private createMeshInfo;
  133144. /**
  133145. * Gets the ray of the controller in the direction the controller is pointing
  133146. * @param length the length the resulting ray should be
  133147. * @returns a ray in the direction the controller is pointing
  133148. */
  133149. getForwardRay(length?: number): Ray;
  133150. /**
  133151. * Disposes of the controller
  133152. */
  133153. dispose(): void;
  133154. }
  133155. /**
  133156. * This class represents a new windows motion controller in XR.
  133157. */
  133158. export class XRWindowsMotionController extends WindowsMotionController {
  133159. /**
  133160. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133161. */
  133162. protected readonly _mapping: {
  133163. buttons: string[];
  133164. buttonMeshNames: {
  133165. trigger: string;
  133166. menu: string;
  133167. grip: string;
  133168. thumbstick: string;
  133169. trackpad: string;
  133170. };
  133171. buttonObservableNames: {
  133172. trigger: string;
  133173. menu: string;
  133174. grip: string;
  133175. thumbstick: string;
  133176. trackpad: string;
  133177. };
  133178. axisMeshNames: string[];
  133179. pointingPoseMeshName: string;
  133180. };
  133181. /**
  133182. * Construct a new XR-Based windows motion controller
  133183. *
  133184. * @param gamepadInfo the gamepad object from the browser
  133185. */
  133186. constructor(gamepadInfo: any);
  133187. /**
  133188. * holds the thumbstick values (X,Y)
  133189. */
  133190. thumbstickValues: StickValues;
  133191. /**
  133192. * Fired when the thumbstick on this controller is clicked
  133193. */
  133194. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133195. /**
  133196. * Fired when the thumbstick on this controller is modified
  133197. */
  133198. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133199. /**
  133200. * Fired when the touchpad button on this controller is modified
  133201. */
  133202. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133203. /**
  133204. * Fired when the touchpad values on this controller are modified
  133205. */
  133206. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133207. /**
  133208. * Fired when the thumbstick button on this controller is modified
  133209. * here to prevent breaking changes
  133210. */
  133211. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133212. /**
  133213. * updating the thumbstick(!) and not the trackpad.
  133214. * This is named this way due to the difference between WebVR and XR and to avoid
  133215. * changing the parent class.
  133216. */
  133217. protected _updateTrackpad(): void;
  133218. /**
  133219. * Disposes the class with joy
  133220. */
  133221. dispose(): void;
  133222. }
  133223. }
  133224. declare module BABYLON {
  133225. /**
  133226. * Class containing static functions to help procedurally build meshes
  133227. */
  133228. export class PolyhedronBuilder {
  133229. /**
  133230. * Creates a polyhedron mesh
  133231. * * 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
  133232. * * The parameter `size` (positive float, default 1) sets the polygon size
  133233. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133234. * * 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`
  133235. * * 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
  133236. * * 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)`)
  133237. * * 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
  133238. * * 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
  133239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133242. * @param name defines the name of the mesh
  133243. * @param options defines the options used to create the mesh
  133244. * @param scene defines the hosting scene
  133245. * @returns the polyhedron mesh
  133246. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133247. */
  133248. static CreatePolyhedron(name: string, options: {
  133249. type?: number;
  133250. size?: number;
  133251. sizeX?: number;
  133252. sizeY?: number;
  133253. sizeZ?: number;
  133254. custom?: any;
  133255. faceUV?: Vector4[];
  133256. faceColors?: Color4[];
  133257. flat?: boolean;
  133258. updatable?: boolean;
  133259. sideOrientation?: number;
  133260. frontUVs?: Vector4;
  133261. backUVs?: Vector4;
  133262. }, scene?: Nullable<Scene>): Mesh;
  133263. }
  133264. }
  133265. declare module BABYLON {
  133266. /**
  133267. * Gizmo that enables scaling a mesh along 3 axis
  133268. */
  133269. export class ScaleGizmo extends Gizmo {
  133270. /**
  133271. * Internal gizmo used for interactions on the x axis
  133272. */
  133273. xGizmo: AxisScaleGizmo;
  133274. /**
  133275. * Internal gizmo used for interactions on the y axis
  133276. */
  133277. yGizmo: AxisScaleGizmo;
  133278. /**
  133279. * Internal gizmo used for interactions on the z axis
  133280. */
  133281. zGizmo: AxisScaleGizmo;
  133282. /**
  133283. * Internal gizmo used to scale all axis equally
  133284. */
  133285. uniformScaleGizmo: AxisScaleGizmo;
  133286. private _meshAttached;
  133287. private _nodeAttached;
  133288. private _snapDistance;
  133289. private _uniformScalingMesh;
  133290. private _octahedron;
  133291. private _sensitivity;
  133292. /** Fires an event when any of it's sub gizmos are dragged */
  133293. onDragStartObservable: Observable<unknown>;
  133294. /** Fires an event when any of it's sub gizmos are released from dragging */
  133295. onDragEndObservable: Observable<unknown>;
  133296. get attachedMesh(): Nullable<AbstractMesh>;
  133297. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133298. get attachedNode(): Nullable<Node>;
  133299. set attachedNode(node: Nullable<Node>);
  133300. /**
  133301. * Creates a ScaleGizmo
  133302. * @param gizmoLayer The utility layer the gizmo will be added to
  133303. * @param thickness display gizmo axis thickness
  133304. */
  133305. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133306. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133307. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133308. /**
  133309. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133310. */
  133311. set snapDistance(value: number);
  133312. get snapDistance(): number;
  133313. /**
  133314. * Ratio for the scale of the gizmo (Default: 1)
  133315. */
  133316. set scaleRatio(value: number);
  133317. get scaleRatio(): number;
  133318. /**
  133319. * Sensitivity factor for dragging (Default: 1)
  133320. */
  133321. set sensitivity(value: number);
  133322. get sensitivity(): number;
  133323. /**
  133324. * Disposes of the gizmo
  133325. */
  133326. dispose(): void;
  133327. }
  133328. }
  133329. declare module BABYLON {
  133330. /**
  133331. * Single axis scale gizmo
  133332. */
  133333. export class AxisScaleGizmo extends Gizmo {
  133334. /**
  133335. * Drag behavior responsible for the gizmos dragging interactions
  133336. */
  133337. dragBehavior: PointerDragBehavior;
  133338. private _pointerObserver;
  133339. /**
  133340. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133341. */
  133342. snapDistance: number;
  133343. /**
  133344. * Event that fires each time the gizmo snaps to a new location.
  133345. * * snapDistance is the the change in distance
  133346. */
  133347. onSnapObservable: Observable<{
  133348. snapDistance: number;
  133349. }>;
  133350. /**
  133351. * If the scaling operation should be done on all axis (default: false)
  133352. */
  133353. uniformScaling: boolean;
  133354. /**
  133355. * Custom sensitivity value for the drag strength
  133356. */
  133357. sensitivity: number;
  133358. private _isEnabled;
  133359. private _parent;
  133360. private _arrow;
  133361. private _coloredMaterial;
  133362. private _hoverMaterial;
  133363. /**
  133364. * Creates an AxisScaleGizmo
  133365. * @param gizmoLayer The utility layer the gizmo will be added to
  133366. * @param dragAxis The axis which the gizmo will be able to scale on
  133367. * @param color The color of the gizmo
  133368. * @param thickness display gizmo axis thickness
  133369. */
  133370. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133371. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133372. /**
  133373. * If the gizmo is enabled
  133374. */
  133375. set isEnabled(value: boolean);
  133376. get isEnabled(): boolean;
  133377. /**
  133378. * Disposes of the gizmo
  133379. */
  133380. dispose(): void;
  133381. /**
  133382. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133383. * @param mesh The mesh to replace the default mesh of the gizmo
  133384. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  133385. */
  133386. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  133387. }
  133388. }
  133389. declare module BABYLON {
  133390. /**
  133391. * Bounding box gizmo
  133392. */
  133393. export class BoundingBoxGizmo extends Gizmo {
  133394. private _lineBoundingBox;
  133395. private _rotateSpheresParent;
  133396. private _scaleBoxesParent;
  133397. private _boundingDimensions;
  133398. private _renderObserver;
  133399. private _pointerObserver;
  133400. private _scaleDragSpeed;
  133401. private _tmpQuaternion;
  133402. private _tmpVector;
  133403. private _tmpRotationMatrix;
  133404. /**
  133405. * 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)
  133406. */
  133407. ignoreChildren: boolean;
  133408. /**
  133409. * 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)
  133410. */
  133411. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  133412. /**
  133413. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  133414. */
  133415. rotationSphereSize: number;
  133416. /**
  133417. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  133418. */
  133419. scaleBoxSize: number;
  133420. /**
  133421. * 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)
  133422. */
  133423. fixedDragMeshScreenSize: boolean;
  133424. /**
  133425. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  133426. */
  133427. fixedDragMeshScreenSizeDistanceFactor: number;
  133428. /**
  133429. * Fired when a rotation sphere or scale box is dragged
  133430. */
  133431. onDragStartObservable: Observable<{}>;
  133432. /**
  133433. * Fired when a scale box is dragged
  133434. */
  133435. onScaleBoxDragObservable: Observable<{}>;
  133436. /**
  133437. * Fired when a scale box drag is ended
  133438. */
  133439. onScaleBoxDragEndObservable: Observable<{}>;
  133440. /**
  133441. * Fired when a rotation sphere is dragged
  133442. */
  133443. onRotationSphereDragObservable: Observable<{}>;
  133444. /**
  133445. * Fired when a rotation sphere drag is ended
  133446. */
  133447. onRotationSphereDragEndObservable: Observable<{}>;
  133448. /**
  133449. * 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)
  133450. */
  133451. scalePivot: Nullable<Vector3>;
  133452. /**
  133453. * Mesh used as a pivot to rotate the attached node
  133454. */
  133455. private _anchorMesh;
  133456. private _existingMeshScale;
  133457. private _dragMesh;
  133458. private pointerDragBehavior;
  133459. private coloredMaterial;
  133460. private hoverColoredMaterial;
  133461. /**
  133462. * Sets the color of the bounding box gizmo
  133463. * @param color the color to set
  133464. */
  133465. setColor(color: Color3): void;
  133466. /**
  133467. * Creates an BoundingBoxGizmo
  133468. * @param gizmoLayer The utility layer the gizmo will be added to
  133469. * @param color The color of the gizmo
  133470. */
  133471. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  133472. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  133473. private _selectNode;
  133474. /**
  133475. * Updates the bounding box information for the Gizmo
  133476. */
  133477. updateBoundingBox(): void;
  133478. private _updateRotationSpheres;
  133479. private _updateScaleBoxes;
  133480. /**
  133481. * Enables rotation on the specified axis and disables rotation on the others
  133482. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  133483. */
  133484. setEnabledRotationAxis(axis: string): void;
  133485. /**
  133486. * Enables/disables scaling
  133487. * @param enable if scaling should be enabled
  133488. * @param homogeneousScaling defines if scaling should only be homogeneous
  133489. */
  133490. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  133491. private _updateDummy;
  133492. /**
  133493. * Enables a pointer drag behavior on the bounding box of the gizmo
  133494. */
  133495. enableDragBehavior(): void;
  133496. /**
  133497. * Disposes of the gizmo
  133498. */
  133499. dispose(): void;
  133500. /**
  133501. * 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)
  133502. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  133503. * @returns the bounding box mesh with the passed in mesh as a child
  133504. */
  133505. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  133506. /**
  133507. * CustomMeshes are not supported by this gizmo
  133508. * @param mesh The mesh to replace the default mesh of the gizmo
  133509. */
  133510. setCustomMesh(mesh: Mesh): void;
  133511. }
  133512. }
  133513. declare module BABYLON {
  133514. /**
  133515. * Single plane rotation gizmo
  133516. */
  133517. export class PlaneRotationGizmo extends Gizmo {
  133518. /**
  133519. * Drag behavior responsible for the gizmos dragging interactions
  133520. */
  133521. dragBehavior: PointerDragBehavior;
  133522. private _pointerObserver;
  133523. /**
  133524. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  133525. */
  133526. snapDistance: number;
  133527. /**
  133528. * Event that fires each time the gizmo snaps to a new location.
  133529. * * snapDistance is the the change in distance
  133530. */
  133531. onSnapObservable: Observable<{
  133532. snapDistance: number;
  133533. }>;
  133534. private _isEnabled;
  133535. private _parent;
  133536. /**
  133537. * Creates a PlaneRotationGizmo
  133538. * @param gizmoLayer The utility layer the gizmo will be added to
  133539. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  133540. * @param color The color of the gizmo
  133541. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133542. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133543. * @param thickness display gizmo axis thickness
  133544. */
  133545. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  133546. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133547. /**
  133548. * If the gizmo is enabled
  133549. */
  133550. set isEnabled(value: boolean);
  133551. get isEnabled(): boolean;
  133552. /**
  133553. * Disposes of the gizmo
  133554. */
  133555. dispose(): void;
  133556. }
  133557. }
  133558. declare module BABYLON {
  133559. /**
  133560. * Gizmo that enables rotating a mesh along 3 axis
  133561. */
  133562. export class RotationGizmo extends Gizmo {
  133563. /**
  133564. * Internal gizmo used for interactions on the x axis
  133565. */
  133566. xGizmo: PlaneRotationGizmo;
  133567. /**
  133568. * Internal gizmo used for interactions on the y axis
  133569. */
  133570. yGizmo: PlaneRotationGizmo;
  133571. /**
  133572. * Internal gizmo used for interactions on the z axis
  133573. */
  133574. zGizmo: PlaneRotationGizmo;
  133575. /** Fires an event when any of it's sub gizmos are dragged */
  133576. onDragStartObservable: Observable<unknown>;
  133577. /** Fires an event when any of it's sub gizmos are released from dragging */
  133578. onDragEndObservable: Observable<unknown>;
  133579. private _meshAttached;
  133580. private _nodeAttached;
  133581. get attachedMesh(): Nullable<AbstractMesh>;
  133582. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133583. get attachedNode(): Nullable<Node>;
  133584. set attachedNode(node: Nullable<Node>);
  133585. /**
  133586. * Creates a RotationGizmo
  133587. * @param gizmoLayer The utility layer the gizmo will be added to
  133588. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133589. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133590. * @param thickness display gizmo axis thickness
  133591. */
  133592. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  133593. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133594. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133595. /**
  133596. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133597. */
  133598. set snapDistance(value: number);
  133599. get snapDistance(): number;
  133600. /**
  133601. * Ratio for the scale of the gizmo (Default: 1)
  133602. */
  133603. set scaleRatio(value: number);
  133604. get scaleRatio(): number;
  133605. /**
  133606. * Disposes of the gizmo
  133607. */
  133608. dispose(): void;
  133609. /**
  133610. * CustomMeshes are not supported by this gizmo
  133611. * @param mesh The mesh to replace the default mesh of the gizmo
  133612. */
  133613. setCustomMesh(mesh: Mesh): void;
  133614. }
  133615. }
  133616. declare module BABYLON {
  133617. /**
  133618. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  133619. */
  133620. export class GizmoManager implements IDisposable {
  133621. private scene;
  133622. /**
  133623. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  133624. */
  133625. gizmos: {
  133626. positionGizmo: Nullable<PositionGizmo>;
  133627. rotationGizmo: Nullable<RotationGizmo>;
  133628. scaleGizmo: Nullable<ScaleGizmo>;
  133629. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  133630. };
  133631. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  133632. clearGizmoOnEmptyPointerEvent: boolean;
  133633. /** Fires an event when the manager is attached to a mesh */
  133634. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  133635. /** Fires an event when the manager is attached to a node */
  133636. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  133637. private _gizmosEnabled;
  133638. private _pointerObserver;
  133639. private _attachedMesh;
  133640. private _attachedNode;
  133641. private _boundingBoxColor;
  133642. private _defaultUtilityLayer;
  133643. private _defaultKeepDepthUtilityLayer;
  133644. private _thickness;
  133645. /**
  133646. * When bounding box gizmo is enabled, this can be used to track drag/end events
  133647. */
  133648. boundingBoxDragBehavior: SixDofDragBehavior;
  133649. /**
  133650. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  133651. */
  133652. attachableMeshes: Nullable<Array<AbstractMesh>>;
  133653. /**
  133654. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  133655. */
  133656. attachableNodes: Nullable<Array<Node>>;
  133657. /**
  133658. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  133659. */
  133660. usePointerToAttachGizmos: boolean;
  133661. /**
  133662. * Utility layer that the bounding box gizmo belongs to
  133663. */
  133664. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  133665. /**
  133666. * Utility layer that all gizmos besides bounding box belong to
  133667. */
  133668. get utilityLayer(): UtilityLayerRenderer;
  133669. /**
  133670. * Instatiates a gizmo manager
  133671. * @param scene the scene to overlay the gizmos on top of
  133672. * @param thickness display gizmo axis thickness
  133673. */
  133674. constructor(scene: Scene, thickness?: number);
  133675. /**
  133676. * Attaches a set of gizmos to the specified mesh
  133677. * @param mesh The mesh the gizmo's should be attached to
  133678. */
  133679. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133680. /**
  133681. * Attaches a set of gizmos to the specified node
  133682. * @param node The node the gizmo's should be attached to
  133683. */
  133684. attachToNode(node: Nullable<Node>): void;
  133685. /**
  133686. * If the position gizmo is enabled
  133687. */
  133688. set positionGizmoEnabled(value: boolean);
  133689. get positionGizmoEnabled(): boolean;
  133690. /**
  133691. * If the rotation gizmo is enabled
  133692. */
  133693. set rotationGizmoEnabled(value: boolean);
  133694. get rotationGizmoEnabled(): boolean;
  133695. /**
  133696. * If the scale gizmo is enabled
  133697. */
  133698. set scaleGizmoEnabled(value: boolean);
  133699. get scaleGizmoEnabled(): boolean;
  133700. /**
  133701. * If the boundingBox gizmo is enabled
  133702. */
  133703. set boundingBoxGizmoEnabled(value: boolean);
  133704. get boundingBoxGizmoEnabled(): boolean;
  133705. /**
  133706. * Disposes of the gizmo manager
  133707. */
  133708. dispose(): void;
  133709. }
  133710. }
  133711. declare module BABYLON {
  133712. /**
  133713. * A directional light is defined by a direction (what a surprise!).
  133714. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133715. * 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.
  133716. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133717. */
  133718. export class DirectionalLight extends ShadowLight {
  133719. private _shadowFrustumSize;
  133720. /**
  133721. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  133722. */
  133723. get shadowFrustumSize(): number;
  133724. /**
  133725. * Specifies a fix frustum size for the shadow generation.
  133726. */
  133727. set shadowFrustumSize(value: number);
  133728. private _shadowOrthoScale;
  133729. /**
  133730. * Gets the shadow projection scale against the optimal computed one.
  133731. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133732. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133733. */
  133734. get shadowOrthoScale(): number;
  133735. /**
  133736. * Sets the shadow projection scale against the optimal computed one.
  133737. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133738. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133739. */
  133740. set shadowOrthoScale(value: number);
  133741. /**
  133742. * Automatically compute the projection matrix to best fit (including all the casters)
  133743. * on each frame.
  133744. */
  133745. autoUpdateExtends: boolean;
  133746. /**
  133747. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  133748. * on each frame. autoUpdateExtends must be set to true for this to work
  133749. */
  133750. autoCalcShadowZBounds: boolean;
  133751. private _orthoLeft;
  133752. private _orthoRight;
  133753. private _orthoTop;
  133754. private _orthoBottom;
  133755. /**
  133756. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  133757. * The directional light is emitted from everywhere in the given direction.
  133758. * It can cast shadows.
  133759. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133760. * @param name The friendly name of the light
  133761. * @param direction The direction of the light
  133762. * @param scene The scene the light belongs to
  133763. */
  133764. constructor(name: string, direction: Vector3, scene: Scene);
  133765. /**
  133766. * Returns the string "DirectionalLight".
  133767. * @return The class name
  133768. */
  133769. getClassName(): string;
  133770. /**
  133771. * Returns the integer 1.
  133772. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133773. */
  133774. getTypeID(): number;
  133775. /**
  133776. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  133777. * Returns the DirectionalLight Shadow projection matrix.
  133778. */
  133779. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133780. /**
  133781. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  133782. * Returns the DirectionalLight Shadow projection matrix.
  133783. */
  133784. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  133785. /**
  133786. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  133787. * Returns the DirectionalLight Shadow projection matrix.
  133788. */
  133789. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133790. protected _buildUniformLayout(): void;
  133791. /**
  133792. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  133793. * @param effect The effect to update
  133794. * @param lightIndex The index of the light in the effect to update
  133795. * @returns The directional light
  133796. */
  133797. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  133798. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  133799. /**
  133800. * Gets the minZ used for shadow according to both the scene and the light.
  133801. *
  133802. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133803. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133804. * @param activeCamera The camera we are returning the min for
  133805. * @returns the depth min z
  133806. */
  133807. getDepthMinZ(activeCamera: Camera): number;
  133808. /**
  133809. * Gets the maxZ used for shadow according to both the scene and the light.
  133810. *
  133811. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133812. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133813. * @param activeCamera The camera we are returning the max for
  133814. * @returns the depth max z
  133815. */
  133816. getDepthMaxZ(activeCamera: Camera): number;
  133817. /**
  133818. * Prepares the list of defines specific to the light type.
  133819. * @param defines the list of defines
  133820. * @param lightIndex defines the index of the light for the effect
  133821. */
  133822. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133823. }
  133824. }
  133825. declare module BABYLON {
  133826. /**
  133827. * Class containing static functions to help procedurally build meshes
  133828. */
  133829. export class HemisphereBuilder {
  133830. /**
  133831. * Creates a hemisphere mesh
  133832. * @param name defines the name of the mesh
  133833. * @param options defines the options used to create the mesh
  133834. * @param scene defines the hosting scene
  133835. * @returns the hemisphere mesh
  133836. */
  133837. static CreateHemisphere(name: string, options: {
  133838. segments?: number;
  133839. diameter?: number;
  133840. sideOrientation?: number;
  133841. }, scene: any): Mesh;
  133842. }
  133843. }
  133844. declare module BABYLON {
  133845. /**
  133846. * A spot light is defined by a position, a direction, an angle, and an exponent.
  133847. * These values define a cone of light starting from the position, emitting toward the direction.
  133848. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  133849. * and the exponent defines the speed of the decay of the light with distance (reach).
  133850. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133851. */
  133852. export class SpotLight extends ShadowLight {
  133853. private _angle;
  133854. private _innerAngle;
  133855. private _cosHalfAngle;
  133856. private _lightAngleScale;
  133857. private _lightAngleOffset;
  133858. /**
  133859. * Gets the cone angle of the spot light in Radians.
  133860. */
  133861. get angle(): number;
  133862. /**
  133863. * Sets the cone angle of the spot light in Radians.
  133864. */
  133865. set angle(value: number);
  133866. /**
  133867. * Only used in gltf falloff mode, this defines the angle where
  133868. * the directional falloff will start before cutting at angle which could be seen
  133869. * as outer angle.
  133870. */
  133871. get innerAngle(): number;
  133872. /**
  133873. * Only used in gltf falloff mode, this defines the angle where
  133874. * the directional falloff will start before cutting at angle which could be seen
  133875. * as outer angle.
  133876. */
  133877. set innerAngle(value: number);
  133878. private _shadowAngleScale;
  133879. /**
  133880. * Allows scaling the angle of the light for shadow generation only.
  133881. */
  133882. get shadowAngleScale(): number;
  133883. /**
  133884. * Allows scaling the angle of the light for shadow generation only.
  133885. */
  133886. set shadowAngleScale(value: number);
  133887. /**
  133888. * The light decay speed with the distance from the emission spot.
  133889. */
  133890. exponent: number;
  133891. private _projectionTextureMatrix;
  133892. /**
  133893. * Allows reading the projecton texture
  133894. */
  133895. get projectionTextureMatrix(): Matrix;
  133896. protected _projectionTextureLightNear: number;
  133897. /**
  133898. * Gets the near clip of the Spotlight for texture projection.
  133899. */
  133900. get projectionTextureLightNear(): number;
  133901. /**
  133902. * Sets the near clip of the Spotlight for texture projection.
  133903. */
  133904. set projectionTextureLightNear(value: number);
  133905. protected _projectionTextureLightFar: number;
  133906. /**
  133907. * Gets the far clip of the Spotlight for texture projection.
  133908. */
  133909. get projectionTextureLightFar(): number;
  133910. /**
  133911. * Sets the far clip of the Spotlight for texture projection.
  133912. */
  133913. set projectionTextureLightFar(value: number);
  133914. protected _projectionTextureUpDirection: Vector3;
  133915. /**
  133916. * Gets the Up vector of the Spotlight for texture projection.
  133917. */
  133918. get projectionTextureUpDirection(): Vector3;
  133919. /**
  133920. * Sets the Up vector of the Spotlight for texture projection.
  133921. */
  133922. set projectionTextureUpDirection(value: Vector3);
  133923. private _projectionTexture;
  133924. /**
  133925. * Gets the projection texture of the light.
  133926. */
  133927. get projectionTexture(): Nullable<BaseTexture>;
  133928. /**
  133929. * Sets the projection texture of the light.
  133930. */
  133931. set projectionTexture(value: Nullable<BaseTexture>);
  133932. private _projectionTextureViewLightDirty;
  133933. private _projectionTextureProjectionLightDirty;
  133934. private _projectionTextureDirty;
  133935. private _projectionTextureViewTargetVector;
  133936. private _projectionTextureViewLightMatrix;
  133937. private _projectionTextureProjectionLightMatrix;
  133938. private _projectionTextureScalingMatrix;
  133939. /**
  133940. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  133941. * It can cast shadows.
  133942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133943. * @param name The light friendly name
  133944. * @param position The position of the spot light in the scene
  133945. * @param direction The direction of the light in the scene
  133946. * @param angle The cone angle of the light in Radians
  133947. * @param exponent The light decay speed with the distance from the emission spot
  133948. * @param scene The scene the lights belongs to
  133949. */
  133950. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  133951. /**
  133952. * Returns the string "SpotLight".
  133953. * @returns the class name
  133954. */
  133955. getClassName(): string;
  133956. /**
  133957. * Returns the integer 2.
  133958. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133959. */
  133960. getTypeID(): number;
  133961. /**
  133962. * Overrides the direction setter to recompute the projection texture view light Matrix.
  133963. */
  133964. protected _setDirection(value: Vector3): void;
  133965. /**
  133966. * Overrides the position setter to recompute the projection texture view light Matrix.
  133967. */
  133968. protected _setPosition(value: Vector3): void;
  133969. /**
  133970. * 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.
  133971. * Returns the SpotLight.
  133972. */
  133973. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133974. protected _computeProjectionTextureViewLightMatrix(): void;
  133975. protected _computeProjectionTextureProjectionLightMatrix(): void;
  133976. /**
  133977. * Main function for light texture projection matrix computing.
  133978. */
  133979. protected _computeProjectionTextureMatrix(): void;
  133980. protected _buildUniformLayout(): void;
  133981. private _computeAngleValues;
  133982. /**
  133983. * Sets the passed Effect "effect" with the Light textures.
  133984. * @param effect The effect to update
  133985. * @param lightIndex The index of the light in the effect to update
  133986. * @returns The light
  133987. */
  133988. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  133989. /**
  133990. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  133991. * @param effect The effect to update
  133992. * @param lightIndex The index of the light in the effect to update
  133993. * @returns The spot light
  133994. */
  133995. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  133996. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  133997. /**
  133998. * Disposes the light and the associated resources.
  133999. */
  134000. dispose(): void;
  134001. /**
  134002. * Prepares the list of defines specific to the light type.
  134003. * @param defines the list of defines
  134004. * @param lightIndex defines the index of the light for the effect
  134005. */
  134006. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134007. }
  134008. }
  134009. declare module BABYLON {
  134010. /**
  134011. * Gizmo that enables viewing a light
  134012. */
  134013. export class LightGizmo extends Gizmo {
  134014. private _lightMesh;
  134015. private _material;
  134016. private _cachedPosition;
  134017. private _cachedForward;
  134018. private _attachedMeshParent;
  134019. private _pointerObserver;
  134020. /**
  134021. * Event that fires each time the gizmo is clicked
  134022. */
  134023. onClickedObservable: Observable<Light>;
  134024. /**
  134025. * Creates a LightGizmo
  134026. * @param gizmoLayer The utility layer the gizmo will be added to
  134027. */
  134028. constructor(gizmoLayer?: UtilityLayerRenderer);
  134029. private _light;
  134030. /**
  134031. * The light that the gizmo is attached to
  134032. */
  134033. set light(light: Nullable<Light>);
  134034. get light(): Nullable<Light>;
  134035. /**
  134036. * Gets the material used to render the light gizmo
  134037. */
  134038. get material(): StandardMaterial;
  134039. /**
  134040. * @hidden
  134041. * Updates the gizmo to match the attached mesh's position/rotation
  134042. */
  134043. protected _update(): void;
  134044. private static _Scale;
  134045. /**
  134046. * Creates the lines for a light mesh
  134047. */
  134048. private static _CreateLightLines;
  134049. /**
  134050. * Disposes of the light gizmo
  134051. */
  134052. dispose(): void;
  134053. private static _CreateHemisphericLightMesh;
  134054. private static _CreatePointLightMesh;
  134055. private static _CreateSpotLightMesh;
  134056. private static _CreateDirectionalLightMesh;
  134057. }
  134058. }
  134059. declare module BABYLON {
  134060. /**
  134061. * Gizmo that enables viewing a camera
  134062. */
  134063. export class CameraGizmo extends Gizmo {
  134064. private _cameraMesh;
  134065. private _cameraLinesMesh;
  134066. private _material;
  134067. private _pointerObserver;
  134068. /**
  134069. * Event that fires each time the gizmo is clicked
  134070. */
  134071. onClickedObservable: Observable<Camera>;
  134072. /**
  134073. * Creates a CameraGizmo
  134074. * @param gizmoLayer The utility layer the gizmo will be added to
  134075. */
  134076. constructor(gizmoLayer?: UtilityLayerRenderer);
  134077. private _camera;
  134078. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134079. get displayFrustum(): boolean;
  134080. set displayFrustum(value: boolean);
  134081. /**
  134082. * The camera that the gizmo is attached to
  134083. */
  134084. set camera(camera: Nullable<Camera>);
  134085. get camera(): Nullable<Camera>;
  134086. /**
  134087. * Gets the material used to render the camera gizmo
  134088. */
  134089. get material(): StandardMaterial;
  134090. /**
  134091. * @hidden
  134092. * Updates the gizmo to match the attached mesh's position/rotation
  134093. */
  134094. protected _update(): void;
  134095. private static _Scale;
  134096. private _invProjection;
  134097. /**
  134098. * Disposes of the camera gizmo
  134099. */
  134100. dispose(): void;
  134101. private static _CreateCameraMesh;
  134102. private static _CreateCameraFrustum;
  134103. }
  134104. }
  134105. declare module BABYLON {
  134106. /** @hidden */
  134107. export var backgroundFragmentDeclaration: {
  134108. name: string;
  134109. shader: string;
  134110. };
  134111. }
  134112. declare module BABYLON {
  134113. /** @hidden */
  134114. export var backgroundUboDeclaration: {
  134115. name: string;
  134116. shader: string;
  134117. };
  134118. }
  134119. declare module BABYLON {
  134120. /** @hidden */
  134121. export var backgroundPixelShader: {
  134122. name: string;
  134123. shader: string;
  134124. };
  134125. }
  134126. declare module BABYLON {
  134127. /** @hidden */
  134128. export var backgroundVertexDeclaration: {
  134129. name: string;
  134130. shader: string;
  134131. };
  134132. }
  134133. declare module BABYLON {
  134134. /** @hidden */
  134135. export var backgroundVertexShader: {
  134136. name: string;
  134137. shader: string;
  134138. };
  134139. }
  134140. declare module BABYLON {
  134141. /**
  134142. * Background material used to create an efficient environement around your scene.
  134143. */
  134144. export class BackgroundMaterial extends PushMaterial {
  134145. /**
  134146. * Standard reflectance value at parallel view angle.
  134147. */
  134148. static StandardReflectance0: number;
  134149. /**
  134150. * Standard reflectance value at grazing angle.
  134151. */
  134152. static StandardReflectance90: number;
  134153. protected _primaryColor: Color3;
  134154. /**
  134155. * Key light Color (multiply against the environement texture)
  134156. */
  134157. primaryColor: Color3;
  134158. protected __perceptualColor: Nullable<Color3>;
  134159. /**
  134160. * Experimental Internal Use Only.
  134161. *
  134162. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134163. * This acts as a helper to set the primary color to a more "human friendly" value.
  134164. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134165. * output color as close as possible from the chosen value.
  134166. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134167. * part of lighting setup.)
  134168. */
  134169. get _perceptualColor(): Nullable<Color3>;
  134170. set _perceptualColor(value: Nullable<Color3>);
  134171. protected _primaryColorShadowLevel: float;
  134172. /**
  134173. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134174. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134175. */
  134176. get primaryColorShadowLevel(): float;
  134177. set primaryColorShadowLevel(value: float);
  134178. protected _primaryColorHighlightLevel: float;
  134179. /**
  134180. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134181. * The primary color is used at the level chosen to define what the white area would look.
  134182. */
  134183. get primaryColorHighlightLevel(): float;
  134184. set primaryColorHighlightLevel(value: float);
  134185. protected _reflectionTexture: Nullable<BaseTexture>;
  134186. /**
  134187. * Reflection Texture used in the material.
  134188. * Should be author in a specific way for the best result (refer to the documentation).
  134189. */
  134190. reflectionTexture: Nullable<BaseTexture>;
  134191. protected _reflectionBlur: float;
  134192. /**
  134193. * Reflection Texture level of blur.
  134194. *
  134195. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134196. * texture twice.
  134197. */
  134198. reflectionBlur: float;
  134199. protected _diffuseTexture: Nullable<BaseTexture>;
  134200. /**
  134201. * Diffuse Texture used in the material.
  134202. * Should be author in a specific way for the best result (refer to the documentation).
  134203. */
  134204. diffuseTexture: Nullable<BaseTexture>;
  134205. protected _shadowLights: Nullable<IShadowLight[]>;
  134206. /**
  134207. * Specify the list of lights casting shadow on the material.
  134208. * All scene shadow lights will be included if null.
  134209. */
  134210. shadowLights: Nullable<IShadowLight[]>;
  134211. protected _shadowLevel: float;
  134212. /**
  134213. * Helps adjusting the shadow to a softer level if required.
  134214. * 0 means black shadows and 1 means no shadows.
  134215. */
  134216. shadowLevel: float;
  134217. protected _sceneCenter: Vector3;
  134218. /**
  134219. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134220. * It is usually zero but might be interesting to modify according to your setup.
  134221. */
  134222. sceneCenter: Vector3;
  134223. protected _opacityFresnel: boolean;
  134224. /**
  134225. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134226. * This helps ensuring a nice transition when the camera goes under the ground.
  134227. */
  134228. opacityFresnel: boolean;
  134229. protected _reflectionFresnel: boolean;
  134230. /**
  134231. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134232. * This helps adding a mirror texture on the ground.
  134233. */
  134234. reflectionFresnel: boolean;
  134235. protected _reflectionFalloffDistance: number;
  134236. /**
  134237. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134238. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134239. */
  134240. reflectionFalloffDistance: number;
  134241. protected _reflectionAmount: number;
  134242. /**
  134243. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134244. */
  134245. reflectionAmount: number;
  134246. protected _reflectionReflectance0: number;
  134247. /**
  134248. * This specifies the weight of the reflection at grazing angle.
  134249. */
  134250. reflectionReflectance0: number;
  134251. protected _reflectionReflectance90: number;
  134252. /**
  134253. * This specifies the weight of the reflection at a perpendicular point of view.
  134254. */
  134255. reflectionReflectance90: number;
  134256. /**
  134257. * Sets the reflection reflectance fresnel values according to the default standard
  134258. * empirically know to work well :-)
  134259. */
  134260. set reflectionStandardFresnelWeight(value: number);
  134261. protected _useRGBColor: boolean;
  134262. /**
  134263. * Helps to directly use the maps channels instead of their level.
  134264. */
  134265. useRGBColor: boolean;
  134266. protected _enableNoise: boolean;
  134267. /**
  134268. * This helps reducing the banding effect that could occur on the background.
  134269. */
  134270. enableNoise: boolean;
  134271. /**
  134272. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134273. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134274. * Recommended to be keep at 1.0 except for special cases.
  134275. */
  134276. get fovMultiplier(): number;
  134277. set fovMultiplier(value: number);
  134278. private _fovMultiplier;
  134279. /**
  134280. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134281. */
  134282. useEquirectangularFOV: boolean;
  134283. private _maxSimultaneousLights;
  134284. /**
  134285. * Number of Simultaneous lights allowed on the material.
  134286. */
  134287. maxSimultaneousLights: int;
  134288. private _shadowOnly;
  134289. /**
  134290. * Make the material only render shadows
  134291. */
  134292. shadowOnly: boolean;
  134293. /**
  134294. * Default configuration related to image processing available in the Background Material.
  134295. */
  134296. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134297. /**
  134298. * Keep track of the image processing observer to allow dispose and replace.
  134299. */
  134300. private _imageProcessingObserver;
  134301. /**
  134302. * Attaches a new image processing configuration to the PBR Material.
  134303. * @param configuration (if null the scene configuration will be use)
  134304. */
  134305. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134306. /**
  134307. * Gets the image processing configuration used either in this material.
  134308. */
  134309. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134310. /**
  134311. * Sets the Default image processing configuration used either in the this material.
  134312. *
  134313. * If sets to null, the scene one is in use.
  134314. */
  134315. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134316. /**
  134317. * Gets wether the color curves effect is enabled.
  134318. */
  134319. get cameraColorCurvesEnabled(): boolean;
  134320. /**
  134321. * Sets wether the color curves effect is enabled.
  134322. */
  134323. set cameraColorCurvesEnabled(value: boolean);
  134324. /**
  134325. * Gets wether the color grading effect is enabled.
  134326. */
  134327. get cameraColorGradingEnabled(): boolean;
  134328. /**
  134329. * Gets wether the color grading effect is enabled.
  134330. */
  134331. set cameraColorGradingEnabled(value: boolean);
  134332. /**
  134333. * Gets wether tonemapping is enabled or not.
  134334. */
  134335. get cameraToneMappingEnabled(): boolean;
  134336. /**
  134337. * Sets wether tonemapping is enabled or not
  134338. */
  134339. set cameraToneMappingEnabled(value: boolean);
  134340. /**
  134341. * The camera exposure used on this material.
  134342. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134343. * This corresponds to a photographic exposure.
  134344. */
  134345. get cameraExposure(): float;
  134346. /**
  134347. * The camera exposure used on this material.
  134348. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134349. * This corresponds to a photographic exposure.
  134350. */
  134351. set cameraExposure(value: float);
  134352. /**
  134353. * Gets The camera contrast used on this material.
  134354. */
  134355. get cameraContrast(): float;
  134356. /**
  134357. * Sets The camera contrast used on this material.
  134358. */
  134359. set cameraContrast(value: float);
  134360. /**
  134361. * Gets the Color Grading 2D Lookup Texture.
  134362. */
  134363. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134364. /**
  134365. * Sets the Color Grading 2D Lookup Texture.
  134366. */
  134367. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134368. /**
  134369. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134370. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134371. * 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;
  134372. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134373. */
  134374. get cameraColorCurves(): Nullable<ColorCurves>;
  134375. /**
  134376. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134377. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134378. * 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;
  134379. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134380. */
  134381. set cameraColorCurves(value: Nullable<ColorCurves>);
  134382. /**
  134383. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  134384. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  134385. */
  134386. switchToBGR: boolean;
  134387. private _renderTargets;
  134388. private _reflectionControls;
  134389. private _white;
  134390. private _primaryShadowColor;
  134391. private _primaryHighlightColor;
  134392. /**
  134393. * Instantiates a Background Material in the given scene
  134394. * @param name The friendly name of the material
  134395. * @param scene The scene to add the material to
  134396. */
  134397. constructor(name: string, scene: Scene);
  134398. /**
  134399. * Gets a boolean indicating that current material needs to register RTT
  134400. */
  134401. get hasRenderTargetTextures(): boolean;
  134402. /**
  134403. * The entire material has been created in order to prevent overdraw.
  134404. * @returns false
  134405. */
  134406. needAlphaTesting(): boolean;
  134407. /**
  134408. * The entire material has been created in order to prevent overdraw.
  134409. * @returns true if blending is enable
  134410. */
  134411. needAlphaBlending(): boolean;
  134412. /**
  134413. * Checks wether the material is ready to be rendered for a given mesh.
  134414. * @param mesh The mesh to render
  134415. * @param subMesh The submesh to check against
  134416. * @param useInstances Specify wether or not the material is used with instances
  134417. * @returns true if all the dependencies are ready (Textures, Effects...)
  134418. */
  134419. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134420. /**
  134421. * Compute the primary color according to the chosen perceptual color.
  134422. */
  134423. private _computePrimaryColorFromPerceptualColor;
  134424. /**
  134425. * Compute the highlights and shadow colors according to their chosen levels.
  134426. */
  134427. private _computePrimaryColors;
  134428. /**
  134429. * Build the uniform buffer used in the material.
  134430. */
  134431. buildUniformLayout(): void;
  134432. /**
  134433. * Unbind the material.
  134434. */
  134435. unbind(): void;
  134436. /**
  134437. * Bind only the world matrix to the material.
  134438. * @param world The world matrix to bind.
  134439. */
  134440. bindOnlyWorldMatrix(world: Matrix): void;
  134441. /**
  134442. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  134443. * @param world The world matrix to bind.
  134444. * @param subMesh The submesh to bind for.
  134445. */
  134446. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134447. /**
  134448. * Checks to see if a texture is used in the material.
  134449. * @param texture - Base texture to use.
  134450. * @returns - Boolean specifying if a texture is used in the material.
  134451. */
  134452. hasTexture(texture: BaseTexture): boolean;
  134453. /**
  134454. * Dispose the material.
  134455. * @param forceDisposeEffect Force disposal of the associated effect.
  134456. * @param forceDisposeTextures Force disposal of the associated textures.
  134457. */
  134458. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134459. /**
  134460. * Clones the material.
  134461. * @param name The cloned name.
  134462. * @returns The cloned material.
  134463. */
  134464. clone(name: string): BackgroundMaterial;
  134465. /**
  134466. * Serializes the current material to its JSON representation.
  134467. * @returns The JSON representation.
  134468. */
  134469. serialize(): any;
  134470. /**
  134471. * Gets the class name of the material
  134472. * @returns "BackgroundMaterial"
  134473. */
  134474. getClassName(): string;
  134475. /**
  134476. * Parse a JSON input to create back a background material.
  134477. * @param source The JSON data to parse
  134478. * @param scene The scene to create the parsed material in
  134479. * @param rootUrl The root url of the assets the material depends upon
  134480. * @returns the instantiated BackgroundMaterial.
  134481. */
  134482. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  134483. }
  134484. }
  134485. declare module BABYLON {
  134486. /**
  134487. * Represents the different options available during the creation of
  134488. * a Environment helper.
  134489. *
  134490. * This can control the default ground, skybox and image processing setup of your scene.
  134491. */
  134492. export interface IEnvironmentHelperOptions {
  134493. /**
  134494. * Specifies whether or not to create a ground.
  134495. * True by default.
  134496. */
  134497. createGround: boolean;
  134498. /**
  134499. * Specifies the ground size.
  134500. * 15 by default.
  134501. */
  134502. groundSize: number;
  134503. /**
  134504. * The texture used on the ground for the main color.
  134505. * Comes from the BabylonJS CDN by default.
  134506. *
  134507. * Remarks: Can be either a texture or a url.
  134508. */
  134509. groundTexture: string | BaseTexture;
  134510. /**
  134511. * The color mixed in the ground texture by default.
  134512. * BabylonJS clearColor by default.
  134513. */
  134514. groundColor: Color3;
  134515. /**
  134516. * Specifies the ground opacity.
  134517. * 1 by default.
  134518. */
  134519. groundOpacity: number;
  134520. /**
  134521. * Enables the ground to receive shadows.
  134522. * True by default.
  134523. */
  134524. enableGroundShadow: boolean;
  134525. /**
  134526. * Helps preventing the shadow to be fully black on the ground.
  134527. * 0.5 by default.
  134528. */
  134529. groundShadowLevel: number;
  134530. /**
  134531. * Creates a mirror texture attach to the ground.
  134532. * false by default.
  134533. */
  134534. enableGroundMirror: boolean;
  134535. /**
  134536. * Specifies the ground mirror size ratio.
  134537. * 0.3 by default as the default kernel is 64.
  134538. */
  134539. groundMirrorSizeRatio: number;
  134540. /**
  134541. * Specifies the ground mirror blur kernel size.
  134542. * 64 by default.
  134543. */
  134544. groundMirrorBlurKernel: number;
  134545. /**
  134546. * Specifies the ground mirror visibility amount.
  134547. * 1 by default
  134548. */
  134549. groundMirrorAmount: number;
  134550. /**
  134551. * Specifies the ground mirror reflectance weight.
  134552. * This uses the standard weight of the background material to setup the fresnel effect
  134553. * of the mirror.
  134554. * 1 by default.
  134555. */
  134556. groundMirrorFresnelWeight: number;
  134557. /**
  134558. * Specifies the ground mirror Falloff distance.
  134559. * This can helps reducing the size of the reflection.
  134560. * 0 by Default.
  134561. */
  134562. groundMirrorFallOffDistance: number;
  134563. /**
  134564. * Specifies the ground mirror texture type.
  134565. * Unsigned Int by Default.
  134566. */
  134567. groundMirrorTextureType: number;
  134568. /**
  134569. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  134570. * the shown objects.
  134571. */
  134572. groundYBias: number;
  134573. /**
  134574. * Specifies whether or not to create a skybox.
  134575. * True by default.
  134576. */
  134577. createSkybox: boolean;
  134578. /**
  134579. * Specifies the skybox size.
  134580. * 20 by default.
  134581. */
  134582. skyboxSize: number;
  134583. /**
  134584. * The texture used on the skybox for the main color.
  134585. * Comes from the BabylonJS CDN by default.
  134586. *
  134587. * Remarks: Can be either a texture or a url.
  134588. */
  134589. skyboxTexture: string | BaseTexture;
  134590. /**
  134591. * The color mixed in the skybox texture by default.
  134592. * BabylonJS clearColor by default.
  134593. */
  134594. skyboxColor: Color3;
  134595. /**
  134596. * The background rotation around the Y axis of the scene.
  134597. * This helps aligning the key lights of your scene with the background.
  134598. * 0 by default.
  134599. */
  134600. backgroundYRotation: number;
  134601. /**
  134602. * Compute automatically the size of the elements to best fit with the scene.
  134603. */
  134604. sizeAuto: boolean;
  134605. /**
  134606. * Default position of the rootMesh if autoSize is not true.
  134607. */
  134608. rootPosition: Vector3;
  134609. /**
  134610. * Sets up the image processing in the scene.
  134611. * true by default.
  134612. */
  134613. setupImageProcessing: boolean;
  134614. /**
  134615. * The texture used as your environment texture in the scene.
  134616. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  134617. *
  134618. * Remarks: Can be either a texture or a url.
  134619. */
  134620. environmentTexture: string | BaseTexture;
  134621. /**
  134622. * The value of the exposure to apply to the scene.
  134623. * 0.6 by default if setupImageProcessing is true.
  134624. */
  134625. cameraExposure: number;
  134626. /**
  134627. * The value of the contrast to apply to the scene.
  134628. * 1.6 by default if setupImageProcessing is true.
  134629. */
  134630. cameraContrast: number;
  134631. /**
  134632. * Specifies whether or not tonemapping should be enabled in the scene.
  134633. * true by default if setupImageProcessing is true.
  134634. */
  134635. toneMappingEnabled: boolean;
  134636. }
  134637. /**
  134638. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  134639. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  134640. * It also helps with the default setup of your imageProcessing configuration.
  134641. */
  134642. export class EnvironmentHelper {
  134643. /**
  134644. * Default ground texture URL.
  134645. */
  134646. private static _groundTextureCDNUrl;
  134647. /**
  134648. * Default skybox texture URL.
  134649. */
  134650. private static _skyboxTextureCDNUrl;
  134651. /**
  134652. * Default environment texture URL.
  134653. */
  134654. private static _environmentTextureCDNUrl;
  134655. /**
  134656. * Creates the default options for the helper.
  134657. */
  134658. private static _getDefaultOptions;
  134659. private _rootMesh;
  134660. /**
  134661. * Gets the root mesh created by the helper.
  134662. */
  134663. get rootMesh(): Mesh;
  134664. private _skybox;
  134665. /**
  134666. * Gets the skybox created by the helper.
  134667. */
  134668. get skybox(): Nullable<Mesh>;
  134669. private _skyboxTexture;
  134670. /**
  134671. * Gets the skybox texture created by the helper.
  134672. */
  134673. get skyboxTexture(): Nullable<BaseTexture>;
  134674. private _skyboxMaterial;
  134675. /**
  134676. * Gets the skybox material created by the helper.
  134677. */
  134678. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  134679. private _ground;
  134680. /**
  134681. * Gets the ground mesh created by the helper.
  134682. */
  134683. get ground(): Nullable<Mesh>;
  134684. private _groundTexture;
  134685. /**
  134686. * Gets the ground texture created by the helper.
  134687. */
  134688. get groundTexture(): Nullable<BaseTexture>;
  134689. private _groundMirror;
  134690. /**
  134691. * Gets the ground mirror created by the helper.
  134692. */
  134693. get groundMirror(): Nullable<MirrorTexture>;
  134694. /**
  134695. * Gets the ground mirror render list to helps pushing the meshes
  134696. * you wish in the ground reflection.
  134697. */
  134698. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134699. private _groundMaterial;
  134700. /**
  134701. * Gets the ground material created by the helper.
  134702. */
  134703. get groundMaterial(): Nullable<BackgroundMaterial>;
  134704. /**
  134705. * Stores the creation options.
  134706. */
  134707. private readonly _scene;
  134708. private _options;
  134709. /**
  134710. * This observable will be notified with any error during the creation of the environment,
  134711. * mainly texture creation errors.
  134712. */
  134713. onErrorObservable: Observable<{
  134714. message?: string;
  134715. exception?: any;
  134716. }>;
  134717. /**
  134718. * constructor
  134719. * @param options Defines the options we want to customize the helper
  134720. * @param scene The scene to add the material to
  134721. */
  134722. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  134723. /**
  134724. * Updates the background according to the new options
  134725. * @param options
  134726. */
  134727. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  134728. /**
  134729. * Sets the primary color of all the available elements.
  134730. * @param color the main color to affect to the ground and the background
  134731. */
  134732. setMainColor(color: Color3): void;
  134733. /**
  134734. * Setup the image processing according to the specified options.
  134735. */
  134736. private _setupImageProcessing;
  134737. /**
  134738. * Setup the environment texture according to the specified options.
  134739. */
  134740. private _setupEnvironmentTexture;
  134741. /**
  134742. * Setup the background according to the specified options.
  134743. */
  134744. private _setupBackground;
  134745. /**
  134746. * Get the scene sizes according to the setup.
  134747. */
  134748. private _getSceneSize;
  134749. /**
  134750. * Setup the ground according to the specified options.
  134751. */
  134752. private _setupGround;
  134753. /**
  134754. * Setup the ground material according to the specified options.
  134755. */
  134756. private _setupGroundMaterial;
  134757. /**
  134758. * Setup the ground diffuse texture according to the specified options.
  134759. */
  134760. private _setupGroundDiffuseTexture;
  134761. /**
  134762. * Setup the ground mirror texture according to the specified options.
  134763. */
  134764. private _setupGroundMirrorTexture;
  134765. /**
  134766. * Setup the ground to receive the mirror texture.
  134767. */
  134768. private _setupMirrorInGroundMaterial;
  134769. /**
  134770. * Setup the skybox according to the specified options.
  134771. */
  134772. private _setupSkybox;
  134773. /**
  134774. * Setup the skybox material according to the specified options.
  134775. */
  134776. private _setupSkyboxMaterial;
  134777. /**
  134778. * Setup the skybox reflection texture according to the specified options.
  134779. */
  134780. private _setupSkyboxReflectionTexture;
  134781. private _errorHandler;
  134782. /**
  134783. * Dispose all the elements created by the Helper.
  134784. */
  134785. dispose(): void;
  134786. }
  134787. }
  134788. declare module BABYLON {
  134789. /**
  134790. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  134791. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  134792. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134793. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134794. */
  134795. export abstract class TextureDome<T extends Texture> extends TransformNode {
  134796. protected onError: Nullable<(message?: string, exception?: any) => void>;
  134797. /**
  134798. * Define the source as a Monoscopic panoramic 360/180.
  134799. */
  134800. static readonly MODE_MONOSCOPIC: number;
  134801. /**
  134802. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  134803. */
  134804. static readonly MODE_TOPBOTTOM: number;
  134805. /**
  134806. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  134807. */
  134808. static readonly MODE_SIDEBYSIDE: number;
  134809. private _halfDome;
  134810. protected _useDirectMapping: boolean;
  134811. /**
  134812. * The texture being displayed on the sphere
  134813. */
  134814. protected _texture: T;
  134815. /**
  134816. * Gets the texture being displayed on the sphere
  134817. */
  134818. get texture(): T;
  134819. /**
  134820. * Sets the texture being displayed on the sphere
  134821. */
  134822. set texture(newTexture: T);
  134823. /**
  134824. * The skybox material
  134825. */
  134826. protected _material: BackgroundMaterial;
  134827. /**
  134828. * The surface used for the dome
  134829. */
  134830. protected _mesh: Mesh;
  134831. /**
  134832. * Gets the mesh used for the dome.
  134833. */
  134834. get mesh(): Mesh;
  134835. /**
  134836. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  134837. */
  134838. private _halfDomeMask;
  134839. /**
  134840. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134841. * Also see the options.resolution property.
  134842. */
  134843. get fovMultiplier(): number;
  134844. set fovMultiplier(value: number);
  134845. protected _textureMode: number;
  134846. /**
  134847. * Gets or set the current texture mode for the texture. It can be:
  134848. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134849. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134850. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134851. */
  134852. get textureMode(): number;
  134853. /**
  134854. * Sets the current texture mode for the texture. It can be:
  134855. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134856. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134857. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134858. */
  134859. set textureMode(value: number);
  134860. /**
  134861. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  134862. */
  134863. get halfDome(): boolean;
  134864. /**
  134865. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134866. */
  134867. set halfDome(enabled: boolean);
  134868. /**
  134869. * Oberserver used in Stereoscopic VR Mode.
  134870. */
  134871. private _onBeforeCameraRenderObserver;
  134872. /**
  134873. * Observable raised when an error occured while loading the 360 image
  134874. */
  134875. onLoadErrorObservable: Observable<string>;
  134876. /**
  134877. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  134878. * @param name Element's name, child elements will append suffixes for their own names.
  134879. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  134880. * @param options An object containing optional or exposed sub element properties
  134881. */
  134882. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  134883. resolution?: number;
  134884. clickToPlay?: boolean;
  134885. autoPlay?: boolean;
  134886. loop?: boolean;
  134887. size?: number;
  134888. poster?: string;
  134889. faceForward?: boolean;
  134890. useDirectMapping?: boolean;
  134891. halfDomeMode?: boolean;
  134892. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  134893. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  134894. protected _changeTextureMode(value: number): void;
  134895. /**
  134896. * Releases resources associated with this node.
  134897. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134898. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134899. */
  134900. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134901. }
  134902. }
  134903. declare module BABYLON {
  134904. /**
  134905. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  134906. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  134907. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134908. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134909. */
  134910. export class PhotoDome extends TextureDome<Texture> {
  134911. /**
  134912. * Define the image as a Monoscopic panoramic 360 image.
  134913. */
  134914. static readonly MODE_MONOSCOPIC: number;
  134915. /**
  134916. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  134917. */
  134918. static readonly MODE_TOPBOTTOM: number;
  134919. /**
  134920. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  134921. */
  134922. static readonly MODE_SIDEBYSIDE: number;
  134923. /**
  134924. * Gets or sets the texture being displayed on the sphere
  134925. */
  134926. get photoTexture(): Texture;
  134927. /**
  134928. * sets the texture being displayed on the sphere
  134929. */
  134930. set photoTexture(value: Texture);
  134931. /**
  134932. * Gets the current video mode for the video. It can be:
  134933. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134934. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134935. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134936. */
  134937. get imageMode(): number;
  134938. /**
  134939. * Sets the current video mode for the video. It can be:
  134940. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134941. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134942. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134943. */
  134944. set imageMode(value: number);
  134945. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  134946. }
  134947. }
  134948. declare module BABYLON {
  134949. /**
  134950. * Class used to host RGBD texture specific utilities
  134951. */
  134952. export class RGBDTextureTools {
  134953. /**
  134954. * Expand the RGBD Texture from RGBD to Half Float if possible.
  134955. * @param texture the texture to expand.
  134956. */
  134957. static ExpandRGBDTexture(texture: Texture): void;
  134958. }
  134959. }
  134960. declare module BABYLON {
  134961. /**
  134962. * Class used to host texture specific utilities
  134963. */
  134964. export class BRDFTextureTools {
  134965. /**
  134966. * Prevents texture cache collision
  134967. */
  134968. private static _instanceNumber;
  134969. /**
  134970. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  134971. * @param scene defines the hosting scene
  134972. * @returns the environment BRDF texture
  134973. */
  134974. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  134975. private static _environmentBRDFBase64Texture;
  134976. }
  134977. }
  134978. declare module BABYLON {
  134979. /**
  134980. * @hidden
  134981. */
  134982. export interface IMaterialClearCoatDefines {
  134983. CLEARCOAT: boolean;
  134984. CLEARCOAT_DEFAULTIOR: boolean;
  134985. CLEARCOAT_TEXTURE: boolean;
  134986. CLEARCOAT_TEXTUREDIRECTUV: number;
  134987. CLEARCOAT_BUMP: boolean;
  134988. CLEARCOAT_BUMPDIRECTUV: number;
  134989. CLEARCOAT_TINT: boolean;
  134990. CLEARCOAT_TINT_TEXTURE: boolean;
  134991. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134992. /** @hidden */
  134993. _areTexturesDirty: boolean;
  134994. }
  134995. /**
  134996. * Define the code related to the clear coat parameters of the pbr material.
  134997. */
  134998. export class PBRClearCoatConfiguration {
  134999. /**
  135000. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135001. * The default fits with a polyurethane material.
  135002. */
  135003. private static readonly _DefaultIndexOfRefraction;
  135004. private _isEnabled;
  135005. /**
  135006. * Defines if the clear coat is enabled in the material.
  135007. */
  135008. isEnabled: boolean;
  135009. /**
  135010. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135011. */
  135012. intensity: number;
  135013. /**
  135014. * Defines the clear coat layer roughness.
  135015. */
  135016. roughness: number;
  135017. private _indexOfRefraction;
  135018. /**
  135019. * Defines the index of refraction of the clear coat.
  135020. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135021. * The default fits with a polyurethane material.
  135022. * Changing the default value is more performance intensive.
  135023. */
  135024. indexOfRefraction: number;
  135025. private _texture;
  135026. /**
  135027. * Stores the clear coat values in a texture.
  135028. */
  135029. texture: Nullable<BaseTexture>;
  135030. private _bumpTexture;
  135031. /**
  135032. * Define the clear coat specific bump texture.
  135033. */
  135034. bumpTexture: Nullable<BaseTexture>;
  135035. private _isTintEnabled;
  135036. /**
  135037. * Defines if the clear coat tint is enabled in the material.
  135038. */
  135039. isTintEnabled: boolean;
  135040. /**
  135041. * Defines the clear coat tint of the material.
  135042. * This is only use if tint is enabled
  135043. */
  135044. tintColor: Color3;
  135045. /**
  135046. * Defines the distance at which the tint color should be found in the
  135047. * clear coat media.
  135048. * This is only use if tint is enabled
  135049. */
  135050. tintColorAtDistance: number;
  135051. /**
  135052. * Defines the clear coat layer thickness.
  135053. * This is only use if tint is enabled
  135054. */
  135055. tintThickness: number;
  135056. private _tintTexture;
  135057. /**
  135058. * Stores the clear tint values in a texture.
  135059. * rgb is tint
  135060. * a is a thickness factor
  135061. */
  135062. tintTexture: Nullable<BaseTexture>;
  135063. /** @hidden */
  135064. private _internalMarkAllSubMeshesAsTexturesDirty;
  135065. /** @hidden */
  135066. _markAllSubMeshesAsTexturesDirty(): void;
  135067. /**
  135068. * Instantiate a new istance of clear coat configuration.
  135069. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135070. */
  135071. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135072. /**
  135073. * Gets wehter the submesh is ready to be used or not.
  135074. * @param defines the list of "defines" to update.
  135075. * @param scene defines the scene the material belongs to.
  135076. * @param engine defines the engine the material belongs to.
  135077. * @param disableBumpMap defines wether the material disables bump or not.
  135078. * @returns - boolean indicating that the submesh is ready or not.
  135079. */
  135080. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135081. /**
  135082. * Checks to see if a texture is used in the material.
  135083. * @param defines the list of "defines" to update.
  135084. * @param scene defines the scene to the material belongs to.
  135085. */
  135086. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135087. /**
  135088. * Binds the material data.
  135089. * @param uniformBuffer defines the Uniform buffer to fill in.
  135090. * @param scene defines the scene the material belongs to.
  135091. * @param engine defines the engine the material belongs to.
  135092. * @param disableBumpMap defines wether the material disables bump or not.
  135093. * @param isFrozen defines wether the material is frozen or not.
  135094. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135095. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135096. */
  135097. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135098. /**
  135099. * Checks to see if a texture is used in the material.
  135100. * @param texture - Base texture to use.
  135101. * @returns - Boolean specifying if a texture is used in the material.
  135102. */
  135103. hasTexture(texture: BaseTexture): boolean;
  135104. /**
  135105. * Returns an array of the actively used textures.
  135106. * @param activeTextures Array of BaseTextures
  135107. */
  135108. getActiveTextures(activeTextures: BaseTexture[]): void;
  135109. /**
  135110. * Returns the animatable textures.
  135111. * @param animatables Array of animatable textures.
  135112. */
  135113. getAnimatables(animatables: IAnimatable[]): void;
  135114. /**
  135115. * Disposes the resources of the material.
  135116. * @param forceDisposeTextures - Forces the disposal of all textures.
  135117. */
  135118. dispose(forceDisposeTextures?: boolean): void;
  135119. /**
  135120. * Get the current class name of the texture useful for serialization or dynamic coding.
  135121. * @returns "PBRClearCoatConfiguration"
  135122. */
  135123. getClassName(): string;
  135124. /**
  135125. * Add fallbacks to the effect fallbacks list.
  135126. * @param defines defines the Base texture to use.
  135127. * @param fallbacks defines the current fallback list.
  135128. * @param currentRank defines the current fallback rank.
  135129. * @returns the new fallback rank.
  135130. */
  135131. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135132. /**
  135133. * Add the required uniforms to the current list.
  135134. * @param uniforms defines the current uniform list.
  135135. */
  135136. static AddUniforms(uniforms: string[]): void;
  135137. /**
  135138. * Add the required samplers to the current list.
  135139. * @param samplers defines the current sampler list.
  135140. */
  135141. static AddSamplers(samplers: string[]): void;
  135142. /**
  135143. * Add the required uniforms to the current buffer.
  135144. * @param uniformBuffer defines the current uniform buffer.
  135145. */
  135146. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135147. /**
  135148. * Makes a duplicate of the current configuration into another one.
  135149. * @param clearCoatConfiguration define the config where to copy the info
  135150. */
  135151. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135152. /**
  135153. * Serializes this clear coat configuration.
  135154. * @returns - An object with the serialized config.
  135155. */
  135156. serialize(): any;
  135157. /**
  135158. * Parses a anisotropy Configuration from a serialized object.
  135159. * @param source - Serialized object.
  135160. * @param scene Defines the scene we are parsing for
  135161. * @param rootUrl Defines the rootUrl to load from
  135162. */
  135163. parse(source: any, scene: Scene, rootUrl: string): void;
  135164. }
  135165. }
  135166. declare module BABYLON {
  135167. /**
  135168. * @hidden
  135169. */
  135170. export interface IMaterialAnisotropicDefines {
  135171. ANISOTROPIC: boolean;
  135172. ANISOTROPIC_TEXTURE: boolean;
  135173. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135174. MAINUV1: boolean;
  135175. _areTexturesDirty: boolean;
  135176. _needUVs: boolean;
  135177. }
  135178. /**
  135179. * Define the code related to the anisotropic parameters of the pbr material.
  135180. */
  135181. export class PBRAnisotropicConfiguration {
  135182. private _isEnabled;
  135183. /**
  135184. * Defines if the anisotropy is enabled in the material.
  135185. */
  135186. isEnabled: boolean;
  135187. /**
  135188. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135189. */
  135190. intensity: number;
  135191. /**
  135192. * Defines if the effect is along the tangents, bitangents or in between.
  135193. * By default, the effect is "strectching" the highlights along the tangents.
  135194. */
  135195. direction: Vector2;
  135196. private _texture;
  135197. /**
  135198. * Stores the anisotropy values in a texture.
  135199. * rg is direction (like normal from -1 to 1)
  135200. * b is a intensity
  135201. */
  135202. texture: Nullable<BaseTexture>;
  135203. /** @hidden */
  135204. private _internalMarkAllSubMeshesAsTexturesDirty;
  135205. /** @hidden */
  135206. _markAllSubMeshesAsTexturesDirty(): void;
  135207. /**
  135208. * Instantiate a new istance of anisotropy configuration.
  135209. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135210. */
  135211. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135212. /**
  135213. * Specifies that the submesh is ready to be used.
  135214. * @param defines the list of "defines" to update.
  135215. * @param scene defines the scene the material belongs to.
  135216. * @returns - boolean indicating that the submesh is ready or not.
  135217. */
  135218. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135219. /**
  135220. * Checks to see if a texture is used in the material.
  135221. * @param defines the list of "defines" to update.
  135222. * @param mesh the mesh we are preparing the defines for.
  135223. * @param scene defines the scene the material belongs to.
  135224. */
  135225. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135226. /**
  135227. * Binds the material data.
  135228. * @param uniformBuffer defines the Uniform buffer to fill in.
  135229. * @param scene defines the scene the material belongs to.
  135230. * @param isFrozen defines wether the material is frozen or not.
  135231. */
  135232. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135233. /**
  135234. * Checks to see if a texture is used in the material.
  135235. * @param texture - Base texture to use.
  135236. * @returns - Boolean specifying if a texture is used in the material.
  135237. */
  135238. hasTexture(texture: BaseTexture): boolean;
  135239. /**
  135240. * Returns an array of the actively used textures.
  135241. * @param activeTextures Array of BaseTextures
  135242. */
  135243. getActiveTextures(activeTextures: BaseTexture[]): void;
  135244. /**
  135245. * Returns the animatable textures.
  135246. * @param animatables Array of animatable textures.
  135247. */
  135248. getAnimatables(animatables: IAnimatable[]): void;
  135249. /**
  135250. * Disposes the resources of the material.
  135251. * @param forceDisposeTextures - Forces the disposal of all textures.
  135252. */
  135253. dispose(forceDisposeTextures?: boolean): void;
  135254. /**
  135255. * Get the current class name of the texture useful for serialization or dynamic coding.
  135256. * @returns "PBRAnisotropicConfiguration"
  135257. */
  135258. getClassName(): string;
  135259. /**
  135260. * Add fallbacks to the effect fallbacks list.
  135261. * @param defines defines the Base texture to use.
  135262. * @param fallbacks defines the current fallback list.
  135263. * @param currentRank defines the current fallback rank.
  135264. * @returns the new fallback rank.
  135265. */
  135266. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135267. /**
  135268. * Add the required uniforms to the current list.
  135269. * @param uniforms defines the current uniform list.
  135270. */
  135271. static AddUniforms(uniforms: string[]): void;
  135272. /**
  135273. * Add the required uniforms to the current buffer.
  135274. * @param uniformBuffer defines the current uniform buffer.
  135275. */
  135276. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135277. /**
  135278. * Add the required samplers to the current list.
  135279. * @param samplers defines the current sampler list.
  135280. */
  135281. static AddSamplers(samplers: string[]): void;
  135282. /**
  135283. * Makes a duplicate of the current configuration into another one.
  135284. * @param anisotropicConfiguration define the config where to copy the info
  135285. */
  135286. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135287. /**
  135288. * Serializes this anisotropy configuration.
  135289. * @returns - An object with the serialized config.
  135290. */
  135291. serialize(): any;
  135292. /**
  135293. * Parses a anisotropy Configuration from a serialized object.
  135294. * @param source - Serialized object.
  135295. * @param scene Defines the scene we are parsing for
  135296. * @param rootUrl Defines the rootUrl to load from
  135297. */
  135298. parse(source: any, scene: Scene, rootUrl: string): void;
  135299. }
  135300. }
  135301. declare module BABYLON {
  135302. /**
  135303. * @hidden
  135304. */
  135305. export interface IMaterialBRDFDefines {
  135306. BRDF_V_HEIGHT_CORRELATED: boolean;
  135307. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135308. SPHERICAL_HARMONICS: boolean;
  135309. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135310. /** @hidden */
  135311. _areMiscDirty: boolean;
  135312. }
  135313. /**
  135314. * Define the code related to the BRDF parameters of the pbr material.
  135315. */
  135316. export class PBRBRDFConfiguration {
  135317. /**
  135318. * Default value used for the energy conservation.
  135319. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135320. */
  135321. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135322. /**
  135323. * Default value used for the Smith Visibility Height Correlated mode.
  135324. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135325. */
  135326. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135327. /**
  135328. * Default value used for the IBL diffuse part.
  135329. * This can help switching back to the polynomials mode globally which is a tiny bit
  135330. * less GPU intensive at the drawback of a lower quality.
  135331. */
  135332. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135333. /**
  135334. * Default value used for activating energy conservation for the specular workflow.
  135335. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135336. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135337. */
  135338. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135339. private _useEnergyConservation;
  135340. /**
  135341. * Defines if the material uses energy conservation.
  135342. */
  135343. useEnergyConservation: boolean;
  135344. private _useSmithVisibilityHeightCorrelated;
  135345. /**
  135346. * LEGACY Mode set to false
  135347. * Defines if the material uses height smith correlated visibility term.
  135348. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135349. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135350. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135351. * Not relying on height correlated will also disable energy conservation.
  135352. */
  135353. useSmithVisibilityHeightCorrelated: boolean;
  135354. private _useSphericalHarmonics;
  135355. /**
  135356. * LEGACY Mode set to false
  135357. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135358. * diffuse part of the IBL.
  135359. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135360. * to the ground truth.
  135361. */
  135362. useSphericalHarmonics: boolean;
  135363. private _useSpecularGlossinessInputEnergyConservation;
  135364. /**
  135365. * Defines if the material uses energy conservation, when the specular workflow is active.
  135366. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135367. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135368. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135369. */
  135370. useSpecularGlossinessInputEnergyConservation: boolean;
  135371. /** @hidden */
  135372. private _internalMarkAllSubMeshesAsMiscDirty;
  135373. /** @hidden */
  135374. _markAllSubMeshesAsMiscDirty(): void;
  135375. /**
  135376. * Instantiate a new istance of clear coat configuration.
  135377. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135378. */
  135379. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135380. /**
  135381. * Checks to see if a texture is used in the material.
  135382. * @param defines the list of "defines" to update.
  135383. */
  135384. prepareDefines(defines: IMaterialBRDFDefines): void;
  135385. /**
  135386. * Get the current class name of the texture useful for serialization or dynamic coding.
  135387. * @returns "PBRClearCoatConfiguration"
  135388. */
  135389. getClassName(): string;
  135390. /**
  135391. * Makes a duplicate of the current configuration into another one.
  135392. * @param brdfConfiguration define the config where to copy the info
  135393. */
  135394. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  135395. /**
  135396. * Serializes this BRDF configuration.
  135397. * @returns - An object with the serialized config.
  135398. */
  135399. serialize(): any;
  135400. /**
  135401. * Parses a anisotropy Configuration from a serialized object.
  135402. * @param source - Serialized object.
  135403. * @param scene Defines the scene we are parsing for
  135404. * @param rootUrl Defines the rootUrl to load from
  135405. */
  135406. parse(source: any, scene: Scene, rootUrl: string): void;
  135407. }
  135408. }
  135409. declare module BABYLON {
  135410. /**
  135411. * @hidden
  135412. */
  135413. export interface IMaterialSheenDefines {
  135414. SHEEN: boolean;
  135415. SHEEN_TEXTURE: boolean;
  135416. SHEEN_TEXTUREDIRECTUV: number;
  135417. SHEEN_LINKWITHALBEDO: boolean;
  135418. SHEEN_ROUGHNESS: boolean;
  135419. SHEEN_ALBEDOSCALING: boolean;
  135420. /** @hidden */
  135421. _areTexturesDirty: boolean;
  135422. }
  135423. /**
  135424. * Define the code related to the Sheen parameters of the pbr material.
  135425. */
  135426. export class PBRSheenConfiguration {
  135427. private _isEnabled;
  135428. /**
  135429. * Defines if the material uses sheen.
  135430. */
  135431. isEnabled: boolean;
  135432. private _linkSheenWithAlbedo;
  135433. /**
  135434. * Defines if the sheen is linked to the sheen color.
  135435. */
  135436. linkSheenWithAlbedo: boolean;
  135437. /**
  135438. * Defines the sheen intensity.
  135439. */
  135440. intensity: number;
  135441. /**
  135442. * Defines the sheen color.
  135443. */
  135444. color: Color3;
  135445. private _texture;
  135446. /**
  135447. * Stores the sheen tint values in a texture.
  135448. * rgb is tint
  135449. * a is a intensity or roughness if roughness has been defined
  135450. */
  135451. texture: Nullable<BaseTexture>;
  135452. private _roughness;
  135453. /**
  135454. * Defines the sheen roughness.
  135455. * It is not taken into account if linkSheenWithAlbedo is true.
  135456. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  135457. */
  135458. roughness: Nullable<number>;
  135459. private _albedoScaling;
  135460. /**
  135461. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  135462. * It allows the strength of the sheen effect to not depend on the base color of the material,
  135463. * making it easier to setup and tweak the effect
  135464. */
  135465. albedoScaling: boolean;
  135466. /** @hidden */
  135467. private _internalMarkAllSubMeshesAsTexturesDirty;
  135468. /** @hidden */
  135469. _markAllSubMeshesAsTexturesDirty(): void;
  135470. /**
  135471. * Instantiate a new istance of clear coat configuration.
  135472. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135473. */
  135474. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135475. /**
  135476. * Specifies that the submesh is ready to be used.
  135477. * @param defines the list of "defines" to update.
  135478. * @param scene defines the scene the material belongs to.
  135479. * @returns - boolean indicating that the submesh is ready or not.
  135480. */
  135481. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  135482. /**
  135483. * Checks to see if a texture is used in the material.
  135484. * @param defines the list of "defines" to update.
  135485. * @param scene defines the scene the material belongs to.
  135486. */
  135487. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  135488. /**
  135489. * Binds the material data.
  135490. * @param uniformBuffer defines the Uniform buffer to fill in.
  135491. * @param scene defines the scene the material belongs to.
  135492. * @param isFrozen defines wether the material is frozen or not.
  135493. */
  135494. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135495. /**
  135496. * Checks to see if a texture is used in the material.
  135497. * @param texture - Base texture to use.
  135498. * @returns - Boolean specifying if a texture is used in the material.
  135499. */
  135500. hasTexture(texture: BaseTexture): boolean;
  135501. /**
  135502. * Returns an array of the actively used textures.
  135503. * @param activeTextures Array of BaseTextures
  135504. */
  135505. getActiveTextures(activeTextures: BaseTexture[]): void;
  135506. /**
  135507. * Returns the animatable textures.
  135508. * @param animatables Array of animatable textures.
  135509. */
  135510. getAnimatables(animatables: IAnimatable[]): void;
  135511. /**
  135512. * Disposes the resources of the material.
  135513. * @param forceDisposeTextures - Forces the disposal of all textures.
  135514. */
  135515. dispose(forceDisposeTextures?: boolean): void;
  135516. /**
  135517. * Get the current class name of the texture useful for serialization or dynamic coding.
  135518. * @returns "PBRSheenConfiguration"
  135519. */
  135520. getClassName(): string;
  135521. /**
  135522. * Add fallbacks to the effect fallbacks list.
  135523. * @param defines defines the Base texture to use.
  135524. * @param fallbacks defines the current fallback list.
  135525. * @param currentRank defines the current fallback rank.
  135526. * @returns the new fallback rank.
  135527. */
  135528. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135529. /**
  135530. * Add the required uniforms to the current list.
  135531. * @param uniforms defines the current uniform list.
  135532. */
  135533. static AddUniforms(uniforms: string[]): void;
  135534. /**
  135535. * Add the required uniforms to the current buffer.
  135536. * @param uniformBuffer defines the current uniform buffer.
  135537. */
  135538. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135539. /**
  135540. * Add the required samplers to the current list.
  135541. * @param samplers defines the current sampler list.
  135542. */
  135543. static AddSamplers(samplers: string[]): void;
  135544. /**
  135545. * Makes a duplicate of the current configuration into another one.
  135546. * @param sheenConfiguration define the config where to copy the info
  135547. */
  135548. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  135549. /**
  135550. * Serializes this BRDF configuration.
  135551. * @returns - An object with the serialized config.
  135552. */
  135553. serialize(): any;
  135554. /**
  135555. * Parses a anisotropy Configuration from a serialized object.
  135556. * @param source - Serialized object.
  135557. * @param scene Defines the scene we are parsing for
  135558. * @param rootUrl Defines the rootUrl to load from
  135559. */
  135560. parse(source: any, scene: Scene, rootUrl: string): void;
  135561. }
  135562. }
  135563. declare module BABYLON {
  135564. /**
  135565. * @hidden
  135566. */
  135567. export interface IMaterialSubSurfaceDefines {
  135568. SUBSURFACE: boolean;
  135569. SS_REFRACTION: boolean;
  135570. SS_TRANSLUCENCY: boolean;
  135571. SS_SCATTERING: boolean;
  135572. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135573. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135574. SS_REFRACTIONMAP_3D: boolean;
  135575. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135576. SS_LODINREFRACTIONALPHA: boolean;
  135577. SS_GAMMAREFRACTION: boolean;
  135578. SS_RGBDREFRACTION: boolean;
  135579. SS_LINEARSPECULARREFRACTION: boolean;
  135580. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135581. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135582. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135583. /** @hidden */
  135584. _areTexturesDirty: boolean;
  135585. }
  135586. /**
  135587. * Define the code related to the sub surface parameters of the pbr material.
  135588. */
  135589. export class PBRSubSurfaceConfiguration {
  135590. private _isRefractionEnabled;
  135591. /**
  135592. * Defines if the refraction is enabled in the material.
  135593. */
  135594. isRefractionEnabled: boolean;
  135595. private _isTranslucencyEnabled;
  135596. /**
  135597. * Defines if the translucency is enabled in the material.
  135598. */
  135599. isTranslucencyEnabled: boolean;
  135600. private _isScatteringEnabled;
  135601. /**
  135602. * Defines if the sub surface scattering is enabled in the material.
  135603. */
  135604. isScatteringEnabled: boolean;
  135605. private _scatteringDiffusionProfileIndex;
  135606. /**
  135607. * Diffusion profile for subsurface scattering.
  135608. * Useful for better scattering in the skins or foliages.
  135609. */
  135610. get scatteringDiffusionProfile(): Nullable<Color3>;
  135611. set scatteringDiffusionProfile(c: Nullable<Color3>);
  135612. /**
  135613. * Defines the refraction intensity of the material.
  135614. * The refraction when enabled replaces the Diffuse part of the material.
  135615. * The intensity helps transitionning between diffuse and refraction.
  135616. */
  135617. refractionIntensity: number;
  135618. /**
  135619. * Defines the translucency intensity of the material.
  135620. * When translucency has been enabled, this defines how much of the "translucency"
  135621. * is addded to the diffuse part of the material.
  135622. */
  135623. translucencyIntensity: number;
  135624. /**
  135625. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  135626. */
  135627. useAlbedoToTintRefraction: boolean;
  135628. private _thicknessTexture;
  135629. /**
  135630. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  135631. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  135632. * 0 would mean minimumThickness
  135633. * 1 would mean maximumThickness
  135634. * The other channels might be use as a mask to vary the different effects intensity.
  135635. */
  135636. thicknessTexture: Nullable<BaseTexture>;
  135637. private _refractionTexture;
  135638. /**
  135639. * Defines the texture to use for refraction.
  135640. */
  135641. refractionTexture: Nullable<BaseTexture>;
  135642. private _indexOfRefraction;
  135643. /**
  135644. * Index of refraction of the material base layer.
  135645. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135646. *
  135647. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135648. *
  135649. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135650. */
  135651. indexOfRefraction: number;
  135652. private _volumeIndexOfRefraction;
  135653. /**
  135654. * Index of refraction of the material's volume.
  135655. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135656. *
  135657. * This ONLY impacts refraction. If not provided or given a non-valid value,
  135658. * the volume will use the same IOR as the surface.
  135659. */
  135660. get volumeIndexOfRefraction(): number;
  135661. set volumeIndexOfRefraction(value: number);
  135662. private _invertRefractionY;
  135663. /**
  135664. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135665. */
  135666. invertRefractionY: boolean;
  135667. private _linkRefractionWithTransparency;
  135668. /**
  135669. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135670. * Materials half opaque for instance using refraction could benefit from this control.
  135671. */
  135672. linkRefractionWithTransparency: boolean;
  135673. /**
  135674. * Defines the minimum thickness stored in the thickness map.
  135675. * If no thickness map is defined, this value will be used to simulate thickness.
  135676. */
  135677. minimumThickness: number;
  135678. /**
  135679. * Defines the maximum thickness stored in the thickness map.
  135680. */
  135681. maximumThickness: number;
  135682. /**
  135683. * Defines the volume tint of the material.
  135684. * This is used for both translucency and scattering.
  135685. */
  135686. tintColor: Color3;
  135687. /**
  135688. * Defines the distance at which the tint color should be found in the media.
  135689. * This is used for refraction only.
  135690. */
  135691. tintColorAtDistance: number;
  135692. /**
  135693. * Defines how far each channel transmit through the media.
  135694. * It is defined as a color to simplify it selection.
  135695. */
  135696. diffusionDistance: Color3;
  135697. private _useMaskFromThicknessTexture;
  135698. /**
  135699. * Stores the intensity of the different subsurface effects in the thickness texture.
  135700. * * the green channel is the translucency intensity.
  135701. * * the blue channel is the scattering intensity.
  135702. * * the alpha channel is the refraction intensity.
  135703. */
  135704. useMaskFromThicknessTexture: boolean;
  135705. private _scene;
  135706. /** @hidden */
  135707. private _internalMarkAllSubMeshesAsTexturesDirty;
  135708. private _internalMarkScenePrePassDirty;
  135709. /** @hidden */
  135710. _markAllSubMeshesAsTexturesDirty(): void;
  135711. /** @hidden */
  135712. _markScenePrePassDirty(): void;
  135713. /**
  135714. * Instantiate a new istance of sub surface configuration.
  135715. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135716. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  135717. * @param scene The scene
  135718. */
  135719. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  135720. /**
  135721. * Gets wehter the submesh is ready to be used or not.
  135722. * @param defines the list of "defines" to update.
  135723. * @param scene defines the scene the material belongs to.
  135724. * @returns - boolean indicating that the submesh is ready or not.
  135725. */
  135726. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  135727. /**
  135728. * Checks to see if a texture is used in the material.
  135729. * @param defines the list of "defines" to update.
  135730. * @param scene defines the scene to the material belongs to.
  135731. */
  135732. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  135733. /**
  135734. * Binds the material data.
  135735. * @param uniformBuffer defines the Uniform buffer to fill in.
  135736. * @param scene defines the scene the material belongs to.
  135737. * @param engine defines the engine the material belongs to.
  135738. * @param isFrozen defines whether the material is frozen or not.
  135739. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  135740. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  135741. */
  135742. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  135743. /**
  135744. * Unbinds the material from the mesh.
  135745. * @param activeEffect defines the effect that should be unbound from.
  135746. * @returns true if unbound, otherwise false
  135747. */
  135748. unbind(activeEffect: Effect): boolean;
  135749. /**
  135750. * Returns the texture used for refraction or null if none is used.
  135751. * @param scene defines the scene the material belongs to.
  135752. * @returns - Refraction texture if present. If no refraction texture and refraction
  135753. * is linked with transparency, returns environment texture. Otherwise, returns null.
  135754. */
  135755. private _getRefractionTexture;
  135756. /**
  135757. * Returns true if alpha blending should be disabled.
  135758. */
  135759. get disableAlphaBlending(): boolean;
  135760. /**
  135761. * Fills the list of render target textures.
  135762. * @param renderTargets the list of render targets to update
  135763. */
  135764. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  135765. /**
  135766. * Checks to see if a texture is used in the material.
  135767. * @param texture - Base texture to use.
  135768. * @returns - Boolean specifying if a texture is used in the material.
  135769. */
  135770. hasTexture(texture: BaseTexture): boolean;
  135771. /**
  135772. * Gets a boolean indicating that current material needs to register RTT
  135773. * @returns true if this uses a render target otherwise false.
  135774. */
  135775. hasRenderTargetTextures(): boolean;
  135776. /**
  135777. * Returns an array of the actively used textures.
  135778. * @param activeTextures Array of BaseTextures
  135779. */
  135780. getActiveTextures(activeTextures: BaseTexture[]): void;
  135781. /**
  135782. * Returns the animatable textures.
  135783. * @param animatables Array of animatable textures.
  135784. */
  135785. getAnimatables(animatables: IAnimatable[]): void;
  135786. /**
  135787. * Disposes the resources of the material.
  135788. * @param forceDisposeTextures - Forces the disposal of all textures.
  135789. */
  135790. dispose(forceDisposeTextures?: boolean): void;
  135791. /**
  135792. * Get the current class name of the texture useful for serialization or dynamic coding.
  135793. * @returns "PBRSubSurfaceConfiguration"
  135794. */
  135795. getClassName(): string;
  135796. /**
  135797. * Add fallbacks to the effect fallbacks list.
  135798. * @param defines defines the Base texture to use.
  135799. * @param fallbacks defines the current fallback list.
  135800. * @param currentRank defines the current fallback rank.
  135801. * @returns the new fallback rank.
  135802. */
  135803. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135804. /**
  135805. * Add the required uniforms to the current list.
  135806. * @param uniforms defines the current uniform list.
  135807. */
  135808. static AddUniforms(uniforms: string[]): void;
  135809. /**
  135810. * Add the required samplers to the current list.
  135811. * @param samplers defines the current sampler list.
  135812. */
  135813. static AddSamplers(samplers: string[]): void;
  135814. /**
  135815. * Add the required uniforms to the current buffer.
  135816. * @param uniformBuffer defines the current uniform buffer.
  135817. */
  135818. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135819. /**
  135820. * Makes a duplicate of the current configuration into another one.
  135821. * @param configuration define the config where to copy the info
  135822. */
  135823. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  135824. /**
  135825. * Serializes this Sub Surface configuration.
  135826. * @returns - An object with the serialized config.
  135827. */
  135828. serialize(): any;
  135829. /**
  135830. * Parses a anisotropy Configuration from a serialized object.
  135831. * @param source - Serialized object.
  135832. * @param scene Defines the scene we are parsing for
  135833. * @param rootUrl Defines the rootUrl to load from
  135834. */
  135835. parse(source: any, scene: Scene, rootUrl: string): void;
  135836. }
  135837. }
  135838. declare module BABYLON {
  135839. /** @hidden */
  135840. export var pbrFragmentDeclaration: {
  135841. name: string;
  135842. shader: string;
  135843. };
  135844. }
  135845. declare module BABYLON {
  135846. /** @hidden */
  135847. export var pbrUboDeclaration: {
  135848. name: string;
  135849. shader: string;
  135850. };
  135851. }
  135852. declare module BABYLON {
  135853. /** @hidden */
  135854. export var pbrFragmentExtraDeclaration: {
  135855. name: string;
  135856. shader: string;
  135857. };
  135858. }
  135859. declare module BABYLON {
  135860. /** @hidden */
  135861. export var pbrFragmentSamplersDeclaration: {
  135862. name: string;
  135863. shader: string;
  135864. };
  135865. }
  135866. declare module BABYLON {
  135867. /** @hidden */
  135868. export var importanceSampling: {
  135869. name: string;
  135870. shader: string;
  135871. };
  135872. }
  135873. declare module BABYLON {
  135874. /** @hidden */
  135875. export var pbrHelperFunctions: {
  135876. name: string;
  135877. shader: string;
  135878. };
  135879. }
  135880. declare module BABYLON {
  135881. /** @hidden */
  135882. export var harmonicsFunctions: {
  135883. name: string;
  135884. shader: string;
  135885. };
  135886. }
  135887. declare module BABYLON {
  135888. /** @hidden */
  135889. export var pbrDirectLightingSetupFunctions: {
  135890. name: string;
  135891. shader: string;
  135892. };
  135893. }
  135894. declare module BABYLON {
  135895. /** @hidden */
  135896. export var pbrDirectLightingFalloffFunctions: {
  135897. name: string;
  135898. shader: string;
  135899. };
  135900. }
  135901. declare module BABYLON {
  135902. /** @hidden */
  135903. export var pbrBRDFFunctions: {
  135904. name: string;
  135905. shader: string;
  135906. };
  135907. }
  135908. declare module BABYLON {
  135909. /** @hidden */
  135910. export var hdrFilteringFunctions: {
  135911. name: string;
  135912. shader: string;
  135913. };
  135914. }
  135915. declare module BABYLON {
  135916. /** @hidden */
  135917. export var pbrDirectLightingFunctions: {
  135918. name: string;
  135919. shader: string;
  135920. };
  135921. }
  135922. declare module BABYLON {
  135923. /** @hidden */
  135924. export var pbrIBLFunctions: {
  135925. name: string;
  135926. shader: string;
  135927. };
  135928. }
  135929. declare module BABYLON {
  135930. /** @hidden */
  135931. export var pbrBlockAlbedoOpacity: {
  135932. name: string;
  135933. shader: string;
  135934. };
  135935. }
  135936. declare module BABYLON {
  135937. /** @hidden */
  135938. export var pbrBlockReflectivity: {
  135939. name: string;
  135940. shader: string;
  135941. };
  135942. }
  135943. declare module BABYLON {
  135944. /** @hidden */
  135945. export var pbrBlockAmbientOcclusion: {
  135946. name: string;
  135947. shader: string;
  135948. };
  135949. }
  135950. declare module BABYLON {
  135951. /** @hidden */
  135952. export var pbrBlockAlphaFresnel: {
  135953. name: string;
  135954. shader: string;
  135955. };
  135956. }
  135957. declare module BABYLON {
  135958. /** @hidden */
  135959. export var pbrBlockAnisotropic: {
  135960. name: string;
  135961. shader: string;
  135962. };
  135963. }
  135964. declare module BABYLON {
  135965. /** @hidden */
  135966. export var pbrBlockReflection: {
  135967. name: string;
  135968. shader: string;
  135969. };
  135970. }
  135971. declare module BABYLON {
  135972. /** @hidden */
  135973. export var pbrBlockSheen: {
  135974. name: string;
  135975. shader: string;
  135976. };
  135977. }
  135978. declare module BABYLON {
  135979. /** @hidden */
  135980. export var pbrBlockClearcoat: {
  135981. name: string;
  135982. shader: string;
  135983. };
  135984. }
  135985. declare module BABYLON {
  135986. /** @hidden */
  135987. export var pbrBlockSubSurface: {
  135988. name: string;
  135989. shader: string;
  135990. };
  135991. }
  135992. declare module BABYLON {
  135993. /** @hidden */
  135994. export var pbrBlockNormalGeometric: {
  135995. name: string;
  135996. shader: string;
  135997. };
  135998. }
  135999. declare module BABYLON {
  136000. /** @hidden */
  136001. export var pbrBlockNormalFinal: {
  136002. name: string;
  136003. shader: string;
  136004. };
  136005. }
  136006. declare module BABYLON {
  136007. /** @hidden */
  136008. export var pbrBlockLightmapInit: {
  136009. name: string;
  136010. shader: string;
  136011. };
  136012. }
  136013. declare module BABYLON {
  136014. /** @hidden */
  136015. export var pbrBlockGeometryInfo: {
  136016. name: string;
  136017. shader: string;
  136018. };
  136019. }
  136020. declare module BABYLON {
  136021. /** @hidden */
  136022. export var pbrBlockReflectance0: {
  136023. name: string;
  136024. shader: string;
  136025. };
  136026. }
  136027. declare module BABYLON {
  136028. /** @hidden */
  136029. export var pbrBlockReflectance: {
  136030. name: string;
  136031. shader: string;
  136032. };
  136033. }
  136034. declare module BABYLON {
  136035. /** @hidden */
  136036. export var pbrBlockDirectLighting: {
  136037. name: string;
  136038. shader: string;
  136039. };
  136040. }
  136041. declare module BABYLON {
  136042. /** @hidden */
  136043. export var pbrBlockFinalLitComponents: {
  136044. name: string;
  136045. shader: string;
  136046. };
  136047. }
  136048. declare module BABYLON {
  136049. /** @hidden */
  136050. export var pbrBlockFinalUnlitComponents: {
  136051. name: string;
  136052. shader: string;
  136053. };
  136054. }
  136055. declare module BABYLON {
  136056. /** @hidden */
  136057. export var pbrBlockFinalColorComposition: {
  136058. name: string;
  136059. shader: string;
  136060. };
  136061. }
  136062. declare module BABYLON {
  136063. /** @hidden */
  136064. export var pbrBlockImageProcessing: {
  136065. name: string;
  136066. shader: string;
  136067. };
  136068. }
  136069. declare module BABYLON {
  136070. /** @hidden */
  136071. export var pbrDebug: {
  136072. name: string;
  136073. shader: string;
  136074. };
  136075. }
  136076. declare module BABYLON {
  136077. /** @hidden */
  136078. export var pbrPixelShader: {
  136079. name: string;
  136080. shader: string;
  136081. };
  136082. }
  136083. declare module BABYLON {
  136084. /** @hidden */
  136085. export var pbrVertexDeclaration: {
  136086. name: string;
  136087. shader: string;
  136088. };
  136089. }
  136090. declare module BABYLON {
  136091. /** @hidden */
  136092. export var pbrVertexShader: {
  136093. name: string;
  136094. shader: string;
  136095. };
  136096. }
  136097. declare module BABYLON {
  136098. /**
  136099. * Manages the defines for the PBR Material.
  136100. * @hidden
  136101. */
  136102. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136103. PBR: boolean;
  136104. NUM_SAMPLES: string;
  136105. REALTIME_FILTERING: boolean;
  136106. MAINUV1: boolean;
  136107. MAINUV2: boolean;
  136108. UV1: boolean;
  136109. UV2: boolean;
  136110. ALBEDO: boolean;
  136111. GAMMAALBEDO: boolean;
  136112. ALBEDODIRECTUV: number;
  136113. VERTEXCOLOR: boolean;
  136114. DETAIL: boolean;
  136115. DETAILDIRECTUV: number;
  136116. DETAIL_NORMALBLENDMETHOD: number;
  136117. AMBIENT: boolean;
  136118. AMBIENTDIRECTUV: number;
  136119. AMBIENTINGRAYSCALE: boolean;
  136120. OPACITY: boolean;
  136121. VERTEXALPHA: boolean;
  136122. OPACITYDIRECTUV: number;
  136123. OPACITYRGB: boolean;
  136124. ALPHATEST: boolean;
  136125. DEPTHPREPASS: boolean;
  136126. ALPHABLEND: boolean;
  136127. ALPHAFROMALBEDO: boolean;
  136128. ALPHATESTVALUE: string;
  136129. SPECULAROVERALPHA: boolean;
  136130. RADIANCEOVERALPHA: boolean;
  136131. ALPHAFRESNEL: boolean;
  136132. LINEARALPHAFRESNEL: boolean;
  136133. PREMULTIPLYALPHA: boolean;
  136134. EMISSIVE: boolean;
  136135. EMISSIVEDIRECTUV: number;
  136136. REFLECTIVITY: boolean;
  136137. REFLECTIVITYDIRECTUV: number;
  136138. SPECULARTERM: boolean;
  136139. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136140. MICROSURFACEAUTOMATIC: boolean;
  136141. LODBASEDMICROSFURACE: boolean;
  136142. MICROSURFACEMAP: boolean;
  136143. MICROSURFACEMAPDIRECTUV: number;
  136144. METALLICWORKFLOW: boolean;
  136145. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136146. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136147. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136148. AOSTOREINMETALMAPRED: boolean;
  136149. METALLIC_REFLECTANCE: boolean;
  136150. METALLIC_REFLECTANCEDIRECTUV: number;
  136151. ENVIRONMENTBRDF: boolean;
  136152. ENVIRONMENTBRDF_RGBD: boolean;
  136153. NORMAL: boolean;
  136154. TANGENT: boolean;
  136155. BUMP: boolean;
  136156. BUMPDIRECTUV: number;
  136157. OBJECTSPACE_NORMALMAP: boolean;
  136158. PARALLAX: boolean;
  136159. PARALLAXOCCLUSION: boolean;
  136160. NORMALXYSCALE: boolean;
  136161. LIGHTMAP: boolean;
  136162. LIGHTMAPDIRECTUV: number;
  136163. USELIGHTMAPASSHADOWMAP: boolean;
  136164. GAMMALIGHTMAP: boolean;
  136165. RGBDLIGHTMAP: boolean;
  136166. REFLECTION: boolean;
  136167. REFLECTIONMAP_3D: boolean;
  136168. REFLECTIONMAP_SPHERICAL: boolean;
  136169. REFLECTIONMAP_PLANAR: boolean;
  136170. REFLECTIONMAP_CUBIC: boolean;
  136171. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136172. REFLECTIONMAP_PROJECTION: boolean;
  136173. REFLECTIONMAP_SKYBOX: boolean;
  136174. REFLECTIONMAP_EXPLICIT: boolean;
  136175. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136176. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136177. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136178. INVERTCUBICMAP: boolean;
  136179. USESPHERICALFROMREFLECTIONMAP: boolean;
  136180. USEIRRADIANCEMAP: boolean;
  136181. SPHERICAL_HARMONICS: boolean;
  136182. USESPHERICALINVERTEX: boolean;
  136183. REFLECTIONMAP_OPPOSITEZ: boolean;
  136184. LODINREFLECTIONALPHA: boolean;
  136185. GAMMAREFLECTION: boolean;
  136186. RGBDREFLECTION: boolean;
  136187. LINEARSPECULARREFLECTION: boolean;
  136188. RADIANCEOCCLUSION: boolean;
  136189. HORIZONOCCLUSION: boolean;
  136190. INSTANCES: boolean;
  136191. THIN_INSTANCES: boolean;
  136192. PREPASS: boolean;
  136193. SCENE_MRT_COUNT: number;
  136194. NUM_BONE_INFLUENCERS: number;
  136195. BonesPerMesh: number;
  136196. BONETEXTURE: boolean;
  136197. NONUNIFORMSCALING: boolean;
  136198. MORPHTARGETS: boolean;
  136199. MORPHTARGETS_NORMAL: boolean;
  136200. MORPHTARGETS_TANGENT: boolean;
  136201. MORPHTARGETS_UV: boolean;
  136202. NUM_MORPH_INFLUENCERS: number;
  136203. IMAGEPROCESSING: boolean;
  136204. VIGNETTE: boolean;
  136205. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136206. VIGNETTEBLENDMODEOPAQUE: boolean;
  136207. TONEMAPPING: boolean;
  136208. TONEMAPPING_ACES: boolean;
  136209. CONTRAST: boolean;
  136210. COLORCURVES: boolean;
  136211. COLORGRADING: boolean;
  136212. COLORGRADING3D: boolean;
  136213. SAMPLER3DGREENDEPTH: boolean;
  136214. SAMPLER3DBGRMAP: boolean;
  136215. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136216. EXPOSURE: boolean;
  136217. MULTIVIEW: boolean;
  136218. USEPHYSICALLIGHTFALLOFF: boolean;
  136219. USEGLTFLIGHTFALLOFF: boolean;
  136220. TWOSIDEDLIGHTING: boolean;
  136221. SHADOWFLOAT: boolean;
  136222. CLIPPLANE: boolean;
  136223. CLIPPLANE2: boolean;
  136224. CLIPPLANE3: boolean;
  136225. CLIPPLANE4: boolean;
  136226. CLIPPLANE5: boolean;
  136227. CLIPPLANE6: boolean;
  136228. POINTSIZE: boolean;
  136229. FOG: boolean;
  136230. LOGARITHMICDEPTH: boolean;
  136231. FORCENORMALFORWARD: boolean;
  136232. SPECULARAA: boolean;
  136233. CLEARCOAT: boolean;
  136234. CLEARCOAT_DEFAULTIOR: boolean;
  136235. CLEARCOAT_TEXTURE: boolean;
  136236. CLEARCOAT_TEXTUREDIRECTUV: number;
  136237. CLEARCOAT_BUMP: boolean;
  136238. CLEARCOAT_BUMPDIRECTUV: number;
  136239. CLEARCOAT_TINT: boolean;
  136240. CLEARCOAT_TINT_TEXTURE: boolean;
  136241. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136242. ANISOTROPIC: boolean;
  136243. ANISOTROPIC_TEXTURE: boolean;
  136244. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136245. BRDF_V_HEIGHT_CORRELATED: boolean;
  136246. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136247. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136248. SHEEN: boolean;
  136249. SHEEN_TEXTURE: boolean;
  136250. SHEEN_TEXTUREDIRECTUV: number;
  136251. SHEEN_LINKWITHALBEDO: boolean;
  136252. SHEEN_ROUGHNESS: boolean;
  136253. SHEEN_ALBEDOSCALING: boolean;
  136254. SUBSURFACE: boolean;
  136255. SS_REFRACTION: boolean;
  136256. SS_TRANSLUCENCY: boolean;
  136257. SS_SCATTERING: boolean;
  136258. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136259. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136260. SS_REFRACTIONMAP_3D: boolean;
  136261. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136262. SS_LODINREFRACTIONALPHA: boolean;
  136263. SS_GAMMAREFRACTION: boolean;
  136264. SS_RGBDREFRACTION: boolean;
  136265. SS_LINEARSPECULARREFRACTION: boolean;
  136266. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136267. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136268. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136269. UNLIT: boolean;
  136270. DEBUGMODE: number;
  136271. /**
  136272. * Initializes the PBR Material defines.
  136273. */
  136274. constructor();
  136275. /**
  136276. * Resets the PBR Material defines.
  136277. */
  136278. reset(): void;
  136279. }
  136280. /**
  136281. * The Physically based material base class of BJS.
  136282. *
  136283. * This offers the main features of a standard PBR material.
  136284. * For more information, please refer to the documentation :
  136285. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136286. */
  136287. export abstract class PBRBaseMaterial extends PushMaterial {
  136288. /**
  136289. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136290. */
  136291. static readonly PBRMATERIAL_OPAQUE: number;
  136292. /**
  136293. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136294. */
  136295. static readonly PBRMATERIAL_ALPHATEST: number;
  136296. /**
  136297. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136298. */
  136299. static readonly PBRMATERIAL_ALPHABLEND: number;
  136300. /**
  136301. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136302. * They are also discarded below the alpha cutoff threshold to improve performances.
  136303. */
  136304. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136305. /**
  136306. * Defines the default value of how much AO map is occluding the analytical lights
  136307. * (point spot...).
  136308. */
  136309. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136310. /**
  136311. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136312. */
  136313. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136314. /**
  136315. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136316. * to enhance interoperability with other engines.
  136317. */
  136318. static readonly LIGHTFALLOFF_GLTF: number;
  136319. /**
  136320. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136321. * to enhance interoperability with other materials.
  136322. */
  136323. static readonly LIGHTFALLOFF_STANDARD: number;
  136324. /**
  136325. * Intensity of the direct lights e.g. the four lights available in your scene.
  136326. * This impacts both the direct diffuse and specular highlights.
  136327. */
  136328. protected _directIntensity: number;
  136329. /**
  136330. * Intensity of the emissive part of the material.
  136331. * This helps controlling the emissive effect without modifying the emissive color.
  136332. */
  136333. protected _emissiveIntensity: number;
  136334. /**
  136335. * Intensity of the environment e.g. how much the environment will light the object
  136336. * either through harmonics for rough material or through the refelction for shiny ones.
  136337. */
  136338. protected _environmentIntensity: number;
  136339. /**
  136340. * This is a special control allowing the reduction of the specular highlights coming from the
  136341. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136342. */
  136343. protected _specularIntensity: number;
  136344. /**
  136345. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136346. */
  136347. private _lightingInfos;
  136348. /**
  136349. * Debug Control allowing disabling the bump map on this material.
  136350. */
  136351. protected _disableBumpMap: boolean;
  136352. /**
  136353. * AKA Diffuse Texture in standard nomenclature.
  136354. */
  136355. protected _albedoTexture: Nullable<BaseTexture>;
  136356. /**
  136357. * AKA Occlusion Texture in other nomenclature.
  136358. */
  136359. protected _ambientTexture: Nullable<BaseTexture>;
  136360. /**
  136361. * AKA Occlusion Texture Intensity in other nomenclature.
  136362. */
  136363. protected _ambientTextureStrength: number;
  136364. /**
  136365. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136366. * 1 means it completely occludes it
  136367. * 0 mean it has no impact
  136368. */
  136369. protected _ambientTextureImpactOnAnalyticalLights: number;
  136370. /**
  136371. * Stores the alpha values in a texture.
  136372. */
  136373. protected _opacityTexture: Nullable<BaseTexture>;
  136374. /**
  136375. * Stores the reflection values in a texture.
  136376. */
  136377. protected _reflectionTexture: Nullable<BaseTexture>;
  136378. /**
  136379. * Stores the emissive values in a texture.
  136380. */
  136381. protected _emissiveTexture: Nullable<BaseTexture>;
  136382. /**
  136383. * AKA Specular texture in other nomenclature.
  136384. */
  136385. protected _reflectivityTexture: Nullable<BaseTexture>;
  136386. /**
  136387. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136388. */
  136389. protected _metallicTexture: Nullable<BaseTexture>;
  136390. /**
  136391. * Specifies the metallic scalar of the metallic/roughness workflow.
  136392. * Can also be used to scale the metalness values of the metallic texture.
  136393. */
  136394. protected _metallic: Nullable<number>;
  136395. /**
  136396. * Specifies the roughness scalar of the metallic/roughness workflow.
  136397. * Can also be used to scale the roughness values of the metallic texture.
  136398. */
  136399. protected _roughness: Nullable<number>;
  136400. /**
  136401. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136402. * By default the indexOfrefraction is used to compute F0;
  136403. *
  136404. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136405. *
  136406. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136407. * F90 = metallicReflectanceColor;
  136408. */
  136409. protected _metallicF0Factor: number;
  136410. /**
  136411. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136412. * By default the F90 is always 1;
  136413. *
  136414. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136415. *
  136416. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136417. * F90 = metallicReflectanceColor;
  136418. */
  136419. protected _metallicReflectanceColor: Color3;
  136420. /**
  136421. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136422. * This is multiply against the scalar values defined in the material.
  136423. */
  136424. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  136425. /**
  136426. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136427. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136428. */
  136429. protected _microSurfaceTexture: Nullable<BaseTexture>;
  136430. /**
  136431. * Stores surface normal data used to displace a mesh in a texture.
  136432. */
  136433. protected _bumpTexture: Nullable<BaseTexture>;
  136434. /**
  136435. * Stores the pre-calculated light information of a mesh in a texture.
  136436. */
  136437. protected _lightmapTexture: Nullable<BaseTexture>;
  136438. /**
  136439. * The color of a material in ambient lighting.
  136440. */
  136441. protected _ambientColor: Color3;
  136442. /**
  136443. * AKA Diffuse Color in other nomenclature.
  136444. */
  136445. protected _albedoColor: Color3;
  136446. /**
  136447. * AKA Specular Color in other nomenclature.
  136448. */
  136449. protected _reflectivityColor: Color3;
  136450. /**
  136451. * The color applied when light is reflected from a material.
  136452. */
  136453. protected _reflectionColor: Color3;
  136454. /**
  136455. * The color applied when light is emitted from a material.
  136456. */
  136457. protected _emissiveColor: Color3;
  136458. /**
  136459. * AKA Glossiness in other nomenclature.
  136460. */
  136461. protected _microSurface: number;
  136462. /**
  136463. * Specifies that the material will use the light map as a show map.
  136464. */
  136465. protected _useLightmapAsShadowmap: boolean;
  136466. /**
  136467. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136468. * makes the reflect vector face the model (under horizon).
  136469. */
  136470. protected _useHorizonOcclusion: boolean;
  136471. /**
  136472. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136473. * too much the area relying on ambient texture to define their ambient occlusion.
  136474. */
  136475. protected _useRadianceOcclusion: boolean;
  136476. /**
  136477. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136478. */
  136479. protected _useAlphaFromAlbedoTexture: boolean;
  136480. /**
  136481. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  136482. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136483. */
  136484. protected _useSpecularOverAlpha: boolean;
  136485. /**
  136486. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136487. */
  136488. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136489. /**
  136490. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136491. */
  136492. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  136493. /**
  136494. * Specifies if the metallic texture contains the roughness information in its green channel.
  136495. */
  136496. protected _useRoughnessFromMetallicTextureGreen: boolean;
  136497. /**
  136498. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136499. */
  136500. protected _useMetallnessFromMetallicTextureBlue: boolean;
  136501. /**
  136502. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136503. */
  136504. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  136505. /**
  136506. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136507. */
  136508. protected _useAmbientInGrayScale: boolean;
  136509. /**
  136510. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136511. * The material will try to infer what glossiness each pixel should be.
  136512. */
  136513. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  136514. /**
  136515. * Defines the falloff type used in this material.
  136516. * It by default is Physical.
  136517. */
  136518. protected _lightFalloff: number;
  136519. /**
  136520. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136521. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136522. */
  136523. protected _useRadianceOverAlpha: boolean;
  136524. /**
  136525. * Allows using an object space normal map (instead of tangent space).
  136526. */
  136527. protected _useObjectSpaceNormalMap: boolean;
  136528. /**
  136529. * Allows using the bump map in parallax mode.
  136530. */
  136531. protected _useParallax: boolean;
  136532. /**
  136533. * Allows using the bump map in parallax occlusion mode.
  136534. */
  136535. protected _useParallaxOcclusion: boolean;
  136536. /**
  136537. * Controls the scale bias of the parallax mode.
  136538. */
  136539. protected _parallaxScaleBias: number;
  136540. /**
  136541. * If sets to true, disables all the lights affecting the material.
  136542. */
  136543. protected _disableLighting: boolean;
  136544. /**
  136545. * Number of Simultaneous lights allowed on the material.
  136546. */
  136547. protected _maxSimultaneousLights: number;
  136548. /**
  136549. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136550. */
  136551. protected _invertNormalMapX: boolean;
  136552. /**
  136553. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136554. */
  136555. protected _invertNormalMapY: boolean;
  136556. /**
  136557. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136558. */
  136559. protected _twoSidedLighting: boolean;
  136560. /**
  136561. * Defines the alpha limits in alpha test mode.
  136562. */
  136563. protected _alphaCutOff: number;
  136564. /**
  136565. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136566. */
  136567. protected _forceAlphaTest: boolean;
  136568. /**
  136569. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136570. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136571. */
  136572. protected _useAlphaFresnel: boolean;
  136573. /**
  136574. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136575. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136576. */
  136577. protected _useLinearAlphaFresnel: boolean;
  136578. /**
  136579. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  136580. * from cos thetav and roughness:
  136581. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  136582. */
  136583. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  136584. /**
  136585. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136586. */
  136587. protected _forceIrradianceInFragment: boolean;
  136588. private _realTimeFiltering;
  136589. /**
  136590. * Enables realtime filtering on the texture.
  136591. */
  136592. get realTimeFiltering(): boolean;
  136593. set realTimeFiltering(b: boolean);
  136594. private _realTimeFilteringQuality;
  136595. /**
  136596. * Quality switch for realtime filtering
  136597. */
  136598. get realTimeFilteringQuality(): number;
  136599. set realTimeFilteringQuality(n: number);
  136600. /**
  136601. * Can this material render to several textures at once
  136602. */
  136603. get canRenderToMRT(): boolean;
  136604. /**
  136605. * Force normal to face away from face.
  136606. */
  136607. protected _forceNormalForward: boolean;
  136608. /**
  136609. * Enables specular anti aliasing in the PBR shader.
  136610. * It will both interacts on the Geometry for analytical and IBL lighting.
  136611. * It also prefilter the roughness map based on the bump values.
  136612. */
  136613. protected _enableSpecularAntiAliasing: boolean;
  136614. /**
  136615. * Default configuration related to image processing available in the PBR Material.
  136616. */
  136617. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  136618. /**
  136619. * Keep track of the image processing observer to allow dispose and replace.
  136620. */
  136621. private _imageProcessingObserver;
  136622. /**
  136623. * Attaches a new image processing configuration to the PBR Material.
  136624. * @param configuration
  136625. */
  136626. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  136627. /**
  136628. * Stores the available render targets.
  136629. */
  136630. private _renderTargets;
  136631. /**
  136632. * Sets the global ambient color for the material used in lighting calculations.
  136633. */
  136634. private _globalAmbientColor;
  136635. /**
  136636. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  136637. */
  136638. private _useLogarithmicDepth;
  136639. /**
  136640. * If set to true, no lighting calculations will be applied.
  136641. */
  136642. private _unlit;
  136643. private _debugMode;
  136644. /**
  136645. * @hidden
  136646. * This is reserved for the inspector.
  136647. * Defines the material debug mode.
  136648. * It helps seeing only some components of the material while troubleshooting.
  136649. */
  136650. debugMode: number;
  136651. /**
  136652. * @hidden
  136653. * This is reserved for the inspector.
  136654. * Specify from where on screen the debug mode should start.
  136655. * The value goes from -1 (full screen) to 1 (not visible)
  136656. * It helps with side by side comparison against the final render
  136657. * This defaults to -1
  136658. */
  136659. private debugLimit;
  136660. /**
  136661. * @hidden
  136662. * This is reserved for the inspector.
  136663. * As the default viewing range might not be enough (if the ambient is really small for instance)
  136664. * You can use the factor to better multiply the final value.
  136665. */
  136666. private debugFactor;
  136667. /**
  136668. * Defines the clear coat layer parameters for the material.
  136669. */
  136670. readonly clearCoat: PBRClearCoatConfiguration;
  136671. /**
  136672. * Defines the anisotropic parameters for the material.
  136673. */
  136674. readonly anisotropy: PBRAnisotropicConfiguration;
  136675. /**
  136676. * Defines the BRDF parameters for the material.
  136677. */
  136678. readonly brdf: PBRBRDFConfiguration;
  136679. /**
  136680. * Defines the Sheen parameters for the material.
  136681. */
  136682. readonly sheen: PBRSheenConfiguration;
  136683. /**
  136684. * Defines the SubSurface parameters for the material.
  136685. */
  136686. readonly subSurface: PBRSubSurfaceConfiguration;
  136687. /**
  136688. * Defines the detail map parameters for the material.
  136689. */
  136690. readonly detailMap: DetailMapConfiguration;
  136691. protected _rebuildInParallel: boolean;
  136692. /**
  136693. * Instantiates a new PBRMaterial instance.
  136694. *
  136695. * @param name The material name
  136696. * @param scene The scene the material will be use in.
  136697. */
  136698. constructor(name: string, scene: Scene);
  136699. /**
  136700. * Gets a boolean indicating that current material needs to register RTT
  136701. */
  136702. get hasRenderTargetTextures(): boolean;
  136703. /**
  136704. * Gets the name of the material class.
  136705. */
  136706. getClassName(): string;
  136707. /**
  136708. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136709. */
  136710. get useLogarithmicDepth(): boolean;
  136711. /**
  136712. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136713. */
  136714. set useLogarithmicDepth(value: boolean);
  136715. /**
  136716. * Returns true if alpha blending should be disabled.
  136717. */
  136718. protected get _disableAlphaBlending(): boolean;
  136719. /**
  136720. * Specifies whether or not this material should be rendered in alpha blend mode.
  136721. */
  136722. needAlphaBlending(): boolean;
  136723. /**
  136724. * Specifies whether or not this material should be rendered in alpha test mode.
  136725. */
  136726. needAlphaTesting(): boolean;
  136727. /**
  136728. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  136729. */
  136730. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  136731. /**
  136732. * Gets the texture used for the alpha test.
  136733. */
  136734. getAlphaTestTexture(): Nullable<BaseTexture>;
  136735. /**
  136736. * Specifies that the submesh is ready to be used.
  136737. * @param mesh - BJS mesh.
  136738. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  136739. * @param useInstances - Specifies that instances should be used.
  136740. * @returns - boolean indicating that the submesh is ready or not.
  136741. */
  136742. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  136743. /**
  136744. * Specifies if the material uses metallic roughness workflow.
  136745. * @returns boolean specifiying if the material uses metallic roughness workflow.
  136746. */
  136747. isMetallicWorkflow(): boolean;
  136748. private _prepareEffect;
  136749. private _prepareDefines;
  136750. /**
  136751. * Force shader compilation
  136752. */
  136753. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  136754. /**
  136755. * Initializes the uniform buffer layout for the shader.
  136756. */
  136757. buildUniformLayout(): void;
  136758. /**
  136759. * Unbinds the material from the mesh
  136760. */
  136761. unbind(): void;
  136762. /**
  136763. * Binds the submesh data.
  136764. * @param world - The world matrix.
  136765. * @param mesh - The BJS mesh.
  136766. * @param subMesh - A submesh of the BJS mesh.
  136767. */
  136768. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  136769. /**
  136770. * Returns the animatable textures.
  136771. * @returns - Array of animatable textures.
  136772. */
  136773. getAnimatables(): IAnimatable[];
  136774. /**
  136775. * Returns the texture used for reflections.
  136776. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  136777. */
  136778. private _getReflectionTexture;
  136779. /**
  136780. * Returns an array of the actively used textures.
  136781. * @returns - Array of BaseTextures
  136782. */
  136783. getActiveTextures(): BaseTexture[];
  136784. /**
  136785. * Checks to see if a texture is used in the material.
  136786. * @param texture - Base texture to use.
  136787. * @returns - Boolean specifying if a texture is used in the material.
  136788. */
  136789. hasTexture(texture: BaseTexture): boolean;
  136790. /**
  136791. * Sets the required values to the prepass renderer.
  136792. * @param prePassRenderer defines the prepass renderer to setup
  136793. */
  136794. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  136795. /**
  136796. * Disposes the resources of the material.
  136797. * @param forceDisposeEffect - Forces the disposal of effects.
  136798. * @param forceDisposeTextures - Forces the disposal of all textures.
  136799. */
  136800. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  136801. }
  136802. }
  136803. declare module BABYLON {
  136804. /**
  136805. * The Physically based material of BJS.
  136806. *
  136807. * This offers the main features of a standard PBR material.
  136808. * For more information, please refer to the documentation :
  136809. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136810. */
  136811. export class PBRMaterial extends PBRBaseMaterial {
  136812. /**
  136813. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136814. */
  136815. static readonly PBRMATERIAL_OPAQUE: number;
  136816. /**
  136817. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136818. */
  136819. static readonly PBRMATERIAL_ALPHATEST: number;
  136820. /**
  136821. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136822. */
  136823. static readonly PBRMATERIAL_ALPHABLEND: number;
  136824. /**
  136825. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136826. * They are also discarded below the alpha cutoff threshold to improve performances.
  136827. */
  136828. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136829. /**
  136830. * Defines the default value of how much AO map is occluding the analytical lights
  136831. * (point spot...).
  136832. */
  136833. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136834. /**
  136835. * Intensity of the direct lights e.g. the four lights available in your scene.
  136836. * This impacts both the direct diffuse and specular highlights.
  136837. */
  136838. directIntensity: number;
  136839. /**
  136840. * Intensity of the emissive part of the material.
  136841. * This helps controlling the emissive effect without modifying the emissive color.
  136842. */
  136843. emissiveIntensity: number;
  136844. /**
  136845. * Intensity of the environment e.g. how much the environment will light the object
  136846. * either through harmonics for rough material or through the refelction for shiny ones.
  136847. */
  136848. environmentIntensity: number;
  136849. /**
  136850. * This is a special control allowing the reduction of the specular highlights coming from the
  136851. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136852. */
  136853. specularIntensity: number;
  136854. /**
  136855. * Debug Control allowing disabling the bump map on this material.
  136856. */
  136857. disableBumpMap: boolean;
  136858. /**
  136859. * AKA Diffuse Texture in standard nomenclature.
  136860. */
  136861. albedoTexture: BaseTexture;
  136862. /**
  136863. * AKA Occlusion Texture in other nomenclature.
  136864. */
  136865. ambientTexture: BaseTexture;
  136866. /**
  136867. * AKA Occlusion Texture Intensity in other nomenclature.
  136868. */
  136869. ambientTextureStrength: number;
  136870. /**
  136871. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136872. * 1 means it completely occludes it
  136873. * 0 mean it has no impact
  136874. */
  136875. ambientTextureImpactOnAnalyticalLights: number;
  136876. /**
  136877. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  136878. */
  136879. opacityTexture: BaseTexture;
  136880. /**
  136881. * Stores the reflection values in a texture.
  136882. */
  136883. reflectionTexture: Nullable<BaseTexture>;
  136884. /**
  136885. * Stores the emissive values in a texture.
  136886. */
  136887. emissiveTexture: BaseTexture;
  136888. /**
  136889. * AKA Specular texture in other nomenclature.
  136890. */
  136891. reflectivityTexture: BaseTexture;
  136892. /**
  136893. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136894. */
  136895. metallicTexture: BaseTexture;
  136896. /**
  136897. * Specifies the metallic scalar of the metallic/roughness workflow.
  136898. * Can also be used to scale the metalness values of the metallic texture.
  136899. */
  136900. metallic: Nullable<number>;
  136901. /**
  136902. * Specifies the roughness scalar of the metallic/roughness workflow.
  136903. * Can also be used to scale the roughness values of the metallic texture.
  136904. */
  136905. roughness: Nullable<number>;
  136906. /**
  136907. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136908. * By default the indexOfrefraction is used to compute F0;
  136909. *
  136910. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136911. *
  136912. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136913. * F90 = metallicReflectanceColor;
  136914. */
  136915. metallicF0Factor: number;
  136916. /**
  136917. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136918. * By default the F90 is always 1;
  136919. *
  136920. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136921. *
  136922. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136923. * F90 = metallicReflectanceColor;
  136924. */
  136925. metallicReflectanceColor: Color3;
  136926. /**
  136927. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136928. * This is multiply against the scalar values defined in the material.
  136929. */
  136930. metallicReflectanceTexture: Nullable<BaseTexture>;
  136931. /**
  136932. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136933. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136934. */
  136935. microSurfaceTexture: BaseTexture;
  136936. /**
  136937. * Stores surface normal data used to displace a mesh in a texture.
  136938. */
  136939. bumpTexture: BaseTexture;
  136940. /**
  136941. * Stores the pre-calculated light information of a mesh in a texture.
  136942. */
  136943. lightmapTexture: BaseTexture;
  136944. /**
  136945. * Stores the refracted light information in a texture.
  136946. */
  136947. get refractionTexture(): Nullable<BaseTexture>;
  136948. set refractionTexture(value: Nullable<BaseTexture>);
  136949. /**
  136950. * The color of a material in ambient lighting.
  136951. */
  136952. ambientColor: Color3;
  136953. /**
  136954. * AKA Diffuse Color in other nomenclature.
  136955. */
  136956. albedoColor: Color3;
  136957. /**
  136958. * AKA Specular Color in other nomenclature.
  136959. */
  136960. reflectivityColor: Color3;
  136961. /**
  136962. * The color reflected from the material.
  136963. */
  136964. reflectionColor: Color3;
  136965. /**
  136966. * The color emitted from the material.
  136967. */
  136968. emissiveColor: Color3;
  136969. /**
  136970. * AKA Glossiness in other nomenclature.
  136971. */
  136972. microSurface: number;
  136973. /**
  136974. * Index of refraction of the material base layer.
  136975. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136976. *
  136977. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136978. *
  136979. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136980. */
  136981. get indexOfRefraction(): number;
  136982. set indexOfRefraction(value: number);
  136983. /**
  136984. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136985. */
  136986. get invertRefractionY(): boolean;
  136987. set invertRefractionY(value: boolean);
  136988. /**
  136989. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136990. * Materials half opaque for instance using refraction could benefit from this control.
  136991. */
  136992. get linkRefractionWithTransparency(): boolean;
  136993. set linkRefractionWithTransparency(value: boolean);
  136994. /**
  136995. * If true, the light map contains occlusion information instead of lighting info.
  136996. */
  136997. useLightmapAsShadowmap: boolean;
  136998. /**
  136999. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137000. */
  137001. useAlphaFromAlbedoTexture: boolean;
  137002. /**
  137003. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137004. */
  137005. forceAlphaTest: boolean;
  137006. /**
  137007. * Defines the alpha limits in alpha test mode.
  137008. */
  137009. alphaCutOff: number;
  137010. /**
  137011. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137012. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137013. */
  137014. useSpecularOverAlpha: boolean;
  137015. /**
  137016. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137017. */
  137018. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137019. /**
  137020. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137021. */
  137022. useRoughnessFromMetallicTextureAlpha: boolean;
  137023. /**
  137024. * Specifies if the metallic texture contains the roughness information in its green channel.
  137025. */
  137026. useRoughnessFromMetallicTextureGreen: boolean;
  137027. /**
  137028. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137029. */
  137030. useMetallnessFromMetallicTextureBlue: boolean;
  137031. /**
  137032. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137033. */
  137034. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137035. /**
  137036. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137037. */
  137038. useAmbientInGrayScale: boolean;
  137039. /**
  137040. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137041. * The material will try to infer what glossiness each pixel should be.
  137042. */
  137043. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137044. /**
  137045. * BJS is using an harcoded light falloff based on a manually sets up range.
  137046. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137047. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137048. */
  137049. get usePhysicalLightFalloff(): boolean;
  137050. /**
  137051. * BJS is using an harcoded light falloff based on a manually sets up range.
  137052. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137053. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137054. */
  137055. set usePhysicalLightFalloff(value: boolean);
  137056. /**
  137057. * In order to support the falloff compatibility with gltf, a special mode has been added
  137058. * to reproduce the gltf light falloff.
  137059. */
  137060. get useGLTFLightFalloff(): boolean;
  137061. /**
  137062. * In order to support the falloff compatibility with gltf, a special mode has been added
  137063. * to reproduce the gltf light falloff.
  137064. */
  137065. set useGLTFLightFalloff(value: boolean);
  137066. /**
  137067. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137068. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137069. */
  137070. useRadianceOverAlpha: boolean;
  137071. /**
  137072. * Allows using an object space normal map (instead of tangent space).
  137073. */
  137074. useObjectSpaceNormalMap: boolean;
  137075. /**
  137076. * Allows using the bump map in parallax mode.
  137077. */
  137078. useParallax: boolean;
  137079. /**
  137080. * Allows using the bump map in parallax occlusion mode.
  137081. */
  137082. useParallaxOcclusion: boolean;
  137083. /**
  137084. * Controls the scale bias of the parallax mode.
  137085. */
  137086. parallaxScaleBias: number;
  137087. /**
  137088. * If sets to true, disables all the lights affecting the material.
  137089. */
  137090. disableLighting: boolean;
  137091. /**
  137092. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137093. */
  137094. forceIrradianceInFragment: boolean;
  137095. /**
  137096. * Number of Simultaneous lights allowed on the material.
  137097. */
  137098. maxSimultaneousLights: number;
  137099. /**
  137100. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137101. */
  137102. invertNormalMapX: boolean;
  137103. /**
  137104. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137105. */
  137106. invertNormalMapY: boolean;
  137107. /**
  137108. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137109. */
  137110. twoSidedLighting: boolean;
  137111. /**
  137112. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137113. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137114. */
  137115. useAlphaFresnel: boolean;
  137116. /**
  137117. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137118. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137119. */
  137120. useLinearAlphaFresnel: boolean;
  137121. /**
  137122. * Let user defines the brdf lookup texture used for IBL.
  137123. * A default 8bit version is embedded but you could point at :
  137124. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137125. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137126. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137127. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137128. */
  137129. environmentBRDFTexture: Nullable<BaseTexture>;
  137130. /**
  137131. * Force normal to face away from face.
  137132. */
  137133. forceNormalForward: boolean;
  137134. /**
  137135. * Enables specular anti aliasing in the PBR shader.
  137136. * It will both interacts on the Geometry for analytical and IBL lighting.
  137137. * It also prefilter the roughness map based on the bump values.
  137138. */
  137139. enableSpecularAntiAliasing: boolean;
  137140. /**
  137141. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137142. * makes the reflect vector face the model (under horizon).
  137143. */
  137144. useHorizonOcclusion: boolean;
  137145. /**
  137146. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137147. * too much the area relying on ambient texture to define their ambient occlusion.
  137148. */
  137149. useRadianceOcclusion: boolean;
  137150. /**
  137151. * If set to true, no lighting calculations will be applied.
  137152. */
  137153. unlit: boolean;
  137154. /**
  137155. * Gets the image processing configuration used either in this material.
  137156. */
  137157. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137158. /**
  137159. * Sets the Default image processing configuration used either in the this material.
  137160. *
  137161. * If sets to null, the scene one is in use.
  137162. */
  137163. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137164. /**
  137165. * Gets wether the color curves effect is enabled.
  137166. */
  137167. get cameraColorCurvesEnabled(): boolean;
  137168. /**
  137169. * Sets wether the color curves effect is enabled.
  137170. */
  137171. set cameraColorCurvesEnabled(value: boolean);
  137172. /**
  137173. * Gets wether the color grading effect is enabled.
  137174. */
  137175. get cameraColorGradingEnabled(): boolean;
  137176. /**
  137177. * Gets wether the color grading effect is enabled.
  137178. */
  137179. set cameraColorGradingEnabled(value: boolean);
  137180. /**
  137181. * Gets wether tonemapping is enabled or not.
  137182. */
  137183. get cameraToneMappingEnabled(): boolean;
  137184. /**
  137185. * Sets wether tonemapping is enabled or not
  137186. */
  137187. set cameraToneMappingEnabled(value: boolean);
  137188. /**
  137189. * The camera exposure used on this material.
  137190. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137191. * This corresponds to a photographic exposure.
  137192. */
  137193. get cameraExposure(): number;
  137194. /**
  137195. * The camera exposure used on this material.
  137196. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137197. * This corresponds to a photographic exposure.
  137198. */
  137199. set cameraExposure(value: number);
  137200. /**
  137201. * Gets The camera contrast used on this material.
  137202. */
  137203. get cameraContrast(): number;
  137204. /**
  137205. * Sets The camera contrast used on this material.
  137206. */
  137207. set cameraContrast(value: number);
  137208. /**
  137209. * Gets the Color Grading 2D Lookup Texture.
  137210. */
  137211. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137212. /**
  137213. * Sets the Color Grading 2D Lookup Texture.
  137214. */
  137215. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137216. /**
  137217. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137218. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137219. * 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;
  137220. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137221. */
  137222. get cameraColorCurves(): Nullable<ColorCurves>;
  137223. /**
  137224. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137225. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137226. * 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;
  137227. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137228. */
  137229. set cameraColorCurves(value: Nullable<ColorCurves>);
  137230. /**
  137231. * Instantiates a new PBRMaterial instance.
  137232. *
  137233. * @param name The material name
  137234. * @param scene The scene the material will be use in.
  137235. */
  137236. constructor(name: string, scene: Scene);
  137237. /**
  137238. * Returns the name of this material class.
  137239. */
  137240. getClassName(): string;
  137241. /**
  137242. * Makes a duplicate of the current material.
  137243. * @param name - name to use for the new material.
  137244. */
  137245. clone(name: string): PBRMaterial;
  137246. /**
  137247. * Serializes this PBR Material.
  137248. * @returns - An object with the serialized material.
  137249. */
  137250. serialize(): any;
  137251. /**
  137252. * Parses a PBR Material from a serialized object.
  137253. * @param source - Serialized object.
  137254. * @param scene - BJS scene instance.
  137255. * @param rootUrl - url for the scene object
  137256. * @returns - PBRMaterial
  137257. */
  137258. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137259. }
  137260. }
  137261. declare module BABYLON {
  137262. /**
  137263. * Direct draw surface info
  137264. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137265. */
  137266. export interface DDSInfo {
  137267. /**
  137268. * Width of the texture
  137269. */
  137270. width: number;
  137271. /**
  137272. * Width of the texture
  137273. */
  137274. height: number;
  137275. /**
  137276. * Number of Mipmaps for the texture
  137277. * @see https://en.wikipedia.org/wiki/Mipmap
  137278. */
  137279. mipmapCount: number;
  137280. /**
  137281. * If the textures format is a known fourCC format
  137282. * @see https://www.fourcc.org/
  137283. */
  137284. isFourCC: boolean;
  137285. /**
  137286. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137287. */
  137288. isRGB: boolean;
  137289. /**
  137290. * If the texture is a lumincance format
  137291. */
  137292. isLuminance: boolean;
  137293. /**
  137294. * If this is a cube texture
  137295. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137296. */
  137297. isCube: boolean;
  137298. /**
  137299. * If the texture is a compressed format eg. FOURCC_DXT1
  137300. */
  137301. isCompressed: boolean;
  137302. /**
  137303. * The dxgiFormat of the texture
  137304. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137305. */
  137306. dxgiFormat: number;
  137307. /**
  137308. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137309. */
  137310. textureType: number;
  137311. /**
  137312. * Sphericle polynomial created for the dds texture
  137313. */
  137314. sphericalPolynomial?: SphericalPolynomial;
  137315. }
  137316. /**
  137317. * Class used to provide DDS decompression tools
  137318. */
  137319. export class DDSTools {
  137320. /**
  137321. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137322. */
  137323. static StoreLODInAlphaChannel: boolean;
  137324. /**
  137325. * Gets DDS information from an array buffer
  137326. * @param data defines the array buffer view to read data from
  137327. * @returns the DDS information
  137328. */
  137329. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137330. private static _FloatView;
  137331. private static _Int32View;
  137332. private static _ToHalfFloat;
  137333. private static _FromHalfFloat;
  137334. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137335. private static _GetHalfFloatRGBAArrayBuffer;
  137336. private static _GetFloatRGBAArrayBuffer;
  137337. private static _GetFloatAsUIntRGBAArrayBuffer;
  137338. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137339. private static _GetRGBAArrayBuffer;
  137340. private static _ExtractLongWordOrder;
  137341. private static _GetRGBArrayBuffer;
  137342. private static _GetLuminanceArrayBuffer;
  137343. /**
  137344. * Uploads DDS Levels to a Babylon Texture
  137345. * @hidden
  137346. */
  137347. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137348. }
  137349. interface ThinEngine {
  137350. /**
  137351. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137352. * @param rootUrl defines the url where the file to load is located
  137353. * @param scene defines the current scene
  137354. * @param lodScale defines scale to apply to the mip map selection
  137355. * @param lodOffset defines offset to apply to the mip map selection
  137356. * @param onLoad defines an optional callback raised when the texture is loaded
  137357. * @param onError defines an optional callback raised if there is an issue to load the texture
  137358. * @param format defines the format of the data
  137359. * @param forcedExtension defines the extension to use to pick the right loader
  137360. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137361. * @returns the cube texture as an InternalTexture
  137362. */
  137363. 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;
  137364. }
  137365. }
  137366. declare module BABYLON {
  137367. /**
  137368. * Implementation of the DDS Texture Loader.
  137369. * @hidden
  137370. */
  137371. export class _DDSTextureLoader implements IInternalTextureLoader {
  137372. /**
  137373. * Defines wether the loader supports cascade loading the different faces.
  137374. */
  137375. readonly supportCascades: boolean;
  137376. /**
  137377. * This returns if the loader support the current file information.
  137378. * @param extension defines the file extension of the file being loaded
  137379. * @returns true if the loader can load the specified file
  137380. */
  137381. canLoad(extension: string): boolean;
  137382. /**
  137383. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137384. * @param data contains the texture data
  137385. * @param texture defines the BabylonJS internal texture
  137386. * @param createPolynomials will be true if polynomials have been requested
  137387. * @param onLoad defines the callback to trigger once the texture is ready
  137388. * @param onError defines the callback to trigger in case of error
  137389. */
  137390. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137391. /**
  137392. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137393. * @param data contains the texture data
  137394. * @param texture defines the BabylonJS internal texture
  137395. * @param callback defines the method to call once ready to upload
  137396. */
  137397. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137398. }
  137399. }
  137400. declare module BABYLON {
  137401. /**
  137402. * Implementation of the ENV Texture Loader.
  137403. * @hidden
  137404. */
  137405. export class _ENVTextureLoader implements IInternalTextureLoader {
  137406. /**
  137407. * Defines wether the loader supports cascade loading the different faces.
  137408. */
  137409. readonly supportCascades: boolean;
  137410. /**
  137411. * This returns if the loader support the current file information.
  137412. * @param extension defines the file extension of the file being loaded
  137413. * @returns true if the loader can load the specified file
  137414. */
  137415. canLoad(extension: string): boolean;
  137416. /**
  137417. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137418. * @param data contains the texture data
  137419. * @param texture defines the BabylonJS internal texture
  137420. * @param createPolynomials will be true if polynomials have been requested
  137421. * @param onLoad defines the callback to trigger once the texture is ready
  137422. * @param onError defines the callback to trigger in case of error
  137423. */
  137424. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137425. /**
  137426. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137427. * @param data contains the texture data
  137428. * @param texture defines the BabylonJS internal texture
  137429. * @param callback defines the method to call once ready to upload
  137430. */
  137431. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137432. }
  137433. }
  137434. declare module BABYLON {
  137435. /**
  137436. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137437. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137438. */
  137439. export class KhronosTextureContainer {
  137440. /** contents of the KTX container file */
  137441. data: ArrayBufferView;
  137442. private static HEADER_LEN;
  137443. private static COMPRESSED_2D;
  137444. private static COMPRESSED_3D;
  137445. private static TEX_2D;
  137446. private static TEX_3D;
  137447. /**
  137448. * Gets the openGL type
  137449. */
  137450. glType: number;
  137451. /**
  137452. * Gets the openGL type size
  137453. */
  137454. glTypeSize: number;
  137455. /**
  137456. * Gets the openGL format
  137457. */
  137458. glFormat: number;
  137459. /**
  137460. * Gets the openGL internal format
  137461. */
  137462. glInternalFormat: number;
  137463. /**
  137464. * Gets the base internal format
  137465. */
  137466. glBaseInternalFormat: number;
  137467. /**
  137468. * Gets image width in pixel
  137469. */
  137470. pixelWidth: number;
  137471. /**
  137472. * Gets image height in pixel
  137473. */
  137474. pixelHeight: number;
  137475. /**
  137476. * Gets image depth in pixels
  137477. */
  137478. pixelDepth: number;
  137479. /**
  137480. * Gets the number of array elements
  137481. */
  137482. numberOfArrayElements: number;
  137483. /**
  137484. * Gets the number of faces
  137485. */
  137486. numberOfFaces: number;
  137487. /**
  137488. * Gets the number of mipmap levels
  137489. */
  137490. numberOfMipmapLevels: number;
  137491. /**
  137492. * Gets the bytes of key value data
  137493. */
  137494. bytesOfKeyValueData: number;
  137495. /**
  137496. * Gets the load type
  137497. */
  137498. loadType: number;
  137499. /**
  137500. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  137501. */
  137502. isInvalid: boolean;
  137503. /**
  137504. * Creates a new KhronosTextureContainer
  137505. * @param data contents of the KTX container file
  137506. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  137507. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  137508. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  137509. */
  137510. constructor(
  137511. /** contents of the KTX container file */
  137512. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  137513. /**
  137514. * Uploads KTX content to a Babylon Texture.
  137515. * It is assumed that the texture has already been created & is currently bound
  137516. * @hidden
  137517. */
  137518. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  137519. private _upload2DCompressedLevels;
  137520. /**
  137521. * Checks if the given data starts with a KTX file identifier.
  137522. * @param data the data to check
  137523. * @returns true if the data is a KTX file or false otherwise
  137524. */
  137525. static IsValid(data: ArrayBufferView): boolean;
  137526. }
  137527. }
  137528. declare module BABYLON {
  137529. /**
  137530. * Helper class to push actions to a pool of workers.
  137531. */
  137532. export class WorkerPool implements IDisposable {
  137533. private _workerInfos;
  137534. private _pendingActions;
  137535. /**
  137536. * Constructor
  137537. * @param workers Array of workers to use for actions
  137538. */
  137539. constructor(workers: Array<Worker>);
  137540. /**
  137541. * Terminates all workers and clears any pending actions.
  137542. */
  137543. dispose(): void;
  137544. /**
  137545. * Pushes an action to the worker pool. If all the workers are active, the action will be
  137546. * pended until a worker has completed its action.
  137547. * @param action The action to perform. Call onComplete when the action is complete.
  137548. */
  137549. push(action: (worker: Worker, onComplete: () => void) => void): void;
  137550. private _execute;
  137551. }
  137552. }
  137553. declare module BABYLON {
  137554. /**
  137555. * Class for loading KTX2 files
  137556. * @hidden
  137557. */
  137558. export class KhronosTextureContainer2 {
  137559. private static _WorkerPoolPromise?;
  137560. private static _Initialized;
  137561. private static _Ktx2Decoder;
  137562. /**
  137563. * URL to use when loading the KTX2 decoder module
  137564. */
  137565. static JSModuleURL: string;
  137566. /**
  137567. * Default number of workers used to handle data decoding
  137568. */
  137569. static DefaultNumWorkers: number;
  137570. private static GetDefaultNumWorkers;
  137571. private _engine;
  137572. private static _CreateWorkerPool;
  137573. /**
  137574. * Constructor
  137575. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  137576. */
  137577. constructor(engine: ThinEngine, numWorkers?: number);
  137578. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  137579. /**
  137580. * Stop all async operations and release resources.
  137581. */
  137582. dispose(): void;
  137583. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  137584. /**
  137585. * Checks if the given data starts with a KTX2 file identifier.
  137586. * @param data the data to check
  137587. * @returns true if the data is a KTX2 file or false otherwise
  137588. */
  137589. static IsValid(data: ArrayBufferView): boolean;
  137590. }
  137591. export function workerFunc(): void;
  137592. }
  137593. declare module BABYLON {
  137594. /**
  137595. * Implementation of the KTX Texture Loader.
  137596. * @hidden
  137597. */
  137598. export class _KTXTextureLoader implements IInternalTextureLoader {
  137599. /**
  137600. * Defines wether the loader supports cascade loading the different faces.
  137601. */
  137602. readonly supportCascades: boolean;
  137603. /**
  137604. * This returns if the loader support the current file information.
  137605. * @param extension defines the file extension of the file being loaded
  137606. * @param mimeType defines the optional mime type of the file being loaded
  137607. * @returns true if the loader can load the specified file
  137608. */
  137609. canLoad(extension: string, mimeType?: string): boolean;
  137610. /**
  137611. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137612. * @param data contains the texture data
  137613. * @param texture defines the BabylonJS internal texture
  137614. * @param createPolynomials will be true if polynomials have been requested
  137615. * @param onLoad defines the callback to trigger once the texture is ready
  137616. * @param onError defines the callback to trigger in case of error
  137617. */
  137618. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137619. /**
  137620. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137621. * @param data contains the texture data
  137622. * @param texture defines the BabylonJS internal texture
  137623. * @param callback defines the method to call once ready to upload
  137624. */
  137625. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  137626. }
  137627. }
  137628. declare module BABYLON {
  137629. /** @hidden */
  137630. export var _forceSceneHelpersToBundle: boolean;
  137631. interface Scene {
  137632. /**
  137633. * Creates a default light for the scene.
  137634. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  137635. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  137636. */
  137637. createDefaultLight(replace?: boolean): void;
  137638. /**
  137639. * Creates a default camera for the scene.
  137640. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  137641. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137642. * @param replace has default false, when true replaces the active camera in the scene
  137643. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  137644. */
  137645. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137646. /**
  137647. * Creates a default camera and a default light.
  137648. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  137649. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137650. * @param replace has the default false, when true replaces the active camera/light in the scene
  137651. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  137652. */
  137653. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137654. /**
  137655. * Creates a new sky box
  137656. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  137657. * @param environmentTexture defines the texture to use as environment texture
  137658. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  137659. * @param scale defines the overall scale of the skybox
  137660. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  137661. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  137662. * @returns a new mesh holding the sky box
  137663. */
  137664. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  137665. /**
  137666. * Creates a new environment
  137667. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  137668. * @param options defines the options you can use to configure the environment
  137669. * @returns the new EnvironmentHelper
  137670. */
  137671. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  137672. /**
  137673. * Creates a new VREXperienceHelper
  137674. * @see https://doc.babylonjs.com/how_to/webvr_helper
  137675. * @param webVROptions defines the options used to create the new VREXperienceHelper
  137676. * @returns a new VREXperienceHelper
  137677. */
  137678. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  137679. /**
  137680. * Creates a new WebXRDefaultExperience
  137681. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  137682. * @param options experience options
  137683. * @returns a promise for a new WebXRDefaultExperience
  137684. */
  137685. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  137686. }
  137687. }
  137688. declare module BABYLON {
  137689. /**
  137690. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  137691. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  137692. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  137693. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  137694. */
  137695. export class VideoDome extends TextureDome<VideoTexture> {
  137696. /**
  137697. * Define the video source as a Monoscopic panoramic 360 video.
  137698. */
  137699. static readonly MODE_MONOSCOPIC: number;
  137700. /**
  137701. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  137702. */
  137703. static readonly MODE_TOPBOTTOM: number;
  137704. /**
  137705. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  137706. */
  137707. static readonly MODE_SIDEBYSIDE: number;
  137708. /**
  137709. * Get the video texture associated with this video dome
  137710. */
  137711. get videoTexture(): VideoTexture;
  137712. /**
  137713. * Get the video mode of this dome
  137714. */
  137715. get videoMode(): number;
  137716. /**
  137717. * Set the video mode of this dome.
  137718. * @see textureMode
  137719. */
  137720. set videoMode(value: number);
  137721. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  137722. }
  137723. }
  137724. declare module BABYLON {
  137725. /**
  137726. * This class can be used to get instrumentation data from a Babylon engine
  137727. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137728. */
  137729. export class EngineInstrumentation implements IDisposable {
  137730. /**
  137731. * Define the instrumented engine.
  137732. */
  137733. engine: Engine;
  137734. private _captureGPUFrameTime;
  137735. private _gpuFrameTimeToken;
  137736. private _gpuFrameTime;
  137737. private _captureShaderCompilationTime;
  137738. private _shaderCompilationTime;
  137739. private _onBeginFrameObserver;
  137740. private _onEndFrameObserver;
  137741. private _onBeforeShaderCompilationObserver;
  137742. private _onAfterShaderCompilationObserver;
  137743. /**
  137744. * Gets the perf counter used for GPU frame time
  137745. */
  137746. get gpuFrameTimeCounter(): PerfCounter;
  137747. /**
  137748. * Gets the GPU frame time capture status
  137749. */
  137750. get captureGPUFrameTime(): boolean;
  137751. /**
  137752. * Enable or disable the GPU frame time capture
  137753. */
  137754. set captureGPUFrameTime(value: boolean);
  137755. /**
  137756. * Gets the perf counter used for shader compilation time
  137757. */
  137758. get shaderCompilationTimeCounter(): PerfCounter;
  137759. /**
  137760. * Gets the shader compilation time capture status
  137761. */
  137762. get captureShaderCompilationTime(): boolean;
  137763. /**
  137764. * Enable or disable the shader compilation time capture
  137765. */
  137766. set captureShaderCompilationTime(value: boolean);
  137767. /**
  137768. * Instantiates a new engine instrumentation.
  137769. * This class can be used to get instrumentation data from a Babylon engine
  137770. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137771. * @param engine Defines the engine to instrument
  137772. */
  137773. constructor(
  137774. /**
  137775. * Define the instrumented engine.
  137776. */
  137777. engine: Engine);
  137778. /**
  137779. * Dispose and release associated resources.
  137780. */
  137781. dispose(): void;
  137782. }
  137783. }
  137784. declare module BABYLON {
  137785. /**
  137786. * This class can be used to get instrumentation data from a Babylon engine
  137787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137788. */
  137789. export class SceneInstrumentation implements IDisposable {
  137790. /**
  137791. * Defines the scene to instrument
  137792. */
  137793. scene: Scene;
  137794. private _captureActiveMeshesEvaluationTime;
  137795. private _activeMeshesEvaluationTime;
  137796. private _captureRenderTargetsRenderTime;
  137797. private _renderTargetsRenderTime;
  137798. private _captureFrameTime;
  137799. private _frameTime;
  137800. private _captureRenderTime;
  137801. private _renderTime;
  137802. private _captureInterFrameTime;
  137803. private _interFrameTime;
  137804. private _captureParticlesRenderTime;
  137805. private _particlesRenderTime;
  137806. private _captureSpritesRenderTime;
  137807. private _spritesRenderTime;
  137808. private _capturePhysicsTime;
  137809. private _physicsTime;
  137810. private _captureAnimationsTime;
  137811. private _animationsTime;
  137812. private _captureCameraRenderTime;
  137813. private _cameraRenderTime;
  137814. private _onBeforeActiveMeshesEvaluationObserver;
  137815. private _onAfterActiveMeshesEvaluationObserver;
  137816. private _onBeforeRenderTargetsRenderObserver;
  137817. private _onAfterRenderTargetsRenderObserver;
  137818. private _onAfterRenderObserver;
  137819. private _onBeforeDrawPhaseObserver;
  137820. private _onAfterDrawPhaseObserver;
  137821. private _onBeforeAnimationsObserver;
  137822. private _onBeforeParticlesRenderingObserver;
  137823. private _onAfterParticlesRenderingObserver;
  137824. private _onBeforeSpritesRenderingObserver;
  137825. private _onAfterSpritesRenderingObserver;
  137826. private _onBeforePhysicsObserver;
  137827. private _onAfterPhysicsObserver;
  137828. private _onAfterAnimationsObserver;
  137829. private _onBeforeCameraRenderObserver;
  137830. private _onAfterCameraRenderObserver;
  137831. /**
  137832. * Gets the perf counter used for active meshes evaluation time
  137833. */
  137834. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  137835. /**
  137836. * Gets the active meshes evaluation time capture status
  137837. */
  137838. get captureActiveMeshesEvaluationTime(): boolean;
  137839. /**
  137840. * Enable or disable the active meshes evaluation time capture
  137841. */
  137842. set captureActiveMeshesEvaluationTime(value: boolean);
  137843. /**
  137844. * Gets the perf counter used for render targets render time
  137845. */
  137846. get renderTargetsRenderTimeCounter(): PerfCounter;
  137847. /**
  137848. * Gets the render targets render time capture status
  137849. */
  137850. get captureRenderTargetsRenderTime(): boolean;
  137851. /**
  137852. * Enable or disable the render targets render time capture
  137853. */
  137854. set captureRenderTargetsRenderTime(value: boolean);
  137855. /**
  137856. * Gets the perf counter used for particles render time
  137857. */
  137858. get particlesRenderTimeCounter(): PerfCounter;
  137859. /**
  137860. * Gets the particles render time capture status
  137861. */
  137862. get captureParticlesRenderTime(): boolean;
  137863. /**
  137864. * Enable or disable the particles render time capture
  137865. */
  137866. set captureParticlesRenderTime(value: boolean);
  137867. /**
  137868. * Gets the perf counter used for sprites render time
  137869. */
  137870. get spritesRenderTimeCounter(): PerfCounter;
  137871. /**
  137872. * Gets the sprites render time capture status
  137873. */
  137874. get captureSpritesRenderTime(): boolean;
  137875. /**
  137876. * Enable or disable the sprites render time capture
  137877. */
  137878. set captureSpritesRenderTime(value: boolean);
  137879. /**
  137880. * Gets the perf counter used for physics time
  137881. */
  137882. get physicsTimeCounter(): PerfCounter;
  137883. /**
  137884. * Gets the physics time capture status
  137885. */
  137886. get capturePhysicsTime(): boolean;
  137887. /**
  137888. * Enable or disable the physics time capture
  137889. */
  137890. set capturePhysicsTime(value: boolean);
  137891. /**
  137892. * Gets the perf counter used for animations time
  137893. */
  137894. get animationsTimeCounter(): PerfCounter;
  137895. /**
  137896. * Gets the animations time capture status
  137897. */
  137898. get captureAnimationsTime(): boolean;
  137899. /**
  137900. * Enable or disable the animations time capture
  137901. */
  137902. set captureAnimationsTime(value: boolean);
  137903. /**
  137904. * Gets the perf counter used for frame time capture
  137905. */
  137906. get frameTimeCounter(): PerfCounter;
  137907. /**
  137908. * Gets the frame time capture status
  137909. */
  137910. get captureFrameTime(): boolean;
  137911. /**
  137912. * Enable or disable the frame time capture
  137913. */
  137914. set captureFrameTime(value: boolean);
  137915. /**
  137916. * Gets the perf counter used for inter-frames time capture
  137917. */
  137918. get interFrameTimeCounter(): PerfCounter;
  137919. /**
  137920. * Gets the inter-frames time capture status
  137921. */
  137922. get captureInterFrameTime(): boolean;
  137923. /**
  137924. * Enable or disable the inter-frames time capture
  137925. */
  137926. set captureInterFrameTime(value: boolean);
  137927. /**
  137928. * Gets the perf counter used for render time capture
  137929. */
  137930. get renderTimeCounter(): PerfCounter;
  137931. /**
  137932. * Gets the render time capture status
  137933. */
  137934. get captureRenderTime(): boolean;
  137935. /**
  137936. * Enable or disable the render time capture
  137937. */
  137938. set captureRenderTime(value: boolean);
  137939. /**
  137940. * Gets the perf counter used for camera render time capture
  137941. */
  137942. get cameraRenderTimeCounter(): PerfCounter;
  137943. /**
  137944. * Gets the camera render time capture status
  137945. */
  137946. get captureCameraRenderTime(): boolean;
  137947. /**
  137948. * Enable or disable the camera render time capture
  137949. */
  137950. set captureCameraRenderTime(value: boolean);
  137951. /**
  137952. * Gets the perf counter used for draw calls
  137953. */
  137954. get drawCallsCounter(): PerfCounter;
  137955. /**
  137956. * Instantiates a new scene instrumentation.
  137957. * This class can be used to get instrumentation data from a Babylon engine
  137958. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137959. * @param scene Defines the scene to instrument
  137960. */
  137961. constructor(
  137962. /**
  137963. * Defines the scene to instrument
  137964. */
  137965. scene: Scene);
  137966. /**
  137967. * Dispose and release associated resources.
  137968. */
  137969. dispose(): void;
  137970. }
  137971. }
  137972. declare module BABYLON {
  137973. /** @hidden */
  137974. export var glowMapGenerationPixelShader: {
  137975. name: string;
  137976. shader: string;
  137977. };
  137978. }
  137979. declare module BABYLON {
  137980. /** @hidden */
  137981. export var glowMapGenerationVertexShader: {
  137982. name: string;
  137983. shader: string;
  137984. };
  137985. }
  137986. declare module BABYLON {
  137987. /**
  137988. * Effect layer options. This helps customizing the behaviour
  137989. * of the effect layer.
  137990. */
  137991. export interface IEffectLayerOptions {
  137992. /**
  137993. * Multiplication factor apply to the canvas size to compute the render target size
  137994. * used to generated the objects (the smaller the faster).
  137995. */
  137996. mainTextureRatio: number;
  137997. /**
  137998. * Enforces a fixed size texture to ensure effect stability across devices.
  137999. */
  138000. mainTextureFixedSize?: number;
  138001. /**
  138002. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138003. */
  138004. alphaBlendingMode: number;
  138005. /**
  138006. * The camera attached to the layer.
  138007. */
  138008. camera: Nullable<Camera>;
  138009. /**
  138010. * The rendering group to draw the layer in.
  138011. */
  138012. renderingGroupId: number;
  138013. }
  138014. /**
  138015. * The effect layer Helps adding post process effect blended with the main pass.
  138016. *
  138017. * This can be for instance use to generate glow or higlight effects on the scene.
  138018. *
  138019. * The effect layer class can not be used directly and is intented to inherited from to be
  138020. * customized per effects.
  138021. */
  138022. export abstract class EffectLayer {
  138023. private _vertexBuffers;
  138024. private _indexBuffer;
  138025. private _cachedDefines;
  138026. private _effectLayerMapGenerationEffect;
  138027. private _effectLayerOptions;
  138028. private _mergeEffect;
  138029. protected _scene: Scene;
  138030. protected _engine: Engine;
  138031. protected _maxSize: number;
  138032. protected _mainTextureDesiredSize: ISize;
  138033. protected _mainTexture: RenderTargetTexture;
  138034. protected _shouldRender: boolean;
  138035. protected _postProcesses: PostProcess[];
  138036. protected _textures: BaseTexture[];
  138037. protected _emissiveTextureAndColor: {
  138038. texture: Nullable<BaseTexture>;
  138039. color: Color4;
  138040. };
  138041. /**
  138042. * The name of the layer
  138043. */
  138044. name: string;
  138045. /**
  138046. * The clear color of the texture used to generate the glow map.
  138047. */
  138048. neutralColor: Color4;
  138049. /**
  138050. * Specifies whether the highlight layer is enabled or not.
  138051. */
  138052. isEnabled: boolean;
  138053. /**
  138054. * Gets the camera attached to the layer.
  138055. */
  138056. get camera(): Nullable<Camera>;
  138057. /**
  138058. * Gets the rendering group id the layer should render in.
  138059. */
  138060. get renderingGroupId(): number;
  138061. set renderingGroupId(renderingGroupId: number);
  138062. /**
  138063. * An event triggered when the effect layer has been disposed.
  138064. */
  138065. onDisposeObservable: Observable<EffectLayer>;
  138066. /**
  138067. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138068. */
  138069. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138070. /**
  138071. * An event triggered when the generated texture is being merged in the scene.
  138072. */
  138073. onBeforeComposeObservable: Observable<EffectLayer>;
  138074. /**
  138075. * An event triggered when the mesh is rendered into the effect render target.
  138076. */
  138077. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138078. /**
  138079. * An event triggered after the mesh has been rendered into the effect render target.
  138080. */
  138081. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138082. /**
  138083. * An event triggered when the generated texture has been merged in the scene.
  138084. */
  138085. onAfterComposeObservable: Observable<EffectLayer>;
  138086. /**
  138087. * An event triggered when the efffect layer changes its size.
  138088. */
  138089. onSizeChangedObservable: Observable<EffectLayer>;
  138090. /** @hidden */
  138091. static _SceneComponentInitialization: (scene: Scene) => void;
  138092. /**
  138093. * Instantiates a new effect Layer and references it in the scene.
  138094. * @param name The name of the layer
  138095. * @param scene The scene to use the layer in
  138096. */
  138097. constructor(
  138098. /** The Friendly of the effect in the scene */
  138099. name: string, scene: Scene);
  138100. /**
  138101. * Get the effect name of the layer.
  138102. * @return The effect name
  138103. */
  138104. abstract getEffectName(): string;
  138105. /**
  138106. * Checks for the readiness of the element composing the layer.
  138107. * @param subMesh the mesh to check for
  138108. * @param useInstances specify whether or not to use instances to render the mesh
  138109. * @return true if ready otherwise, false
  138110. */
  138111. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138112. /**
  138113. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138114. * @returns true if the effect requires stencil during the main canvas render pass.
  138115. */
  138116. abstract needStencil(): boolean;
  138117. /**
  138118. * Create the merge effect. This is the shader use to blit the information back
  138119. * to the main canvas at the end of the scene rendering.
  138120. * @returns The effect containing the shader used to merge the effect on the main canvas
  138121. */
  138122. protected abstract _createMergeEffect(): Effect;
  138123. /**
  138124. * Creates the render target textures and post processes used in the effect layer.
  138125. */
  138126. protected abstract _createTextureAndPostProcesses(): void;
  138127. /**
  138128. * Implementation specific of rendering the generating effect on the main canvas.
  138129. * @param effect The effect used to render through
  138130. */
  138131. protected abstract _internalRender(effect: Effect): void;
  138132. /**
  138133. * Sets the required values for both the emissive texture and and the main color.
  138134. */
  138135. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138136. /**
  138137. * Free any resources and references associated to a mesh.
  138138. * Internal use
  138139. * @param mesh The mesh to free.
  138140. */
  138141. abstract _disposeMesh(mesh: Mesh): void;
  138142. /**
  138143. * Serializes this layer (Glow or Highlight for example)
  138144. * @returns a serialized layer object
  138145. */
  138146. abstract serialize?(): any;
  138147. /**
  138148. * Initializes the effect layer with the required options.
  138149. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138150. */
  138151. protected _init(options: Partial<IEffectLayerOptions>): void;
  138152. /**
  138153. * Generates the index buffer of the full screen quad blending to the main canvas.
  138154. */
  138155. private _generateIndexBuffer;
  138156. /**
  138157. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138158. */
  138159. private _generateVertexBuffer;
  138160. /**
  138161. * Sets the main texture desired size which is the closest power of two
  138162. * of the engine canvas size.
  138163. */
  138164. private _setMainTextureSize;
  138165. /**
  138166. * Creates the main texture for the effect layer.
  138167. */
  138168. protected _createMainTexture(): void;
  138169. /**
  138170. * Adds specific effects defines.
  138171. * @param defines The defines to add specifics to.
  138172. */
  138173. protected _addCustomEffectDefines(defines: string[]): void;
  138174. /**
  138175. * Checks for the readiness of the element composing the layer.
  138176. * @param subMesh the mesh to check for
  138177. * @param useInstances specify whether or not to use instances to render the mesh
  138178. * @param emissiveTexture the associated emissive texture used to generate the glow
  138179. * @return true if ready otherwise, false
  138180. */
  138181. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138182. /**
  138183. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138184. */
  138185. render(): void;
  138186. /**
  138187. * Determine if a given mesh will be used in the current effect.
  138188. * @param mesh mesh to test
  138189. * @returns true if the mesh will be used
  138190. */
  138191. hasMesh(mesh: AbstractMesh): boolean;
  138192. /**
  138193. * Returns true if the layer contains information to display, otherwise false.
  138194. * @returns true if the glow layer should be rendered
  138195. */
  138196. shouldRender(): boolean;
  138197. /**
  138198. * Returns true if the mesh should render, otherwise false.
  138199. * @param mesh The mesh to render
  138200. * @returns true if it should render otherwise false
  138201. */
  138202. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138203. /**
  138204. * Returns true if the mesh can be rendered, otherwise false.
  138205. * @param mesh The mesh to render
  138206. * @param material The material used on the mesh
  138207. * @returns true if it can be rendered otherwise false
  138208. */
  138209. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138210. /**
  138211. * Returns true if the mesh should render, otherwise false.
  138212. * @param mesh The mesh to render
  138213. * @returns true if it should render otherwise false
  138214. */
  138215. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138216. /**
  138217. * Renders the submesh passed in parameter to the generation map.
  138218. */
  138219. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138220. /**
  138221. * Defines whether the current material of the mesh should be use to render the effect.
  138222. * @param mesh defines the current mesh to render
  138223. */
  138224. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138225. /**
  138226. * Rebuild the required buffers.
  138227. * @hidden Internal use only.
  138228. */
  138229. _rebuild(): void;
  138230. /**
  138231. * Dispose only the render target textures and post process.
  138232. */
  138233. private _disposeTextureAndPostProcesses;
  138234. /**
  138235. * Dispose the highlight layer and free resources.
  138236. */
  138237. dispose(): void;
  138238. /**
  138239. * Gets the class name of the effect layer
  138240. * @returns the string with the class name of the effect layer
  138241. */
  138242. getClassName(): string;
  138243. /**
  138244. * Creates an effect layer from parsed effect layer data
  138245. * @param parsedEffectLayer defines effect layer data
  138246. * @param scene defines the current scene
  138247. * @param rootUrl defines the root URL containing the effect layer information
  138248. * @returns a parsed effect Layer
  138249. */
  138250. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138251. }
  138252. }
  138253. declare module BABYLON {
  138254. interface AbstractScene {
  138255. /**
  138256. * The list of effect layers (highlights/glow) added to the scene
  138257. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138258. * @see https://doc.babylonjs.com/how_to/glow_layer
  138259. */
  138260. effectLayers: Array<EffectLayer>;
  138261. /**
  138262. * Removes the given effect layer from this scene.
  138263. * @param toRemove defines the effect layer to remove
  138264. * @returns the index of the removed effect layer
  138265. */
  138266. removeEffectLayer(toRemove: EffectLayer): number;
  138267. /**
  138268. * Adds the given effect layer to this scene
  138269. * @param newEffectLayer defines the effect layer to add
  138270. */
  138271. addEffectLayer(newEffectLayer: EffectLayer): void;
  138272. }
  138273. /**
  138274. * Defines the layer scene component responsible to manage any effect layers
  138275. * in a given scene.
  138276. */
  138277. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138278. /**
  138279. * The component name helpfull to identify the component in the list of scene components.
  138280. */
  138281. readonly name: string;
  138282. /**
  138283. * The scene the component belongs to.
  138284. */
  138285. scene: Scene;
  138286. private _engine;
  138287. private _renderEffects;
  138288. private _needStencil;
  138289. private _previousStencilState;
  138290. /**
  138291. * Creates a new instance of the component for the given scene
  138292. * @param scene Defines the scene to register the component in
  138293. */
  138294. constructor(scene: Scene);
  138295. /**
  138296. * Registers the component in a given scene
  138297. */
  138298. register(): void;
  138299. /**
  138300. * Rebuilds the elements related to this component in case of
  138301. * context lost for instance.
  138302. */
  138303. rebuild(): void;
  138304. /**
  138305. * Serializes the component data to the specified json object
  138306. * @param serializationObject The object to serialize to
  138307. */
  138308. serialize(serializationObject: any): void;
  138309. /**
  138310. * Adds all the elements from the container to the scene
  138311. * @param container the container holding the elements
  138312. */
  138313. addFromContainer(container: AbstractScene): void;
  138314. /**
  138315. * Removes all the elements in the container from the scene
  138316. * @param container contains the elements to remove
  138317. * @param dispose if the removed element should be disposed (default: false)
  138318. */
  138319. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138320. /**
  138321. * Disposes the component and the associated ressources.
  138322. */
  138323. dispose(): void;
  138324. private _isReadyForMesh;
  138325. private _renderMainTexture;
  138326. private _setStencil;
  138327. private _setStencilBack;
  138328. private _draw;
  138329. private _drawCamera;
  138330. private _drawRenderingGroup;
  138331. }
  138332. }
  138333. declare module BABYLON {
  138334. /** @hidden */
  138335. export var glowMapMergePixelShader: {
  138336. name: string;
  138337. shader: string;
  138338. };
  138339. }
  138340. declare module BABYLON {
  138341. /** @hidden */
  138342. export var glowMapMergeVertexShader: {
  138343. name: string;
  138344. shader: string;
  138345. };
  138346. }
  138347. declare module BABYLON {
  138348. interface AbstractScene {
  138349. /**
  138350. * Return a the first highlight layer of the scene with a given name.
  138351. * @param name The name of the highlight layer to look for.
  138352. * @return The highlight layer if found otherwise null.
  138353. */
  138354. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138355. }
  138356. /**
  138357. * Glow layer options. This helps customizing the behaviour
  138358. * of the glow layer.
  138359. */
  138360. export interface IGlowLayerOptions {
  138361. /**
  138362. * Multiplication factor apply to the canvas size to compute the render target size
  138363. * used to generated the glowing objects (the smaller the faster).
  138364. */
  138365. mainTextureRatio: number;
  138366. /**
  138367. * Enforces a fixed size texture to ensure resize independant blur.
  138368. */
  138369. mainTextureFixedSize?: number;
  138370. /**
  138371. * How big is the kernel of the blur texture.
  138372. */
  138373. blurKernelSize: number;
  138374. /**
  138375. * The camera attached to the layer.
  138376. */
  138377. camera: Nullable<Camera>;
  138378. /**
  138379. * Enable MSAA by chosing the number of samples.
  138380. */
  138381. mainTextureSamples?: number;
  138382. /**
  138383. * The rendering group to draw the layer in.
  138384. */
  138385. renderingGroupId: number;
  138386. }
  138387. /**
  138388. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  138389. *
  138390. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  138391. *
  138392. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  138393. */
  138394. export class GlowLayer extends EffectLayer {
  138395. /**
  138396. * Effect Name of the layer.
  138397. */
  138398. static readonly EffectName: string;
  138399. /**
  138400. * The default blur kernel size used for the glow.
  138401. */
  138402. static DefaultBlurKernelSize: number;
  138403. /**
  138404. * The default texture size ratio used for the glow.
  138405. */
  138406. static DefaultTextureRatio: number;
  138407. /**
  138408. * Sets the kernel size of the blur.
  138409. */
  138410. set blurKernelSize(value: number);
  138411. /**
  138412. * Gets the kernel size of the blur.
  138413. */
  138414. get blurKernelSize(): number;
  138415. /**
  138416. * Sets the glow intensity.
  138417. */
  138418. set intensity(value: number);
  138419. /**
  138420. * Gets the glow intensity.
  138421. */
  138422. get intensity(): number;
  138423. private _options;
  138424. private _intensity;
  138425. private _horizontalBlurPostprocess1;
  138426. private _verticalBlurPostprocess1;
  138427. private _horizontalBlurPostprocess2;
  138428. private _verticalBlurPostprocess2;
  138429. private _blurTexture1;
  138430. private _blurTexture2;
  138431. private _postProcesses1;
  138432. private _postProcesses2;
  138433. private _includedOnlyMeshes;
  138434. private _excludedMeshes;
  138435. private _meshesUsingTheirOwnMaterials;
  138436. /**
  138437. * Callback used to let the user override the color selection on a per mesh basis
  138438. */
  138439. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  138440. /**
  138441. * Callback used to let the user override the texture selection on a per mesh basis
  138442. */
  138443. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  138444. /**
  138445. * Instantiates a new glow Layer and references it to the scene.
  138446. * @param name The name of the layer
  138447. * @param scene The scene to use the layer in
  138448. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  138449. */
  138450. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  138451. /**
  138452. * Get the effect name of the layer.
  138453. * @return The effect name
  138454. */
  138455. getEffectName(): string;
  138456. /**
  138457. * Create the merge effect. This is the shader use to blit the information back
  138458. * to the main canvas at the end of the scene rendering.
  138459. */
  138460. protected _createMergeEffect(): Effect;
  138461. /**
  138462. * Creates the render target textures and post processes used in the glow layer.
  138463. */
  138464. protected _createTextureAndPostProcesses(): void;
  138465. /**
  138466. * Checks for the readiness of the element composing the layer.
  138467. * @param subMesh the mesh to check for
  138468. * @param useInstances specify wether or not to use instances to render the mesh
  138469. * @param emissiveTexture the associated emissive texture used to generate the glow
  138470. * @return true if ready otherwise, false
  138471. */
  138472. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138473. /**
  138474. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138475. */
  138476. needStencil(): boolean;
  138477. /**
  138478. * Returns true if the mesh can be rendered, otherwise false.
  138479. * @param mesh The mesh to render
  138480. * @param material The material used on the mesh
  138481. * @returns true if it can be rendered otherwise false
  138482. */
  138483. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138484. /**
  138485. * Implementation specific of rendering the generating effect on the main canvas.
  138486. * @param effect The effect used to render through
  138487. */
  138488. protected _internalRender(effect: Effect): void;
  138489. /**
  138490. * Sets the required values for both the emissive texture and and the main color.
  138491. */
  138492. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138493. /**
  138494. * Returns true if the mesh should render, otherwise false.
  138495. * @param mesh The mesh to render
  138496. * @returns true if it should render otherwise false
  138497. */
  138498. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138499. /**
  138500. * Adds specific effects defines.
  138501. * @param defines The defines to add specifics to.
  138502. */
  138503. protected _addCustomEffectDefines(defines: string[]): void;
  138504. /**
  138505. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  138506. * @param mesh The mesh to exclude from the glow layer
  138507. */
  138508. addExcludedMesh(mesh: Mesh): void;
  138509. /**
  138510. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  138511. * @param mesh The mesh to remove
  138512. */
  138513. removeExcludedMesh(mesh: Mesh): void;
  138514. /**
  138515. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  138516. * @param mesh The mesh to include in the glow layer
  138517. */
  138518. addIncludedOnlyMesh(mesh: Mesh): void;
  138519. /**
  138520. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  138521. * @param mesh The mesh to remove
  138522. */
  138523. removeIncludedOnlyMesh(mesh: Mesh): void;
  138524. /**
  138525. * Determine if a given mesh will be used in the glow layer
  138526. * @param mesh The mesh to test
  138527. * @returns true if the mesh will be highlighted by the current glow layer
  138528. */
  138529. hasMesh(mesh: AbstractMesh): boolean;
  138530. /**
  138531. * Defines whether the current material of the mesh should be use to render the effect.
  138532. * @param mesh defines the current mesh to render
  138533. */
  138534. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138535. /**
  138536. * Add a mesh to be rendered through its own material and not with emissive only.
  138537. * @param mesh The mesh for which we need to use its material
  138538. */
  138539. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  138540. /**
  138541. * Remove a mesh from being rendered through its own material and not with emissive only.
  138542. * @param mesh The mesh for which we need to not use its material
  138543. */
  138544. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  138545. /**
  138546. * Free any resources and references associated to a mesh.
  138547. * Internal use
  138548. * @param mesh The mesh to free.
  138549. * @hidden
  138550. */
  138551. _disposeMesh(mesh: Mesh): void;
  138552. /**
  138553. * Gets the class name of the effect layer
  138554. * @returns the string with the class name of the effect layer
  138555. */
  138556. getClassName(): string;
  138557. /**
  138558. * Serializes this glow layer
  138559. * @returns a serialized glow layer object
  138560. */
  138561. serialize(): any;
  138562. /**
  138563. * Creates a Glow Layer from parsed glow layer data
  138564. * @param parsedGlowLayer defines glow layer data
  138565. * @param scene defines the current scene
  138566. * @param rootUrl defines the root URL containing the glow layer information
  138567. * @returns a parsed Glow Layer
  138568. */
  138569. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  138570. }
  138571. }
  138572. declare module BABYLON {
  138573. /** @hidden */
  138574. export var glowBlurPostProcessPixelShader: {
  138575. name: string;
  138576. shader: string;
  138577. };
  138578. }
  138579. declare module BABYLON {
  138580. interface AbstractScene {
  138581. /**
  138582. * Return a the first highlight layer of the scene with a given name.
  138583. * @param name The name of the highlight layer to look for.
  138584. * @return The highlight layer if found otherwise null.
  138585. */
  138586. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  138587. }
  138588. /**
  138589. * Highlight layer options. This helps customizing the behaviour
  138590. * of the highlight layer.
  138591. */
  138592. export interface IHighlightLayerOptions {
  138593. /**
  138594. * Multiplication factor apply to the canvas size to compute the render target size
  138595. * used to generated the glowing objects (the smaller the faster).
  138596. */
  138597. mainTextureRatio: number;
  138598. /**
  138599. * Enforces a fixed size texture to ensure resize independant blur.
  138600. */
  138601. mainTextureFixedSize?: number;
  138602. /**
  138603. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  138604. * of the picture to blur (the smaller the faster).
  138605. */
  138606. blurTextureSizeRatio: number;
  138607. /**
  138608. * How big in texel of the blur texture is the vertical blur.
  138609. */
  138610. blurVerticalSize: number;
  138611. /**
  138612. * How big in texel of the blur texture is the horizontal blur.
  138613. */
  138614. blurHorizontalSize: number;
  138615. /**
  138616. * Alpha blending mode used to apply the blur. Default is combine.
  138617. */
  138618. alphaBlendingMode: number;
  138619. /**
  138620. * The camera attached to the layer.
  138621. */
  138622. camera: Nullable<Camera>;
  138623. /**
  138624. * Should we display highlight as a solid stroke?
  138625. */
  138626. isStroke?: boolean;
  138627. /**
  138628. * The rendering group to draw the layer in.
  138629. */
  138630. renderingGroupId: number;
  138631. }
  138632. /**
  138633. * The highlight layer Helps adding a glow effect around a mesh.
  138634. *
  138635. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  138636. * glowy meshes to your scene.
  138637. *
  138638. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  138639. */
  138640. export class HighlightLayer extends EffectLayer {
  138641. name: string;
  138642. /**
  138643. * Effect Name of the highlight layer.
  138644. */
  138645. static readonly EffectName: string;
  138646. /**
  138647. * The neutral color used during the preparation of the glow effect.
  138648. * This is black by default as the blend operation is a blend operation.
  138649. */
  138650. static NeutralColor: Color4;
  138651. /**
  138652. * Stencil value used for glowing meshes.
  138653. */
  138654. static GlowingMeshStencilReference: number;
  138655. /**
  138656. * Stencil value used for the other meshes in the scene.
  138657. */
  138658. static NormalMeshStencilReference: number;
  138659. /**
  138660. * Specifies whether or not the inner glow is ACTIVE in the layer.
  138661. */
  138662. innerGlow: boolean;
  138663. /**
  138664. * Specifies whether or not the outer glow is ACTIVE in the layer.
  138665. */
  138666. outerGlow: boolean;
  138667. /**
  138668. * Specifies the horizontal size of the blur.
  138669. */
  138670. set blurHorizontalSize(value: number);
  138671. /**
  138672. * Specifies the vertical size of the blur.
  138673. */
  138674. set blurVerticalSize(value: number);
  138675. /**
  138676. * Gets the horizontal size of the blur.
  138677. */
  138678. get blurHorizontalSize(): number;
  138679. /**
  138680. * Gets the vertical size of the blur.
  138681. */
  138682. get blurVerticalSize(): number;
  138683. /**
  138684. * An event triggered when the highlight layer is being blurred.
  138685. */
  138686. onBeforeBlurObservable: Observable<HighlightLayer>;
  138687. /**
  138688. * An event triggered when the highlight layer has been blurred.
  138689. */
  138690. onAfterBlurObservable: Observable<HighlightLayer>;
  138691. private _instanceGlowingMeshStencilReference;
  138692. private _options;
  138693. private _downSamplePostprocess;
  138694. private _horizontalBlurPostprocess;
  138695. private _verticalBlurPostprocess;
  138696. private _blurTexture;
  138697. private _meshes;
  138698. private _excludedMeshes;
  138699. /**
  138700. * Instantiates a new highlight Layer and references it to the scene..
  138701. * @param name The name of the layer
  138702. * @param scene The scene to use the layer in
  138703. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  138704. */
  138705. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  138706. /**
  138707. * Get the effect name of the layer.
  138708. * @return The effect name
  138709. */
  138710. getEffectName(): string;
  138711. /**
  138712. * Create the merge effect. This is the shader use to blit the information back
  138713. * to the main canvas at the end of the scene rendering.
  138714. */
  138715. protected _createMergeEffect(): Effect;
  138716. /**
  138717. * Creates the render target textures and post processes used in the highlight layer.
  138718. */
  138719. protected _createTextureAndPostProcesses(): void;
  138720. /**
  138721. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  138722. */
  138723. needStencil(): boolean;
  138724. /**
  138725. * Checks for the readiness of the element composing the layer.
  138726. * @param subMesh the mesh to check for
  138727. * @param useInstances specify wether or not to use instances to render the mesh
  138728. * @param emissiveTexture the associated emissive texture used to generate the glow
  138729. * @return true if ready otherwise, false
  138730. */
  138731. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138732. /**
  138733. * Implementation specific of rendering the generating effect on the main canvas.
  138734. * @param effect The effect used to render through
  138735. */
  138736. protected _internalRender(effect: Effect): void;
  138737. /**
  138738. * Returns true if the layer contains information to display, otherwise false.
  138739. */
  138740. shouldRender(): boolean;
  138741. /**
  138742. * Returns true if the mesh should render, otherwise false.
  138743. * @param mesh The mesh to render
  138744. * @returns true if it should render otherwise false
  138745. */
  138746. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138747. /**
  138748. * Returns true if the mesh can be rendered, otherwise false.
  138749. * @param mesh The mesh to render
  138750. * @param material The material used on the mesh
  138751. * @returns true if it can be rendered otherwise false
  138752. */
  138753. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138754. /**
  138755. * Adds specific effects defines.
  138756. * @param defines The defines to add specifics to.
  138757. */
  138758. protected _addCustomEffectDefines(defines: string[]): void;
  138759. /**
  138760. * Sets the required values for both the emissive texture and and the main color.
  138761. */
  138762. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138763. /**
  138764. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  138765. * @param mesh The mesh to exclude from the highlight layer
  138766. */
  138767. addExcludedMesh(mesh: Mesh): void;
  138768. /**
  138769. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  138770. * @param mesh The mesh to highlight
  138771. */
  138772. removeExcludedMesh(mesh: Mesh): void;
  138773. /**
  138774. * Determine if a given mesh will be highlighted by the current HighlightLayer
  138775. * @param mesh mesh to test
  138776. * @returns true if the mesh will be highlighted by the current HighlightLayer
  138777. */
  138778. hasMesh(mesh: AbstractMesh): boolean;
  138779. /**
  138780. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  138781. * @param mesh The mesh to highlight
  138782. * @param color The color of the highlight
  138783. * @param glowEmissiveOnly Extract the glow from the emissive texture
  138784. */
  138785. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  138786. /**
  138787. * Remove a mesh from the highlight layer in order to make it stop glowing.
  138788. * @param mesh The mesh to highlight
  138789. */
  138790. removeMesh(mesh: Mesh): void;
  138791. /**
  138792. * Remove all the meshes currently referenced in the highlight layer
  138793. */
  138794. removeAllMeshes(): void;
  138795. /**
  138796. * Force the stencil to the normal expected value for none glowing parts
  138797. */
  138798. private _defaultStencilReference;
  138799. /**
  138800. * Free any resources and references associated to a mesh.
  138801. * Internal use
  138802. * @param mesh The mesh to free.
  138803. * @hidden
  138804. */
  138805. _disposeMesh(mesh: Mesh): void;
  138806. /**
  138807. * Dispose the highlight layer and free resources.
  138808. */
  138809. dispose(): void;
  138810. /**
  138811. * Gets the class name of the effect layer
  138812. * @returns the string with the class name of the effect layer
  138813. */
  138814. getClassName(): string;
  138815. /**
  138816. * Serializes this Highlight layer
  138817. * @returns a serialized Highlight layer object
  138818. */
  138819. serialize(): any;
  138820. /**
  138821. * Creates a Highlight layer from parsed Highlight layer data
  138822. * @param parsedHightlightLayer defines the Highlight layer data
  138823. * @param scene defines the current scene
  138824. * @param rootUrl defines the root URL containing the Highlight layer information
  138825. * @returns a parsed Highlight layer
  138826. */
  138827. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  138828. }
  138829. }
  138830. declare module BABYLON {
  138831. interface AbstractScene {
  138832. /**
  138833. * The list of layers (background and foreground) of the scene
  138834. */
  138835. layers: Array<Layer>;
  138836. }
  138837. /**
  138838. * Defines the layer scene component responsible to manage any layers
  138839. * in a given scene.
  138840. */
  138841. export class LayerSceneComponent implements ISceneComponent {
  138842. /**
  138843. * The component name helpfull to identify the component in the list of scene components.
  138844. */
  138845. readonly name: string;
  138846. /**
  138847. * The scene the component belongs to.
  138848. */
  138849. scene: Scene;
  138850. private _engine;
  138851. /**
  138852. * Creates a new instance of the component for the given scene
  138853. * @param scene Defines the scene to register the component in
  138854. */
  138855. constructor(scene: Scene);
  138856. /**
  138857. * Registers the component in a given scene
  138858. */
  138859. register(): void;
  138860. /**
  138861. * Rebuilds the elements related to this component in case of
  138862. * context lost for instance.
  138863. */
  138864. rebuild(): void;
  138865. /**
  138866. * Disposes the component and the associated ressources.
  138867. */
  138868. dispose(): void;
  138869. private _draw;
  138870. private _drawCameraPredicate;
  138871. private _drawCameraBackground;
  138872. private _drawCameraForeground;
  138873. private _drawRenderTargetPredicate;
  138874. private _drawRenderTargetBackground;
  138875. private _drawRenderTargetForeground;
  138876. /**
  138877. * Adds all the elements from the container to the scene
  138878. * @param container the container holding the elements
  138879. */
  138880. addFromContainer(container: AbstractScene): void;
  138881. /**
  138882. * Removes all the elements in the container from the scene
  138883. * @param container contains the elements to remove
  138884. * @param dispose if the removed element should be disposed (default: false)
  138885. */
  138886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138887. }
  138888. }
  138889. declare module BABYLON {
  138890. /** @hidden */
  138891. export var layerPixelShader: {
  138892. name: string;
  138893. shader: string;
  138894. };
  138895. }
  138896. declare module BABYLON {
  138897. /** @hidden */
  138898. export var layerVertexShader: {
  138899. name: string;
  138900. shader: string;
  138901. };
  138902. }
  138903. declare module BABYLON {
  138904. /**
  138905. * This represents a full screen 2d layer.
  138906. * This can be useful to display a picture in the background of your scene for instance.
  138907. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138908. */
  138909. export class Layer {
  138910. /**
  138911. * Define the name of the layer.
  138912. */
  138913. name: string;
  138914. /**
  138915. * Define the texture the layer should display.
  138916. */
  138917. texture: Nullable<Texture>;
  138918. /**
  138919. * Is the layer in background or foreground.
  138920. */
  138921. isBackground: boolean;
  138922. /**
  138923. * Define the color of the layer (instead of texture).
  138924. */
  138925. color: Color4;
  138926. /**
  138927. * Define the scale of the layer in order to zoom in out of the texture.
  138928. */
  138929. scale: Vector2;
  138930. /**
  138931. * Define an offset for the layer in order to shift the texture.
  138932. */
  138933. offset: Vector2;
  138934. /**
  138935. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  138936. */
  138937. alphaBlendingMode: number;
  138938. /**
  138939. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  138940. * Alpha test will not mix with the background color in case of transparency.
  138941. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  138942. */
  138943. alphaTest: boolean;
  138944. /**
  138945. * Define a mask to restrict the layer to only some of the scene cameras.
  138946. */
  138947. layerMask: number;
  138948. /**
  138949. * Define the list of render target the layer is visible into.
  138950. */
  138951. renderTargetTextures: RenderTargetTexture[];
  138952. /**
  138953. * Define if the layer is only used in renderTarget or if it also
  138954. * renders in the main frame buffer of the canvas.
  138955. */
  138956. renderOnlyInRenderTargetTextures: boolean;
  138957. private _scene;
  138958. private _vertexBuffers;
  138959. private _indexBuffer;
  138960. private _effect;
  138961. private _previousDefines;
  138962. /**
  138963. * An event triggered when the layer is disposed.
  138964. */
  138965. onDisposeObservable: Observable<Layer>;
  138966. private _onDisposeObserver;
  138967. /**
  138968. * Back compatibility with callback before the onDisposeObservable existed.
  138969. * The set callback will be triggered when the layer has been disposed.
  138970. */
  138971. set onDispose(callback: () => void);
  138972. /**
  138973. * An event triggered before rendering the scene
  138974. */
  138975. onBeforeRenderObservable: Observable<Layer>;
  138976. private _onBeforeRenderObserver;
  138977. /**
  138978. * Back compatibility with callback before the onBeforeRenderObservable existed.
  138979. * The set callback will be triggered just before rendering the layer.
  138980. */
  138981. set onBeforeRender(callback: () => void);
  138982. /**
  138983. * An event triggered after rendering the scene
  138984. */
  138985. onAfterRenderObservable: Observable<Layer>;
  138986. private _onAfterRenderObserver;
  138987. /**
  138988. * Back compatibility with callback before the onAfterRenderObservable existed.
  138989. * The set callback will be triggered just after rendering the layer.
  138990. */
  138991. set onAfterRender(callback: () => void);
  138992. /**
  138993. * Instantiates a new layer.
  138994. * This represents a full screen 2d layer.
  138995. * This can be useful to display a picture in the background of your scene for instance.
  138996. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138997. * @param name Define the name of the layer in the scene
  138998. * @param imgUrl Define the url of the texture to display in the layer
  138999. * @param scene Define the scene the layer belongs to
  139000. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139001. * @param color Defines a color for the layer
  139002. */
  139003. constructor(
  139004. /**
  139005. * Define the name of the layer.
  139006. */
  139007. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139008. private _createIndexBuffer;
  139009. /** @hidden */
  139010. _rebuild(): void;
  139011. /**
  139012. * Renders the layer in the scene.
  139013. */
  139014. render(): void;
  139015. /**
  139016. * Disposes and releases the associated ressources.
  139017. */
  139018. dispose(): void;
  139019. }
  139020. }
  139021. declare module BABYLON {
  139022. /** @hidden */
  139023. export var lensFlarePixelShader: {
  139024. name: string;
  139025. shader: string;
  139026. };
  139027. }
  139028. declare module BABYLON {
  139029. /** @hidden */
  139030. export var lensFlareVertexShader: {
  139031. name: string;
  139032. shader: string;
  139033. };
  139034. }
  139035. declare module BABYLON {
  139036. /**
  139037. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139038. * It is usually composed of several `lensFlare`.
  139039. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139040. */
  139041. export class LensFlareSystem {
  139042. /**
  139043. * Define the name of the lens flare system
  139044. */
  139045. name: string;
  139046. /**
  139047. * List of lens flares used in this system.
  139048. */
  139049. lensFlares: LensFlare[];
  139050. /**
  139051. * Define a limit from the border the lens flare can be visible.
  139052. */
  139053. borderLimit: number;
  139054. /**
  139055. * Define a viewport border we do not want to see the lens flare in.
  139056. */
  139057. viewportBorder: number;
  139058. /**
  139059. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139060. */
  139061. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139062. /**
  139063. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139064. */
  139065. layerMask: number;
  139066. /**
  139067. * Define the id of the lens flare system in the scene.
  139068. * (equal to name by default)
  139069. */
  139070. id: string;
  139071. private _scene;
  139072. private _emitter;
  139073. private _vertexBuffers;
  139074. private _indexBuffer;
  139075. private _effect;
  139076. private _positionX;
  139077. private _positionY;
  139078. private _isEnabled;
  139079. /** @hidden */
  139080. static _SceneComponentInitialization: (scene: Scene) => void;
  139081. /**
  139082. * Instantiates a lens flare system.
  139083. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139084. * It is usually composed of several `lensFlare`.
  139085. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139086. * @param name Define the name of the lens flare system in the scene
  139087. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139088. * @param scene Define the scene the lens flare system belongs to
  139089. */
  139090. constructor(
  139091. /**
  139092. * Define the name of the lens flare system
  139093. */
  139094. name: string, emitter: any, scene: Scene);
  139095. /**
  139096. * Define if the lens flare system is enabled.
  139097. */
  139098. get isEnabled(): boolean;
  139099. set isEnabled(value: boolean);
  139100. /**
  139101. * Get the scene the effects belongs to.
  139102. * @returns the scene holding the lens flare system
  139103. */
  139104. getScene(): Scene;
  139105. /**
  139106. * Get the emitter of the lens flare system.
  139107. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139108. * @returns the emitter of the lens flare system
  139109. */
  139110. getEmitter(): any;
  139111. /**
  139112. * Set the emitter of the lens flare system.
  139113. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139114. * @param newEmitter Define the new emitter of the system
  139115. */
  139116. setEmitter(newEmitter: any): void;
  139117. /**
  139118. * Get the lens flare system emitter position.
  139119. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139120. * @returns the position
  139121. */
  139122. getEmitterPosition(): Vector3;
  139123. /**
  139124. * @hidden
  139125. */
  139126. computeEffectivePosition(globalViewport: Viewport): boolean;
  139127. /** @hidden */
  139128. _isVisible(): boolean;
  139129. /**
  139130. * @hidden
  139131. */
  139132. render(): boolean;
  139133. /**
  139134. * Dispose and release the lens flare with its associated resources.
  139135. */
  139136. dispose(): void;
  139137. /**
  139138. * Parse a lens flare system from a JSON repressentation
  139139. * @param parsedLensFlareSystem Define the JSON to parse
  139140. * @param scene Define the scene the parsed system should be instantiated in
  139141. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139142. * @returns the parsed system
  139143. */
  139144. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139145. /**
  139146. * Serialize the current Lens Flare System into a JSON representation.
  139147. * @returns the serialized JSON
  139148. */
  139149. serialize(): any;
  139150. }
  139151. }
  139152. declare module BABYLON {
  139153. /**
  139154. * This represents one of the lens effect in a `lensFlareSystem`.
  139155. * It controls one of the indiviual texture used in the effect.
  139156. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139157. */
  139158. export class LensFlare {
  139159. /**
  139160. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139161. */
  139162. size: number;
  139163. /**
  139164. * 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.
  139165. */
  139166. position: number;
  139167. /**
  139168. * Define the lens color.
  139169. */
  139170. color: Color3;
  139171. /**
  139172. * Define the lens texture.
  139173. */
  139174. texture: Nullable<Texture>;
  139175. /**
  139176. * Define the alpha mode to render this particular lens.
  139177. */
  139178. alphaMode: number;
  139179. private _system;
  139180. /**
  139181. * Creates a new Lens Flare.
  139182. * This represents one of the lens effect in a `lensFlareSystem`.
  139183. * It controls one of the indiviual texture used in the effect.
  139184. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139185. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139186. * @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.
  139187. * @param color Define the lens color
  139188. * @param imgUrl Define the lens texture url
  139189. * @param system Define the `lensFlareSystem` this flare is part of
  139190. * @returns The newly created Lens Flare
  139191. */
  139192. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139193. /**
  139194. * Instantiates a new Lens Flare.
  139195. * This represents one of the lens effect in a `lensFlareSystem`.
  139196. * It controls one of the indiviual texture used in the effect.
  139197. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139198. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139199. * @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.
  139200. * @param color Define the lens color
  139201. * @param imgUrl Define the lens texture url
  139202. * @param system Define the `lensFlareSystem` this flare is part of
  139203. */
  139204. constructor(
  139205. /**
  139206. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139207. */
  139208. size: number,
  139209. /**
  139210. * 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.
  139211. */
  139212. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139213. /**
  139214. * Dispose and release the lens flare with its associated resources.
  139215. */
  139216. dispose(): void;
  139217. }
  139218. }
  139219. declare module BABYLON {
  139220. interface AbstractScene {
  139221. /**
  139222. * The list of lens flare system added to the scene
  139223. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139224. */
  139225. lensFlareSystems: Array<LensFlareSystem>;
  139226. /**
  139227. * Removes the given lens flare system from this scene.
  139228. * @param toRemove The lens flare system to remove
  139229. * @returns The index of the removed lens flare system
  139230. */
  139231. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139232. /**
  139233. * Adds the given lens flare system to this scene
  139234. * @param newLensFlareSystem The lens flare system to add
  139235. */
  139236. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139237. /**
  139238. * Gets a lens flare system using its name
  139239. * @param name defines the name to look for
  139240. * @returns the lens flare system or null if not found
  139241. */
  139242. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139243. /**
  139244. * Gets a lens flare system using its id
  139245. * @param id defines the id to look for
  139246. * @returns the lens flare system or null if not found
  139247. */
  139248. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139249. }
  139250. /**
  139251. * Defines the lens flare scene component responsible to manage any lens flares
  139252. * in a given scene.
  139253. */
  139254. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139255. /**
  139256. * The component name helpfull to identify the component in the list of scene components.
  139257. */
  139258. readonly name: string;
  139259. /**
  139260. * The scene the component belongs to.
  139261. */
  139262. scene: Scene;
  139263. /**
  139264. * Creates a new instance of the component for the given scene
  139265. * @param scene Defines the scene to register the component in
  139266. */
  139267. constructor(scene: Scene);
  139268. /**
  139269. * Registers the component in a given scene
  139270. */
  139271. register(): void;
  139272. /**
  139273. * Rebuilds the elements related to this component in case of
  139274. * context lost for instance.
  139275. */
  139276. rebuild(): void;
  139277. /**
  139278. * Adds all the elements from the container to the scene
  139279. * @param container the container holding the elements
  139280. */
  139281. addFromContainer(container: AbstractScene): void;
  139282. /**
  139283. * Removes all the elements in the container from the scene
  139284. * @param container contains the elements to remove
  139285. * @param dispose if the removed element should be disposed (default: false)
  139286. */
  139287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139288. /**
  139289. * Serializes the component data to the specified json object
  139290. * @param serializationObject The object to serialize to
  139291. */
  139292. serialize(serializationObject: any): void;
  139293. /**
  139294. * Disposes the component and the associated ressources.
  139295. */
  139296. dispose(): void;
  139297. private _draw;
  139298. }
  139299. }
  139300. declare module BABYLON {
  139301. /** @hidden */
  139302. export var depthPixelShader: {
  139303. name: string;
  139304. shader: string;
  139305. };
  139306. }
  139307. declare module BABYLON {
  139308. /** @hidden */
  139309. export var depthVertexShader: {
  139310. name: string;
  139311. shader: string;
  139312. };
  139313. }
  139314. declare module BABYLON {
  139315. /**
  139316. * This represents a depth renderer in Babylon.
  139317. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139318. */
  139319. export class DepthRenderer {
  139320. private _scene;
  139321. private _depthMap;
  139322. private _effect;
  139323. private readonly _storeNonLinearDepth;
  139324. private readonly _clearColor;
  139325. /** Get if the depth renderer is using packed depth or not */
  139326. readonly isPacked: boolean;
  139327. private _cachedDefines;
  139328. private _camera;
  139329. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  139330. enabled: boolean;
  139331. /**
  139332. * Specifiess that the depth renderer will only be used within
  139333. * the camera it is created for.
  139334. * This can help forcing its rendering during the camera processing.
  139335. */
  139336. useOnlyInActiveCamera: boolean;
  139337. /** @hidden */
  139338. static _SceneComponentInitialization: (scene: Scene) => void;
  139339. /**
  139340. * Instantiates a depth renderer
  139341. * @param scene The scene the renderer belongs to
  139342. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139343. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139344. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139345. */
  139346. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139347. /**
  139348. * Creates the depth rendering effect and checks if the effect is ready.
  139349. * @param subMesh The submesh to be used to render the depth map of
  139350. * @param useInstances If multiple world instances should be used
  139351. * @returns if the depth renderer is ready to render the depth map
  139352. */
  139353. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139354. /**
  139355. * Gets the texture which the depth map will be written to.
  139356. * @returns The depth map texture
  139357. */
  139358. getDepthMap(): RenderTargetTexture;
  139359. /**
  139360. * Disposes of the depth renderer.
  139361. */
  139362. dispose(): void;
  139363. }
  139364. }
  139365. declare module BABYLON {
  139366. /** @hidden */
  139367. export var minmaxReduxPixelShader: {
  139368. name: string;
  139369. shader: string;
  139370. };
  139371. }
  139372. declare module BABYLON {
  139373. /**
  139374. * This class computes a min/max reduction from a texture: it means it computes the minimum
  139375. * and maximum values from all values of the texture.
  139376. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  139377. * The source values are read from the red channel of the texture.
  139378. */
  139379. export class MinMaxReducer {
  139380. /**
  139381. * Observable triggered when the computation has been performed
  139382. */
  139383. onAfterReductionPerformed: Observable<{
  139384. min: number;
  139385. max: number;
  139386. }>;
  139387. protected _camera: Camera;
  139388. protected _sourceTexture: Nullable<RenderTargetTexture>;
  139389. protected _reductionSteps: Nullable<Array<PostProcess>>;
  139390. protected _postProcessManager: PostProcessManager;
  139391. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  139392. protected _forceFullscreenViewport: boolean;
  139393. /**
  139394. * Creates a min/max reducer
  139395. * @param camera The camera to use for the post processes
  139396. */
  139397. constructor(camera: Camera);
  139398. /**
  139399. * Gets the texture used to read the values from.
  139400. */
  139401. get sourceTexture(): Nullable<RenderTargetTexture>;
  139402. /**
  139403. * Sets the source texture to read the values from.
  139404. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  139405. * because in such textures '1' value must not be taken into account to compute the maximum
  139406. * as this value is used to clear the texture.
  139407. * Note that the computation is not activated by calling this function, you must call activate() for that!
  139408. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  139409. * @param depthRedux Indicates if the texture is a depth texture or not
  139410. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  139411. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139412. */
  139413. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139414. /**
  139415. * Defines the refresh rate of the computation.
  139416. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139417. */
  139418. get refreshRate(): number;
  139419. set refreshRate(value: number);
  139420. protected _activated: boolean;
  139421. /**
  139422. * Gets the activation status of the reducer
  139423. */
  139424. get activated(): boolean;
  139425. /**
  139426. * Activates the reduction computation.
  139427. * When activated, the observers registered in onAfterReductionPerformed are
  139428. * called after the compuation is performed
  139429. */
  139430. activate(): void;
  139431. /**
  139432. * Deactivates the reduction computation.
  139433. */
  139434. deactivate(): void;
  139435. /**
  139436. * Disposes the min/max reducer
  139437. * @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.
  139438. */
  139439. dispose(disposeAll?: boolean): void;
  139440. }
  139441. }
  139442. declare module BABYLON {
  139443. /**
  139444. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  139445. */
  139446. export class DepthReducer extends MinMaxReducer {
  139447. private _depthRenderer;
  139448. private _depthRendererId;
  139449. /**
  139450. * Gets the depth renderer used for the computation.
  139451. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  139452. */
  139453. get depthRenderer(): Nullable<DepthRenderer>;
  139454. /**
  139455. * Creates a depth reducer
  139456. * @param camera The camera used to render the depth texture
  139457. */
  139458. constructor(camera: Camera);
  139459. /**
  139460. * Sets the depth renderer to use to generate the depth map
  139461. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  139462. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  139463. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139464. */
  139465. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  139466. /** @hidden */
  139467. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139468. /**
  139469. * Activates the reduction computation.
  139470. * When activated, the observers registered in onAfterReductionPerformed are
  139471. * called after the compuation is performed
  139472. */
  139473. activate(): void;
  139474. /**
  139475. * Deactivates the reduction computation.
  139476. */
  139477. deactivate(): void;
  139478. /**
  139479. * Disposes the depth reducer
  139480. * @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.
  139481. */
  139482. dispose(disposeAll?: boolean): void;
  139483. }
  139484. }
  139485. declare module BABYLON {
  139486. /**
  139487. * A CSM implementation allowing casting shadows on large scenes.
  139488. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139489. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  139490. */
  139491. export class CascadedShadowGenerator extends ShadowGenerator {
  139492. private static readonly frustumCornersNDCSpace;
  139493. /**
  139494. * Name of the CSM class
  139495. */
  139496. static CLASSNAME: string;
  139497. /**
  139498. * Defines the default number of cascades used by the CSM.
  139499. */
  139500. static readonly DEFAULT_CASCADES_COUNT: number;
  139501. /**
  139502. * Defines the minimum number of cascades used by the CSM.
  139503. */
  139504. static readonly MIN_CASCADES_COUNT: number;
  139505. /**
  139506. * Defines the maximum number of cascades used by the CSM.
  139507. */
  139508. static readonly MAX_CASCADES_COUNT: number;
  139509. protected _validateFilter(filter: number): number;
  139510. /**
  139511. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  139512. */
  139513. penumbraDarkness: number;
  139514. private _numCascades;
  139515. /**
  139516. * Gets or set the number of cascades used by the CSM.
  139517. */
  139518. get numCascades(): number;
  139519. set numCascades(value: number);
  139520. /**
  139521. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  139522. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  139523. */
  139524. stabilizeCascades: boolean;
  139525. private _freezeShadowCastersBoundingInfo;
  139526. private _freezeShadowCastersBoundingInfoObservable;
  139527. /**
  139528. * Enables or disables the shadow casters bounding info computation.
  139529. * If your shadow casters don't move, you can disable this feature.
  139530. * If it is enabled, the bounding box computation is done every frame.
  139531. */
  139532. get freezeShadowCastersBoundingInfo(): boolean;
  139533. set freezeShadowCastersBoundingInfo(freeze: boolean);
  139534. private _scbiMin;
  139535. private _scbiMax;
  139536. protected _computeShadowCastersBoundingInfo(): void;
  139537. protected _shadowCastersBoundingInfo: BoundingInfo;
  139538. /**
  139539. * Gets or sets the shadow casters bounding info.
  139540. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  139541. * so that the system won't overwrite the bounds you provide
  139542. */
  139543. get shadowCastersBoundingInfo(): BoundingInfo;
  139544. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  139545. protected _breaksAreDirty: boolean;
  139546. protected _minDistance: number;
  139547. protected _maxDistance: number;
  139548. /**
  139549. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  139550. *
  139551. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  139552. * If you don't know these values, simply leave them to their defaults and don't call this function.
  139553. * @param min minimal distance for the breaks (default to 0.)
  139554. * @param max maximal distance for the breaks (default to 1.)
  139555. */
  139556. setMinMaxDistance(min: number, max: number): void;
  139557. /** Gets the minimal distance used in the cascade break computation */
  139558. get minDistance(): number;
  139559. /** Gets the maximal distance used in the cascade break computation */
  139560. get maxDistance(): number;
  139561. /**
  139562. * Gets the class name of that object
  139563. * @returns "CascadedShadowGenerator"
  139564. */
  139565. getClassName(): string;
  139566. private _cascadeMinExtents;
  139567. private _cascadeMaxExtents;
  139568. /**
  139569. * Gets a cascade minimum extents
  139570. * @param cascadeIndex index of the cascade
  139571. * @returns the minimum cascade extents
  139572. */
  139573. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  139574. /**
  139575. * Gets a cascade maximum extents
  139576. * @param cascadeIndex index of the cascade
  139577. * @returns the maximum cascade extents
  139578. */
  139579. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  139580. private _cascades;
  139581. private _currentLayer;
  139582. private _viewSpaceFrustumsZ;
  139583. private _viewMatrices;
  139584. private _projectionMatrices;
  139585. private _transformMatrices;
  139586. private _transformMatricesAsArray;
  139587. private _frustumLengths;
  139588. private _lightSizeUVCorrection;
  139589. private _depthCorrection;
  139590. private _frustumCornersWorldSpace;
  139591. private _frustumCenter;
  139592. private _shadowCameraPos;
  139593. private _shadowMaxZ;
  139594. /**
  139595. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  139596. * It defaults to camera.maxZ
  139597. */
  139598. get shadowMaxZ(): number;
  139599. /**
  139600. * Sets the shadow max z distance.
  139601. */
  139602. set shadowMaxZ(value: number);
  139603. protected _debug: boolean;
  139604. /**
  139605. * Gets or sets the debug flag.
  139606. * When enabled, the cascades are materialized by different colors on the screen.
  139607. */
  139608. get debug(): boolean;
  139609. set debug(dbg: boolean);
  139610. private _depthClamp;
  139611. /**
  139612. * Gets or sets the depth clamping value.
  139613. *
  139614. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  139615. * to account for the shadow casters far away.
  139616. *
  139617. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  139618. */
  139619. get depthClamp(): boolean;
  139620. set depthClamp(value: boolean);
  139621. private _cascadeBlendPercentage;
  139622. /**
  139623. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  139624. * It defaults to 0.1 (10% blending).
  139625. */
  139626. get cascadeBlendPercentage(): number;
  139627. set cascadeBlendPercentage(value: number);
  139628. private _lambda;
  139629. /**
  139630. * Gets or set the lambda parameter.
  139631. * This parameter is used to split the camera frustum and create the cascades.
  139632. * 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.
  139633. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  139634. */
  139635. get lambda(): number;
  139636. set lambda(value: number);
  139637. /**
  139638. * Gets the view matrix corresponding to a given cascade
  139639. * @param cascadeNum cascade to retrieve the view matrix from
  139640. * @returns the cascade view matrix
  139641. */
  139642. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  139643. /**
  139644. * Gets the projection matrix corresponding to a given cascade
  139645. * @param cascadeNum cascade to retrieve the projection matrix from
  139646. * @returns the cascade projection matrix
  139647. */
  139648. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  139649. /**
  139650. * Gets the transformation matrix corresponding to a given cascade
  139651. * @param cascadeNum cascade to retrieve the transformation matrix from
  139652. * @returns the cascade transformation matrix
  139653. */
  139654. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  139655. private _depthRenderer;
  139656. /**
  139657. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  139658. *
  139659. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  139660. *
  139661. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  139662. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  139663. * @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
  139664. */
  139665. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  139666. private _depthReducer;
  139667. private _autoCalcDepthBounds;
  139668. /**
  139669. * Gets or sets the autoCalcDepthBounds property.
  139670. *
  139671. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  139672. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  139673. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  139674. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  139675. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  139676. */
  139677. get autoCalcDepthBounds(): boolean;
  139678. set autoCalcDepthBounds(value: boolean);
  139679. /**
  139680. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  139681. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139682. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  139683. * for setting the refresh rate on the renderer yourself!
  139684. */
  139685. get autoCalcDepthBoundsRefreshRate(): number;
  139686. set autoCalcDepthBoundsRefreshRate(value: number);
  139687. /**
  139688. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  139689. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  139690. * you change the camera near/far planes!
  139691. */
  139692. splitFrustum(): void;
  139693. private _splitFrustum;
  139694. private _computeMatrices;
  139695. private _computeFrustumInWorldSpace;
  139696. private _computeCascadeFrustum;
  139697. /**
  139698. * Support test.
  139699. */
  139700. static get IsSupported(): boolean;
  139701. /** @hidden */
  139702. static _SceneComponentInitialization: (scene: Scene) => void;
  139703. /**
  139704. * Creates a Cascaded Shadow Generator object.
  139705. * A ShadowGenerator is the required tool to use the shadows.
  139706. * Each directional light casting shadows needs to use its own ShadowGenerator.
  139707. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139708. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  139709. * @param light The directional light object generating the shadows.
  139710. * @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.
  139711. */
  139712. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  139713. protected _initializeGenerator(): void;
  139714. protected _createTargetRenderTexture(): void;
  139715. protected _initializeShadowMap(): void;
  139716. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  139717. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  139718. /**
  139719. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  139720. * @param defines Defines of the material we want to update
  139721. * @param lightIndex Index of the light in the enabled light list of the material
  139722. */
  139723. prepareDefines(defines: any, lightIndex: number): void;
  139724. /**
  139725. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  139726. * defined in the generator but impacting the effect).
  139727. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  139728. * @param effect The effect we are binfing the information for
  139729. */
  139730. bindShadowLight(lightIndex: string, effect: Effect): void;
  139731. /**
  139732. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  139733. * (eq to view projection * shadow projection matrices)
  139734. * @returns The transform matrix used to create the shadow map
  139735. */
  139736. getTransformMatrix(): Matrix;
  139737. /**
  139738. * Disposes the ShadowGenerator.
  139739. * Returns nothing.
  139740. */
  139741. dispose(): void;
  139742. /**
  139743. * Serializes the shadow generator setup to a json object.
  139744. * @returns The serialized JSON object
  139745. */
  139746. serialize(): any;
  139747. /**
  139748. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  139749. * @param parsedShadowGenerator The JSON object to parse
  139750. * @param scene The scene to create the shadow map for
  139751. * @returns The parsed shadow generator
  139752. */
  139753. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  139754. }
  139755. }
  139756. declare module BABYLON {
  139757. /**
  139758. * Defines the shadow generator component responsible to manage any shadow generators
  139759. * in a given scene.
  139760. */
  139761. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  139762. /**
  139763. * The component name helpfull to identify the component in the list of scene components.
  139764. */
  139765. readonly name: string;
  139766. /**
  139767. * The scene the component belongs to.
  139768. */
  139769. scene: Scene;
  139770. /**
  139771. * Creates a new instance of the component for the given scene
  139772. * @param scene Defines the scene to register the component in
  139773. */
  139774. constructor(scene: Scene);
  139775. /**
  139776. * Registers the component in a given scene
  139777. */
  139778. register(): void;
  139779. /**
  139780. * Rebuilds the elements related to this component in case of
  139781. * context lost for instance.
  139782. */
  139783. rebuild(): void;
  139784. /**
  139785. * Serializes the component data to the specified json object
  139786. * @param serializationObject The object to serialize to
  139787. */
  139788. serialize(serializationObject: any): void;
  139789. /**
  139790. * Adds all the elements from the container to the scene
  139791. * @param container the container holding the elements
  139792. */
  139793. addFromContainer(container: AbstractScene): void;
  139794. /**
  139795. * Removes all the elements in the container from the scene
  139796. * @param container contains the elements to remove
  139797. * @param dispose if the removed element should be disposed (default: false)
  139798. */
  139799. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139800. /**
  139801. * Rebuilds the elements related to this component in case of
  139802. * context lost for instance.
  139803. */
  139804. dispose(): void;
  139805. private _gatherRenderTargets;
  139806. }
  139807. }
  139808. declare module BABYLON {
  139809. /**
  139810. * A point light is a light defined by an unique point in world space.
  139811. * The light is emitted in every direction from this point.
  139812. * A good example of a point light is a standard light bulb.
  139813. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139814. */
  139815. export class PointLight extends ShadowLight {
  139816. private _shadowAngle;
  139817. /**
  139818. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139819. * This specifies what angle the shadow will use to be created.
  139820. *
  139821. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139822. */
  139823. get shadowAngle(): number;
  139824. /**
  139825. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139826. * This specifies what angle the shadow will use to be created.
  139827. *
  139828. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139829. */
  139830. set shadowAngle(value: number);
  139831. /**
  139832. * Gets the direction if it has been set.
  139833. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139834. */
  139835. get direction(): Vector3;
  139836. /**
  139837. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139838. */
  139839. set direction(value: Vector3);
  139840. /**
  139841. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  139842. * A PointLight emits the light in every direction.
  139843. * It can cast shadows.
  139844. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  139845. * ```javascript
  139846. * var pointLight = new PointLight("pl", camera.position, scene);
  139847. * ```
  139848. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139849. * @param name The light friendly name
  139850. * @param position The position of the point light in the scene
  139851. * @param scene The scene the lights belongs to
  139852. */
  139853. constructor(name: string, position: Vector3, scene: Scene);
  139854. /**
  139855. * Returns the string "PointLight"
  139856. * @returns the class name
  139857. */
  139858. getClassName(): string;
  139859. /**
  139860. * Returns the integer 0.
  139861. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139862. */
  139863. getTypeID(): number;
  139864. /**
  139865. * Specifies wether or not the shadowmap should be a cube texture.
  139866. * @returns true if the shadowmap needs to be a cube texture.
  139867. */
  139868. needCube(): boolean;
  139869. /**
  139870. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  139871. * @param faceIndex The index of the face we are computed the direction to generate shadow
  139872. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  139873. */
  139874. getShadowDirection(faceIndex?: number): Vector3;
  139875. /**
  139876. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  139877. * - fov = PI / 2
  139878. * - aspect ratio : 1.0
  139879. * - z-near and far equal to the active camera minZ and maxZ.
  139880. * Returns the PointLight.
  139881. */
  139882. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139883. protected _buildUniformLayout(): void;
  139884. /**
  139885. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  139886. * @param effect The effect to update
  139887. * @param lightIndex The index of the light in the effect to update
  139888. * @returns The point light
  139889. */
  139890. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  139891. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139892. /**
  139893. * Prepares the list of defines specific to the light type.
  139894. * @param defines the list of defines
  139895. * @param lightIndex defines the index of the light for the effect
  139896. */
  139897. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139898. }
  139899. }
  139900. declare module BABYLON {
  139901. /**
  139902. * Header information of HDR texture files.
  139903. */
  139904. export interface HDRInfo {
  139905. /**
  139906. * The height of the texture in pixels.
  139907. */
  139908. height: number;
  139909. /**
  139910. * The width of the texture in pixels.
  139911. */
  139912. width: number;
  139913. /**
  139914. * The index of the beginning of the data in the binary file.
  139915. */
  139916. dataPosition: number;
  139917. }
  139918. /**
  139919. * This groups tools to convert HDR texture to native colors array.
  139920. */
  139921. export class HDRTools {
  139922. private static Ldexp;
  139923. private static Rgbe2float;
  139924. private static readStringLine;
  139925. /**
  139926. * Reads header information from an RGBE texture stored in a native array.
  139927. * More information on this format are available here:
  139928. * https://en.wikipedia.org/wiki/RGBE_image_format
  139929. *
  139930. * @param uint8array The binary file stored in native array.
  139931. * @return The header information.
  139932. */
  139933. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  139934. /**
  139935. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  139936. * This RGBE texture needs to store the information as a panorama.
  139937. *
  139938. * More information on this format are available here:
  139939. * https://en.wikipedia.org/wiki/RGBE_image_format
  139940. *
  139941. * @param buffer The binary file stored in an array buffer.
  139942. * @param size The expected size of the extracted cubemap.
  139943. * @return The Cube Map information.
  139944. */
  139945. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  139946. /**
  139947. * Returns the pixels data extracted from an RGBE texture.
  139948. * This pixels will be stored left to right up to down in the R G B order in one array.
  139949. *
  139950. * More information on this format are available here:
  139951. * https://en.wikipedia.org/wiki/RGBE_image_format
  139952. *
  139953. * @param uint8array The binary file stored in an array buffer.
  139954. * @param hdrInfo The header information of the file.
  139955. * @return The pixels data in RGB right to left up to down order.
  139956. */
  139957. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  139958. private static RGBE_ReadPixels_RLE;
  139959. private static RGBE_ReadPixels_NOT_RLE;
  139960. }
  139961. }
  139962. declare module BABYLON {
  139963. /**
  139964. * Effect Render Options
  139965. */
  139966. export interface IEffectRendererOptions {
  139967. /**
  139968. * Defines the vertices positions.
  139969. */
  139970. positions?: number[];
  139971. /**
  139972. * Defines the indices.
  139973. */
  139974. indices?: number[];
  139975. }
  139976. /**
  139977. * Helper class to render one or more effects.
  139978. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  139979. */
  139980. export class EffectRenderer {
  139981. private engine;
  139982. private static _DefaultOptions;
  139983. private _vertexBuffers;
  139984. private _indexBuffer;
  139985. private _fullscreenViewport;
  139986. /**
  139987. * Creates an effect renderer
  139988. * @param engine the engine to use for rendering
  139989. * @param options defines the options of the effect renderer
  139990. */
  139991. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  139992. /**
  139993. * Sets the current viewport in normalized coordinates 0-1
  139994. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  139995. */
  139996. setViewport(viewport?: Viewport): void;
  139997. /**
  139998. * Binds the embedded attributes buffer to the effect.
  139999. * @param effect Defines the effect to bind the attributes for
  140000. */
  140001. bindBuffers(effect: Effect): void;
  140002. /**
  140003. * Sets the current effect wrapper to use during draw.
  140004. * The effect needs to be ready before calling this api.
  140005. * This also sets the default full screen position attribute.
  140006. * @param effectWrapper Defines the effect to draw with
  140007. */
  140008. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140009. /**
  140010. * Restores engine states
  140011. */
  140012. restoreStates(): void;
  140013. /**
  140014. * Draws a full screen quad.
  140015. */
  140016. draw(): void;
  140017. private isRenderTargetTexture;
  140018. /**
  140019. * renders one or more effects to a specified texture
  140020. * @param effectWrapper the effect to renderer
  140021. * @param outputTexture texture to draw to, if null it will render to the screen.
  140022. */
  140023. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140024. /**
  140025. * Disposes of the effect renderer
  140026. */
  140027. dispose(): void;
  140028. }
  140029. /**
  140030. * Options to create an EffectWrapper
  140031. */
  140032. interface EffectWrapperCreationOptions {
  140033. /**
  140034. * Engine to use to create the effect
  140035. */
  140036. engine: ThinEngine;
  140037. /**
  140038. * Fragment shader for the effect
  140039. */
  140040. fragmentShader: string;
  140041. /**
  140042. * Use the shader store instead of direct source code
  140043. */
  140044. useShaderStore?: boolean;
  140045. /**
  140046. * Vertex shader for the effect
  140047. */
  140048. vertexShader?: string;
  140049. /**
  140050. * Attributes to use in the shader
  140051. */
  140052. attributeNames?: Array<string>;
  140053. /**
  140054. * Uniforms to use in the shader
  140055. */
  140056. uniformNames?: Array<string>;
  140057. /**
  140058. * Texture sampler names to use in the shader
  140059. */
  140060. samplerNames?: Array<string>;
  140061. /**
  140062. * Defines to use in the shader
  140063. */
  140064. defines?: Array<string>;
  140065. /**
  140066. * Callback when effect is compiled
  140067. */
  140068. onCompiled?: Nullable<(effect: Effect) => void>;
  140069. /**
  140070. * The friendly name of the effect displayed in Spector.
  140071. */
  140072. name?: string;
  140073. }
  140074. /**
  140075. * Wraps an effect to be used for rendering
  140076. */
  140077. export class EffectWrapper {
  140078. /**
  140079. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140080. */
  140081. onApplyObservable: Observable<{}>;
  140082. /**
  140083. * The underlying effect
  140084. */
  140085. effect: Effect;
  140086. /**
  140087. * Creates an effect to be renderer
  140088. * @param creationOptions options to create the effect
  140089. */
  140090. constructor(creationOptions: EffectWrapperCreationOptions);
  140091. /**
  140092. * Disposes of the effect wrapper
  140093. */
  140094. dispose(): void;
  140095. }
  140096. }
  140097. declare module BABYLON {
  140098. /** @hidden */
  140099. export var hdrFilteringVertexShader: {
  140100. name: string;
  140101. shader: string;
  140102. };
  140103. }
  140104. declare module BABYLON {
  140105. /** @hidden */
  140106. export var hdrFilteringPixelShader: {
  140107. name: string;
  140108. shader: string;
  140109. };
  140110. }
  140111. declare module BABYLON {
  140112. /**
  140113. * Options for texture filtering
  140114. */
  140115. interface IHDRFilteringOptions {
  140116. /**
  140117. * Scales pixel intensity for the input HDR map.
  140118. */
  140119. hdrScale?: number;
  140120. /**
  140121. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140122. */
  140123. quality?: number;
  140124. }
  140125. /**
  140126. * Filters HDR maps to get correct renderings of PBR reflections
  140127. */
  140128. export class HDRFiltering {
  140129. private _engine;
  140130. private _effectRenderer;
  140131. private _effectWrapper;
  140132. private _lodGenerationOffset;
  140133. private _lodGenerationScale;
  140134. /**
  140135. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140136. * you care about baking speed.
  140137. */
  140138. quality: number;
  140139. /**
  140140. * Scales pixel intensity for the input HDR map.
  140141. */
  140142. hdrScale: number;
  140143. /**
  140144. * Instantiates HDR filter for reflection maps
  140145. *
  140146. * @param engine Thin engine
  140147. * @param options Options
  140148. */
  140149. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140150. private _createRenderTarget;
  140151. private _prefilterInternal;
  140152. private _createEffect;
  140153. /**
  140154. * Get a value indicating if the filter is ready to be used
  140155. * @param texture Texture to filter
  140156. * @returns true if the filter is ready
  140157. */
  140158. isReady(texture: BaseTexture): boolean;
  140159. /**
  140160. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140161. * Prefiltering will be invoked at the end of next rendering pass.
  140162. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140163. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140164. * @param texture Texture to filter
  140165. * @param onFinished Callback when filtering is done
  140166. * @return Promise called when prefiltering is done
  140167. */
  140168. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140169. }
  140170. }
  140171. declare module BABYLON {
  140172. /**
  140173. * This represents a texture coming from an HDR input.
  140174. *
  140175. * The only supported format is currently panorama picture stored in RGBE format.
  140176. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140177. */
  140178. export class HDRCubeTexture extends BaseTexture {
  140179. private static _facesMapping;
  140180. private _generateHarmonics;
  140181. private _noMipmap;
  140182. private _prefilterOnLoad;
  140183. private _textureMatrix;
  140184. private _size;
  140185. private _onLoad;
  140186. private _onError;
  140187. /**
  140188. * The texture URL.
  140189. */
  140190. url: string;
  140191. protected _isBlocking: boolean;
  140192. /**
  140193. * Sets wether or not the texture is blocking during loading.
  140194. */
  140195. set isBlocking(value: boolean);
  140196. /**
  140197. * Gets wether or not the texture is blocking during loading.
  140198. */
  140199. get isBlocking(): boolean;
  140200. protected _rotationY: number;
  140201. /**
  140202. * Sets texture matrix rotation angle around Y axis in radians.
  140203. */
  140204. set rotationY(value: number);
  140205. /**
  140206. * Gets texture matrix rotation angle around Y axis radians.
  140207. */
  140208. get rotationY(): number;
  140209. /**
  140210. * Gets or sets the center of the bounding box associated with the cube texture
  140211. * It must define where the camera used to render the texture was set
  140212. */
  140213. boundingBoxPosition: Vector3;
  140214. private _boundingBoxSize;
  140215. /**
  140216. * Gets or sets the size of the bounding box associated with the cube texture
  140217. * When defined, the cubemap will switch to local mode
  140218. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140219. * @example https://www.babylonjs-playground.com/#RNASML
  140220. */
  140221. set boundingBoxSize(value: Vector3);
  140222. get boundingBoxSize(): Vector3;
  140223. /**
  140224. * Instantiates an HDRTexture from the following parameters.
  140225. *
  140226. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140227. * @param sceneOrEngine The scene or engine the texture will be used in
  140228. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140229. * @param noMipmap Forces to not generate the mipmap if true
  140230. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140231. * @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)
  140232. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140233. */
  140234. 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>);
  140235. /**
  140236. * Get the current class name of the texture useful for serialization or dynamic coding.
  140237. * @returns "HDRCubeTexture"
  140238. */
  140239. getClassName(): string;
  140240. /**
  140241. * Occurs when the file is raw .hdr file.
  140242. */
  140243. private loadTexture;
  140244. clone(): HDRCubeTexture;
  140245. delayLoad(): void;
  140246. /**
  140247. * Get the texture reflection matrix used to rotate/transform the reflection.
  140248. * @returns the reflection matrix
  140249. */
  140250. getReflectionTextureMatrix(): Matrix;
  140251. /**
  140252. * Set the texture reflection matrix used to rotate/transform the reflection.
  140253. * @param value Define the reflection matrix to set
  140254. */
  140255. setReflectionTextureMatrix(value: Matrix): void;
  140256. /**
  140257. * Parses a JSON representation of an HDR Texture in order to create the texture
  140258. * @param parsedTexture Define the JSON representation
  140259. * @param scene Define the scene the texture should be created in
  140260. * @param rootUrl Define the root url in case we need to load relative dependencies
  140261. * @returns the newly created texture after parsing
  140262. */
  140263. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140264. serialize(): any;
  140265. }
  140266. }
  140267. declare module BABYLON {
  140268. /**
  140269. * Class used to control physics engine
  140270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140271. */
  140272. export class PhysicsEngine implements IPhysicsEngine {
  140273. private _physicsPlugin;
  140274. /**
  140275. * Global value used to control the smallest number supported by the simulation
  140276. */
  140277. static Epsilon: number;
  140278. private _impostors;
  140279. private _joints;
  140280. private _subTimeStep;
  140281. /**
  140282. * Gets the gravity vector used by the simulation
  140283. */
  140284. gravity: Vector3;
  140285. /**
  140286. * Factory used to create the default physics plugin.
  140287. * @returns The default physics plugin
  140288. */
  140289. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140290. /**
  140291. * Creates a new Physics Engine
  140292. * @param gravity defines the gravity vector used by the simulation
  140293. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140294. */
  140295. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140296. /**
  140297. * Sets the gravity vector used by the simulation
  140298. * @param gravity defines the gravity vector to use
  140299. */
  140300. setGravity(gravity: Vector3): void;
  140301. /**
  140302. * Set the time step of the physics engine.
  140303. * Default is 1/60.
  140304. * To slow it down, enter 1/600 for example.
  140305. * To speed it up, 1/30
  140306. * @param newTimeStep defines the new timestep to apply to this world.
  140307. */
  140308. setTimeStep(newTimeStep?: number): void;
  140309. /**
  140310. * Get the time step of the physics engine.
  140311. * @returns the current time step
  140312. */
  140313. getTimeStep(): number;
  140314. /**
  140315. * Set the sub time step of the physics engine.
  140316. * Default is 0 meaning there is no sub steps
  140317. * To increase physics resolution precision, set a small value (like 1 ms)
  140318. * @param subTimeStep defines the new sub timestep used for physics resolution.
  140319. */
  140320. setSubTimeStep(subTimeStep?: number): void;
  140321. /**
  140322. * Get the sub time step of the physics engine.
  140323. * @returns the current sub time step
  140324. */
  140325. getSubTimeStep(): number;
  140326. /**
  140327. * Release all resources
  140328. */
  140329. dispose(): void;
  140330. /**
  140331. * Gets the name of the current physics plugin
  140332. * @returns the name of the plugin
  140333. */
  140334. getPhysicsPluginName(): string;
  140335. /**
  140336. * Adding a new impostor for the impostor tracking.
  140337. * This will be done by the impostor itself.
  140338. * @param impostor the impostor to add
  140339. */
  140340. addImpostor(impostor: PhysicsImpostor): void;
  140341. /**
  140342. * Remove an impostor from the engine.
  140343. * This impostor and its mesh will not longer be updated by the physics engine.
  140344. * @param impostor the impostor to remove
  140345. */
  140346. removeImpostor(impostor: PhysicsImpostor): void;
  140347. /**
  140348. * Add a joint to the physics engine
  140349. * @param mainImpostor defines the main impostor to which the joint is added.
  140350. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140351. * @param joint defines the joint that will connect both impostors.
  140352. */
  140353. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140354. /**
  140355. * Removes a joint from the simulation
  140356. * @param mainImpostor defines the impostor used with the joint
  140357. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140358. * @param joint defines the joint to remove
  140359. */
  140360. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140361. /**
  140362. * Called by the scene. No need to call it.
  140363. * @param delta defines the timespam between frames
  140364. */
  140365. _step(delta: number): void;
  140366. /**
  140367. * Gets the current plugin used to run the simulation
  140368. * @returns current plugin
  140369. */
  140370. getPhysicsPlugin(): IPhysicsEnginePlugin;
  140371. /**
  140372. * Gets the list of physic impostors
  140373. * @returns an array of PhysicsImpostor
  140374. */
  140375. getImpostors(): Array<PhysicsImpostor>;
  140376. /**
  140377. * Gets the impostor for a physics enabled object
  140378. * @param object defines the object impersonated by the impostor
  140379. * @returns the PhysicsImpostor or null if not found
  140380. */
  140381. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  140382. /**
  140383. * Gets the impostor for a physics body object
  140384. * @param body defines physics body used by the impostor
  140385. * @returns the PhysicsImpostor or null if not found
  140386. */
  140387. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  140388. /**
  140389. * Does a raycast in the physics world
  140390. * @param from when should the ray start?
  140391. * @param to when should the ray end?
  140392. * @returns PhysicsRaycastResult
  140393. */
  140394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140395. }
  140396. }
  140397. declare module BABYLON {
  140398. /** @hidden */
  140399. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  140400. private _useDeltaForWorldStep;
  140401. world: any;
  140402. name: string;
  140403. private _physicsMaterials;
  140404. private _fixedTimeStep;
  140405. private _cannonRaycastResult;
  140406. private _raycastResult;
  140407. private _physicsBodysToRemoveAfterStep;
  140408. private _firstFrame;
  140409. BJSCANNON: any;
  140410. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  140411. setGravity(gravity: Vector3): void;
  140412. setTimeStep(timeStep: number): void;
  140413. getTimeStep(): number;
  140414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140415. private _removeMarkedPhysicsBodiesFromWorld;
  140416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140419. private _processChildMeshes;
  140420. removePhysicsBody(impostor: PhysicsImpostor): void;
  140421. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140422. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140423. private _addMaterial;
  140424. private _checkWithEpsilon;
  140425. private _createShape;
  140426. private _createHeightmap;
  140427. private _minus90X;
  140428. private _plus90X;
  140429. private _tmpPosition;
  140430. private _tmpDeltaPosition;
  140431. private _tmpUnityRotation;
  140432. private _updatePhysicsBodyTransformation;
  140433. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140434. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140435. isSupported(): boolean;
  140436. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140437. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140438. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140439. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140440. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140441. getBodyMass(impostor: PhysicsImpostor): number;
  140442. getBodyFriction(impostor: PhysicsImpostor): number;
  140443. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140444. getBodyRestitution(impostor: PhysicsImpostor): number;
  140445. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140446. sleepBody(impostor: PhysicsImpostor): void;
  140447. wakeUpBody(impostor: PhysicsImpostor): void;
  140448. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  140449. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140450. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140451. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140452. getRadius(impostor: PhysicsImpostor): number;
  140453. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140454. dispose(): void;
  140455. private _extendNamespace;
  140456. /**
  140457. * Does a raycast in the physics world
  140458. * @param from when should the ray start?
  140459. * @param to when should the ray end?
  140460. * @returns PhysicsRaycastResult
  140461. */
  140462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140463. }
  140464. }
  140465. declare module BABYLON {
  140466. /** @hidden */
  140467. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  140468. private _useDeltaForWorldStep;
  140469. world: any;
  140470. name: string;
  140471. BJSOIMO: any;
  140472. private _raycastResult;
  140473. private _fixedTimeStep;
  140474. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  140475. setGravity(gravity: Vector3): void;
  140476. setTimeStep(timeStep: number): void;
  140477. getTimeStep(): number;
  140478. private _tmpImpostorsArray;
  140479. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140480. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140481. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140482. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140483. private _tmpPositionVector;
  140484. removePhysicsBody(impostor: PhysicsImpostor): void;
  140485. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140486. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140487. isSupported(): boolean;
  140488. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140489. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140491. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140492. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140493. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140494. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140495. getBodyMass(impostor: PhysicsImpostor): number;
  140496. getBodyFriction(impostor: PhysicsImpostor): number;
  140497. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140498. getBodyRestitution(impostor: PhysicsImpostor): number;
  140499. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140500. sleepBody(impostor: PhysicsImpostor): void;
  140501. wakeUpBody(impostor: PhysicsImpostor): void;
  140502. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140503. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  140504. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  140505. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140506. getRadius(impostor: PhysicsImpostor): number;
  140507. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140508. dispose(): void;
  140509. /**
  140510. * Does a raycast in the physics world
  140511. * @param from when should the ray start?
  140512. * @param to when should the ray end?
  140513. * @returns PhysicsRaycastResult
  140514. */
  140515. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140516. }
  140517. }
  140518. declare module BABYLON {
  140519. /**
  140520. * AmmoJS Physics plugin
  140521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140522. * @see https://github.com/kripken/ammo.js/
  140523. */
  140524. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  140525. private _useDeltaForWorldStep;
  140526. /**
  140527. * Reference to the Ammo library
  140528. */
  140529. bjsAMMO: any;
  140530. /**
  140531. * Created ammoJS world which physics bodies are added to
  140532. */
  140533. world: any;
  140534. /**
  140535. * Name of the plugin
  140536. */
  140537. name: string;
  140538. private _timeStep;
  140539. private _fixedTimeStep;
  140540. private _maxSteps;
  140541. private _tmpQuaternion;
  140542. private _tmpAmmoTransform;
  140543. private _tmpAmmoQuaternion;
  140544. private _tmpAmmoConcreteContactResultCallback;
  140545. private _collisionConfiguration;
  140546. private _dispatcher;
  140547. private _overlappingPairCache;
  140548. private _solver;
  140549. private _softBodySolver;
  140550. private _tmpAmmoVectorA;
  140551. private _tmpAmmoVectorB;
  140552. private _tmpAmmoVectorC;
  140553. private _tmpAmmoVectorD;
  140554. private _tmpContactCallbackResult;
  140555. private _tmpAmmoVectorRCA;
  140556. private _tmpAmmoVectorRCB;
  140557. private _raycastResult;
  140558. private static readonly DISABLE_COLLISION_FLAG;
  140559. private static readonly KINEMATIC_FLAG;
  140560. private static readonly DISABLE_DEACTIVATION_FLAG;
  140561. /**
  140562. * Initializes the ammoJS plugin
  140563. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  140564. * @param ammoInjection can be used to inject your own ammo reference
  140565. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  140566. */
  140567. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  140568. /**
  140569. * Sets the gravity of the physics world (m/(s^2))
  140570. * @param gravity Gravity to set
  140571. */
  140572. setGravity(gravity: Vector3): void;
  140573. /**
  140574. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  140575. * @param timeStep timestep to use in seconds
  140576. */
  140577. setTimeStep(timeStep: number): void;
  140578. /**
  140579. * 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)
  140580. * @param fixedTimeStep fixedTimeStep to use in seconds
  140581. */
  140582. setFixedTimeStep(fixedTimeStep: number): void;
  140583. /**
  140584. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  140585. * @param maxSteps the maximum number of steps by the physics engine per frame
  140586. */
  140587. setMaxSteps(maxSteps: number): void;
  140588. /**
  140589. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  140590. * @returns the current timestep in seconds
  140591. */
  140592. getTimeStep(): number;
  140593. /**
  140594. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  140595. */
  140596. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  140597. private _isImpostorInContact;
  140598. private _isImpostorPairInContact;
  140599. private _stepSimulation;
  140600. /**
  140601. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  140602. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  140603. * After the step the babylon meshes are set to the position of the physics imposters
  140604. * @param delta amount of time to step forward
  140605. * @param impostors array of imposters to update before/after the step
  140606. */
  140607. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140608. /**
  140609. * Update babylon mesh to match physics world object
  140610. * @param impostor imposter to match
  140611. */
  140612. private _afterSoftStep;
  140613. /**
  140614. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140615. * @param impostor imposter to match
  140616. */
  140617. private _ropeStep;
  140618. /**
  140619. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140620. * @param impostor imposter to match
  140621. */
  140622. private _softbodyOrClothStep;
  140623. private _tmpMatrix;
  140624. /**
  140625. * Applies an impulse on the imposter
  140626. * @param impostor imposter to apply impulse to
  140627. * @param force amount of force to be applied to the imposter
  140628. * @param contactPoint the location to apply the impulse on the imposter
  140629. */
  140630. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140631. /**
  140632. * Applies a force on the imposter
  140633. * @param impostor imposter to apply force
  140634. * @param force amount of force to be applied to the imposter
  140635. * @param contactPoint the location to apply the force on the imposter
  140636. */
  140637. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140638. /**
  140639. * Creates a physics body using the plugin
  140640. * @param impostor the imposter to create the physics body on
  140641. */
  140642. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140643. /**
  140644. * Removes the physics body from the imposter and disposes of the body's memory
  140645. * @param impostor imposter to remove the physics body from
  140646. */
  140647. removePhysicsBody(impostor: PhysicsImpostor): void;
  140648. /**
  140649. * Generates a joint
  140650. * @param impostorJoint the imposter joint to create the joint with
  140651. */
  140652. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140653. /**
  140654. * Removes a joint
  140655. * @param impostorJoint the imposter joint to remove the joint from
  140656. */
  140657. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140658. private _addMeshVerts;
  140659. /**
  140660. * Initialise the soft body vertices to match its object's (mesh) vertices
  140661. * Softbody vertices (nodes) are in world space and to match this
  140662. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  140663. * @param impostor to create the softbody for
  140664. */
  140665. private _softVertexData;
  140666. /**
  140667. * Create an impostor's soft body
  140668. * @param impostor to create the softbody for
  140669. */
  140670. private _createSoftbody;
  140671. /**
  140672. * Create cloth for an impostor
  140673. * @param impostor to create the softbody for
  140674. */
  140675. private _createCloth;
  140676. /**
  140677. * Create rope for an impostor
  140678. * @param impostor to create the softbody for
  140679. */
  140680. private _createRope;
  140681. /**
  140682. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  140683. * @param impostor to create the custom physics shape for
  140684. */
  140685. private _createCustom;
  140686. private _addHullVerts;
  140687. private _createShape;
  140688. /**
  140689. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  140690. * @param impostor imposter containing the physics body and babylon object
  140691. */
  140692. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140693. /**
  140694. * Sets the babylon object's position/rotation from the physics body's position/rotation
  140695. * @param impostor imposter containing the physics body and babylon object
  140696. * @param newPosition new position
  140697. * @param newRotation new rotation
  140698. */
  140699. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140700. /**
  140701. * If this plugin is supported
  140702. * @returns true if its supported
  140703. */
  140704. isSupported(): boolean;
  140705. /**
  140706. * Sets the linear velocity of the physics body
  140707. * @param impostor imposter to set the velocity on
  140708. * @param velocity velocity to set
  140709. */
  140710. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140711. /**
  140712. * Sets the angular velocity of the physics body
  140713. * @param impostor imposter to set the velocity on
  140714. * @param velocity velocity to set
  140715. */
  140716. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140717. /**
  140718. * gets the linear velocity
  140719. * @param impostor imposter to get linear velocity from
  140720. * @returns linear velocity
  140721. */
  140722. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140723. /**
  140724. * gets the angular velocity
  140725. * @param impostor imposter to get angular velocity from
  140726. * @returns angular velocity
  140727. */
  140728. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140729. /**
  140730. * Sets the mass of physics body
  140731. * @param impostor imposter to set the mass on
  140732. * @param mass mass to set
  140733. */
  140734. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140735. /**
  140736. * Gets the mass of the physics body
  140737. * @param impostor imposter to get the mass from
  140738. * @returns mass
  140739. */
  140740. getBodyMass(impostor: PhysicsImpostor): number;
  140741. /**
  140742. * Gets friction of the impostor
  140743. * @param impostor impostor to get friction from
  140744. * @returns friction value
  140745. */
  140746. getBodyFriction(impostor: PhysicsImpostor): number;
  140747. /**
  140748. * Sets friction of the impostor
  140749. * @param impostor impostor to set friction on
  140750. * @param friction friction value
  140751. */
  140752. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140753. /**
  140754. * Gets restitution of the impostor
  140755. * @param impostor impostor to get restitution from
  140756. * @returns restitution value
  140757. */
  140758. getBodyRestitution(impostor: PhysicsImpostor): number;
  140759. /**
  140760. * Sets resitution of the impostor
  140761. * @param impostor impostor to set resitution on
  140762. * @param restitution resitution value
  140763. */
  140764. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140765. /**
  140766. * Gets pressure inside the impostor
  140767. * @param impostor impostor to get pressure from
  140768. * @returns pressure value
  140769. */
  140770. getBodyPressure(impostor: PhysicsImpostor): number;
  140771. /**
  140772. * Sets pressure inside a soft body impostor
  140773. * Cloth and rope must remain 0 pressure
  140774. * @param impostor impostor to set pressure on
  140775. * @param pressure pressure value
  140776. */
  140777. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  140778. /**
  140779. * Gets stiffness of the impostor
  140780. * @param impostor impostor to get stiffness from
  140781. * @returns pressure value
  140782. */
  140783. getBodyStiffness(impostor: PhysicsImpostor): number;
  140784. /**
  140785. * Sets stiffness of the impostor
  140786. * @param impostor impostor to set stiffness on
  140787. * @param stiffness stiffness value from 0 to 1
  140788. */
  140789. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  140790. /**
  140791. * Gets velocityIterations of the impostor
  140792. * @param impostor impostor to get velocity iterations from
  140793. * @returns velocityIterations value
  140794. */
  140795. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  140796. /**
  140797. * Sets velocityIterations of the impostor
  140798. * @param impostor impostor to set velocity iterations on
  140799. * @param velocityIterations velocityIterations value
  140800. */
  140801. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  140802. /**
  140803. * Gets positionIterations of the impostor
  140804. * @param impostor impostor to get position iterations from
  140805. * @returns positionIterations value
  140806. */
  140807. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  140808. /**
  140809. * Sets positionIterations of the impostor
  140810. * @param impostor impostor to set position on
  140811. * @param positionIterations positionIterations value
  140812. */
  140813. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  140814. /**
  140815. * Append an anchor to a cloth object
  140816. * @param impostor is the cloth impostor to add anchor to
  140817. * @param otherImpostor is the rigid impostor to anchor to
  140818. * @param width ratio across width from 0 to 1
  140819. * @param height ratio up height from 0 to 1
  140820. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  140821. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140822. */
  140823. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140824. /**
  140825. * Append an hook to a rope object
  140826. * @param impostor is the rope impostor to add hook to
  140827. * @param otherImpostor is the rigid impostor to hook to
  140828. * @param length ratio along the rope from 0 to 1
  140829. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  140830. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140831. */
  140832. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140833. /**
  140834. * Sleeps the physics body and stops it from being active
  140835. * @param impostor impostor to sleep
  140836. */
  140837. sleepBody(impostor: PhysicsImpostor): void;
  140838. /**
  140839. * Activates the physics body
  140840. * @param impostor impostor to activate
  140841. */
  140842. wakeUpBody(impostor: PhysicsImpostor): void;
  140843. /**
  140844. * Updates the distance parameters of the joint
  140845. * @param joint joint to update
  140846. * @param maxDistance maximum distance of the joint
  140847. * @param minDistance minimum distance of the joint
  140848. */
  140849. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140850. /**
  140851. * Sets a motor on the joint
  140852. * @param joint joint to set motor on
  140853. * @param speed speed of the motor
  140854. * @param maxForce maximum force of the motor
  140855. * @param motorIndex index of the motor
  140856. */
  140857. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140858. /**
  140859. * Sets the motors limit
  140860. * @param joint joint to set limit on
  140861. * @param upperLimit upper limit
  140862. * @param lowerLimit lower limit
  140863. */
  140864. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140865. /**
  140866. * Syncs the position and rotation of a mesh with the impostor
  140867. * @param mesh mesh to sync
  140868. * @param impostor impostor to update the mesh with
  140869. */
  140870. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140871. /**
  140872. * Gets the radius of the impostor
  140873. * @param impostor impostor to get radius from
  140874. * @returns the radius
  140875. */
  140876. getRadius(impostor: PhysicsImpostor): number;
  140877. /**
  140878. * Gets the box size of the impostor
  140879. * @param impostor impostor to get box size from
  140880. * @param result the resulting box size
  140881. */
  140882. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140883. /**
  140884. * Disposes of the impostor
  140885. */
  140886. dispose(): void;
  140887. /**
  140888. * Does a raycast in the physics world
  140889. * @param from when should the ray start?
  140890. * @param to when should the ray end?
  140891. * @returns PhysicsRaycastResult
  140892. */
  140893. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140894. }
  140895. }
  140896. declare module BABYLON {
  140897. interface AbstractScene {
  140898. /**
  140899. * The list of reflection probes added to the scene
  140900. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140901. */
  140902. reflectionProbes: Array<ReflectionProbe>;
  140903. /**
  140904. * Removes the given reflection probe from this scene.
  140905. * @param toRemove The reflection probe to remove
  140906. * @returns The index of the removed reflection probe
  140907. */
  140908. removeReflectionProbe(toRemove: ReflectionProbe): number;
  140909. /**
  140910. * Adds the given reflection probe to this scene.
  140911. * @param newReflectionProbe The reflection probe to add
  140912. */
  140913. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  140914. }
  140915. /**
  140916. * Class used to generate realtime reflection / refraction cube textures
  140917. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140918. */
  140919. export class ReflectionProbe {
  140920. /** defines the name of the probe */
  140921. name: string;
  140922. private _scene;
  140923. private _renderTargetTexture;
  140924. private _projectionMatrix;
  140925. private _viewMatrix;
  140926. private _target;
  140927. private _add;
  140928. private _attachedMesh;
  140929. private _invertYAxis;
  140930. /** Gets or sets probe position (center of the cube map) */
  140931. position: Vector3;
  140932. /**
  140933. * Creates a new reflection probe
  140934. * @param name defines the name of the probe
  140935. * @param size defines the texture resolution (for each face)
  140936. * @param scene defines the hosting scene
  140937. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  140938. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  140939. */
  140940. constructor(
  140941. /** defines the name of the probe */
  140942. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  140943. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  140944. get samples(): number;
  140945. set samples(value: number);
  140946. /** Gets or sets the refresh rate to use (on every frame by default) */
  140947. get refreshRate(): number;
  140948. set refreshRate(value: number);
  140949. /**
  140950. * Gets the hosting scene
  140951. * @returns a Scene
  140952. */
  140953. getScene(): Scene;
  140954. /** Gets the internal CubeTexture used to render to */
  140955. get cubeTexture(): RenderTargetTexture;
  140956. /** Gets the list of meshes to render */
  140957. get renderList(): Nullable<AbstractMesh[]>;
  140958. /**
  140959. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  140960. * @param mesh defines the mesh to attach to
  140961. */
  140962. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  140963. /**
  140964. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  140965. * @param renderingGroupId The rendering group id corresponding to its index
  140966. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  140967. */
  140968. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  140969. /**
  140970. * Clean all associated resources
  140971. */
  140972. dispose(): void;
  140973. /**
  140974. * Converts the reflection probe information to a readable string for debug purpose.
  140975. * @param fullDetails Supports for multiple levels of logging within scene loading
  140976. * @returns the human readable reflection probe info
  140977. */
  140978. toString(fullDetails?: boolean): string;
  140979. /**
  140980. * Get the class name of the relfection probe.
  140981. * @returns "ReflectionProbe"
  140982. */
  140983. getClassName(): string;
  140984. /**
  140985. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  140986. * @returns The JSON representation of the texture
  140987. */
  140988. serialize(): any;
  140989. /**
  140990. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  140991. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  140992. * @param scene Define the scene the parsed reflection probe should be instantiated in
  140993. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  140994. * @returns The parsed reflection probe if successful
  140995. */
  140996. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  140997. }
  140998. }
  140999. declare module BABYLON {
  141000. /** @hidden */
  141001. export var _BabylonLoaderRegistered: boolean;
  141002. /**
  141003. * Helps setting up some configuration for the babylon file loader.
  141004. */
  141005. export class BabylonFileLoaderConfiguration {
  141006. /**
  141007. * The loader does not allow injecting custom physix engine into the plugins.
  141008. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141009. * So you could set this variable to your engine import to make it work.
  141010. */
  141011. static LoaderInjectedPhysicsEngine: any;
  141012. }
  141013. }
  141014. declare module BABYLON {
  141015. /**
  141016. * The Physically based simple base material of BJS.
  141017. *
  141018. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141019. * It is used as the base class for both the specGloss and metalRough conventions.
  141020. */
  141021. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141022. /**
  141023. * Number of Simultaneous lights allowed on the material.
  141024. */
  141025. maxSimultaneousLights: number;
  141026. /**
  141027. * If sets to true, disables all the lights affecting the material.
  141028. */
  141029. disableLighting: boolean;
  141030. /**
  141031. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141032. */
  141033. environmentTexture: BaseTexture;
  141034. /**
  141035. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141036. */
  141037. invertNormalMapX: boolean;
  141038. /**
  141039. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141040. */
  141041. invertNormalMapY: boolean;
  141042. /**
  141043. * Normal map used in the model.
  141044. */
  141045. normalTexture: BaseTexture;
  141046. /**
  141047. * Emissivie color used to self-illuminate the model.
  141048. */
  141049. emissiveColor: Color3;
  141050. /**
  141051. * Emissivie texture used to self-illuminate the model.
  141052. */
  141053. emissiveTexture: BaseTexture;
  141054. /**
  141055. * Occlusion Channel Strenght.
  141056. */
  141057. occlusionStrength: number;
  141058. /**
  141059. * Occlusion Texture of the material (adding extra occlusion effects).
  141060. */
  141061. occlusionTexture: BaseTexture;
  141062. /**
  141063. * Defines the alpha limits in alpha test mode.
  141064. */
  141065. alphaCutOff: number;
  141066. /**
  141067. * Gets the current double sided mode.
  141068. */
  141069. get doubleSided(): boolean;
  141070. /**
  141071. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141072. */
  141073. set doubleSided(value: boolean);
  141074. /**
  141075. * Stores the pre-calculated light information of a mesh in a texture.
  141076. */
  141077. lightmapTexture: BaseTexture;
  141078. /**
  141079. * If true, the light map contains occlusion information instead of lighting info.
  141080. */
  141081. useLightmapAsShadowmap: boolean;
  141082. /**
  141083. * Instantiates a new PBRMaterial instance.
  141084. *
  141085. * @param name The material name
  141086. * @param scene The scene the material will be use in.
  141087. */
  141088. constructor(name: string, scene: Scene);
  141089. getClassName(): string;
  141090. }
  141091. }
  141092. declare module BABYLON {
  141093. /**
  141094. * The PBR material of BJS following the metal roughness convention.
  141095. *
  141096. * This fits to the PBR convention in the GLTF definition:
  141097. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141098. */
  141099. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141100. /**
  141101. * The base color has two different interpretations depending on the value of metalness.
  141102. * When the material is a metal, the base color is the specific measured reflectance value
  141103. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141104. * of the material.
  141105. */
  141106. baseColor: Color3;
  141107. /**
  141108. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141109. * well as opacity information in the alpha channel.
  141110. */
  141111. baseTexture: BaseTexture;
  141112. /**
  141113. * Specifies the metallic scalar value of the material.
  141114. * Can also be used to scale the metalness values of the metallic texture.
  141115. */
  141116. metallic: number;
  141117. /**
  141118. * Specifies the roughness scalar value of the material.
  141119. * Can also be used to scale the roughness values of the metallic texture.
  141120. */
  141121. roughness: number;
  141122. /**
  141123. * Texture containing both the metallic value in the B channel and the
  141124. * roughness value in the G channel to keep better precision.
  141125. */
  141126. metallicRoughnessTexture: BaseTexture;
  141127. /**
  141128. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141129. *
  141130. * @param name The material name
  141131. * @param scene The scene the material will be use in.
  141132. */
  141133. constructor(name: string, scene: Scene);
  141134. /**
  141135. * Return the currrent class name of the material.
  141136. */
  141137. getClassName(): string;
  141138. /**
  141139. * Makes a duplicate of the current material.
  141140. * @param name - name to use for the new material.
  141141. */
  141142. clone(name: string): PBRMetallicRoughnessMaterial;
  141143. /**
  141144. * Serialize the material to a parsable JSON object.
  141145. */
  141146. serialize(): any;
  141147. /**
  141148. * Parses a JSON object correponding to the serialize function.
  141149. */
  141150. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141151. }
  141152. }
  141153. declare module BABYLON {
  141154. /**
  141155. * The PBR material of BJS following the specular glossiness convention.
  141156. *
  141157. * This fits to the PBR convention in the GLTF definition:
  141158. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141159. */
  141160. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141161. /**
  141162. * Specifies the diffuse color of the material.
  141163. */
  141164. diffuseColor: Color3;
  141165. /**
  141166. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141167. * channel.
  141168. */
  141169. diffuseTexture: BaseTexture;
  141170. /**
  141171. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141172. */
  141173. specularColor: Color3;
  141174. /**
  141175. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141176. */
  141177. glossiness: number;
  141178. /**
  141179. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141180. */
  141181. specularGlossinessTexture: BaseTexture;
  141182. /**
  141183. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141184. *
  141185. * @param name The material name
  141186. * @param scene The scene the material will be use in.
  141187. */
  141188. constructor(name: string, scene: Scene);
  141189. /**
  141190. * Return the currrent class name of the material.
  141191. */
  141192. getClassName(): string;
  141193. /**
  141194. * Makes a duplicate of the current material.
  141195. * @param name - name to use for the new material.
  141196. */
  141197. clone(name: string): PBRSpecularGlossinessMaterial;
  141198. /**
  141199. * Serialize the material to a parsable JSON object.
  141200. */
  141201. serialize(): any;
  141202. /**
  141203. * Parses a JSON object correponding to the serialize function.
  141204. */
  141205. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141206. }
  141207. }
  141208. declare module BABYLON {
  141209. /**
  141210. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141211. * It can help converting any input color in a desired output one. This can then be used to create effects
  141212. * from sepia, black and white to sixties or futuristic rendering...
  141213. *
  141214. * The only supported format is currently 3dl.
  141215. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141216. */
  141217. export class ColorGradingTexture extends BaseTexture {
  141218. /**
  141219. * The texture URL.
  141220. */
  141221. url: string;
  141222. /**
  141223. * Empty line regex stored for GC.
  141224. */
  141225. private static _noneEmptyLineRegex;
  141226. private _textureMatrix;
  141227. private _onLoad;
  141228. /**
  141229. * Instantiates a ColorGradingTexture from the following parameters.
  141230. *
  141231. * @param url The location of the color gradind data (currently only supporting 3dl)
  141232. * @param sceneOrEngine The scene or engine the texture will be used in
  141233. * @param onLoad defines a callback triggered when the texture has been loaded
  141234. */
  141235. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141236. /**
  141237. * Fires the onload event from the constructor if requested.
  141238. */
  141239. private _triggerOnLoad;
  141240. /**
  141241. * Returns the texture matrix used in most of the material.
  141242. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141243. */
  141244. getTextureMatrix(): Matrix;
  141245. /**
  141246. * Occurs when the file being loaded is a .3dl LUT file.
  141247. */
  141248. private load3dlTexture;
  141249. /**
  141250. * Starts the loading process of the texture.
  141251. */
  141252. private loadTexture;
  141253. /**
  141254. * Clones the color gradind texture.
  141255. */
  141256. clone(): ColorGradingTexture;
  141257. /**
  141258. * Called during delayed load for textures.
  141259. */
  141260. delayLoad(): void;
  141261. /**
  141262. * Parses a color grading texture serialized by Babylon.
  141263. * @param parsedTexture The texture information being parsedTexture
  141264. * @param scene The scene to load the texture in
  141265. * @param rootUrl The root url of the data assets to load
  141266. * @return A color gradind texture
  141267. */
  141268. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141269. /**
  141270. * Serializes the LUT texture to json format.
  141271. */
  141272. serialize(): any;
  141273. }
  141274. }
  141275. declare module BABYLON {
  141276. /**
  141277. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141278. */
  141279. export class EquiRectangularCubeTexture extends BaseTexture {
  141280. /** The six faces of the cube. */
  141281. private static _FacesMapping;
  141282. private _noMipmap;
  141283. private _onLoad;
  141284. private _onError;
  141285. /** The size of the cubemap. */
  141286. private _size;
  141287. /** The buffer of the image. */
  141288. private _buffer;
  141289. /** The width of the input image. */
  141290. private _width;
  141291. /** The height of the input image. */
  141292. private _height;
  141293. /** The URL to the image. */
  141294. url: string;
  141295. /**
  141296. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141297. * @param url The location of the image
  141298. * @param scene The scene the texture will be used in
  141299. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141300. * @param noMipmap Forces to not generate the mipmap if true
  141301. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141302. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141303. * @param onLoad — defines a callback called when texture is loaded
  141304. * @param onError — defines a callback called if there is an error
  141305. */
  141306. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141307. /**
  141308. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141309. */
  141310. private loadImage;
  141311. /**
  141312. * Convert the image buffer into a cubemap and create a CubeTexture.
  141313. */
  141314. private loadTexture;
  141315. /**
  141316. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  141317. * @param buffer The ArrayBuffer that should be converted.
  141318. * @returns The buffer as Float32Array.
  141319. */
  141320. private getFloat32ArrayFromArrayBuffer;
  141321. /**
  141322. * Get the current class name of the texture useful for serialization or dynamic coding.
  141323. * @returns "EquiRectangularCubeTexture"
  141324. */
  141325. getClassName(): string;
  141326. /**
  141327. * Create a clone of the current EquiRectangularCubeTexture and return it.
  141328. * @returns A clone of the current EquiRectangularCubeTexture.
  141329. */
  141330. clone(): EquiRectangularCubeTexture;
  141331. }
  141332. }
  141333. declare module BABYLON {
  141334. /**
  141335. * Defines the options related to the creation of an HtmlElementTexture
  141336. */
  141337. export interface IHtmlElementTextureOptions {
  141338. /**
  141339. * Defines wether mip maps should be created or not.
  141340. */
  141341. generateMipMaps?: boolean;
  141342. /**
  141343. * Defines the sampling mode of the texture.
  141344. */
  141345. samplingMode?: number;
  141346. /**
  141347. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141348. */
  141349. engine: Nullable<ThinEngine>;
  141350. /**
  141351. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141352. */
  141353. scene: Nullable<Scene>;
  141354. }
  141355. /**
  141356. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141357. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141358. * is automatically managed.
  141359. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141360. * in your application.
  141361. *
  141362. * As the update is not automatic, you need to call them manually.
  141363. */
  141364. export class HtmlElementTexture extends BaseTexture {
  141365. /**
  141366. * The texture URL.
  141367. */
  141368. element: HTMLVideoElement | HTMLCanvasElement;
  141369. private static readonly DefaultOptions;
  141370. private _textureMatrix;
  141371. private _isVideo;
  141372. private _generateMipMaps;
  141373. private _samplingMode;
  141374. /**
  141375. * Instantiates a HtmlElementTexture from the following parameters.
  141376. *
  141377. * @param name Defines the name of the texture
  141378. * @param element Defines the video or canvas the texture is filled with
  141379. * @param options Defines the other none mandatory texture creation options
  141380. */
  141381. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  141382. private _createInternalTexture;
  141383. /**
  141384. * Returns the texture matrix used in most of the material.
  141385. */
  141386. getTextureMatrix(): Matrix;
  141387. /**
  141388. * Updates the content of the texture.
  141389. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  141390. */
  141391. update(invertY?: Nullable<boolean>): void;
  141392. }
  141393. }
  141394. declare module BABYLON {
  141395. /**
  141396. * Based on jsTGALoader - Javascript loader for TGA file
  141397. * By Vincent Thibault
  141398. * @see http://blog.robrowser.com/javascript-tga-loader.html
  141399. */
  141400. export class TGATools {
  141401. private static _TYPE_INDEXED;
  141402. private static _TYPE_RGB;
  141403. private static _TYPE_GREY;
  141404. private static _TYPE_RLE_INDEXED;
  141405. private static _TYPE_RLE_RGB;
  141406. private static _TYPE_RLE_GREY;
  141407. private static _ORIGIN_MASK;
  141408. private static _ORIGIN_SHIFT;
  141409. private static _ORIGIN_BL;
  141410. private static _ORIGIN_BR;
  141411. private static _ORIGIN_UL;
  141412. private static _ORIGIN_UR;
  141413. /**
  141414. * Gets the header of a TGA file
  141415. * @param data defines the TGA data
  141416. * @returns the header
  141417. */
  141418. static GetTGAHeader(data: Uint8Array): any;
  141419. /**
  141420. * Uploads TGA content to a Babylon Texture
  141421. * @hidden
  141422. */
  141423. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  141424. /** @hidden */
  141425. 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;
  141426. /** @hidden */
  141427. 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;
  141428. /** @hidden */
  141429. 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;
  141430. /** @hidden */
  141431. 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;
  141432. /** @hidden */
  141433. 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;
  141434. /** @hidden */
  141435. 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;
  141436. }
  141437. }
  141438. declare module BABYLON {
  141439. /**
  141440. * Implementation of the TGA Texture Loader.
  141441. * @hidden
  141442. */
  141443. export class _TGATextureLoader implements IInternalTextureLoader {
  141444. /**
  141445. * Defines wether the loader supports cascade loading the different faces.
  141446. */
  141447. readonly supportCascades: boolean;
  141448. /**
  141449. * This returns if the loader support the current file information.
  141450. * @param extension defines the file extension of the file being loaded
  141451. * @returns true if the loader can load the specified file
  141452. */
  141453. canLoad(extension: string): boolean;
  141454. /**
  141455. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141456. * @param data contains the texture data
  141457. * @param texture defines the BabylonJS internal texture
  141458. * @param createPolynomials will be true if polynomials have been requested
  141459. * @param onLoad defines the callback to trigger once the texture is ready
  141460. * @param onError defines the callback to trigger in case of error
  141461. */
  141462. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141463. /**
  141464. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141465. * @param data contains the texture data
  141466. * @param texture defines the BabylonJS internal texture
  141467. * @param callback defines the method to call once ready to upload
  141468. */
  141469. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141470. }
  141471. }
  141472. declare module BABYLON {
  141473. /**
  141474. * Info about the .basis files
  141475. */
  141476. class BasisFileInfo {
  141477. /**
  141478. * If the file has alpha
  141479. */
  141480. hasAlpha: boolean;
  141481. /**
  141482. * Info about each image of the basis file
  141483. */
  141484. images: Array<{
  141485. levels: Array<{
  141486. width: number;
  141487. height: number;
  141488. transcodedPixels: ArrayBufferView;
  141489. }>;
  141490. }>;
  141491. }
  141492. /**
  141493. * Result of transcoding a basis file
  141494. */
  141495. class TranscodeResult {
  141496. /**
  141497. * Info about the .basis file
  141498. */
  141499. fileInfo: BasisFileInfo;
  141500. /**
  141501. * Format to use when loading the file
  141502. */
  141503. format: number;
  141504. }
  141505. /**
  141506. * Configuration options for the Basis transcoder
  141507. */
  141508. export class BasisTranscodeConfiguration {
  141509. /**
  141510. * Supported compression formats used to determine the supported output format of the transcoder
  141511. */
  141512. supportedCompressionFormats?: {
  141513. /**
  141514. * etc1 compression format
  141515. */
  141516. etc1?: boolean;
  141517. /**
  141518. * s3tc compression format
  141519. */
  141520. s3tc?: boolean;
  141521. /**
  141522. * pvrtc compression format
  141523. */
  141524. pvrtc?: boolean;
  141525. /**
  141526. * etc2 compression format
  141527. */
  141528. etc2?: boolean;
  141529. };
  141530. /**
  141531. * If mipmap levels should be loaded for transcoded images (Default: true)
  141532. */
  141533. loadMipmapLevels?: boolean;
  141534. /**
  141535. * Index of a single image to load (Default: all images)
  141536. */
  141537. loadSingleImage?: number;
  141538. }
  141539. /**
  141540. * Used to load .Basis files
  141541. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  141542. */
  141543. export class BasisTools {
  141544. private static _IgnoreSupportedFormats;
  141545. /**
  141546. * URL to use when loading the basis transcoder
  141547. */
  141548. static JSModuleURL: string;
  141549. /**
  141550. * URL to use when loading the wasm module for the transcoder
  141551. */
  141552. static WasmModuleURL: string;
  141553. /**
  141554. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  141555. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  141556. * @returns internal format corresponding to the Basis format
  141557. */
  141558. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  141559. private static _WorkerPromise;
  141560. private static _Worker;
  141561. private static _actionId;
  141562. private static _CreateWorkerAsync;
  141563. /**
  141564. * Transcodes a loaded image file to compressed pixel data
  141565. * @param data image data to transcode
  141566. * @param config configuration options for the transcoding
  141567. * @returns a promise resulting in the transcoded image
  141568. */
  141569. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  141570. /**
  141571. * Loads a texture from the transcode result
  141572. * @param texture texture load to
  141573. * @param transcodeResult the result of transcoding the basis file to load from
  141574. */
  141575. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  141576. }
  141577. }
  141578. declare module BABYLON {
  141579. /**
  141580. * Loader for .basis file format
  141581. */
  141582. export class _BasisTextureLoader implements IInternalTextureLoader {
  141583. /**
  141584. * Defines whether the loader supports cascade loading the different faces.
  141585. */
  141586. readonly supportCascades: boolean;
  141587. /**
  141588. * This returns if the loader support the current file information.
  141589. * @param extension defines the file extension of the file being loaded
  141590. * @returns true if the loader can load the specified file
  141591. */
  141592. canLoad(extension: string): boolean;
  141593. /**
  141594. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141595. * @param data contains the texture data
  141596. * @param texture defines the BabylonJS internal texture
  141597. * @param createPolynomials will be true if polynomials have been requested
  141598. * @param onLoad defines the callback to trigger once the texture is ready
  141599. * @param onError defines the callback to trigger in case of error
  141600. */
  141601. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141602. /**
  141603. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141604. * @param data contains the texture data
  141605. * @param texture defines the BabylonJS internal texture
  141606. * @param callback defines the method to call once ready to upload
  141607. */
  141608. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141609. }
  141610. }
  141611. declare module BABYLON {
  141612. /**
  141613. * Defines the basic options interface of a TexturePacker Frame
  141614. */
  141615. export interface ITexturePackerFrame {
  141616. /**
  141617. * The frame ID
  141618. */
  141619. id: number;
  141620. /**
  141621. * The frames Scale
  141622. */
  141623. scale: Vector2;
  141624. /**
  141625. * The Frames offset
  141626. */
  141627. offset: Vector2;
  141628. }
  141629. /**
  141630. * This is a support class for frame Data on texture packer sets.
  141631. */
  141632. export class TexturePackerFrame implements ITexturePackerFrame {
  141633. /**
  141634. * The frame ID
  141635. */
  141636. id: number;
  141637. /**
  141638. * The frames Scale
  141639. */
  141640. scale: Vector2;
  141641. /**
  141642. * The Frames offset
  141643. */
  141644. offset: Vector2;
  141645. /**
  141646. * Initializes a texture package frame.
  141647. * @param id The numerical frame identifier
  141648. * @param scale Scalar Vector2 for UV frame
  141649. * @param offset Vector2 for the frame position in UV units.
  141650. * @returns TexturePackerFrame
  141651. */
  141652. constructor(id: number, scale: Vector2, offset: Vector2);
  141653. }
  141654. }
  141655. declare module BABYLON {
  141656. /**
  141657. * Defines the basic options interface of a TexturePacker
  141658. */
  141659. export interface ITexturePackerOptions {
  141660. /**
  141661. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  141662. */
  141663. map?: string[];
  141664. /**
  141665. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141666. */
  141667. uvsIn?: string;
  141668. /**
  141669. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141670. */
  141671. uvsOut?: string;
  141672. /**
  141673. * number representing the layout style. Defaults to LAYOUT_STRIP
  141674. */
  141675. layout?: number;
  141676. /**
  141677. * number of columns if using custom column count layout(2). This defaults to 4.
  141678. */
  141679. colnum?: number;
  141680. /**
  141681. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  141682. */
  141683. updateInputMeshes?: boolean;
  141684. /**
  141685. * boolean flag to dispose all the source textures. Defaults to true.
  141686. */
  141687. disposeSources?: boolean;
  141688. /**
  141689. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  141690. */
  141691. fillBlanks?: boolean;
  141692. /**
  141693. * string value representing the context fill style color. Defaults to 'black'.
  141694. */
  141695. customFillColor?: string;
  141696. /**
  141697. * Width and Height Value of each Frame in the TexturePacker Sets
  141698. */
  141699. frameSize?: number;
  141700. /**
  141701. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  141702. */
  141703. paddingRatio?: number;
  141704. /**
  141705. * Number that declares the fill method for the padding gutter.
  141706. */
  141707. paddingMode?: number;
  141708. /**
  141709. * If in SUBUV_COLOR padding mode what color to use.
  141710. */
  141711. paddingColor?: Color3 | Color4;
  141712. }
  141713. /**
  141714. * Defines the basic interface of a TexturePacker JSON File
  141715. */
  141716. export interface ITexturePackerJSON {
  141717. /**
  141718. * The frame ID
  141719. */
  141720. name: string;
  141721. /**
  141722. * The base64 channel data
  141723. */
  141724. sets: any;
  141725. /**
  141726. * The options of the Packer
  141727. */
  141728. options: ITexturePackerOptions;
  141729. /**
  141730. * The frame data of the Packer
  141731. */
  141732. frames: Array<number>;
  141733. }
  141734. /**
  141735. * This is a support class that generates a series of packed texture sets.
  141736. * @see https://doc.babylonjs.com/babylon101/materials
  141737. */
  141738. export class TexturePacker {
  141739. /** Packer Layout Constant 0 */
  141740. static readonly LAYOUT_STRIP: number;
  141741. /** Packer Layout Constant 1 */
  141742. static readonly LAYOUT_POWER2: number;
  141743. /** Packer Layout Constant 2 */
  141744. static readonly LAYOUT_COLNUM: number;
  141745. /** Packer Layout Constant 0 */
  141746. static readonly SUBUV_WRAP: number;
  141747. /** Packer Layout Constant 1 */
  141748. static readonly SUBUV_EXTEND: number;
  141749. /** Packer Layout Constant 2 */
  141750. static readonly SUBUV_COLOR: number;
  141751. /** The Name of the Texture Package */
  141752. name: string;
  141753. /** The scene scope of the TexturePacker */
  141754. scene: Scene;
  141755. /** The Meshes to target */
  141756. meshes: AbstractMesh[];
  141757. /** Arguments passed with the Constructor */
  141758. options: ITexturePackerOptions;
  141759. /** The promise that is started upon initialization */
  141760. promise: Nullable<Promise<TexturePacker | string>>;
  141761. /** The Container object for the channel sets that are generated */
  141762. sets: object;
  141763. /** The Container array for the frames that are generated */
  141764. frames: TexturePackerFrame[];
  141765. /** The expected number of textures the system is parsing. */
  141766. private _expecting;
  141767. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  141768. private _paddingValue;
  141769. /**
  141770. * Initializes a texture package series from an array of meshes or a single mesh.
  141771. * @param name The name of the package
  141772. * @param meshes The target meshes to compose the package from
  141773. * @param options The arguments that texture packer should follow while building.
  141774. * @param scene The scene which the textures are scoped to.
  141775. * @returns TexturePacker
  141776. */
  141777. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  141778. /**
  141779. * Starts the package process
  141780. * @param resolve The promises resolution function
  141781. * @returns TexturePacker
  141782. */
  141783. private _createFrames;
  141784. /**
  141785. * Calculates the Size of the Channel Sets
  141786. * @returns Vector2
  141787. */
  141788. private _calculateSize;
  141789. /**
  141790. * Calculates the UV data for the frames.
  141791. * @param baseSize the base frameSize
  141792. * @param padding the base frame padding
  141793. * @param dtSize size of the Dynamic Texture for that channel
  141794. * @param dtUnits is 1/dtSize
  141795. * @param update flag to update the input meshes
  141796. */
  141797. private _calculateMeshUVFrames;
  141798. /**
  141799. * Calculates the frames Offset.
  141800. * @param index of the frame
  141801. * @returns Vector2
  141802. */
  141803. private _getFrameOffset;
  141804. /**
  141805. * Updates a Mesh to the frame data
  141806. * @param mesh that is the target
  141807. * @param frameID or the frame index
  141808. */
  141809. private _updateMeshUV;
  141810. /**
  141811. * Updates a Meshes materials to use the texture packer channels
  141812. * @param m is the mesh to target
  141813. * @param force all channels on the packer to be set.
  141814. */
  141815. private _updateTextureReferences;
  141816. /**
  141817. * Public method to set a Mesh to a frame
  141818. * @param m that is the target
  141819. * @param frameID or the frame index
  141820. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  141821. */
  141822. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  141823. /**
  141824. * Starts the async promise to compile the texture packer.
  141825. * @returns Promise<void>
  141826. */
  141827. processAsync(): Promise<void>;
  141828. /**
  141829. * Disposes all textures associated with this packer
  141830. */
  141831. dispose(): void;
  141832. /**
  141833. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  141834. * @param imageType is the image type to use.
  141835. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  141836. */
  141837. download(imageType?: string, quality?: number): void;
  141838. /**
  141839. * Public method to load a texturePacker JSON file.
  141840. * @param data of the JSON file in string format.
  141841. */
  141842. updateFromJSON(data: string): void;
  141843. }
  141844. }
  141845. declare module BABYLON {
  141846. /**
  141847. * 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.
  141848. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141849. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141850. */
  141851. export class CustomProceduralTexture extends ProceduralTexture {
  141852. private _animate;
  141853. private _time;
  141854. private _config;
  141855. private _texturePath;
  141856. /**
  141857. * Instantiates a new Custom Procedural Texture.
  141858. * 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.
  141859. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141860. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141861. * @param name Define the name of the texture
  141862. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  141863. * @param size Define the size of the texture to create
  141864. * @param scene Define the scene the texture belongs to
  141865. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  141866. * @param generateMipMaps Define if the texture should creates mip maps or not
  141867. */
  141868. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141869. private _loadJson;
  141870. /**
  141871. * Is the texture ready to be used ? (rendered at least once)
  141872. * @returns true if ready, otherwise, false.
  141873. */
  141874. isReady(): boolean;
  141875. /**
  141876. * Render the texture to its associated render target.
  141877. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  141878. */
  141879. render(useCameraPostProcess?: boolean): void;
  141880. /**
  141881. * Update the list of dependant textures samplers in the shader.
  141882. */
  141883. updateTextures(): void;
  141884. /**
  141885. * Update the uniform values of the procedural texture in the shader.
  141886. */
  141887. updateShaderUniforms(): void;
  141888. /**
  141889. * Define if the texture animates or not.
  141890. */
  141891. get animate(): boolean;
  141892. set animate(value: boolean);
  141893. }
  141894. }
  141895. declare module BABYLON {
  141896. /** @hidden */
  141897. export var noisePixelShader: {
  141898. name: string;
  141899. shader: string;
  141900. };
  141901. }
  141902. declare module BABYLON {
  141903. /**
  141904. * Class used to generate noise procedural textures
  141905. */
  141906. export class NoiseProceduralTexture extends ProceduralTexture {
  141907. /** Gets or sets the start time (default is 0) */
  141908. time: number;
  141909. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  141910. brightness: number;
  141911. /** Defines the number of octaves to process */
  141912. octaves: number;
  141913. /** Defines the level of persistence (0.8 by default) */
  141914. persistence: number;
  141915. /** Gets or sets animation speed factor (default is 1) */
  141916. animationSpeedFactor: number;
  141917. /**
  141918. * Creates a new NoiseProceduralTexture
  141919. * @param name defines the name fo the texture
  141920. * @param size defines the size of the texture (default is 256)
  141921. * @param scene defines the hosting scene
  141922. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  141923. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  141924. */
  141925. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141926. private _updateShaderUniforms;
  141927. protected _getDefines(): string;
  141928. /** Generate the current state of the procedural texture */
  141929. render(useCameraPostProcess?: boolean): void;
  141930. /**
  141931. * Serializes this noise procedural texture
  141932. * @returns a serialized noise procedural texture object
  141933. */
  141934. serialize(): any;
  141935. /**
  141936. * Clone the texture.
  141937. * @returns the cloned texture
  141938. */
  141939. clone(): NoiseProceduralTexture;
  141940. /**
  141941. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  141942. * @param parsedTexture defines parsed texture data
  141943. * @param scene defines the current scene
  141944. * @param rootUrl defines the root URL containing noise procedural texture information
  141945. * @returns a parsed NoiseProceduralTexture
  141946. */
  141947. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  141948. }
  141949. }
  141950. declare module BABYLON {
  141951. /**
  141952. * Raw cube texture where the raw buffers are passed in
  141953. */
  141954. export class RawCubeTexture extends CubeTexture {
  141955. /**
  141956. * Creates a cube texture where the raw buffers are passed in.
  141957. * @param scene defines the scene the texture is attached to
  141958. * @param data defines the array of data to use to create each face
  141959. * @param size defines the size of the textures
  141960. * @param format defines the format of the data
  141961. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  141962. * @param generateMipMaps defines if the engine should generate the mip levels
  141963. * @param invertY defines if data must be stored with Y axis inverted
  141964. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  141965. * @param compression defines the compression used (null by default)
  141966. */
  141967. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  141968. /**
  141969. * Updates the raw cube texture.
  141970. * @param data defines the data to store
  141971. * @param format defines the data format
  141972. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141973. * @param invertY defines if data must be stored with Y axis inverted
  141974. * @param compression defines the compression used (null by default)
  141975. * @param level defines which level of the texture to update
  141976. */
  141977. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  141978. /**
  141979. * Updates a raw cube texture with RGBD encoded data.
  141980. * @param data defines the array of data [mipmap][face] to use to create each face
  141981. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  141982. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  141983. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  141984. * @returns a promsie that resolves when the operation is complete
  141985. */
  141986. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  141987. /**
  141988. * Clones the raw cube texture.
  141989. * @return a new cube texture
  141990. */
  141991. clone(): CubeTexture;
  141992. /** @hidden */
  141993. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  141994. }
  141995. }
  141996. declare module BABYLON {
  141997. /**
  141998. * Class used to store 2D array textures containing user data
  141999. */
  142000. export class RawTexture2DArray extends Texture {
  142001. /** Gets or sets the texture format to use */
  142002. format: number;
  142003. /**
  142004. * Create a new RawTexture2DArray
  142005. * @param data defines the data of the texture
  142006. * @param width defines the width of the texture
  142007. * @param height defines the height of the texture
  142008. * @param depth defines the number of layers of the texture
  142009. * @param format defines the texture format to use
  142010. * @param scene defines the hosting scene
  142011. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142012. * @param invertY defines if texture must be stored with Y axis inverted
  142013. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142014. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142015. */
  142016. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142017. /** Gets or sets the texture format to use */
  142018. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142019. /**
  142020. * Update the texture with new data
  142021. * @param data defines the data to store in the texture
  142022. */
  142023. update(data: ArrayBufferView): void;
  142024. }
  142025. }
  142026. declare module BABYLON {
  142027. /**
  142028. * Class used to store 3D textures containing user data
  142029. */
  142030. export class RawTexture3D extends Texture {
  142031. /** Gets or sets the texture format to use */
  142032. format: number;
  142033. /**
  142034. * Create a new RawTexture3D
  142035. * @param data defines the data of the texture
  142036. * @param width defines the width of the texture
  142037. * @param height defines the height of the texture
  142038. * @param depth defines the depth of the texture
  142039. * @param format defines the texture format to use
  142040. * @param scene defines the hosting scene
  142041. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142042. * @param invertY defines if texture must be stored with Y axis inverted
  142043. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142044. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142045. */
  142046. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142047. /** Gets or sets the texture format to use */
  142048. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142049. /**
  142050. * Update the texture with new data
  142051. * @param data defines the data to store in the texture
  142052. */
  142053. update(data: ArrayBufferView): void;
  142054. }
  142055. }
  142056. declare module BABYLON {
  142057. /**
  142058. * Creates a refraction texture used by refraction channel of the standard material.
  142059. * It is like a mirror but to see through a material.
  142060. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142061. */
  142062. export class RefractionTexture extends RenderTargetTexture {
  142063. /**
  142064. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142065. * 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.
  142066. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142067. */
  142068. refractionPlane: Plane;
  142069. /**
  142070. * Define how deep under the surface we should see.
  142071. */
  142072. depth: number;
  142073. /**
  142074. * Creates a refraction texture used by refraction channel of the standard material.
  142075. * It is like a mirror but to see through a material.
  142076. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142077. * @param name Define the texture name
  142078. * @param size Define the size of the underlying texture
  142079. * @param scene Define the scene the refraction belongs to
  142080. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142081. */
  142082. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142083. /**
  142084. * Clone the refraction texture.
  142085. * @returns the cloned texture
  142086. */
  142087. clone(): RefractionTexture;
  142088. /**
  142089. * Serialize the texture to a JSON representation you could use in Parse later on
  142090. * @returns the serialized JSON representation
  142091. */
  142092. serialize(): any;
  142093. }
  142094. }
  142095. declare module BABYLON {
  142096. /**
  142097. * Block used to add support for vertex skinning (bones)
  142098. */
  142099. export class BonesBlock extends NodeMaterialBlock {
  142100. /**
  142101. * Creates a new BonesBlock
  142102. * @param name defines the block name
  142103. */
  142104. constructor(name: string);
  142105. /**
  142106. * Initialize the block and prepare the context for build
  142107. * @param state defines the state that will be used for the build
  142108. */
  142109. initialize(state: NodeMaterialBuildState): void;
  142110. /**
  142111. * Gets the current class name
  142112. * @returns the class name
  142113. */
  142114. getClassName(): string;
  142115. /**
  142116. * Gets the matrix indices input component
  142117. */
  142118. get matricesIndices(): NodeMaterialConnectionPoint;
  142119. /**
  142120. * Gets the matrix weights input component
  142121. */
  142122. get matricesWeights(): NodeMaterialConnectionPoint;
  142123. /**
  142124. * Gets the extra matrix indices input component
  142125. */
  142126. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142127. /**
  142128. * Gets the extra matrix weights input component
  142129. */
  142130. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142131. /**
  142132. * Gets the world input component
  142133. */
  142134. get world(): NodeMaterialConnectionPoint;
  142135. /**
  142136. * Gets the output component
  142137. */
  142138. get output(): NodeMaterialConnectionPoint;
  142139. autoConfigure(material: NodeMaterial): void;
  142140. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142141. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142142. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142143. protected _buildBlock(state: NodeMaterialBuildState): this;
  142144. }
  142145. }
  142146. declare module BABYLON {
  142147. /**
  142148. * Block used to add support for instances
  142149. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142150. */
  142151. export class InstancesBlock extends NodeMaterialBlock {
  142152. /**
  142153. * Creates a new InstancesBlock
  142154. * @param name defines the block name
  142155. */
  142156. constructor(name: string);
  142157. /**
  142158. * Gets the current class name
  142159. * @returns the class name
  142160. */
  142161. getClassName(): string;
  142162. /**
  142163. * Gets the first world row input component
  142164. */
  142165. get world0(): NodeMaterialConnectionPoint;
  142166. /**
  142167. * Gets the second world row input component
  142168. */
  142169. get world1(): NodeMaterialConnectionPoint;
  142170. /**
  142171. * Gets the third world row input component
  142172. */
  142173. get world2(): NodeMaterialConnectionPoint;
  142174. /**
  142175. * Gets the forth world row input component
  142176. */
  142177. get world3(): NodeMaterialConnectionPoint;
  142178. /**
  142179. * Gets the world input component
  142180. */
  142181. get world(): NodeMaterialConnectionPoint;
  142182. /**
  142183. * Gets the output component
  142184. */
  142185. get output(): NodeMaterialConnectionPoint;
  142186. /**
  142187. * Gets the isntanceID component
  142188. */
  142189. get instanceID(): NodeMaterialConnectionPoint;
  142190. autoConfigure(material: NodeMaterial): void;
  142191. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142192. protected _buildBlock(state: NodeMaterialBuildState): this;
  142193. }
  142194. }
  142195. declare module BABYLON {
  142196. /**
  142197. * Block used to add morph targets support to vertex shader
  142198. */
  142199. export class MorphTargetsBlock extends NodeMaterialBlock {
  142200. private _repeatableContentAnchor;
  142201. /**
  142202. * Create a new MorphTargetsBlock
  142203. * @param name defines the block name
  142204. */
  142205. constructor(name: string);
  142206. /**
  142207. * Gets the current class name
  142208. * @returns the class name
  142209. */
  142210. getClassName(): string;
  142211. /**
  142212. * Gets the position input component
  142213. */
  142214. get position(): NodeMaterialConnectionPoint;
  142215. /**
  142216. * Gets the normal input component
  142217. */
  142218. get normal(): NodeMaterialConnectionPoint;
  142219. /**
  142220. * Gets the tangent input component
  142221. */
  142222. get tangent(): NodeMaterialConnectionPoint;
  142223. /**
  142224. * Gets the tangent input component
  142225. */
  142226. get uv(): NodeMaterialConnectionPoint;
  142227. /**
  142228. * Gets the position output component
  142229. */
  142230. get positionOutput(): NodeMaterialConnectionPoint;
  142231. /**
  142232. * Gets the normal output component
  142233. */
  142234. get normalOutput(): NodeMaterialConnectionPoint;
  142235. /**
  142236. * Gets the tangent output component
  142237. */
  142238. get tangentOutput(): NodeMaterialConnectionPoint;
  142239. /**
  142240. * Gets the tangent output component
  142241. */
  142242. get uvOutput(): NodeMaterialConnectionPoint;
  142243. initialize(state: NodeMaterialBuildState): void;
  142244. autoConfigure(material: NodeMaterial): void;
  142245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142247. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142248. protected _buildBlock(state: NodeMaterialBuildState): this;
  142249. }
  142250. }
  142251. declare module BABYLON {
  142252. /**
  142253. * Block used to get data information from a light
  142254. */
  142255. export class LightInformationBlock extends NodeMaterialBlock {
  142256. private _lightDataUniformName;
  142257. private _lightColorUniformName;
  142258. private _lightTypeDefineName;
  142259. /**
  142260. * Gets or sets the light associated with this block
  142261. */
  142262. light: Nullable<Light>;
  142263. /**
  142264. * Creates a new LightInformationBlock
  142265. * @param name defines the block name
  142266. */
  142267. constructor(name: string);
  142268. /**
  142269. * Gets the current class name
  142270. * @returns the class name
  142271. */
  142272. getClassName(): string;
  142273. /**
  142274. * Gets the world position input component
  142275. */
  142276. get worldPosition(): NodeMaterialConnectionPoint;
  142277. /**
  142278. * Gets the direction output component
  142279. */
  142280. get direction(): NodeMaterialConnectionPoint;
  142281. /**
  142282. * Gets the direction output component
  142283. */
  142284. get color(): NodeMaterialConnectionPoint;
  142285. /**
  142286. * Gets the direction output component
  142287. */
  142288. get intensity(): NodeMaterialConnectionPoint;
  142289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142291. protected _buildBlock(state: NodeMaterialBuildState): this;
  142292. serialize(): any;
  142293. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142294. }
  142295. }
  142296. declare module BABYLON {
  142297. /**
  142298. * Block used to add image processing support to fragment shader
  142299. */
  142300. export class ImageProcessingBlock extends NodeMaterialBlock {
  142301. /**
  142302. * Create a new ImageProcessingBlock
  142303. * @param name defines the block name
  142304. */
  142305. constructor(name: string);
  142306. /**
  142307. * Gets the current class name
  142308. * @returns the class name
  142309. */
  142310. getClassName(): string;
  142311. /**
  142312. * Gets the color input component
  142313. */
  142314. get color(): NodeMaterialConnectionPoint;
  142315. /**
  142316. * Gets the output component
  142317. */
  142318. get output(): NodeMaterialConnectionPoint;
  142319. /**
  142320. * Initialize the block and prepare the context for build
  142321. * @param state defines the state that will be used for the build
  142322. */
  142323. initialize(state: NodeMaterialBuildState): void;
  142324. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  142325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142327. protected _buildBlock(state: NodeMaterialBuildState): this;
  142328. }
  142329. }
  142330. declare module BABYLON {
  142331. /**
  142332. * Block used to pertub normals based on a normal map
  142333. */
  142334. export class PerturbNormalBlock extends NodeMaterialBlock {
  142335. private _tangentSpaceParameterName;
  142336. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142337. invertX: boolean;
  142338. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142339. invertY: boolean;
  142340. /**
  142341. * Create a new PerturbNormalBlock
  142342. * @param name defines the block name
  142343. */
  142344. constructor(name: string);
  142345. /**
  142346. * Gets the current class name
  142347. * @returns the class name
  142348. */
  142349. getClassName(): string;
  142350. /**
  142351. * Gets the world position input component
  142352. */
  142353. get worldPosition(): NodeMaterialConnectionPoint;
  142354. /**
  142355. * Gets the world normal input component
  142356. */
  142357. get worldNormal(): NodeMaterialConnectionPoint;
  142358. /**
  142359. * Gets the world tangent input component
  142360. */
  142361. get worldTangent(): NodeMaterialConnectionPoint;
  142362. /**
  142363. * Gets the uv input component
  142364. */
  142365. get uv(): NodeMaterialConnectionPoint;
  142366. /**
  142367. * Gets the normal map color input component
  142368. */
  142369. get normalMapColor(): NodeMaterialConnectionPoint;
  142370. /**
  142371. * Gets the strength input component
  142372. */
  142373. get strength(): NodeMaterialConnectionPoint;
  142374. /**
  142375. * Gets the output component
  142376. */
  142377. get output(): NodeMaterialConnectionPoint;
  142378. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142379. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142380. autoConfigure(material: NodeMaterial): void;
  142381. protected _buildBlock(state: NodeMaterialBuildState): this;
  142382. protected _dumpPropertiesCode(): string;
  142383. serialize(): any;
  142384. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142385. }
  142386. }
  142387. declare module BABYLON {
  142388. /**
  142389. * Block used to discard a pixel if a value is smaller than a cutoff
  142390. */
  142391. export class DiscardBlock extends NodeMaterialBlock {
  142392. /**
  142393. * Create a new DiscardBlock
  142394. * @param name defines the block name
  142395. */
  142396. constructor(name: string);
  142397. /**
  142398. * Gets the current class name
  142399. * @returns the class name
  142400. */
  142401. getClassName(): string;
  142402. /**
  142403. * Gets the color input component
  142404. */
  142405. get value(): NodeMaterialConnectionPoint;
  142406. /**
  142407. * Gets the cutoff input component
  142408. */
  142409. get cutoff(): NodeMaterialConnectionPoint;
  142410. protected _buildBlock(state: NodeMaterialBuildState): this;
  142411. }
  142412. }
  142413. declare module BABYLON {
  142414. /**
  142415. * Block used to test if the fragment shader is front facing
  142416. */
  142417. export class FrontFacingBlock extends NodeMaterialBlock {
  142418. /**
  142419. * Creates a new FrontFacingBlock
  142420. * @param name defines the block name
  142421. */
  142422. constructor(name: string);
  142423. /**
  142424. * Gets the current class name
  142425. * @returns the class name
  142426. */
  142427. getClassName(): string;
  142428. /**
  142429. * Gets the output component
  142430. */
  142431. get output(): NodeMaterialConnectionPoint;
  142432. protected _buildBlock(state: NodeMaterialBuildState): this;
  142433. }
  142434. }
  142435. declare module BABYLON {
  142436. /**
  142437. * Block used to get the derivative value on x and y of a given input
  142438. */
  142439. export class DerivativeBlock extends NodeMaterialBlock {
  142440. /**
  142441. * Create a new DerivativeBlock
  142442. * @param name defines the block name
  142443. */
  142444. constructor(name: string);
  142445. /**
  142446. * Gets the current class name
  142447. * @returns the class name
  142448. */
  142449. getClassName(): string;
  142450. /**
  142451. * Gets the input component
  142452. */
  142453. get input(): NodeMaterialConnectionPoint;
  142454. /**
  142455. * Gets the derivative output on x
  142456. */
  142457. get dx(): NodeMaterialConnectionPoint;
  142458. /**
  142459. * Gets the derivative output on y
  142460. */
  142461. get dy(): NodeMaterialConnectionPoint;
  142462. protected _buildBlock(state: NodeMaterialBuildState): this;
  142463. }
  142464. }
  142465. declare module BABYLON {
  142466. /**
  142467. * Block used to make gl_FragCoord available
  142468. */
  142469. export class FragCoordBlock extends NodeMaterialBlock {
  142470. /**
  142471. * Creates a new FragCoordBlock
  142472. * @param name defines the block name
  142473. */
  142474. constructor(name: string);
  142475. /**
  142476. * Gets the current class name
  142477. * @returns the class name
  142478. */
  142479. getClassName(): string;
  142480. /**
  142481. * Gets the xy component
  142482. */
  142483. get xy(): NodeMaterialConnectionPoint;
  142484. /**
  142485. * Gets the xyz component
  142486. */
  142487. get xyz(): NodeMaterialConnectionPoint;
  142488. /**
  142489. * Gets the xyzw component
  142490. */
  142491. get xyzw(): NodeMaterialConnectionPoint;
  142492. /**
  142493. * Gets the x component
  142494. */
  142495. get x(): NodeMaterialConnectionPoint;
  142496. /**
  142497. * Gets the y component
  142498. */
  142499. get y(): NodeMaterialConnectionPoint;
  142500. /**
  142501. * Gets the z component
  142502. */
  142503. get z(): NodeMaterialConnectionPoint;
  142504. /**
  142505. * Gets the w component
  142506. */
  142507. get output(): NodeMaterialConnectionPoint;
  142508. protected writeOutputs(state: NodeMaterialBuildState): string;
  142509. protected _buildBlock(state: NodeMaterialBuildState): this;
  142510. }
  142511. }
  142512. declare module BABYLON {
  142513. /**
  142514. * Block used to get the screen sizes
  142515. */
  142516. export class ScreenSizeBlock extends NodeMaterialBlock {
  142517. private _varName;
  142518. private _scene;
  142519. /**
  142520. * Creates a new ScreenSizeBlock
  142521. * @param name defines the block name
  142522. */
  142523. constructor(name: string);
  142524. /**
  142525. * Gets the current class name
  142526. * @returns the class name
  142527. */
  142528. getClassName(): string;
  142529. /**
  142530. * Gets the xy component
  142531. */
  142532. get xy(): NodeMaterialConnectionPoint;
  142533. /**
  142534. * Gets the x component
  142535. */
  142536. get x(): NodeMaterialConnectionPoint;
  142537. /**
  142538. * Gets the y component
  142539. */
  142540. get y(): NodeMaterialConnectionPoint;
  142541. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142542. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  142543. protected _buildBlock(state: NodeMaterialBuildState): this;
  142544. }
  142545. }
  142546. declare module BABYLON {
  142547. /**
  142548. * Block used to add support for scene fog
  142549. */
  142550. export class FogBlock extends NodeMaterialBlock {
  142551. private _fogDistanceName;
  142552. private _fogParameters;
  142553. /**
  142554. * Create a new FogBlock
  142555. * @param name defines the block name
  142556. */
  142557. constructor(name: string);
  142558. /**
  142559. * Gets the current class name
  142560. * @returns the class name
  142561. */
  142562. getClassName(): string;
  142563. /**
  142564. * Gets the world position input component
  142565. */
  142566. get worldPosition(): NodeMaterialConnectionPoint;
  142567. /**
  142568. * Gets the view input component
  142569. */
  142570. get view(): NodeMaterialConnectionPoint;
  142571. /**
  142572. * Gets the color input component
  142573. */
  142574. get input(): NodeMaterialConnectionPoint;
  142575. /**
  142576. * Gets the fog color input component
  142577. */
  142578. get fogColor(): NodeMaterialConnectionPoint;
  142579. /**
  142580. * Gets the output component
  142581. */
  142582. get output(): NodeMaterialConnectionPoint;
  142583. autoConfigure(material: NodeMaterial): void;
  142584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142585. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142586. protected _buildBlock(state: NodeMaterialBuildState): this;
  142587. }
  142588. }
  142589. declare module BABYLON {
  142590. /**
  142591. * Block used to add light in the fragment shader
  142592. */
  142593. export class LightBlock extends NodeMaterialBlock {
  142594. private _lightId;
  142595. /**
  142596. * Gets or sets the light associated with this block
  142597. */
  142598. light: Nullable<Light>;
  142599. /**
  142600. * Create a new LightBlock
  142601. * @param name defines the block name
  142602. */
  142603. constructor(name: string);
  142604. /**
  142605. * Gets the current class name
  142606. * @returns the class name
  142607. */
  142608. getClassName(): string;
  142609. /**
  142610. * Gets the world position input component
  142611. */
  142612. get worldPosition(): NodeMaterialConnectionPoint;
  142613. /**
  142614. * Gets the world normal input component
  142615. */
  142616. get worldNormal(): NodeMaterialConnectionPoint;
  142617. /**
  142618. * Gets the camera (or eye) position component
  142619. */
  142620. get cameraPosition(): NodeMaterialConnectionPoint;
  142621. /**
  142622. * Gets the glossiness component
  142623. */
  142624. get glossiness(): NodeMaterialConnectionPoint;
  142625. /**
  142626. * Gets the glossinness power component
  142627. */
  142628. get glossPower(): NodeMaterialConnectionPoint;
  142629. /**
  142630. * Gets the diffuse color component
  142631. */
  142632. get diffuseColor(): NodeMaterialConnectionPoint;
  142633. /**
  142634. * Gets the specular color component
  142635. */
  142636. get specularColor(): NodeMaterialConnectionPoint;
  142637. /**
  142638. * Gets the diffuse output component
  142639. */
  142640. get diffuseOutput(): NodeMaterialConnectionPoint;
  142641. /**
  142642. * Gets the specular output component
  142643. */
  142644. get specularOutput(): NodeMaterialConnectionPoint;
  142645. /**
  142646. * Gets the shadow output component
  142647. */
  142648. get shadow(): NodeMaterialConnectionPoint;
  142649. autoConfigure(material: NodeMaterial): void;
  142650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142651. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142653. private _injectVertexCode;
  142654. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142655. serialize(): any;
  142656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142657. }
  142658. }
  142659. declare module BABYLON {
  142660. /**
  142661. * Block used to read a reflection texture from a sampler
  142662. */
  142663. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  142664. /**
  142665. * Create a new ReflectionTextureBlock
  142666. * @param name defines the block name
  142667. */
  142668. constructor(name: string);
  142669. /**
  142670. * Gets the current class name
  142671. * @returns the class name
  142672. */
  142673. getClassName(): string;
  142674. /**
  142675. * Gets the world position input component
  142676. */
  142677. get position(): NodeMaterialConnectionPoint;
  142678. /**
  142679. * Gets the world position input component
  142680. */
  142681. get worldPosition(): NodeMaterialConnectionPoint;
  142682. /**
  142683. * Gets the world normal input component
  142684. */
  142685. get worldNormal(): NodeMaterialConnectionPoint;
  142686. /**
  142687. * Gets the world input component
  142688. */
  142689. get world(): NodeMaterialConnectionPoint;
  142690. /**
  142691. * Gets the camera (or eye) position component
  142692. */
  142693. get cameraPosition(): NodeMaterialConnectionPoint;
  142694. /**
  142695. * Gets the view input component
  142696. */
  142697. get view(): NodeMaterialConnectionPoint;
  142698. /**
  142699. * Gets the rgb output component
  142700. */
  142701. get rgb(): NodeMaterialConnectionPoint;
  142702. /**
  142703. * Gets the rgba output component
  142704. */
  142705. get rgba(): NodeMaterialConnectionPoint;
  142706. /**
  142707. * Gets the r output component
  142708. */
  142709. get r(): NodeMaterialConnectionPoint;
  142710. /**
  142711. * Gets the g output component
  142712. */
  142713. get g(): NodeMaterialConnectionPoint;
  142714. /**
  142715. * Gets the b output component
  142716. */
  142717. get b(): NodeMaterialConnectionPoint;
  142718. /**
  142719. * Gets the a output component
  142720. */
  142721. get a(): NodeMaterialConnectionPoint;
  142722. autoConfigure(material: NodeMaterial): void;
  142723. protected _buildBlock(state: NodeMaterialBuildState): this;
  142724. }
  142725. }
  142726. declare module BABYLON {
  142727. /**
  142728. * Block used to add 2 vectors
  142729. */
  142730. export class AddBlock extends NodeMaterialBlock {
  142731. /**
  142732. * Creates a new AddBlock
  142733. * @param name defines the block name
  142734. */
  142735. constructor(name: string);
  142736. /**
  142737. * Gets the current class name
  142738. * @returns the class name
  142739. */
  142740. getClassName(): string;
  142741. /**
  142742. * Gets the left operand input component
  142743. */
  142744. get left(): NodeMaterialConnectionPoint;
  142745. /**
  142746. * Gets the right operand input component
  142747. */
  142748. get right(): NodeMaterialConnectionPoint;
  142749. /**
  142750. * Gets the output component
  142751. */
  142752. get output(): NodeMaterialConnectionPoint;
  142753. protected _buildBlock(state: NodeMaterialBuildState): this;
  142754. }
  142755. }
  142756. declare module BABYLON {
  142757. /**
  142758. * Block used to scale a vector by a float
  142759. */
  142760. export class ScaleBlock extends NodeMaterialBlock {
  142761. /**
  142762. * Creates a new ScaleBlock
  142763. * @param name defines the block name
  142764. */
  142765. constructor(name: string);
  142766. /**
  142767. * Gets the current class name
  142768. * @returns the class name
  142769. */
  142770. getClassName(): string;
  142771. /**
  142772. * Gets the input component
  142773. */
  142774. get input(): NodeMaterialConnectionPoint;
  142775. /**
  142776. * Gets the factor input component
  142777. */
  142778. get factor(): NodeMaterialConnectionPoint;
  142779. /**
  142780. * Gets the output component
  142781. */
  142782. get output(): NodeMaterialConnectionPoint;
  142783. protected _buildBlock(state: NodeMaterialBuildState): this;
  142784. }
  142785. }
  142786. declare module BABYLON {
  142787. /**
  142788. * Block used to clamp a float
  142789. */
  142790. export class ClampBlock extends NodeMaterialBlock {
  142791. /** Gets or sets the minimum range */
  142792. minimum: number;
  142793. /** Gets or sets the maximum range */
  142794. maximum: number;
  142795. /**
  142796. * Creates a new ClampBlock
  142797. * @param name defines the block name
  142798. */
  142799. constructor(name: string);
  142800. /**
  142801. * Gets the current class name
  142802. * @returns the class name
  142803. */
  142804. getClassName(): string;
  142805. /**
  142806. * Gets the value input component
  142807. */
  142808. get value(): NodeMaterialConnectionPoint;
  142809. /**
  142810. * Gets the output component
  142811. */
  142812. get output(): NodeMaterialConnectionPoint;
  142813. protected _buildBlock(state: NodeMaterialBuildState): this;
  142814. protected _dumpPropertiesCode(): string;
  142815. serialize(): any;
  142816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142817. }
  142818. }
  142819. declare module BABYLON {
  142820. /**
  142821. * Block used to apply a cross product between 2 vectors
  142822. */
  142823. export class CrossBlock extends NodeMaterialBlock {
  142824. /**
  142825. * Creates a new CrossBlock
  142826. * @param name defines the block name
  142827. */
  142828. constructor(name: string);
  142829. /**
  142830. * Gets the current class name
  142831. * @returns the class name
  142832. */
  142833. getClassName(): string;
  142834. /**
  142835. * Gets the left operand input component
  142836. */
  142837. get left(): NodeMaterialConnectionPoint;
  142838. /**
  142839. * Gets the right operand input component
  142840. */
  142841. get right(): NodeMaterialConnectionPoint;
  142842. /**
  142843. * Gets the output component
  142844. */
  142845. get output(): NodeMaterialConnectionPoint;
  142846. protected _buildBlock(state: NodeMaterialBuildState): this;
  142847. }
  142848. }
  142849. declare module BABYLON {
  142850. /**
  142851. * Block used to apply a dot product between 2 vectors
  142852. */
  142853. export class DotBlock extends NodeMaterialBlock {
  142854. /**
  142855. * Creates a new DotBlock
  142856. * @param name defines the block name
  142857. */
  142858. constructor(name: string);
  142859. /**
  142860. * Gets the current class name
  142861. * @returns the class name
  142862. */
  142863. getClassName(): string;
  142864. /**
  142865. * Gets the left operand input component
  142866. */
  142867. get left(): NodeMaterialConnectionPoint;
  142868. /**
  142869. * Gets the right operand input component
  142870. */
  142871. get right(): NodeMaterialConnectionPoint;
  142872. /**
  142873. * Gets the output component
  142874. */
  142875. get output(): NodeMaterialConnectionPoint;
  142876. protected _buildBlock(state: NodeMaterialBuildState): this;
  142877. }
  142878. }
  142879. declare module BABYLON {
  142880. /**
  142881. * Block used to normalize a vector
  142882. */
  142883. export class NormalizeBlock extends NodeMaterialBlock {
  142884. /**
  142885. * Creates a new NormalizeBlock
  142886. * @param name defines the block name
  142887. */
  142888. constructor(name: string);
  142889. /**
  142890. * Gets the current class name
  142891. * @returns the class name
  142892. */
  142893. getClassName(): string;
  142894. /**
  142895. * Gets the input component
  142896. */
  142897. get input(): NodeMaterialConnectionPoint;
  142898. /**
  142899. * Gets the output component
  142900. */
  142901. get output(): NodeMaterialConnectionPoint;
  142902. protected _buildBlock(state: NodeMaterialBuildState): this;
  142903. }
  142904. }
  142905. declare module BABYLON {
  142906. /**
  142907. * Operations supported by the Trigonometry block
  142908. */
  142909. export enum TrigonometryBlockOperations {
  142910. /** Cos */
  142911. Cos = 0,
  142912. /** Sin */
  142913. Sin = 1,
  142914. /** Abs */
  142915. Abs = 2,
  142916. /** Exp */
  142917. Exp = 3,
  142918. /** Exp2 */
  142919. Exp2 = 4,
  142920. /** Round */
  142921. Round = 5,
  142922. /** Floor */
  142923. Floor = 6,
  142924. /** Ceiling */
  142925. Ceiling = 7,
  142926. /** Square root */
  142927. Sqrt = 8,
  142928. /** Log */
  142929. Log = 9,
  142930. /** Tangent */
  142931. Tan = 10,
  142932. /** Arc tangent */
  142933. ArcTan = 11,
  142934. /** Arc cosinus */
  142935. ArcCos = 12,
  142936. /** Arc sinus */
  142937. ArcSin = 13,
  142938. /** Fraction */
  142939. Fract = 14,
  142940. /** Sign */
  142941. Sign = 15,
  142942. /** To radians (from degrees) */
  142943. Radians = 16,
  142944. /** To degrees (from radians) */
  142945. Degrees = 17
  142946. }
  142947. /**
  142948. * Block used to apply trigonometry operation to floats
  142949. */
  142950. export class TrigonometryBlock extends NodeMaterialBlock {
  142951. /**
  142952. * Gets or sets the operation applied by the block
  142953. */
  142954. operation: TrigonometryBlockOperations;
  142955. /**
  142956. * Creates a new TrigonometryBlock
  142957. * @param name defines the block name
  142958. */
  142959. constructor(name: string);
  142960. /**
  142961. * Gets the current class name
  142962. * @returns the class name
  142963. */
  142964. getClassName(): string;
  142965. /**
  142966. * Gets the input component
  142967. */
  142968. get input(): NodeMaterialConnectionPoint;
  142969. /**
  142970. * Gets the output component
  142971. */
  142972. get output(): NodeMaterialConnectionPoint;
  142973. protected _buildBlock(state: NodeMaterialBuildState): this;
  142974. serialize(): any;
  142975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142976. protected _dumpPropertiesCode(): string;
  142977. }
  142978. }
  142979. declare module BABYLON {
  142980. /**
  142981. * Block used to create a Color3/4 out of individual inputs (one for each component)
  142982. */
  142983. export class ColorMergerBlock extends NodeMaterialBlock {
  142984. /**
  142985. * Create a new ColorMergerBlock
  142986. * @param name defines the block name
  142987. */
  142988. constructor(name: string);
  142989. /**
  142990. * Gets the current class name
  142991. * @returns the class name
  142992. */
  142993. getClassName(): string;
  142994. /**
  142995. * Gets the rgb component (input)
  142996. */
  142997. get rgbIn(): NodeMaterialConnectionPoint;
  142998. /**
  142999. * Gets the r component (input)
  143000. */
  143001. get r(): NodeMaterialConnectionPoint;
  143002. /**
  143003. * Gets the g component (input)
  143004. */
  143005. get g(): NodeMaterialConnectionPoint;
  143006. /**
  143007. * Gets the b component (input)
  143008. */
  143009. get b(): NodeMaterialConnectionPoint;
  143010. /**
  143011. * Gets the a component (input)
  143012. */
  143013. get a(): NodeMaterialConnectionPoint;
  143014. /**
  143015. * Gets the rgba component (output)
  143016. */
  143017. get rgba(): NodeMaterialConnectionPoint;
  143018. /**
  143019. * Gets the rgb component (output)
  143020. */
  143021. get rgbOut(): NodeMaterialConnectionPoint;
  143022. /**
  143023. * Gets the rgb component (output)
  143024. * @deprecated Please use rgbOut instead.
  143025. */
  143026. get rgb(): NodeMaterialConnectionPoint;
  143027. protected _buildBlock(state: NodeMaterialBuildState): this;
  143028. }
  143029. }
  143030. declare module BABYLON {
  143031. /**
  143032. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143033. */
  143034. export class VectorSplitterBlock extends NodeMaterialBlock {
  143035. /**
  143036. * Create a new VectorSplitterBlock
  143037. * @param name defines the block name
  143038. */
  143039. constructor(name: string);
  143040. /**
  143041. * Gets the current class name
  143042. * @returns the class name
  143043. */
  143044. getClassName(): string;
  143045. /**
  143046. * Gets the xyzw component (input)
  143047. */
  143048. get xyzw(): NodeMaterialConnectionPoint;
  143049. /**
  143050. * Gets the xyz component (input)
  143051. */
  143052. get xyzIn(): NodeMaterialConnectionPoint;
  143053. /**
  143054. * Gets the xy component (input)
  143055. */
  143056. get xyIn(): NodeMaterialConnectionPoint;
  143057. /**
  143058. * Gets the xyz component (output)
  143059. */
  143060. get xyzOut(): NodeMaterialConnectionPoint;
  143061. /**
  143062. * Gets the xy component (output)
  143063. */
  143064. get xyOut(): NodeMaterialConnectionPoint;
  143065. /**
  143066. * Gets the x component (output)
  143067. */
  143068. get x(): NodeMaterialConnectionPoint;
  143069. /**
  143070. * Gets the y component (output)
  143071. */
  143072. get y(): NodeMaterialConnectionPoint;
  143073. /**
  143074. * Gets the z component (output)
  143075. */
  143076. get z(): NodeMaterialConnectionPoint;
  143077. /**
  143078. * Gets the w component (output)
  143079. */
  143080. get w(): NodeMaterialConnectionPoint;
  143081. protected _inputRename(name: string): string;
  143082. protected _outputRename(name: string): string;
  143083. protected _buildBlock(state: NodeMaterialBuildState): this;
  143084. }
  143085. }
  143086. declare module BABYLON {
  143087. /**
  143088. * Block used to lerp between 2 values
  143089. */
  143090. export class LerpBlock extends NodeMaterialBlock {
  143091. /**
  143092. * Creates a new LerpBlock
  143093. * @param name defines the block name
  143094. */
  143095. constructor(name: string);
  143096. /**
  143097. * Gets the current class name
  143098. * @returns the class name
  143099. */
  143100. getClassName(): string;
  143101. /**
  143102. * Gets the left operand input component
  143103. */
  143104. get left(): NodeMaterialConnectionPoint;
  143105. /**
  143106. * Gets the right operand input component
  143107. */
  143108. get right(): NodeMaterialConnectionPoint;
  143109. /**
  143110. * Gets the gradient operand input component
  143111. */
  143112. get gradient(): NodeMaterialConnectionPoint;
  143113. /**
  143114. * Gets the output component
  143115. */
  143116. get output(): NodeMaterialConnectionPoint;
  143117. protected _buildBlock(state: NodeMaterialBuildState): this;
  143118. }
  143119. }
  143120. declare module BABYLON {
  143121. /**
  143122. * Block used to divide 2 vectors
  143123. */
  143124. export class DivideBlock extends NodeMaterialBlock {
  143125. /**
  143126. * Creates a new DivideBlock
  143127. * @param name defines the block name
  143128. */
  143129. constructor(name: string);
  143130. /**
  143131. * Gets the current class name
  143132. * @returns the class name
  143133. */
  143134. getClassName(): string;
  143135. /**
  143136. * Gets the left operand input component
  143137. */
  143138. get left(): NodeMaterialConnectionPoint;
  143139. /**
  143140. * Gets the right operand input component
  143141. */
  143142. get right(): NodeMaterialConnectionPoint;
  143143. /**
  143144. * Gets the output component
  143145. */
  143146. get output(): NodeMaterialConnectionPoint;
  143147. protected _buildBlock(state: NodeMaterialBuildState): this;
  143148. }
  143149. }
  143150. declare module BABYLON {
  143151. /**
  143152. * Block used to subtract 2 vectors
  143153. */
  143154. export class SubtractBlock extends NodeMaterialBlock {
  143155. /**
  143156. * Creates a new SubtractBlock
  143157. * @param name defines the block name
  143158. */
  143159. constructor(name: string);
  143160. /**
  143161. * Gets the current class name
  143162. * @returns the class name
  143163. */
  143164. getClassName(): string;
  143165. /**
  143166. * Gets the left operand input component
  143167. */
  143168. get left(): NodeMaterialConnectionPoint;
  143169. /**
  143170. * Gets the right operand input component
  143171. */
  143172. get right(): NodeMaterialConnectionPoint;
  143173. /**
  143174. * Gets the output component
  143175. */
  143176. get output(): NodeMaterialConnectionPoint;
  143177. protected _buildBlock(state: NodeMaterialBuildState): this;
  143178. }
  143179. }
  143180. declare module BABYLON {
  143181. /**
  143182. * Block used to step a value
  143183. */
  143184. export class StepBlock extends NodeMaterialBlock {
  143185. /**
  143186. * Creates a new StepBlock
  143187. * @param name defines the block name
  143188. */
  143189. constructor(name: string);
  143190. /**
  143191. * Gets the current class name
  143192. * @returns the class name
  143193. */
  143194. getClassName(): string;
  143195. /**
  143196. * Gets the value operand input component
  143197. */
  143198. get value(): NodeMaterialConnectionPoint;
  143199. /**
  143200. * Gets the edge operand input component
  143201. */
  143202. get edge(): NodeMaterialConnectionPoint;
  143203. /**
  143204. * Gets the output component
  143205. */
  143206. get output(): NodeMaterialConnectionPoint;
  143207. protected _buildBlock(state: NodeMaterialBuildState): this;
  143208. }
  143209. }
  143210. declare module BABYLON {
  143211. /**
  143212. * Block used to get the opposite (1 - x) of a value
  143213. */
  143214. export class OneMinusBlock extends NodeMaterialBlock {
  143215. /**
  143216. * Creates a new OneMinusBlock
  143217. * @param name defines the block name
  143218. */
  143219. constructor(name: string);
  143220. /**
  143221. * Gets the current class name
  143222. * @returns the class name
  143223. */
  143224. getClassName(): string;
  143225. /**
  143226. * Gets the input component
  143227. */
  143228. get input(): NodeMaterialConnectionPoint;
  143229. /**
  143230. * Gets the output component
  143231. */
  143232. get output(): NodeMaterialConnectionPoint;
  143233. protected _buildBlock(state: NodeMaterialBuildState): this;
  143234. }
  143235. }
  143236. declare module BABYLON {
  143237. /**
  143238. * Block used to get the view direction
  143239. */
  143240. export class ViewDirectionBlock extends NodeMaterialBlock {
  143241. /**
  143242. * Creates a new ViewDirectionBlock
  143243. * @param name defines the block name
  143244. */
  143245. constructor(name: string);
  143246. /**
  143247. * Gets the current class name
  143248. * @returns the class name
  143249. */
  143250. getClassName(): string;
  143251. /**
  143252. * Gets the world position component
  143253. */
  143254. get worldPosition(): NodeMaterialConnectionPoint;
  143255. /**
  143256. * Gets the camera position component
  143257. */
  143258. get cameraPosition(): NodeMaterialConnectionPoint;
  143259. /**
  143260. * Gets the output component
  143261. */
  143262. get output(): NodeMaterialConnectionPoint;
  143263. autoConfigure(material: NodeMaterial): void;
  143264. protected _buildBlock(state: NodeMaterialBuildState): this;
  143265. }
  143266. }
  143267. declare module BABYLON {
  143268. /**
  143269. * Block used to compute fresnel value
  143270. */
  143271. export class FresnelBlock extends NodeMaterialBlock {
  143272. /**
  143273. * Create a new FresnelBlock
  143274. * @param name defines the block name
  143275. */
  143276. constructor(name: string);
  143277. /**
  143278. * Gets the current class name
  143279. * @returns the class name
  143280. */
  143281. getClassName(): string;
  143282. /**
  143283. * Gets the world normal input component
  143284. */
  143285. get worldNormal(): NodeMaterialConnectionPoint;
  143286. /**
  143287. * Gets the view direction input component
  143288. */
  143289. get viewDirection(): NodeMaterialConnectionPoint;
  143290. /**
  143291. * Gets the bias input component
  143292. */
  143293. get bias(): NodeMaterialConnectionPoint;
  143294. /**
  143295. * Gets the camera (or eye) position component
  143296. */
  143297. get power(): NodeMaterialConnectionPoint;
  143298. /**
  143299. * Gets the fresnel output component
  143300. */
  143301. get fresnel(): NodeMaterialConnectionPoint;
  143302. autoConfigure(material: NodeMaterial): void;
  143303. protected _buildBlock(state: NodeMaterialBuildState): this;
  143304. }
  143305. }
  143306. declare module BABYLON {
  143307. /**
  143308. * Block used to get the max of 2 values
  143309. */
  143310. export class MaxBlock extends NodeMaterialBlock {
  143311. /**
  143312. * Creates a new MaxBlock
  143313. * @param name defines the block name
  143314. */
  143315. constructor(name: string);
  143316. /**
  143317. * Gets the current class name
  143318. * @returns the class name
  143319. */
  143320. getClassName(): string;
  143321. /**
  143322. * Gets the left operand input component
  143323. */
  143324. get left(): NodeMaterialConnectionPoint;
  143325. /**
  143326. * Gets the right operand input component
  143327. */
  143328. get right(): NodeMaterialConnectionPoint;
  143329. /**
  143330. * Gets the output component
  143331. */
  143332. get output(): NodeMaterialConnectionPoint;
  143333. protected _buildBlock(state: NodeMaterialBuildState): this;
  143334. }
  143335. }
  143336. declare module BABYLON {
  143337. /**
  143338. * Block used to get the min of 2 values
  143339. */
  143340. export class MinBlock extends NodeMaterialBlock {
  143341. /**
  143342. * Creates a new MinBlock
  143343. * @param name defines the block name
  143344. */
  143345. constructor(name: string);
  143346. /**
  143347. * Gets the current class name
  143348. * @returns the class name
  143349. */
  143350. getClassName(): string;
  143351. /**
  143352. * Gets the left operand input component
  143353. */
  143354. get left(): NodeMaterialConnectionPoint;
  143355. /**
  143356. * Gets the right operand input component
  143357. */
  143358. get right(): NodeMaterialConnectionPoint;
  143359. /**
  143360. * Gets the output component
  143361. */
  143362. get output(): NodeMaterialConnectionPoint;
  143363. protected _buildBlock(state: NodeMaterialBuildState): this;
  143364. }
  143365. }
  143366. declare module BABYLON {
  143367. /**
  143368. * Block used to get the distance between 2 values
  143369. */
  143370. export class DistanceBlock extends NodeMaterialBlock {
  143371. /**
  143372. * Creates a new DistanceBlock
  143373. * @param name defines the block name
  143374. */
  143375. constructor(name: string);
  143376. /**
  143377. * Gets the current class name
  143378. * @returns the class name
  143379. */
  143380. getClassName(): string;
  143381. /**
  143382. * Gets the left operand input component
  143383. */
  143384. get left(): NodeMaterialConnectionPoint;
  143385. /**
  143386. * Gets the right operand input component
  143387. */
  143388. get right(): NodeMaterialConnectionPoint;
  143389. /**
  143390. * Gets the output component
  143391. */
  143392. get output(): NodeMaterialConnectionPoint;
  143393. protected _buildBlock(state: NodeMaterialBuildState): this;
  143394. }
  143395. }
  143396. declare module BABYLON {
  143397. /**
  143398. * Block used to get the length of a vector
  143399. */
  143400. export class LengthBlock extends NodeMaterialBlock {
  143401. /**
  143402. * Creates a new LengthBlock
  143403. * @param name defines the block name
  143404. */
  143405. constructor(name: string);
  143406. /**
  143407. * Gets the current class name
  143408. * @returns the class name
  143409. */
  143410. getClassName(): string;
  143411. /**
  143412. * Gets the value input component
  143413. */
  143414. get value(): NodeMaterialConnectionPoint;
  143415. /**
  143416. * Gets the output component
  143417. */
  143418. get output(): NodeMaterialConnectionPoint;
  143419. protected _buildBlock(state: NodeMaterialBuildState): this;
  143420. }
  143421. }
  143422. declare module BABYLON {
  143423. /**
  143424. * Block used to get negative version of a value (i.e. x * -1)
  143425. */
  143426. export class NegateBlock extends NodeMaterialBlock {
  143427. /**
  143428. * Creates a new NegateBlock
  143429. * @param name defines the block name
  143430. */
  143431. constructor(name: string);
  143432. /**
  143433. * Gets the current class name
  143434. * @returns the class name
  143435. */
  143436. getClassName(): string;
  143437. /**
  143438. * Gets the value input component
  143439. */
  143440. get value(): NodeMaterialConnectionPoint;
  143441. /**
  143442. * Gets the output component
  143443. */
  143444. get output(): NodeMaterialConnectionPoint;
  143445. protected _buildBlock(state: NodeMaterialBuildState): this;
  143446. }
  143447. }
  143448. declare module BABYLON {
  143449. /**
  143450. * Block used to get the value of the first parameter raised to the power of the second
  143451. */
  143452. export class PowBlock extends NodeMaterialBlock {
  143453. /**
  143454. * Creates a new PowBlock
  143455. * @param name defines the block name
  143456. */
  143457. constructor(name: string);
  143458. /**
  143459. * Gets the current class name
  143460. * @returns the class name
  143461. */
  143462. getClassName(): string;
  143463. /**
  143464. * Gets the value operand input component
  143465. */
  143466. get value(): NodeMaterialConnectionPoint;
  143467. /**
  143468. * Gets the power operand input component
  143469. */
  143470. get power(): NodeMaterialConnectionPoint;
  143471. /**
  143472. * Gets the output component
  143473. */
  143474. get output(): NodeMaterialConnectionPoint;
  143475. protected _buildBlock(state: NodeMaterialBuildState): this;
  143476. }
  143477. }
  143478. declare module BABYLON {
  143479. /**
  143480. * Block used to get a random number
  143481. */
  143482. export class RandomNumberBlock extends NodeMaterialBlock {
  143483. /**
  143484. * Creates a new RandomNumberBlock
  143485. * @param name defines the block name
  143486. */
  143487. constructor(name: string);
  143488. /**
  143489. * Gets the current class name
  143490. * @returns the class name
  143491. */
  143492. getClassName(): string;
  143493. /**
  143494. * Gets the seed input component
  143495. */
  143496. get seed(): NodeMaterialConnectionPoint;
  143497. /**
  143498. * Gets the output component
  143499. */
  143500. get output(): NodeMaterialConnectionPoint;
  143501. protected _buildBlock(state: NodeMaterialBuildState): this;
  143502. }
  143503. }
  143504. declare module BABYLON {
  143505. /**
  143506. * Block used to compute arc tangent of 2 values
  143507. */
  143508. export class ArcTan2Block extends NodeMaterialBlock {
  143509. /**
  143510. * Creates a new ArcTan2Block
  143511. * @param name defines the block name
  143512. */
  143513. constructor(name: string);
  143514. /**
  143515. * Gets the current class name
  143516. * @returns the class name
  143517. */
  143518. getClassName(): string;
  143519. /**
  143520. * Gets the x operand input component
  143521. */
  143522. get x(): NodeMaterialConnectionPoint;
  143523. /**
  143524. * Gets the y operand input component
  143525. */
  143526. get y(): NodeMaterialConnectionPoint;
  143527. /**
  143528. * Gets the output component
  143529. */
  143530. get output(): NodeMaterialConnectionPoint;
  143531. protected _buildBlock(state: NodeMaterialBuildState): this;
  143532. }
  143533. }
  143534. declare module BABYLON {
  143535. /**
  143536. * Block used to smooth step a value
  143537. */
  143538. export class SmoothStepBlock extends NodeMaterialBlock {
  143539. /**
  143540. * Creates a new SmoothStepBlock
  143541. * @param name defines the block name
  143542. */
  143543. constructor(name: string);
  143544. /**
  143545. * Gets the current class name
  143546. * @returns the class name
  143547. */
  143548. getClassName(): string;
  143549. /**
  143550. * Gets the value operand input component
  143551. */
  143552. get value(): NodeMaterialConnectionPoint;
  143553. /**
  143554. * Gets the first edge operand input component
  143555. */
  143556. get edge0(): NodeMaterialConnectionPoint;
  143557. /**
  143558. * Gets the second edge operand input component
  143559. */
  143560. get edge1(): NodeMaterialConnectionPoint;
  143561. /**
  143562. * Gets the output component
  143563. */
  143564. get output(): NodeMaterialConnectionPoint;
  143565. protected _buildBlock(state: NodeMaterialBuildState): this;
  143566. }
  143567. }
  143568. declare module BABYLON {
  143569. /**
  143570. * Block used to get the reciprocal (1 / x) of a value
  143571. */
  143572. export class ReciprocalBlock extends NodeMaterialBlock {
  143573. /**
  143574. * Creates a new ReciprocalBlock
  143575. * @param name defines the block name
  143576. */
  143577. constructor(name: string);
  143578. /**
  143579. * Gets the current class name
  143580. * @returns the class name
  143581. */
  143582. getClassName(): string;
  143583. /**
  143584. * Gets the input component
  143585. */
  143586. get input(): NodeMaterialConnectionPoint;
  143587. /**
  143588. * Gets the output component
  143589. */
  143590. get output(): NodeMaterialConnectionPoint;
  143591. protected _buildBlock(state: NodeMaterialBuildState): this;
  143592. }
  143593. }
  143594. declare module BABYLON {
  143595. /**
  143596. * Block used to replace a color by another one
  143597. */
  143598. export class ReplaceColorBlock extends NodeMaterialBlock {
  143599. /**
  143600. * Creates a new ReplaceColorBlock
  143601. * @param name defines the block name
  143602. */
  143603. constructor(name: string);
  143604. /**
  143605. * Gets the current class name
  143606. * @returns the class name
  143607. */
  143608. getClassName(): string;
  143609. /**
  143610. * Gets the value input component
  143611. */
  143612. get value(): NodeMaterialConnectionPoint;
  143613. /**
  143614. * Gets the reference input component
  143615. */
  143616. get reference(): NodeMaterialConnectionPoint;
  143617. /**
  143618. * Gets the distance input component
  143619. */
  143620. get distance(): NodeMaterialConnectionPoint;
  143621. /**
  143622. * Gets the replacement input component
  143623. */
  143624. get replacement(): NodeMaterialConnectionPoint;
  143625. /**
  143626. * Gets the output component
  143627. */
  143628. get output(): NodeMaterialConnectionPoint;
  143629. protected _buildBlock(state: NodeMaterialBuildState): this;
  143630. }
  143631. }
  143632. declare module BABYLON {
  143633. /**
  143634. * Block used to posterize a value
  143635. * @see https://en.wikipedia.org/wiki/Posterization
  143636. */
  143637. export class PosterizeBlock extends NodeMaterialBlock {
  143638. /**
  143639. * Creates a new PosterizeBlock
  143640. * @param name defines the block name
  143641. */
  143642. constructor(name: string);
  143643. /**
  143644. * Gets the current class name
  143645. * @returns the class name
  143646. */
  143647. getClassName(): string;
  143648. /**
  143649. * Gets the value input component
  143650. */
  143651. get value(): NodeMaterialConnectionPoint;
  143652. /**
  143653. * Gets the steps input component
  143654. */
  143655. get steps(): NodeMaterialConnectionPoint;
  143656. /**
  143657. * Gets the output component
  143658. */
  143659. get output(): NodeMaterialConnectionPoint;
  143660. protected _buildBlock(state: NodeMaterialBuildState): this;
  143661. }
  143662. }
  143663. declare module BABYLON {
  143664. /**
  143665. * Operations supported by the Wave block
  143666. */
  143667. export enum WaveBlockKind {
  143668. /** SawTooth */
  143669. SawTooth = 0,
  143670. /** Square */
  143671. Square = 1,
  143672. /** Triangle */
  143673. Triangle = 2
  143674. }
  143675. /**
  143676. * Block used to apply wave operation to floats
  143677. */
  143678. export class WaveBlock extends NodeMaterialBlock {
  143679. /**
  143680. * Gets or sets the kibnd of wave to be applied by the block
  143681. */
  143682. kind: WaveBlockKind;
  143683. /**
  143684. * Creates a new WaveBlock
  143685. * @param name defines the block name
  143686. */
  143687. constructor(name: string);
  143688. /**
  143689. * Gets the current class name
  143690. * @returns the class name
  143691. */
  143692. getClassName(): string;
  143693. /**
  143694. * Gets the input component
  143695. */
  143696. get input(): NodeMaterialConnectionPoint;
  143697. /**
  143698. * Gets the output component
  143699. */
  143700. get output(): NodeMaterialConnectionPoint;
  143701. protected _buildBlock(state: NodeMaterialBuildState): this;
  143702. serialize(): any;
  143703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143704. }
  143705. }
  143706. declare module BABYLON {
  143707. /**
  143708. * Class used to store a color step for the GradientBlock
  143709. */
  143710. export class GradientBlockColorStep {
  143711. /**
  143712. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  143713. */
  143714. step: number;
  143715. /**
  143716. * Gets or sets the color associated with this step
  143717. */
  143718. color: Color3;
  143719. /**
  143720. * Creates a new GradientBlockColorStep
  143721. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  143722. * @param color defines the color associated with this step
  143723. */
  143724. constructor(
  143725. /**
  143726. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  143727. */
  143728. step: number,
  143729. /**
  143730. * Gets or sets the color associated with this step
  143731. */
  143732. color: Color3);
  143733. }
  143734. /**
  143735. * Block used to return a color from a gradient based on an input value between 0 and 1
  143736. */
  143737. export class GradientBlock extends NodeMaterialBlock {
  143738. /**
  143739. * Gets or sets the list of color steps
  143740. */
  143741. colorSteps: GradientBlockColorStep[];
  143742. /**
  143743. * Creates a new GradientBlock
  143744. * @param name defines the block name
  143745. */
  143746. constructor(name: string);
  143747. /**
  143748. * Gets the current class name
  143749. * @returns the class name
  143750. */
  143751. getClassName(): string;
  143752. /**
  143753. * Gets the gradient input component
  143754. */
  143755. get gradient(): NodeMaterialConnectionPoint;
  143756. /**
  143757. * Gets the output component
  143758. */
  143759. get output(): NodeMaterialConnectionPoint;
  143760. private _writeColorConstant;
  143761. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143762. serialize(): any;
  143763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143764. protected _dumpPropertiesCode(): string;
  143765. }
  143766. }
  143767. declare module BABYLON {
  143768. /**
  143769. * Block used to normalize lerp between 2 values
  143770. */
  143771. export class NLerpBlock extends NodeMaterialBlock {
  143772. /**
  143773. * Creates a new NLerpBlock
  143774. * @param name defines the block name
  143775. */
  143776. constructor(name: string);
  143777. /**
  143778. * Gets the current class name
  143779. * @returns the class name
  143780. */
  143781. getClassName(): string;
  143782. /**
  143783. * Gets the left operand input component
  143784. */
  143785. get left(): NodeMaterialConnectionPoint;
  143786. /**
  143787. * Gets the right operand input component
  143788. */
  143789. get right(): NodeMaterialConnectionPoint;
  143790. /**
  143791. * Gets the gradient operand input component
  143792. */
  143793. get gradient(): NodeMaterialConnectionPoint;
  143794. /**
  143795. * Gets the output component
  143796. */
  143797. get output(): NodeMaterialConnectionPoint;
  143798. protected _buildBlock(state: NodeMaterialBuildState): this;
  143799. }
  143800. }
  143801. declare module BABYLON {
  143802. /**
  143803. * block used to Generate a Worley Noise 3D Noise Pattern
  143804. */
  143805. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  143806. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143807. manhattanDistance: boolean;
  143808. /**
  143809. * Creates a new WorleyNoise3DBlock
  143810. * @param name defines the block name
  143811. */
  143812. constructor(name: string);
  143813. /**
  143814. * Gets the current class name
  143815. * @returns the class name
  143816. */
  143817. getClassName(): string;
  143818. /**
  143819. * Gets the seed input component
  143820. */
  143821. get seed(): NodeMaterialConnectionPoint;
  143822. /**
  143823. * Gets the jitter input component
  143824. */
  143825. get jitter(): NodeMaterialConnectionPoint;
  143826. /**
  143827. * Gets the output component
  143828. */
  143829. get output(): NodeMaterialConnectionPoint;
  143830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143831. /**
  143832. * Exposes the properties to the UI?
  143833. */
  143834. protected _dumpPropertiesCode(): string;
  143835. /**
  143836. * Exposes the properties to the Seralize?
  143837. */
  143838. serialize(): any;
  143839. /**
  143840. * Exposes the properties to the deseralize?
  143841. */
  143842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143843. }
  143844. }
  143845. declare module BABYLON {
  143846. /**
  143847. * block used to Generate a Simplex Perlin 3d Noise Pattern
  143848. */
  143849. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  143850. /**
  143851. * Creates a new SimplexPerlin3DBlock
  143852. * @param name defines the block name
  143853. */
  143854. constructor(name: string);
  143855. /**
  143856. * Gets the current class name
  143857. * @returns the class name
  143858. */
  143859. getClassName(): string;
  143860. /**
  143861. * Gets the seed operand input component
  143862. */
  143863. get seed(): NodeMaterialConnectionPoint;
  143864. /**
  143865. * Gets the output component
  143866. */
  143867. get output(): NodeMaterialConnectionPoint;
  143868. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143869. }
  143870. }
  143871. declare module BABYLON {
  143872. /**
  143873. * Block used to blend normals
  143874. */
  143875. export class NormalBlendBlock extends NodeMaterialBlock {
  143876. /**
  143877. * Creates a new NormalBlendBlock
  143878. * @param name defines the block name
  143879. */
  143880. constructor(name: string);
  143881. /**
  143882. * Gets the current class name
  143883. * @returns the class name
  143884. */
  143885. getClassName(): string;
  143886. /**
  143887. * Gets the first input component
  143888. */
  143889. get normalMap0(): NodeMaterialConnectionPoint;
  143890. /**
  143891. * Gets the second input component
  143892. */
  143893. get normalMap1(): NodeMaterialConnectionPoint;
  143894. /**
  143895. * Gets the output component
  143896. */
  143897. get output(): NodeMaterialConnectionPoint;
  143898. protected _buildBlock(state: NodeMaterialBuildState): this;
  143899. }
  143900. }
  143901. declare module BABYLON {
  143902. /**
  143903. * Block used to rotate a 2d vector by a given angle
  143904. */
  143905. export class Rotate2dBlock extends NodeMaterialBlock {
  143906. /**
  143907. * Creates a new Rotate2dBlock
  143908. * @param name defines the block name
  143909. */
  143910. constructor(name: string);
  143911. /**
  143912. * Gets the current class name
  143913. * @returns the class name
  143914. */
  143915. getClassName(): string;
  143916. /**
  143917. * Gets the input vector
  143918. */
  143919. get input(): NodeMaterialConnectionPoint;
  143920. /**
  143921. * Gets the input angle
  143922. */
  143923. get angle(): NodeMaterialConnectionPoint;
  143924. /**
  143925. * Gets the output component
  143926. */
  143927. get output(): NodeMaterialConnectionPoint;
  143928. autoConfigure(material: NodeMaterial): void;
  143929. protected _buildBlock(state: NodeMaterialBuildState): this;
  143930. }
  143931. }
  143932. declare module BABYLON {
  143933. /**
  143934. * Block used to get the reflected vector from a direction and a normal
  143935. */
  143936. export class ReflectBlock extends NodeMaterialBlock {
  143937. /**
  143938. * Creates a new ReflectBlock
  143939. * @param name defines the block name
  143940. */
  143941. constructor(name: string);
  143942. /**
  143943. * Gets the current class name
  143944. * @returns the class name
  143945. */
  143946. getClassName(): string;
  143947. /**
  143948. * Gets the incident component
  143949. */
  143950. get incident(): NodeMaterialConnectionPoint;
  143951. /**
  143952. * Gets the normal component
  143953. */
  143954. get normal(): NodeMaterialConnectionPoint;
  143955. /**
  143956. * Gets the output component
  143957. */
  143958. get output(): NodeMaterialConnectionPoint;
  143959. protected _buildBlock(state: NodeMaterialBuildState): this;
  143960. }
  143961. }
  143962. declare module BABYLON {
  143963. /**
  143964. * Block used to get the refracted vector from a direction and a normal
  143965. */
  143966. export class RefractBlock extends NodeMaterialBlock {
  143967. /**
  143968. * Creates a new RefractBlock
  143969. * @param name defines the block name
  143970. */
  143971. constructor(name: string);
  143972. /**
  143973. * Gets the current class name
  143974. * @returns the class name
  143975. */
  143976. getClassName(): string;
  143977. /**
  143978. * Gets the incident component
  143979. */
  143980. get incident(): NodeMaterialConnectionPoint;
  143981. /**
  143982. * Gets the normal component
  143983. */
  143984. get normal(): NodeMaterialConnectionPoint;
  143985. /**
  143986. * Gets the index of refraction component
  143987. */
  143988. get ior(): NodeMaterialConnectionPoint;
  143989. /**
  143990. * Gets the output component
  143991. */
  143992. get output(): NodeMaterialConnectionPoint;
  143993. protected _buildBlock(state: NodeMaterialBuildState): this;
  143994. }
  143995. }
  143996. declare module BABYLON {
  143997. /**
  143998. * Block used to desaturate a color
  143999. */
  144000. export class DesaturateBlock extends NodeMaterialBlock {
  144001. /**
  144002. * Creates a new DesaturateBlock
  144003. * @param name defines the block name
  144004. */
  144005. constructor(name: string);
  144006. /**
  144007. * Gets the current class name
  144008. * @returns the class name
  144009. */
  144010. getClassName(): string;
  144011. /**
  144012. * Gets the color operand input component
  144013. */
  144014. get color(): NodeMaterialConnectionPoint;
  144015. /**
  144016. * Gets the level operand input component
  144017. */
  144018. get level(): NodeMaterialConnectionPoint;
  144019. /**
  144020. * Gets the output component
  144021. */
  144022. get output(): NodeMaterialConnectionPoint;
  144023. protected _buildBlock(state: NodeMaterialBuildState): this;
  144024. }
  144025. }
  144026. declare module BABYLON {
  144027. /**
  144028. * Block used to implement the ambient occlusion module of the PBR material
  144029. */
  144030. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144031. /**
  144032. * Create a new AmbientOcclusionBlock
  144033. * @param name defines the block name
  144034. */
  144035. constructor(name: string);
  144036. /**
  144037. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144038. */
  144039. useAmbientInGrayScale: boolean;
  144040. /**
  144041. * Initialize the block and prepare the context for build
  144042. * @param state defines the state that will be used for the build
  144043. */
  144044. initialize(state: NodeMaterialBuildState): void;
  144045. /**
  144046. * Gets the current class name
  144047. * @returns the class name
  144048. */
  144049. getClassName(): string;
  144050. /**
  144051. * Gets the texture input component
  144052. */
  144053. get texture(): NodeMaterialConnectionPoint;
  144054. /**
  144055. * Gets the texture intensity component
  144056. */
  144057. get intensity(): NodeMaterialConnectionPoint;
  144058. /**
  144059. * Gets the direct light intensity input component
  144060. */
  144061. get directLightIntensity(): NodeMaterialConnectionPoint;
  144062. /**
  144063. * Gets the ambient occlusion object output component
  144064. */
  144065. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144066. /**
  144067. * Gets the main code of the block (fragment side)
  144068. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144069. * @returns the shader code
  144070. */
  144071. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144073. protected _buildBlock(state: NodeMaterialBuildState): this;
  144074. protected _dumpPropertiesCode(): string;
  144075. serialize(): any;
  144076. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144077. }
  144078. }
  144079. declare module BABYLON {
  144080. /**
  144081. * Block used to implement the reflection module of the PBR material
  144082. */
  144083. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144084. /** @hidden */
  144085. _defineLODReflectionAlpha: string;
  144086. /** @hidden */
  144087. _defineLinearSpecularReflection: string;
  144088. private _vEnvironmentIrradianceName;
  144089. /** @hidden */
  144090. _vReflectionMicrosurfaceInfosName: string;
  144091. /** @hidden */
  144092. _vReflectionInfosName: string;
  144093. /** @hidden */
  144094. _vReflectionFilteringInfoName: string;
  144095. private _scene;
  144096. /**
  144097. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144098. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144099. * It's less burden on the user side in the editor part.
  144100. */
  144101. /** @hidden */
  144102. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144103. /** @hidden */
  144104. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144105. /** @hidden */
  144106. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144107. /**
  144108. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144109. * diffuse part of the IBL.
  144110. */
  144111. useSphericalHarmonics: boolean;
  144112. /**
  144113. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144114. */
  144115. forceIrradianceInFragment: boolean;
  144116. /**
  144117. * Create a new ReflectionBlock
  144118. * @param name defines the block name
  144119. */
  144120. constructor(name: string);
  144121. /**
  144122. * Gets the current class name
  144123. * @returns the class name
  144124. */
  144125. getClassName(): string;
  144126. /**
  144127. * Gets the position input component
  144128. */
  144129. get position(): NodeMaterialConnectionPoint;
  144130. /**
  144131. * Gets the world position input component
  144132. */
  144133. get worldPosition(): NodeMaterialConnectionPoint;
  144134. /**
  144135. * Gets the world normal input component
  144136. */
  144137. get worldNormal(): NodeMaterialConnectionPoint;
  144138. /**
  144139. * Gets the world input component
  144140. */
  144141. get world(): NodeMaterialConnectionPoint;
  144142. /**
  144143. * Gets the camera (or eye) position component
  144144. */
  144145. get cameraPosition(): NodeMaterialConnectionPoint;
  144146. /**
  144147. * Gets the view input component
  144148. */
  144149. get view(): NodeMaterialConnectionPoint;
  144150. /**
  144151. * Gets the color input component
  144152. */
  144153. get color(): NodeMaterialConnectionPoint;
  144154. /**
  144155. * Gets the reflection object output component
  144156. */
  144157. get reflection(): NodeMaterialConnectionPoint;
  144158. /**
  144159. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144160. */
  144161. get hasTexture(): boolean;
  144162. /**
  144163. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144164. */
  144165. get reflectionColor(): string;
  144166. protected _getTexture(): Nullable<BaseTexture>;
  144167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144169. /**
  144170. * Gets the code to inject in the vertex shader
  144171. * @param state current state of the node material building
  144172. * @returns the shader code
  144173. */
  144174. handleVertexSide(state: NodeMaterialBuildState): string;
  144175. /**
  144176. * Gets the main code of the block (fragment side)
  144177. * @param state current state of the node material building
  144178. * @param normalVarName name of the existing variable corresponding to the normal
  144179. * @returns the shader code
  144180. */
  144181. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144182. protected _buildBlock(state: NodeMaterialBuildState): this;
  144183. protected _dumpPropertiesCode(): string;
  144184. serialize(): any;
  144185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144186. }
  144187. }
  144188. declare module BABYLON {
  144189. /**
  144190. * Block used to implement the sheen module of the PBR material
  144191. */
  144192. export class SheenBlock extends NodeMaterialBlock {
  144193. /**
  144194. * Create a new SheenBlock
  144195. * @param name defines the block name
  144196. */
  144197. constructor(name: string);
  144198. /**
  144199. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144200. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144201. * making it easier to setup and tweak the effect
  144202. */
  144203. albedoScaling: boolean;
  144204. /**
  144205. * Defines if the sheen is linked to the sheen color.
  144206. */
  144207. linkSheenWithAlbedo: boolean;
  144208. /**
  144209. * Initialize the block and prepare the context for build
  144210. * @param state defines the state that will be used for the build
  144211. */
  144212. initialize(state: NodeMaterialBuildState): void;
  144213. /**
  144214. * Gets the current class name
  144215. * @returns the class name
  144216. */
  144217. getClassName(): string;
  144218. /**
  144219. * Gets the intensity input component
  144220. */
  144221. get intensity(): NodeMaterialConnectionPoint;
  144222. /**
  144223. * Gets the color input component
  144224. */
  144225. get color(): NodeMaterialConnectionPoint;
  144226. /**
  144227. * Gets the roughness input component
  144228. */
  144229. get roughness(): NodeMaterialConnectionPoint;
  144230. /**
  144231. * Gets the sheen object output component
  144232. */
  144233. get sheen(): NodeMaterialConnectionPoint;
  144234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144235. /**
  144236. * Gets the main code of the block (fragment side)
  144237. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144238. * @returns the shader code
  144239. */
  144240. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144241. protected _buildBlock(state: NodeMaterialBuildState): this;
  144242. protected _dumpPropertiesCode(): string;
  144243. serialize(): any;
  144244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144245. }
  144246. }
  144247. declare module BABYLON {
  144248. /**
  144249. * Block used to implement the reflectivity module of the PBR material
  144250. */
  144251. export class ReflectivityBlock extends NodeMaterialBlock {
  144252. private _metallicReflectanceColor;
  144253. private _metallicF0Factor;
  144254. /** @hidden */
  144255. _vMetallicReflectanceFactorsName: string;
  144256. /**
  144257. * The property below is set by the main PBR block prior to calling methods of this class.
  144258. */
  144259. /** @hidden */
  144260. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144261. /**
  144262. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144263. */
  144264. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144265. /**
  144266. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144267. */
  144268. useMetallnessFromMetallicTextureBlue: boolean;
  144269. /**
  144270. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144271. */
  144272. useRoughnessFromMetallicTextureAlpha: boolean;
  144273. /**
  144274. * Specifies if the metallic texture contains the roughness information in its green channel.
  144275. */
  144276. useRoughnessFromMetallicTextureGreen: boolean;
  144277. /**
  144278. * Create a new ReflectivityBlock
  144279. * @param name defines the block name
  144280. */
  144281. constructor(name: string);
  144282. /**
  144283. * Initialize the block and prepare the context for build
  144284. * @param state defines the state that will be used for the build
  144285. */
  144286. initialize(state: NodeMaterialBuildState): void;
  144287. /**
  144288. * Gets the current class name
  144289. * @returns the class name
  144290. */
  144291. getClassName(): string;
  144292. /**
  144293. * Gets the metallic input component
  144294. */
  144295. get metallic(): NodeMaterialConnectionPoint;
  144296. /**
  144297. * Gets the roughness input component
  144298. */
  144299. get roughness(): NodeMaterialConnectionPoint;
  144300. /**
  144301. * Gets the texture input component
  144302. */
  144303. get texture(): NodeMaterialConnectionPoint;
  144304. /**
  144305. * Gets the reflectivity object output component
  144306. */
  144307. get reflectivity(): NodeMaterialConnectionPoint;
  144308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144309. /**
  144310. * Gets the main code of the block (fragment side)
  144311. * @param state current state of the node material building
  144312. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144313. * @returns the shader code
  144314. */
  144315. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144317. protected _buildBlock(state: NodeMaterialBuildState): this;
  144318. protected _dumpPropertiesCode(): string;
  144319. serialize(): any;
  144320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144321. }
  144322. }
  144323. declare module BABYLON {
  144324. /**
  144325. * Block used to implement the anisotropy module of the PBR material
  144326. */
  144327. export class AnisotropyBlock extends NodeMaterialBlock {
  144328. /**
  144329. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144330. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144331. * It's less burden on the user side in the editor part.
  144332. */
  144333. /** @hidden */
  144334. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144335. /** @hidden */
  144336. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144337. /**
  144338. * Create a new AnisotropyBlock
  144339. * @param name defines the block name
  144340. */
  144341. constructor(name: string);
  144342. /**
  144343. * Initialize the block and prepare the context for build
  144344. * @param state defines the state that will be used for the build
  144345. */
  144346. initialize(state: NodeMaterialBuildState): void;
  144347. /**
  144348. * Gets the current class name
  144349. * @returns the class name
  144350. */
  144351. getClassName(): string;
  144352. /**
  144353. * Gets the intensity input component
  144354. */
  144355. get intensity(): NodeMaterialConnectionPoint;
  144356. /**
  144357. * Gets the direction input component
  144358. */
  144359. get direction(): NodeMaterialConnectionPoint;
  144360. /**
  144361. * Gets the texture input component
  144362. */
  144363. get texture(): NodeMaterialConnectionPoint;
  144364. /**
  144365. * Gets the uv input component
  144366. */
  144367. get uv(): NodeMaterialConnectionPoint;
  144368. /**
  144369. * Gets the worldTangent input component
  144370. */
  144371. get worldTangent(): NodeMaterialConnectionPoint;
  144372. /**
  144373. * Gets the anisotropy object output component
  144374. */
  144375. get anisotropy(): NodeMaterialConnectionPoint;
  144376. private _generateTBNSpace;
  144377. /**
  144378. * Gets the main code of the block (fragment side)
  144379. * @param state current state of the node material building
  144380. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144381. * @returns the shader code
  144382. */
  144383. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144384. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144385. protected _buildBlock(state: NodeMaterialBuildState): this;
  144386. }
  144387. }
  144388. declare module BABYLON {
  144389. /**
  144390. * Block used to implement the clear coat module of the PBR material
  144391. */
  144392. export class ClearCoatBlock extends NodeMaterialBlock {
  144393. private _scene;
  144394. /**
  144395. * Create a new ClearCoatBlock
  144396. * @param name defines the block name
  144397. */
  144398. constructor(name: string);
  144399. /**
  144400. * Initialize the block and prepare the context for build
  144401. * @param state defines the state that will be used for the build
  144402. */
  144403. initialize(state: NodeMaterialBuildState): void;
  144404. /**
  144405. * Gets the current class name
  144406. * @returns the class name
  144407. */
  144408. getClassName(): string;
  144409. /**
  144410. * Gets the intensity input component
  144411. */
  144412. get intensity(): NodeMaterialConnectionPoint;
  144413. /**
  144414. * Gets the roughness input component
  144415. */
  144416. get roughness(): NodeMaterialConnectionPoint;
  144417. /**
  144418. * Gets the ior input component
  144419. */
  144420. get ior(): NodeMaterialConnectionPoint;
  144421. /**
  144422. * Gets the texture input component
  144423. */
  144424. get texture(): NodeMaterialConnectionPoint;
  144425. /**
  144426. * Gets the bump texture input component
  144427. */
  144428. get bumpTexture(): NodeMaterialConnectionPoint;
  144429. /**
  144430. * Gets the uv input component
  144431. */
  144432. get uv(): NodeMaterialConnectionPoint;
  144433. /**
  144434. * Gets the tint color input component
  144435. */
  144436. get tintColor(): NodeMaterialConnectionPoint;
  144437. /**
  144438. * Gets the tint "at distance" input component
  144439. */
  144440. get tintAtDistance(): NodeMaterialConnectionPoint;
  144441. /**
  144442. * Gets the tint thickness input component
  144443. */
  144444. get tintThickness(): NodeMaterialConnectionPoint;
  144445. /**
  144446. * Gets the world tangent input component
  144447. */
  144448. get worldTangent(): NodeMaterialConnectionPoint;
  144449. /**
  144450. * Gets the clear coat object output component
  144451. */
  144452. get clearcoat(): NodeMaterialConnectionPoint;
  144453. autoConfigure(material: NodeMaterial): void;
  144454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144456. private _generateTBNSpace;
  144457. /**
  144458. * Gets the main code of the block (fragment side)
  144459. * @param state current state of the node material building
  144460. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  144461. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144462. * @param worldPosVarName name of the variable holding the world position
  144463. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144464. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  144465. * @param worldNormalVarName name of the variable holding the world normal
  144466. * @returns the shader code
  144467. */
  144468. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  144469. protected _buildBlock(state: NodeMaterialBuildState): this;
  144470. }
  144471. }
  144472. declare module BABYLON {
  144473. /**
  144474. * Block used to implement the sub surface module of the PBR material
  144475. */
  144476. export class SubSurfaceBlock extends NodeMaterialBlock {
  144477. /**
  144478. * Create a new SubSurfaceBlock
  144479. * @param name defines the block name
  144480. */
  144481. constructor(name: string);
  144482. /**
  144483. * Stores the intensity of the different subsurface effects in the thickness texture.
  144484. * * the green channel is the translucency intensity.
  144485. * * the blue channel is the scattering intensity.
  144486. * * the alpha channel is the refraction intensity.
  144487. */
  144488. useMaskFromThicknessTexture: boolean;
  144489. /**
  144490. * Initialize the block and prepare the context for build
  144491. * @param state defines the state that will be used for the build
  144492. */
  144493. initialize(state: NodeMaterialBuildState): void;
  144494. /**
  144495. * Gets the current class name
  144496. * @returns the class name
  144497. */
  144498. getClassName(): string;
  144499. /**
  144500. * Gets the min thickness input component
  144501. */
  144502. get minThickness(): NodeMaterialConnectionPoint;
  144503. /**
  144504. * Gets the max thickness input component
  144505. */
  144506. get maxThickness(): NodeMaterialConnectionPoint;
  144507. /**
  144508. * Gets the thickness texture component
  144509. */
  144510. get thicknessTexture(): NodeMaterialConnectionPoint;
  144511. /**
  144512. * Gets the tint color input component
  144513. */
  144514. get tintColor(): NodeMaterialConnectionPoint;
  144515. /**
  144516. * Gets the translucency intensity input component
  144517. */
  144518. get translucencyIntensity(): NodeMaterialConnectionPoint;
  144519. /**
  144520. * Gets the translucency diffusion distance input component
  144521. */
  144522. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  144523. /**
  144524. * Gets the refraction object parameters
  144525. */
  144526. get refraction(): NodeMaterialConnectionPoint;
  144527. /**
  144528. * Gets the sub surface object output component
  144529. */
  144530. get subsurface(): NodeMaterialConnectionPoint;
  144531. autoConfigure(material: NodeMaterial): void;
  144532. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144533. /**
  144534. * Gets the main code of the block (fragment side)
  144535. * @param state current state of the node material building
  144536. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  144537. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144538. * @param worldPosVarName name of the variable holding the world position
  144539. * @returns the shader code
  144540. */
  144541. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  144542. protected _buildBlock(state: NodeMaterialBuildState): this;
  144543. }
  144544. }
  144545. declare module BABYLON {
  144546. /**
  144547. * Block used to implement the PBR metallic/roughness model
  144548. */
  144549. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  144550. /**
  144551. * Gets or sets the light associated with this block
  144552. */
  144553. light: Nullable<Light>;
  144554. private _lightId;
  144555. private _scene;
  144556. private _environmentBRDFTexture;
  144557. private _environmentBrdfSamplerName;
  144558. private _vNormalWName;
  144559. private _invertNormalName;
  144560. /**
  144561. * Create a new ReflectionBlock
  144562. * @param name defines the block name
  144563. */
  144564. constructor(name: string);
  144565. /**
  144566. * Intensity of the direct lights e.g. the four lights available in your scene.
  144567. * This impacts both the direct diffuse and specular highlights.
  144568. */
  144569. directIntensity: number;
  144570. /**
  144571. * Intensity of the environment e.g. how much the environment will light the object
  144572. * either through harmonics for rough material or through the refelction for shiny ones.
  144573. */
  144574. environmentIntensity: number;
  144575. /**
  144576. * This is a special control allowing the reduction of the specular highlights coming from the
  144577. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  144578. */
  144579. specularIntensity: number;
  144580. /**
  144581. * Defines the falloff type used in this material.
  144582. * It by default is Physical.
  144583. */
  144584. lightFalloff: number;
  144585. /**
  144586. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  144587. */
  144588. useAlphaFromAlbedoTexture: boolean;
  144589. /**
  144590. * Specifies that alpha test should be used
  144591. */
  144592. useAlphaTest: boolean;
  144593. /**
  144594. * Defines the alpha limits in alpha test mode.
  144595. */
  144596. alphaTestCutoff: number;
  144597. /**
  144598. * Specifies that alpha blending should be used
  144599. */
  144600. useAlphaBlending: boolean;
  144601. /**
  144602. * Defines if the alpha value should be determined via the rgb values.
  144603. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  144604. */
  144605. opacityRGB: boolean;
  144606. /**
  144607. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  144608. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  144609. */
  144610. useRadianceOverAlpha: boolean;
  144611. /**
  144612. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  144613. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  144614. */
  144615. useSpecularOverAlpha: boolean;
  144616. /**
  144617. * Enables specular anti aliasing in the PBR shader.
  144618. * It will both interacts on the Geometry for analytical and IBL lighting.
  144619. * It also prefilter the roughness map based on the bump values.
  144620. */
  144621. enableSpecularAntiAliasing: boolean;
  144622. /**
  144623. * Enables realtime filtering on the texture.
  144624. */
  144625. realTimeFiltering: boolean;
  144626. /**
  144627. * Quality switch for realtime filtering
  144628. */
  144629. realTimeFilteringQuality: number;
  144630. /**
  144631. * Defines if the material uses energy conservation.
  144632. */
  144633. useEnergyConservation: boolean;
  144634. /**
  144635. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  144636. * too much the area relying on ambient texture to define their ambient occlusion.
  144637. */
  144638. useRadianceOcclusion: boolean;
  144639. /**
  144640. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  144641. * makes the reflect vector face the model (under horizon).
  144642. */
  144643. useHorizonOcclusion: boolean;
  144644. /**
  144645. * If set to true, no lighting calculations will be applied.
  144646. */
  144647. unlit: boolean;
  144648. /**
  144649. * Force normal to face away from face.
  144650. */
  144651. forceNormalForward: boolean;
  144652. /**
  144653. * Defines the material debug mode.
  144654. * It helps seeing only some components of the material while troubleshooting.
  144655. */
  144656. debugMode: number;
  144657. /**
  144658. * Specify from where on screen the debug mode should start.
  144659. * The value goes from -1 (full screen) to 1 (not visible)
  144660. * It helps with side by side comparison against the final render
  144661. * This defaults to 0
  144662. */
  144663. debugLimit: number;
  144664. /**
  144665. * As the default viewing range might not be enough (if the ambient is really small for instance)
  144666. * You can use the factor to better multiply the final value.
  144667. */
  144668. debugFactor: number;
  144669. /**
  144670. * Initialize the block and prepare the context for build
  144671. * @param state defines the state that will be used for the build
  144672. */
  144673. initialize(state: NodeMaterialBuildState): void;
  144674. /**
  144675. * Gets the current class name
  144676. * @returns the class name
  144677. */
  144678. getClassName(): string;
  144679. /**
  144680. * Gets the world position input component
  144681. */
  144682. get worldPosition(): NodeMaterialConnectionPoint;
  144683. /**
  144684. * Gets the world normal input component
  144685. */
  144686. get worldNormal(): NodeMaterialConnectionPoint;
  144687. /**
  144688. * Gets the perturbed normal input component
  144689. */
  144690. get perturbedNormal(): NodeMaterialConnectionPoint;
  144691. /**
  144692. * Gets the camera position input component
  144693. */
  144694. get cameraPosition(): NodeMaterialConnectionPoint;
  144695. /**
  144696. * Gets the base color input component
  144697. */
  144698. get baseColor(): NodeMaterialConnectionPoint;
  144699. /**
  144700. * Gets the opacity texture input component
  144701. */
  144702. get opacityTexture(): NodeMaterialConnectionPoint;
  144703. /**
  144704. * Gets the ambient color input component
  144705. */
  144706. get ambientColor(): NodeMaterialConnectionPoint;
  144707. /**
  144708. * Gets the reflectivity object parameters
  144709. */
  144710. get reflectivity(): NodeMaterialConnectionPoint;
  144711. /**
  144712. * Gets the ambient occlusion object parameters
  144713. */
  144714. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144715. /**
  144716. * Gets the reflection object parameters
  144717. */
  144718. get reflection(): NodeMaterialConnectionPoint;
  144719. /**
  144720. * Gets the sheen object parameters
  144721. */
  144722. get sheen(): NodeMaterialConnectionPoint;
  144723. /**
  144724. * Gets the clear coat object parameters
  144725. */
  144726. get clearcoat(): NodeMaterialConnectionPoint;
  144727. /**
  144728. * Gets the sub surface object parameters
  144729. */
  144730. get subsurface(): NodeMaterialConnectionPoint;
  144731. /**
  144732. * Gets the anisotropy object parameters
  144733. */
  144734. get anisotropy(): NodeMaterialConnectionPoint;
  144735. /**
  144736. * Gets the ambient output component
  144737. */
  144738. get ambient(): NodeMaterialConnectionPoint;
  144739. /**
  144740. * Gets the diffuse output component
  144741. */
  144742. get diffuse(): NodeMaterialConnectionPoint;
  144743. /**
  144744. * Gets the specular output component
  144745. */
  144746. get specular(): NodeMaterialConnectionPoint;
  144747. /**
  144748. * Gets the sheen output component
  144749. */
  144750. get sheenDir(): NodeMaterialConnectionPoint;
  144751. /**
  144752. * Gets the clear coat output component
  144753. */
  144754. get clearcoatDir(): NodeMaterialConnectionPoint;
  144755. /**
  144756. * Gets the indirect diffuse output component
  144757. */
  144758. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144759. /**
  144760. * Gets the indirect specular output component
  144761. */
  144762. get specularIndirect(): NodeMaterialConnectionPoint;
  144763. /**
  144764. * Gets the indirect sheen output component
  144765. */
  144766. get sheenIndirect(): NodeMaterialConnectionPoint;
  144767. /**
  144768. * Gets the indirect clear coat output component
  144769. */
  144770. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144771. /**
  144772. * Gets the refraction output component
  144773. */
  144774. get refraction(): NodeMaterialConnectionPoint;
  144775. /**
  144776. * Gets the global lighting output component
  144777. */
  144778. get lighting(): NodeMaterialConnectionPoint;
  144779. /**
  144780. * Gets the shadow output component
  144781. */
  144782. get shadow(): NodeMaterialConnectionPoint;
  144783. /**
  144784. * Gets the alpha output component
  144785. */
  144786. get alpha(): NodeMaterialConnectionPoint;
  144787. autoConfigure(material: NodeMaterial): void;
  144788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144789. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144790. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144791. private _injectVertexCode;
  144792. /**
  144793. * Gets the code corresponding to the albedo/opacity module
  144794. * @returns the shader code
  144795. */
  144796. getAlbedoOpacityCode(): string;
  144797. protected _buildBlock(state: NodeMaterialBuildState): this;
  144798. protected _dumpPropertiesCode(): string;
  144799. serialize(): any;
  144800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144801. }
  144802. }
  144803. declare module BABYLON {
  144804. /**
  144805. * Block used to compute value of one parameter modulo another
  144806. */
  144807. export class ModBlock extends NodeMaterialBlock {
  144808. /**
  144809. * Creates a new ModBlock
  144810. * @param name defines the block name
  144811. */
  144812. constructor(name: string);
  144813. /**
  144814. * Gets the current class name
  144815. * @returns the class name
  144816. */
  144817. getClassName(): string;
  144818. /**
  144819. * Gets the left operand input component
  144820. */
  144821. get left(): NodeMaterialConnectionPoint;
  144822. /**
  144823. * Gets the right operand input component
  144824. */
  144825. get right(): NodeMaterialConnectionPoint;
  144826. /**
  144827. * Gets the output component
  144828. */
  144829. get output(): NodeMaterialConnectionPoint;
  144830. protected _buildBlock(state: NodeMaterialBuildState): this;
  144831. }
  144832. }
  144833. declare module BABYLON {
  144834. /**
  144835. * Configuration for Draco compression
  144836. */
  144837. export interface IDracoCompressionConfiguration {
  144838. /**
  144839. * Configuration for the decoder.
  144840. */
  144841. decoder: {
  144842. /**
  144843. * The url to the WebAssembly module.
  144844. */
  144845. wasmUrl?: string;
  144846. /**
  144847. * The url to the WebAssembly binary.
  144848. */
  144849. wasmBinaryUrl?: string;
  144850. /**
  144851. * The url to the fallback JavaScript module.
  144852. */
  144853. fallbackUrl?: string;
  144854. };
  144855. }
  144856. /**
  144857. * Draco compression (https://google.github.io/draco/)
  144858. *
  144859. * This class wraps the Draco module.
  144860. *
  144861. * **Encoder**
  144862. *
  144863. * The encoder is not currently implemented.
  144864. *
  144865. * **Decoder**
  144866. *
  144867. * 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.
  144868. *
  144869. * To update the configuration, use the following code:
  144870. * ```javascript
  144871. * DracoCompression.Configuration = {
  144872. * decoder: {
  144873. * wasmUrl: "<url to the WebAssembly library>",
  144874. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  144875. * fallbackUrl: "<url to the fallback JavaScript library>",
  144876. * }
  144877. * };
  144878. * ```
  144879. *
  144880. * 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.
  144881. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  144882. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  144883. *
  144884. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  144885. * ```javascript
  144886. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  144887. * ```
  144888. *
  144889. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  144890. */
  144891. export class DracoCompression implements IDisposable {
  144892. private _workerPoolPromise?;
  144893. private _decoderModulePromise?;
  144894. /**
  144895. * The configuration. Defaults to the following urls:
  144896. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  144897. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  144898. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  144899. */
  144900. static Configuration: IDracoCompressionConfiguration;
  144901. /**
  144902. * Returns true if the decoder configuration is available.
  144903. */
  144904. static get DecoderAvailable(): boolean;
  144905. /**
  144906. * Default number of workers to create when creating the draco compression object.
  144907. */
  144908. static DefaultNumWorkers: number;
  144909. private static GetDefaultNumWorkers;
  144910. private static _Default;
  144911. /**
  144912. * Default instance for the draco compression object.
  144913. */
  144914. static get Default(): DracoCompression;
  144915. /**
  144916. * Constructor
  144917. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  144918. */
  144919. constructor(numWorkers?: number);
  144920. /**
  144921. * Stop all async operations and release resources.
  144922. */
  144923. dispose(): void;
  144924. /**
  144925. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  144926. * @returns a promise that resolves when ready
  144927. */
  144928. whenReadyAsync(): Promise<void>;
  144929. /**
  144930. * Decode Draco compressed mesh data to vertex data.
  144931. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  144932. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  144933. * @returns A promise that resolves with the decoded vertex data
  144934. */
  144935. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  144936. [kind: string]: number;
  144937. }): Promise<VertexData>;
  144938. }
  144939. }
  144940. declare module BABYLON {
  144941. /**
  144942. * Class for building Constructive Solid Geometry
  144943. */
  144944. export class CSG {
  144945. private polygons;
  144946. /**
  144947. * The world matrix
  144948. */
  144949. matrix: Matrix;
  144950. /**
  144951. * Stores the position
  144952. */
  144953. position: Vector3;
  144954. /**
  144955. * Stores the rotation
  144956. */
  144957. rotation: Vector3;
  144958. /**
  144959. * Stores the rotation quaternion
  144960. */
  144961. rotationQuaternion: Nullable<Quaternion>;
  144962. /**
  144963. * Stores the scaling vector
  144964. */
  144965. scaling: Vector3;
  144966. /**
  144967. * Convert the Mesh to CSG
  144968. * @param mesh The Mesh to convert to CSG
  144969. * @returns A new CSG from the Mesh
  144970. */
  144971. static FromMesh(mesh: Mesh): CSG;
  144972. /**
  144973. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  144974. * @param polygons Polygons used to construct a CSG solid
  144975. */
  144976. private static FromPolygons;
  144977. /**
  144978. * Clones, or makes a deep copy, of the CSG
  144979. * @returns A new CSG
  144980. */
  144981. clone(): CSG;
  144982. /**
  144983. * Unions this CSG with another CSG
  144984. * @param csg The CSG to union against this CSG
  144985. * @returns The unioned CSG
  144986. */
  144987. union(csg: CSG): CSG;
  144988. /**
  144989. * Unions this CSG with another CSG in place
  144990. * @param csg The CSG to union against this CSG
  144991. */
  144992. unionInPlace(csg: CSG): void;
  144993. /**
  144994. * Subtracts this CSG with another CSG
  144995. * @param csg The CSG to subtract against this CSG
  144996. * @returns A new CSG
  144997. */
  144998. subtract(csg: CSG): CSG;
  144999. /**
  145000. * Subtracts this CSG with another CSG in place
  145001. * @param csg The CSG to subtact against this CSG
  145002. */
  145003. subtractInPlace(csg: CSG): void;
  145004. /**
  145005. * Intersect this CSG with another CSG
  145006. * @param csg The CSG to intersect against this CSG
  145007. * @returns A new CSG
  145008. */
  145009. intersect(csg: CSG): CSG;
  145010. /**
  145011. * Intersects this CSG with another CSG in place
  145012. * @param csg The CSG to intersect against this CSG
  145013. */
  145014. intersectInPlace(csg: CSG): void;
  145015. /**
  145016. * Return a new CSG solid with solid and empty space switched. This solid is
  145017. * not modified.
  145018. * @returns A new CSG solid with solid and empty space switched
  145019. */
  145020. inverse(): CSG;
  145021. /**
  145022. * Inverses the CSG in place
  145023. */
  145024. inverseInPlace(): void;
  145025. /**
  145026. * This is used to keep meshes transformations so they can be restored
  145027. * when we build back a Babylon Mesh
  145028. * NB : All CSG operations are performed in world coordinates
  145029. * @param csg The CSG to copy the transform attributes from
  145030. * @returns This CSG
  145031. */
  145032. copyTransformAttributes(csg: CSG): CSG;
  145033. /**
  145034. * Build Raw mesh from CSG
  145035. * Coordinates here are in world space
  145036. * @param name The name of the mesh geometry
  145037. * @param scene The Scene
  145038. * @param keepSubMeshes Specifies if the submeshes should be kept
  145039. * @returns A new Mesh
  145040. */
  145041. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145042. /**
  145043. * Build Mesh from CSG taking material and transforms into account
  145044. * @param name The name of the Mesh
  145045. * @param material The material of the Mesh
  145046. * @param scene The Scene
  145047. * @param keepSubMeshes Specifies if submeshes should be kept
  145048. * @returns The new Mesh
  145049. */
  145050. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145051. }
  145052. }
  145053. declare module BABYLON {
  145054. /**
  145055. * Class used to create a trail following a mesh
  145056. */
  145057. export class TrailMesh extends Mesh {
  145058. private _generator;
  145059. private _autoStart;
  145060. private _running;
  145061. private _diameter;
  145062. private _length;
  145063. private _sectionPolygonPointsCount;
  145064. private _sectionVectors;
  145065. private _sectionNormalVectors;
  145066. private _beforeRenderObserver;
  145067. /**
  145068. * @constructor
  145069. * @param name The value used by scene.getMeshByName() to do a lookup.
  145070. * @param generator The mesh or transform node to generate a trail.
  145071. * @param scene The scene to add this mesh to.
  145072. * @param diameter Diameter of trailing mesh. Default is 1.
  145073. * @param length Length of trailing mesh. Default is 60.
  145074. * @param autoStart Automatically start trailing mesh. Default true.
  145075. */
  145076. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145077. /**
  145078. * "TrailMesh"
  145079. * @returns "TrailMesh"
  145080. */
  145081. getClassName(): string;
  145082. private _createMesh;
  145083. /**
  145084. * Start trailing mesh.
  145085. */
  145086. start(): void;
  145087. /**
  145088. * Stop trailing mesh.
  145089. */
  145090. stop(): void;
  145091. /**
  145092. * Update trailing mesh geometry.
  145093. */
  145094. update(): void;
  145095. /**
  145096. * Returns a new TrailMesh object.
  145097. * @param name is a string, the name given to the new mesh
  145098. * @param newGenerator use new generator object for cloned trail mesh
  145099. * @returns a new mesh
  145100. */
  145101. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145102. /**
  145103. * Serializes this trail mesh
  145104. * @param serializationObject object to write serialization to
  145105. */
  145106. serialize(serializationObject: any): void;
  145107. /**
  145108. * Parses a serialized trail mesh
  145109. * @param parsedMesh the serialized mesh
  145110. * @param scene the scene to create the trail mesh in
  145111. * @returns the created trail mesh
  145112. */
  145113. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145114. }
  145115. }
  145116. declare module BABYLON {
  145117. /**
  145118. * Class containing static functions to help procedurally build meshes
  145119. */
  145120. export class TiledBoxBuilder {
  145121. /**
  145122. * Creates a box mesh
  145123. * 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)
  145124. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145128. * @param name defines the name of the mesh
  145129. * @param options defines the options used to create the mesh
  145130. * @param scene defines the hosting scene
  145131. * @returns the box mesh
  145132. */
  145133. static CreateTiledBox(name: string, options: {
  145134. pattern?: number;
  145135. width?: number;
  145136. height?: number;
  145137. depth?: number;
  145138. tileSize?: number;
  145139. tileWidth?: number;
  145140. tileHeight?: number;
  145141. alignHorizontal?: number;
  145142. alignVertical?: number;
  145143. faceUV?: Vector4[];
  145144. faceColors?: Color4[];
  145145. sideOrientation?: number;
  145146. updatable?: boolean;
  145147. }, scene?: Nullable<Scene>): Mesh;
  145148. }
  145149. }
  145150. declare module BABYLON {
  145151. /**
  145152. * Class containing static functions to help procedurally build meshes
  145153. */
  145154. export class TorusKnotBuilder {
  145155. /**
  145156. * Creates a torus knot mesh
  145157. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145158. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145159. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145160. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145164. * @param name defines the name of the mesh
  145165. * @param options defines the options used to create the mesh
  145166. * @param scene defines the hosting scene
  145167. * @returns the torus knot mesh
  145168. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145169. */
  145170. static CreateTorusKnot(name: string, options: {
  145171. radius?: number;
  145172. tube?: number;
  145173. radialSegments?: number;
  145174. tubularSegments?: number;
  145175. p?: number;
  145176. q?: number;
  145177. updatable?: boolean;
  145178. sideOrientation?: number;
  145179. frontUVs?: Vector4;
  145180. backUVs?: Vector4;
  145181. }, scene: any): Mesh;
  145182. }
  145183. }
  145184. declare module BABYLON {
  145185. /**
  145186. * Polygon
  145187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145188. */
  145189. export class Polygon {
  145190. /**
  145191. * Creates a rectangle
  145192. * @param xmin bottom X coord
  145193. * @param ymin bottom Y coord
  145194. * @param xmax top X coord
  145195. * @param ymax top Y coord
  145196. * @returns points that make the resulting rectation
  145197. */
  145198. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145199. /**
  145200. * Creates a circle
  145201. * @param radius radius of circle
  145202. * @param cx scale in x
  145203. * @param cy scale in y
  145204. * @param numberOfSides number of sides that make up the circle
  145205. * @returns points that make the resulting circle
  145206. */
  145207. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145208. /**
  145209. * Creates a polygon from input string
  145210. * @param input Input polygon data
  145211. * @returns the parsed points
  145212. */
  145213. static Parse(input: string): Vector2[];
  145214. /**
  145215. * Starts building a polygon from x and y coordinates
  145216. * @param x x coordinate
  145217. * @param y y coordinate
  145218. * @returns the started path2
  145219. */
  145220. static StartingAt(x: number, y: number): Path2;
  145221. }
  145222. /**
  145223. * Builds a polygon
  145224. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145225. */
  145226. export class PolygonMeshBuilder {
  145227. private _points;
  145228. private _outlinepoints;
  145229. private _holes;
  145230. private _name;
  145231. private _scene;
  145232. private _epoints;
  145233. private _eholes;
  145234. private _addToepoint;
  145235. /**
  145236. * Babylon reference to the earcut plugin.
  145237. */
  145238. bjsEarcut: any;
  145239. /**
  145240. * Creates a PolygonMeshBuilder
  145241. * @param name name of the builder
  145242. * @param contours Path of the polygon
  145243. * @param scene scene to add to when creating the mesh
  145244. * @param earcutInjection can be used to inject your own earcut reference
  145245. */
  145246. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145247. /**
  145248. * Adds a whole within the polygon
  145249. * @param hole Array of points defining the hole
  145250. * @returns this
  145251. */
  145252. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145253. /**
  145254. * Creates the polygon
  145255. * @param updatable If the mesh should be updatable
  145256. * @param depth The depth of the mesh created
  145257. * @returns the created mesh
  145258. */
  145259. build(updatable?: boolean, depth?: number): Mesh;
  145260. /**
  145261. * Creates the polygon
  145262. * @param depth The depth of the mesh created
  145263. * @returns the created VertexData
  145264. */
  145265. buildVertexData(depth?: number): VertexData;
  145266. /**
  145267. * Adds a side to the polygon
  145268. * @param positions points that make the polygon
  145269. * @param normals normals of the polygon
  145270. * @param uvs uvs of the polygon
  145271. * @param indices indices of the polygon
  145272. * @param bounds bounds of the polygon
  145273. * @param points points of the polygon
  145274. * @param depth depth of the polygon
  145275. * @param flip flip of the polygon
  145276. */
  145277. private addSide;
  145278. }
  145279. }
  145280. declare module BABYLON {
  145281. /**
  145282. * Class containing static functions to help procedurally build meshes
  145283. */
  145284. export class PolygonBuilder {
  145285. /**
  145286. * Creates a polygon mesh
  145287. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145288. * * 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
  145289. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145292. * * Remember you can only change the shape positions, not their number when updating a polygon
  145293. * @param name defines the name of the mesh
  145294. * @param options defines the options used to create the mesh
  145295. * @param scene defines the hosting scene
  145296. * @param earcutInjection can be used to inject your own earcut reference
  145297. * @returns the polygon mesh
  145298. */
  145299. static CreatePolygon(name: string, options: {
  145300. shape: Vector3[];
  145301. holes?: Vector3[][];
  145302. depth?: number;
  145303. faceUV?: Vector4[];
  145304. faceColors?: Color4[];
  145305. updatable?: boolean;
  145306. sideOrientation?: number;
  145307. frontUVs?: Vector4;
  145308. backUVs?: Vector4;
  145309. wrap?: boolean;
  145310. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145311. /**
  145312. * Creates an extruded polygon mesh, with depth in the Y direction.
  145313. * * 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)
  145314. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145315. * @param name defines the name of the mesh
  145316. * @param options defines the options used to create the mesh
  145317. * @param scene defines the hosting scene
  145318. * @param earcutInjection can be used to inject your own earcut reference
  145319. * @returns the polygon mesh
  145320. */
  145321. static ExtrudePolygon(name: string, options: {
  145322. shape: Vector3[];
  145323. holes?: Vector3[][];
  145324. depth?: number;
  145325. faceUV?: Vector4[];
  145326. faceColors?: Color4[];
  145327. updatable?: boolean;
  145328. sideOrientation?: number;
  145329. frontUVs?: Vector4;
  145330. backUVs?: Vector4;
  145331. wrap?: boolean;
  145332. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145333. }
  145334. }
  145335. declare module BABYLON {
  145336. /**
  145337. * Class containing static functions to help procedurally build meshes
  145338. */
  145339. export class LatheBuilder {
  145340. /**
  145341. * Creates lathe mesh.
  145342. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145343. * * 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
  145344. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145345. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145346. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145347. * * 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
  145348. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145349. * * 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
  145350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145352. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145354. * @param name defines the name of the mesh
  145355. * @param options defines the options used to create the mesh
  145356. * @param scene defines the hosting scene
  145357. * @returns the lathe mesh
  145358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145359. */
  145360. static CreateLathe(name: string, options: {
  145361. shape: Vector3[];
  145362. radius?: number;
  145363. tessellation?: number;
  145364. clip?: number;
  145365. arc?: number;
  145366. closed?: boolean;
  145367. updatable?: boolean;
  145368. sideOrientation?: number;
  145369. frontUVs?: Vector4;
  145370. backUVs?: Vector4;
  145371. cap?: number;
  145372. invertUV?: boolean;
  145373. }, scene?: Nullable<Scene>): Mesh;
  145374. }
  145375. }
  145376. declare module BABYLON {
  145377. /**
  145378. * Class containing static functions to help procedurally build meshes
  145379. */
  145380. export class TiledPlaneBuilder {
  145381. /**
  145382. * Creates a tiled plane mesh
  145383. * * The parameter `pattern` will, depending on value, do nothing or
  145384. * * * flip (reflect about central vertical) alternate tiles across and up
  145385. * * * flip every tile on alternate rows
  145386. * * * rotate (180 degs) alternate tiles across and up
  145387. * * * rotate every tile on alternate rows
  145388. * * * flip and rotate alternate tiles across and up
  145389. * * * flip and rotate every tile on alternate rows
  145390. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145391. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145393. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145394. * * 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)
  145395. * * 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)
  145396. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145397. * @param name defines the name of the mesh
  145398. * @param options defines the options used to create the mesh
  145399. * @param scene defines the hosting scene
  145400. * @returns the box mesh
  145401. */
  145402. static CreateTiledPlane(name: string, options: {
  145403. pattern?: number;
  145404. tileSize?: number;
  145405. tileWidth?: number;
  145406. tileHeight?: number;
  145407. size?: number;
  145408. width?: number;
  145409. height?: number;
  145410. alignHorizontal?: number;
  145411. alignVertical?: number;
  145412. sideOrientation?: number;
  145413. frontUVs?: Vector4;
  145414. backUVs?: Vector4;
  145415. updatable?: boolean;
  145416. }, scene?: Nullable<Scene>): Mesh;
  145417. }
  145418. }
  145419. declare module BABYLON {
  145420. /**
  145421. * Class containing static functions to help procedurally build meshes
  145422. */
  145423. export class TubeBuilder {
  145424. /**
  145425. * Creates a tube mesh.
  145426. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145427. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145428. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145429. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145430. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145431. * * 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)
  145432. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145433. * * 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
  145434. * * 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
  145435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145437. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145439. * @param name defines the name of the mesh
  145440. * @param options defines the options used to create the mesh
  145441. * @param scene defines the hosting scene
  145442. * @returns the tube mesh
  145443. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145444. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145445. */
  145446. static CreateTube(name: string, options: {
  145447. path: Vector3[];
  145448. radius?: number;
  145449. tessellation?: number;
  145450. radiusFunction?: {
  145451. (i: number, distance: number): number;
  145452. };
  145453. cap?: number;
  145454. arc?: number;
  145455. updatable?: boolean;
  145456. sideOrientation?: number;
  145457. frontUVs?: Vector4;
  145458. backUVs?: Vector4;
  145459. instance?: Mesh;
  145460. invertUV?: boolean;
  145461. }, scene?: Nullable<Scene>): Mesh;
  145462. }
  145463. }
  145464. declare module BABYLON {
  145465. /**
  145466. * Class containing static functions to help procedurally build meshes
  145467. */
  145468. export class IcoSphereBuilder {
  145469. /**
  145470. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145471. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145472. * * 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`)
  145473. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145474. * * 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
  145475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145476. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145478. * @param name defines the name of the mesh
  145479. * @param options defines the options used to create the mesh
  145480. * @param scene defines the hosting scene
  145481. * @returns the icosahedron mesh
  145482. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145483. */
  145484. static CreateIcoSphere(name: string, options: {
  145485. radius?: number;
  145486. radiusX?: number;
  145487. radiusY?: number;
  145488. radiusZ?: number;
  145489. flat?: boolean;
  145490. subdivisions?: number;
  145491. sideOrientation?: number;
  145492. frontUVs?: Vector4;
  145493. backUVs?: Vector4;
  145494. updatable?: boolean;
  145495. }, scene?: Nullable<Scene>): Mesh;
  145496. }
  145497. }
  145498. declare module BABYLON {
  145499. /**
  145500. * Class containing static functions to help procedurally build meshes
  145501. */
  145502. export class DecalBuilder {
  145503. /**
  145504. * Creates a decal mesh.
  145505. * 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
  145506. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145507. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145508. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145509. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145510. * @param name defines the name of the mesh
  145511. * @param sourceMesh defines the mesh where the decal must be applied
  145512. * @param options defines the options used to create the mesh
  145513. * @param scene defines the hosting scene
  145514. * @returns the decal mesh
  145515. * @see https://doc.babylonjs.com/how_to/decals
  145516. */
  145517. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145518. position?: Vector3;
  145519. normal?: Vector3;
  145520. size?: Vector3;
  145521. angle?: number;
  145522. }): Mesh;
  145523. }
  145524. }
  145525. declare module BABYLON {
  145526. /**
  145527. * Class containing static functions to help procedurally build meshes
  145528. */
  145529. export class MeshBuilder {
  145530. /**
  145531. * Creates a box mesh
  145532. * * The parameter `size` sets the size (float) of each box side (default 1)
  145533. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  145534. * * 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)
  145535. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145539. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145540. * @param name defines the name of the mesh
  145541. * @param options defines the options used to create the mesh
  145542. * @param scene defines the hosting scene
  145543. * @returns the box mesh
  145544. */
  145545. static CreateBox(name: string, options: {
  145546. size?: number;
  145547. width?: number;
  145548. height?: number;
  145549. depth?: number;
  145550. faceUV?: Vector4[];
  145551. faceColors?: Color4[];
  145552. sideOrientation?: number;
  145553. frontUVs?: Vector4;
  145554. backUVs?: Vector4;
  145555. wrap?: boolean;
  145556. topBaseAt?: number;
  145557. bottomBaseAt?: number;
  145558. updatable?: boolean;
  145559. }, scene?: Nullable<Scene>): Mesh;
  145560. /**
  145561. * Creates a tiled box mesh
  145562. * * faceTiles sets the pattern, tile size and number of tiles for a face
  145563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145564. * @param name defines the name of the mesh
  145565. * @param options defines the options used to create the mesh
  145566. * @param scene defines the hosting scene
  145567. * @returns the tiled box mesh
  145568. */
  145569. static CreateTiledBox(name: string, options: {
  145570. pattern?: number;
  145571. size?: number;
  145572. width?: number;
  145573. height?: number;
  145574. depth: number;
  145575. tileSize?: number;
  145576. tileWidth?: number;
  145577. tileHeight?: number;
  145578. faceUV?: Vector4[];
  145579. faceColors?: Color4[];
  145580. alignHorizontal?: number;
  145581. alignVertical?: number;
  145582. sideOrientation?: number;
  145583. updatable?: boolean;
  145584. }, scene?: Nullable<Scene>): Mesh;
  145585. /**
  145586. * Creates a sphere mesh
  145587. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  145588. * * 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`)
  145589. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  145590. * * 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
  145591. * * 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)
  145592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145595. * @param name defines the name of the mesh
  145596. * @param options defines the options used to create the mesh
  145597. * @param scene defines the hosting scene
  145598. * @returns the sphere mesh
  145599. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  145600. */
  145601. static CreateSphere(name: string, options: {
  145602. segments?: number;
  145603. diameter?: number;
  145604. diameterX?: number;
  145605. diameterY?: number;
  145606. diameterZ?: number;
  145607. arc?: number;
  145608. slice?: number;
  145609. sideOrientation?: number;
  145610. frontUVs?: Vector4;
  145611. backUVs?: Vector4;
  145612. updatable?: boolean;
  145613. }, scene?: Nullable<Scene>): Mesh;
  145614. /**
  145615. * Creates a plane polygonal mesh. By default, this is a disc
  145616. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  145617. * * 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
  145618. * * 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
  145619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145622. * @param name defines the name of the mesh
  145623. * @param options defines the options used to create the mesh
  145624. * @param scene defines the hosting scene
  145625. * @returns the plane polygonal mesh
  145626. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  145627. */
  145628. static CreateDisc(name: string, options: {
  145629. radius?: number;
  145630. tessellation?: number;
  145631. arc?: number;
  145632. updatable?: boolean;
  145633. sideOrientation?: number;
  145634. frontUVs?: Vector4;
  145635. backUVs?: Vector4;
  145636. }, scene?: Nullable<Scene>): Mesh;
  145637. /**
  145638. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145639. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145640. * * 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`)
  145641. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145642. * * 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
  145643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145646. * @param name defines the name of the mesh
  145647. * @param options defines the options used to create the mesh
  145648. * @param scene defines the hosting scene
  145649. * @returns the icosahedron mesh
  145650. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145651. */
  145652. static CreateIcoSphere(name: string, options: {
  145653. radius?: number;
  145654. radiusX?: number;
  145655. radiusY?: number;
  145656. radiusZ?: number;
  145657. flat?: boolean;
  145658. subdivisions?: number;
  145659. sideOrientation?: number;
  145660. frontUVs?: Vector4;
  145661. backUVs?: Vector4;
  145662. updatable?: boolean;
  145663. }, scene?: Nullable<Scene>): Mesh;
  145664. /**
  145665. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145666. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  145667. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  145668. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  145669. * * 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
  145670. * * 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
  145671. * * 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
  145672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145674. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145675. * * 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
  145676. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  145677. * * 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
  145678. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  145679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145680. * @param name defines the name of the mesh
  145681. * @param options defines the options used to create the mesh
  145682. * @param scene defines the hosting scene
  145683. * @returns the ribbon mesh
  145684. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  145685. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145686. */
  145687. static CreateRibbon(name: string, options: {
  145688. pathArray: Vector3[][];
  145689. closeArray?: boolean;
  145690. closePath?: boolean;
  145691. offset?: number;
  145692. updatable?: boolean;
  145693. sideOrientation?: number;
  145694. frontUVs?: Vector4;
  145695. backUVs?: Vector4;
  145696. instance?: Mesh;
  145697. invertUV?: boolean;
  145698. uvs?: Vector2[];
  145699. colors?: Color4[];
  145700. }, scene?: Nullable<Scene>): Mesh;
  145701. /**
  145702. * Creates a cylinder or a cone mesh
  145703. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  145704. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  145705. * * 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.
  145706. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  145707. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  145708. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  145709. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  145710. * * 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).
  145711. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145712. * * 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).
  145713. * * 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
  145714. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145715. * * 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
  145716. * * 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.
  145717. * * If `enclose` is false, a ring surface is one element.
  145718. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145719. * * 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
  145720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145723. * @param name defines the name of the mesh
  145724. * @param options defines the options used to create the mesh
  145725. * @param scene defines the hosting scene
  145726. * @returns the cylinder mesh
  145727. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145728. */
  145729. static CreateCylinder(name: string, options: {
  145730. height?: number;
  145731. diameterTop?: number;
  145732. diameterBottom?: number;
  145733. diameter?: number;
  145734. tessellation?: number;
  145735. subdivisions?: number;
  145736. arc?: number;
  145737. faceColors?: Color4[];
  145738. faceUV?: Vector4[];
  145739. updatable?: boolean;
  145740. hasRings?: boolean;
  145741. enclose?: boolean;
  145742. cap?: number;
  145743. sideOrientation?: number;
  145744. frontUVs?: Vector4;
  145745. backUVs?: Vector4;
  145746. }, scene?: Nullable<Scene>): Mesh;
  145747. /**
  145748. * Creates a torus mesh
  145749. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145750. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145751. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145755. * @param name defines the name of the mesh
  145756. * @param options defines the options used to create the mesh
  145757. * @param scene defines the hosting scene
  145758. * @returns the torus mesh
  145759. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145760. */
  145761. static CreateTorus(name: string, options: {
  145762. diameter?: number;
  145763. thickness?: number;
  145764. tessellation?: number;
  145765. updatable?: boolean;
  145766. sideOrientation?: number;
  145767. frontUVs?: Vector4;
  145768. backUVs?: Vector4;
  145769. }, scene?: Nullable<Scene>): Mesh;
  145770. /**
  145771. * Creates a torus knot mesh
  145772. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145773. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145774. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145775. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145779. * @param name defines the name of the mesh
  145780. * @param options defines the options used to create the mesh
  145781. * @param scene defines the hosting scene
  145782. * @returns the torus knot mesh
  145783. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145784. */
  145785. static CreateTorusKnot(name: string, options: {
  145786. radius?: number;
  145787. tube?: number;
  145788. radialSegments?: number;
  145789. tubularSegments?: number;
  145790. p?: number;
  145791. q?: number;
  145792. updatable?: boolean;
  145793. sideOrientation?: number;
  145794. frontUVs?: Vector4;
  145795. backUVs?: Vector4;
  145796. }, scene?: Nullable<Scene>): Mesh;
  145797. /**
  145798. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  145799. * * 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
  145800. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  145801. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  145802. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  145803. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  145804. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  145805. * * 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
  145806. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  145807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145808. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  145809. * @param name defines the name of the new line system
  145810. * @param options defines the options used to create the line system
  145811. * @param scene defines the hosting scene
  145812. * @returns a new line system mesh
  145813. */
  145814. static CreateLineSystem(name: string, options: {
  145815. lines: Vector3[][];
  145816. updatable?: boolean;
  145817. instance?: Nullable<LinesMesh>;
  145818. colors?: Nullable<Color4[][]>;
  145819. useVertexAlpha?: boolean;
  145820. }, scene: Nullable<Scene>): LinesMesh;
  145821. /**
  145822. * Creates a line mesh
  145823. * 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
  145824. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145825. * * The parameter `points` is an array successive Vector3
  145826. * * 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
  145827. * * The optional parameter `colors` is an array of successive Color4, one per line point
  145828. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  145829. * * When updating an instance, remember that only point positions can change, not the number of points
  145830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  145832. * @param name defines the name of the new line system
  145833. * @param options defines the options used to create the line system
  145834. * @param scene defines the hosting scene
  145835. * @returns a new line mesh
  145836. */
  145837. static CreateLines(name: string, options: {
  145838. points: Vector3[];
  145839. updatable?: boolean;
  145840. instance?: Nullable<LinesMesh>;
  145841. colors?: Color4[];
  145842. useVertexAlpha?: boolean;
  145843. }, scene?: Nullable<Scene>): LinesMesh;
  145844. /**
  145845. * Creates a dashed line mesh
  145846. * * 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
  145847. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145848. * * The parameter `points` is an array successive Vector3
  145849. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  145850. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  145851. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  145852. * * 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
  145853. * * When updating an instance, remember that only point positions can change, not the number of points
  145854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145855. * @param name defines the name of the mesh
  145856. * @param options defines the options used to create the mesh
  145857. * @param scene defines the hosting scene
  145858. * @returns the dashed line mesh
  145859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  145860. */
  145861. static CreateDashedLines(name: string, options: {
  145862. points: Vector3[];
  145863. dashSize?: number;
  145864. gapSize?: number;
  145865. dashNb?: number;
  145866. updatable?: boolean;
  145867. instance?: LinesMesh;
  145868. }, scene?: Nullable<Scene>): LinesMesh;
  145869. /**
  145870. * 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.
  145871. * * 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.
  145872. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145873. * * 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.
  145874. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  145875. * * 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
  145876. * * 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
  145877. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  145878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145880. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  145881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145882. * @param name defines the name of the mesh
  145883. * @param options defines the options used to create the mesh
  145884. * @param scene defines the hosting scene
  145885. * @returns the extruded shape mesh
  145886. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145888. */
  145889. static ExtrudeShape(name: string, options: {
  145890. shape: Vector3[];
  145891. path: Vector3[];
  145892. scale?: number;
  145893. rotation?: number;
  145894. cap?: number;
  145895. updatable?: boolean;
  145896. sideOrientation?: number;
  145897. frontUVs?: Vector4;
  145898. backUVs?: Vector4;
  145899. instance?: Mesh;
  145900. invertUV?: boolean;
  145901. }, scene?: Nullable<Scene>): Mesh;
  145902. /**
  145903. * Creates an custom extruded shape mesh.
  145904. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  145905. * * 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.
  145906. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145907. * * 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
  145908. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  145909. * * 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
  145910. * * It must returns a float value that will be the scale value applied to the shape on each path point
  145911. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  145912. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  145913. * * 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
  145914. * * 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
  145915. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  145916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145920. * @param name defines the name of the mesh
  145921. * @param options defines the options used to create the mesh
  145922. * @param scene defines the hosting scene
  145923. * @returns the custom extruded shape mesh
  145924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  145925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145927. */
  145928. static ExtrudeShapeCustom(name: string, options: {
  145929. shape: Vector3[];
  145930. path: Vector3[];
  145931. scaleFunction?: any;
  145932. rotationFunction?: any;
  145933. ribbonCloseArray?: boolean;
  145934. ribbonClosePath?: boolean;
  145935. cap?: number;
  145936. updatable?: boolean;
  145937. sideOrientation?: number;
  145938. frontUVs?: Vector4;
  145939. backUVs?: Vector4;
  145940. instance?: Mesh;
  145941. invertUV?: boolean;
  145942. }, scene?: Nullable<Scene>): Mesh;
  145943. /**
  145944. * Creates lathe mesh.
  145945. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145946. * * 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
  145947. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145948. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145949. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145950. * * 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
  145951. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145952. * * 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
  145953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145957. * @param name defines the name of the mesh
  145958. * @param options defines the options used to create the mesh
  145959. * @param scene defines the hosting scene
  145960. * @returns the lathe mesh
  145961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145962. */
  145963. static CreateLathe(name: string, options: {
  145964. shape: Vector3[];
  145965. radius?: number;
  145966. tessellation?: number;
  145967. clip?: number;
  145968. arc?: number;
  145969. closed?: boolean;
  145970. updatable?: boolean;
  145971. sideOrientation?: number;
  145972. frontUVs?: Vector4;
  145973. backUVs?: Vector4;
  145974. cap?: number;
  145975. invertUV?: boolean;
  145976. }, scene?: Nullable<Scene>): Mesh;
  145977. /**
  145978. * Creates a tiled plane mesh
  145979. * * You can set a limited pattern arrangement with the tiles
  145980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145983. * @param name defines the name of the mesh
  145984. * @param options defines the options used to create the mesh
  145985. * @param scene defines the hosting scene
  145986. * @returns the plane mesh
  145987. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145988. */
  145989. static CreateTiledPlane(name: string, options: {
  145990. pattern?: number;
  145991. tileSize?: number;
  145992. tileWidth?: number;
  145993. tileHeight?: number;
  145994. size?: number;
  145995. width?: number;
  145996. height?: number;
  145997. alignHorizontal?: number;
  145998. alignVertical?: number;
  145999. sideOrientation?: number;
  146000. frontUVs?: Vector4;
  146001. backUVs?: Vector4;
  146002. updatable?: boolean;
  146003. }, scene?: Nullable<Scene>): Mesh;
  146004. /**
  146005. * Creates a plane mesh
  146006. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146007. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146008. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146012. * @param name defines the name of the mesh
  146013. * @param options defines the options used to create the mesh
  146014. * @param scene defines the hosting scene
  146015. * @returns the plane mesh
  146016. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146017. */
  146018. static CreatePlane(name: string, options: {
  146019. size?: number;
  146020. width?: number;
  146021. height?: number;
  146022. sideOrientation?: number;
  146023. frontUVs?: Vector4;
  146024. backUVs?: Vector4;
  146025. updatable?: boolean;
  146026. sourcePlane?: Plane;
  146027. }, scene?: Nullable<Scene>): Mesh;
  146028. /**
  146029. * Creates a ground mesh
  146030. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146031. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146033. * @param name defines the name of the mesh
  146034. * @param options defines the options used to create the mesh
  146035. * @param scene defines the hosting scene
  146036. * @returns the ground mesh
  146037. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146038. */
  146039. static CreateGround(name: string, options: {
  146040. width?: number;
  146041. height?: number;
  146042. subdivisions?: number;
  146043. subdivisionsX?: number;
  146044. subdivisionsY?: number;
  146045. updatable?: boolean;
  146046. }, scene?: Nullable<Scene>): Mesh;
  146047. /**
  146048. * Creates a tiled ground mesh
  146049. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146050. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146051. * * 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
  146052. * * 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
  146053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146054. * @param name defines the name of the mesh
  146055. * @param options defines the options used to create the mesh
  146056. * @param scene defines the hosting scene
  146057. * @returns the tiled ground mesh
  146058. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146059. */
  146060. static CreateTiledGround(name: string, options: {
  146061. xmin: number;
  146062. zmin: number;
  146063. xmax: number;
  146064. zmax: number;
  146065. subdivisions?: {
  146066. w: number;
  146067. h: number;
  146068. };
  146069. precision?: {
  146070. w: number;
  146071. h: number;
  146072. };
  146073. updatable?: boolean;
  146074. }, scene?: Nullable<Scene>): Mesh;
  146075. /**
  146076. * Creates a ground mesh from a height map
  146077. * * The parameter `url` sets the URL of the height map image resource.
  146078. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146079. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146080. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146081. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146082. * * 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.
  146083. * * 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).
  146084. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146086. * @param name defines the name of the mesh
  146087. * @param url defines the url to the height map
  146088. * @param options defines the options used to create the mesh
  146089. * @param scene defines the hosting scene
  146090. * @returns the ground mesh
  146091. * @see https://doc.babylonjs.com/babylon101/height_map
  146092. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146093. */
  146094. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146095. width?: number;
  146096. height?: number;
  146097. subdivisions?: number;
  146098. minHeight?: number;
  146099. maxHeight?: number;
  146100. colorFilter?: Color3;
  146101. alphaFilter?: number;
  146102. updatable?: boolean;
  146103. onReady?: (mesh: GroundMesh) => void;
  146104. }, scene?: Nullable<Scene>): GroundMesh;
  146105. /**
  146106. * Creates a polygon mesh
  146107. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146108. * * 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
  146109. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146112. * * Remember you can only change the shape positions, not their number when updating a polygon
  146113. * @param name defines the name of the mesh
  146114. * @param options defines the options used to create the mesh
  146115. * @param scene defines the hosting scene
  146116. * @param earcutInjection can be used to inject your own earcut reference
  146117. * @returns the polygon mesh
  146118. */
  146119. static CreatePolygon(name: string, options: {
  146120. shape: Vector3[];
  146121. holes?: Vector3[][];
  146122. depth?: number;
  146123. faceUV?: Vector4[];
  146124. faceColors?: Color4[];
  146125. updatable?: boolean;
  146126. sideOrientation?: number;
  146127. frontUVs?: Vector4;
  146128. backUVs?: Vector4;
  146129. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146130. /**
  146131. * Creates an extruded polygon mesh, with depth in the Y direction.
  146132. * * 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)
  146133. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146134. * @param name defines the name of the mesh
  146135. * @param options defines the options used to create the mesh
  146136. * @param scene defines the hosting scene
  146137. * @param earcutInjection can be used to inject your own earcut reference
  146138. * @returns the polygon mesh
  146139. */
  146140. static ExtrudePolygon(name: string, options: {
  146141. shape: Vector3[];
  146142. holes?: Vector3[][];
  146143. depth?: number;
  146144. faceUV?: Vector4[];
  146145. faceColors?: Color4[];
  146146. updatable?: boolean;
  146147. sideOrientation?: number;
  146148. frontUVs?: Vector4;
  146149. backUVs?: Vector4;
  146150. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146151. /**
  146152. * Creates a tube mesh.
  146153. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146154. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146155. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146156. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146157. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146158. * * 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)
  146159. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146160. * * 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
  146161. * * 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
  146162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146166. * @param name defines the name of the mesh
  146167. * @param options defines the options used to create the mesh
  146168. * @param scene defines the hosting scene
  146169. * @returns the tube mesh
  146170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146171. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146172. */
  146173. static CreateTube(name: string, options: {
  146174. path: Vector3[];
  146175. radius?: number;
  146176. tessellation?: number;
  146177. radiusFunction?: {
  146178. (i: number, distance: number): number;
  146179. };
  146180. cap?: number;
  146181. arc?: number;
  146182. updatable?: boolean;
  146183. sideOrientation?: number;
  146184. frontUVs?: Vector4;
  146185. backUVs?: Vector4;
  146186. instance?: Mesh;
  146187. invertUV?: boolean;
  146188. }, scene?: Nullable<Scene>): Mesh;
  146189. /**
  146190. * Creates a polyhedron mesh
  146191. * * 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
  146192. * * The parameter `size` (positive float, default 1) sets the polygon size
  146193. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146194. * * 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`
  146195. * * 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
  146196. * * 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)`)
  146197. * * 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
  146198. * * 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
  146199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146202. * @param name defines the name of the mesh
  146203. * @param options defines the options used to create the mesh
  146204. * @param scene defines the hosting scene
  146205. * @returns the polyhedron mesh
  146206. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146207. */
  146208. static CreatePolyhedron(name: string, options: {
  146209. type?: number;
  146210. size?: number;
  146211. sizeX?: number;
  146212. sizeY?: number;
  146213. sizeZ?: number;
  146214. custom?: any;
  146215. faceUV?: Vector4[];
  146216. faceColors?: Color4[];
  146217. flat?: boolean;
  146218. updatable?: boolean;
  146219. sideOrientation?: number;
  146220. frontUVs?: Vector4;
  146221. backUVs?: Vector4;
  146222. }, scene?: Nullable<Scene>): Mesh;
  146223. /**
  146224. * Creates a decal mesh.
  146225. * 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
  146226. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146227. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146228. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146229. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146230. * @param name defines the name of the mesh
  146231. * @param sourceMesh defines the mesh where the decal must be applied
  146232. * @param options defines the options used to create the mesh
  146233. * @param scene defines the hosting scene
  146234. * @returns the decal mesh
  146235. * @see https://doc.babylonjs.com/how_to/decals
  146236. */
  146237. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146238. position?: Vector3;
  146239. normal?: Vector3;
  146240. size?: Vector3;
  146241. angle?: number;
  146242. }): Mesh;
  146243. }
  146244. }
  146245. declare module BABYLON {
  146246. /**
  146247. * A simplifier interface for future simplification implementations
  146248. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146249. */
  146250. export interface ISimplifier {
  146251. /**
  146252. * Simplification of a given mesh according to the given settings.
  146253. * Since this requires computation, it is assumed that the function runs async.
  146254. * @param settings The settings of the simplification, including quality and distance
  146255. * @param successCallback A callback that will be called after the mesh was simplified.
  146256. * @param errorCallback in case of an error, this callback will be called. optional.
  146257. */
  146258. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146259. }
  146260. /**
  146261. * Expected simplification settings.
  146262. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146263. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146264. */
  146265. export interface ISimplificationSettings {
  146266. /**
  146267. * Gets or sets the expected quality
  146268. */
  146269. quality: number;
  146270. /**
  146271. * Gets or sets the distance when this optimized version should be used
  146272. */
  146273. distance: number;
  146274. /**
  146275. * Gets an already optimized mesh
  146276. */
  146277. optimizeMesh?: boolean;
  146278. }
  146279. /**
  146280. * Class used to specify simplification options
  146281. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146282. */
  146283. export class SimplificationSettings implements ISimplificationSettings {
  146284. /** expected quality */
  146285. quality: number;
  146286. /** distance when this optimized version should be used */
  146287. distance: number;
  146288. /** already optimized mesh */
  146289. optimizeMesh?: boolean | undefined;
  146290. /**
  146291. * Creates a SimplificationSettings
  146292. * @param quality expected quality
  146293. * @param distance distance when this optimized version should be used
  146294. * @param optimizeMesh already optimized mesh
  146295. */
  146296. constructor(
  146297. /** expected quality */
  146298. quality: number,
  146299. /** distance when this optimized version should be used */
  146300. distance: number,
  146301. /** already optimized mesh */
  146302. optimizeMesh?: boolean | undefined);
  146303. }
  146304. /**
  146305. * Interface used to define a simplification task
  146306. */
  146307. export interface ISimplificationTask {
  146308. /**
  146309. * Array of settings
  146310. */
  146311. settings: Array<ISimplificationSettings>;
  146312. /**
  146313. * Simplification type
  146314. */
  146315. simplificationType: SimplificationType;
  146316. /**
  146317. * Mesh to simplify
  146318. */
  146319. mesh: Mesh;
  146320. /**
  146321. * Callback called on success
  146322. */
  146323. successCallback?: () => void;
  146324. /**
  146325. * Defines if parallel processing can be used
  146326. */
  146327. parallelProcessing: boolean;
  146328. }
  146329. /**
  146330. * Queue used to order the simplification tasks
  146331. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146332. */
  146333. export class SimplificationQueue {
  146334. private _simplificationArray;
  146335. /**
  146336. * Gets a boolean indicating that the process is still running
  146337. */
  146338. running: boolean;
  146339. /**
  146340. * Creates a new queue
  146341. */
  146342. constructor();
  146343. /**
  146344. * Adds a new simplification task
  146345. * @param task defines a task to add
  146346. */
  146347. addTask(task: ISimplificationTask): void;
  146348. /**
  146349. * Execute next task
  146350. */
  146351. executeNext(): void;
  146352. /**
  146353. * Execute a simplification task
  146354. * @param task defines the task to run
  146355. */
  146356. runSimplification(task: ISimplificationTask): void;
  146357. private getSimplifier;
  146358. }
  146359. /**
  146360. * The implemented types of simplification
  146361. * At the moment only Quadratic Error Decimation is implemented
  146362. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146363. */
  146364. export enum SimplificationType {
  146365. /** Quadratic error decimation */
  146366. QUADRATIC = 0
  146367. }
  146368. /**
  146369. * An implementation of the Quadratic Error simplification algorithm.
  146370. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146371. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146372. * @author RaananW
  146373. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146374. */
  146375. export class QuadraticErrorSimplification implements ISimplifier {
  146376. private _mesh;
  146377. private triangles;
  146378. private vertices;
  146379. private references;
  146380. private _reconstructedMesh;
  146381. /** Gets or sets the number pf sync interations */
  146382. syncIterations: number;
  146383. /** Gets or sets the aggressiveness of the simplifier */
  146384. aggressiveness: number;
  146385. /** Gets or sets the number of allowed iterations for decimation */
  146386. decimationIterations: number;
  146387. /** Gets or sets the espilon to use for bounding box computation */
  146388. boundingBoxEpsilon: number;
  146389. /**
  146390. * Creates a new QuadraticErrorSimplification
  146391. * @param _mesh defines the target mesh
  146392. */
  146393. constructor(_mesh: Mesh);
  146394. /**
  146395. * Simplification of a given mesh according to the given settings.
  146396. * Since this requires computation, it is assumed that the function runs async.
  146397. * @param settings The settings of the simplification, including quality and distance
  146398. * @param successCallback A callback that will be called after the mesh was simplified.
  146399. */
  146400. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146401. private runDecimation;
  146402. private initWithMesh;
  146403. private init;
  146404. private reconstructMesh;
  146405. private initDecimatedMesh;
  146406. private isFlipped;
  146407. private updateTriangles;
  146408. private identifyBorder;
  146409. private updateMesh;
  146410. private vertexError;
  146411. private calculateError;
  146412. }
  146413. }
  146414. declare module BABYLON {
  146415. interface Scene {
  146416. /** @hidden (Backing field) */
  146417. _simplificationQueue: SimplificationQueue;
  146418. /**
  146419. * Gets or sets the simplification queue attached to the scene
  146420. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146421. */
  146422. simplificationQueue: SimplificationQueue;
  146423. }
  146424. interface Mesh {
  146425. /**
  146426. * Simplify the mesh according to the given array of settings.
  146427. * Function will return immediately and will simplify async
  146428. * @param settings a collection of simplification settings
  146429. * @param parallelProcessing should all levels calculate parallel or one after the other
  146430. * @param simplificationType the type of simplification to run
  146431. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  146432. * @returns the current mesh
  146433. */
  146434. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  146435. }
  146436. /**
  146437. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  146438. * created in a scene
  146439. */
  146440. export class SimplicationQueueSceneComponent implements ISceneComponent {
  146441. /**
  146442. * The component name helpfull to identify the component in the list of scene components.
  146443. */
  146444. readonly name: string;
  146445. /**
  146446. * The scene the component belongs to.
  146447. */
  146448. scene: Scene;
  146449. /**
  146450. * Creates a new instance of the component for the given scene
  146451. * @param scene Defines the scene to register the component in
  146452. */
  146453. constructor(scene: Scene);
  146454. /**
  146455. * Registers the component in a given scene
  146456. */
  146457. register(): void;
  146458. /**
  146459. * Rebuilds the elements related to this component in case of
  146460. * context lost for instance.
  146461. */
  146462. rebuild(): void;
  146463. /**
  146464. * Disposes the component and the associated ressources
  146465. */
  146466. dispose(): void;
  146467. private _beforeCameraUpdate;
  146468. }
  146469. }
  146470. declare module BABYLON {
  146471. interface Mesh {
  146472. /**
  146473. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  146474. */
  146475. thinInstanceEnablePicking: boolean;
  146476. /**
  146477. * Creates a new thin instance
  146478. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  146479. * @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
  146480. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  146481. */
  146482. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  146483. /**
  146484. * Adds the transformation (matrix) of the current mesh as a thin instance
  146485. * @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
  146486. * @returns the thin instance index number
  146487. */
  146488. thinInstanceAddSelf(refresh: boolean): number;
  146489. /**
  146490. * Registers a custom attribute to be used with thin instances
  146491. * @param kind name of the attribute
  146492. * @param stride size in floats of the attribute
  146493. */
  146494. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  146495. /**
  146496. * Sets the matrix of a thin instance
  146497. * @param index index of the thin instance
  146498. * @param matrix matrix to set
  146499. * @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
  146500. */
  146501. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  146502. /**
  146503. * Sets the value of a custom attribute for a thin instance
  146504. * @param kind name of the attribute
  146505. * @param index index of the thin instance
  146506. * @param value value to set
  146507. * @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
  146508. */
  146509. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  146510. /**
  146511. * 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.
  146512. */
  146513. thinInstanceCount: number;
  146514. /**
  146515. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  146516. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  146517. * @param buffer buffer to set
  146518. * @param stride size in floats of each value of the buffer
  146519. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  146520. */
  146521. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  146522. /**
  146523. * Gets the list of world matrices
  146524. * @return an array containing all the world matrices from the thin instances
  146525. */
  146526. thinInstanceGetWorldMatrices(): Matrix[];
  146527. /**
  146528. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  146529. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146530. */
  146531. thinInstanceBufferUpdated(kind: string): void;
  146532. /**
  146533. * Applies a partial update to a buffer directly on the GPU
  146534. * 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
  146535. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146536. * @param data the data to set in the GPU buffer
  146537. * @param offset the offset in the GPU buffer where to update the data
  146538. */
  146539. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  146540. /**
  146541. * Refreshes the bounding info, taking into account all the thin instances defined
  146542. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  146543. */
  146544. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  146545. /** @hidden */
  146546. _thinInstanceInitializeUserStorage(): void;
  146547. /** @hidden */
  146548. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  146549. /** @hidden */
  146550. _userThinInstanceBuffersStorage: {
  146551. data: {
  146552. [key: string]: Float32Array;
  146553. };
  146554. sizes: {
  146555. [key: string]: number;
  146556. };
  146557. vertexBuffers: {
  146558. [key: string]: Nullable<VertexBuffer>;
  146559. };
  146560. strides: {
  146561. [key: string]: number;
  146562. };
  146563. };
  146564. }
  146565. }
  146566. declare module BABYLON {
  146567. /**
  146568. * Navigation plugin interface to add navigation constrained by a navigation mesh
  146569. */
  146570. export interface INavigationEnginePlugin {
  146571. /**
  146572. * plugin name
  146573. */
  146574. name: string;
  146575. /**
  146576. * Creates a navigation mesh
  146577. * @param meshes array of all the geometry used to compute the navigatio mesh
  146578. * @param parameters bunch of parameters used to filter geometry
  146579. */
  146580. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146581. /**
  146582. * Create a navigation mesh debug mesh
  146583. * @param scene is where the mesh will be added
  146584. * @returns debug display mesh
  146585. */
  146586. createDebugNavMesh(scene: Scene): Mesh;
  146587. /**
  146588. * Get a navigation mesh constrained position, closest to the parameter position
  146589. * @param position world position
  146590. * @returns the closest point to position constrained by the navigation mesh
  146591. */
  146592. getClosestPoint(position: Vector3): Vector3;
  146593. /**
  146594. * Get a navigation mesh constrained position, closest to the parameter position
  146595. * @param position world position
  146596. * @param result output the closest point to position constrained by the navigation mesh
  146597. */
  146598. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146599. /**
  146600. * Get a navigation mesh constrained position, within a particular radius
  146601. * @param position world position
  146602. * @param maxRadius the maximum distance to the constrained world position
  146603. * @returns the closest point to position constrained by the navigation mesh
  146604. */
  146605. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146606. /**
  146607. * Get a navigation mesh constrained position, within a particular radius
  146608. * @param position world position
  146609. * @param maxRadius the maximum distance to the constrained world position
  146610. * @param result output the closest point to position constrained by the navigation mesh
  146611. */
  146612. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146613. /**
  146614. * Compute the final position from a segment made of destination-position
  146615. * @param position world position
  146616. * @param destination world position
  146617. * @returns the resulting point along the navmesh
  146618. */
  146619. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146620. /**
  146621. * Compute the final position from a segment made of destination-position
  146622. * @param position world position
  146623. * @param destination world position
  146624. * @param result output the resulting point along the navmesh
  146625. */
  146626. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146627. /**
  146628. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146629. * @param start world position
  146630. * @param end world position
  146631. * @returns array containing world position composing the path
  146632. */
  146633. computePath(start: Vector3, end: Vector3): Vector3[];
  146634. /**
  146635. * If this plugin is supported
  146636. * @returns true if plugin is supported
  146637. */
  146638. isSupported(): boolean;
  146639. /**
  146640. * Create a new Crowd so you can add agents
  146641. * @param maxAgents the maximum agent count in the crowd
  146642. * @param maxAgentRadius the maximum radius an agent can have
  146643. * @param scene to attach the crowd to
  146644. * @returns the crowd you can add agents to
  146645. */
  146646. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146647. /**
  146648. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146649. * The queries will try to find a solution within those bounds
  146650. * default is (1,1,1)
  146651. * @param extent x,y,z value that define the extent around the queries point of reference
  146652. */
  146653. setDefaultQueryExtent(extent: Vector3): void;
  146654. /**
  146655. * Get the Bounding box extent specified by setDefaultQueryExtent
  146656. * @returns the box extent values
  146657. */
  146658. getDefaultQueryExtent(): Vector3;
  146659. /**
  146660. * build the navmesh from a previously saved state using getNavmeshData
  146661. * @param data the Uint8Array returned by getNavmeshData
  146662. */
  146663. buildFromNavmeshData(data: Uint8Array): void;
  146664. /**
  146665. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146666. * @returns data the Uint8Array that can be saved and reused
  146667. */
  146668. getNavmeshData(): Uint8Array;
  146669. /**
  146670. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146671. * @param result output the box extent values
  146672. */
  146673. getDefaultQueryExtentToRef(result: Vector3): void;
  146674. /**
  146675. * Release all resources
  146676. */
  146677. dispose(): void;
  146678. }
  146679. /**
  146680. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  146681. */
  146682. export interface ICrowd {
  146683. /**
  146684. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146685. * You can attach anything to that node. The node position is updated in the scene update tick.
  146686. * @param pos world position that will be constrained by the navigation mesh
  146687. * @param parameters agent parameters
  146688. * @param transform hooked to the agent that will be update by the scene
  146689. * @returns agent index
  146690. */
  146691. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146692. /**
  146693. * Returns the agent position in world space
  146694. * @param index agent index returned by addAgent
  146695. * @returns world space position
  146696. */
  146697. getAgentPosition(index: number): Vector3;
  146698. /**
  146699. * Gets the agent position result in world space
  146700. * @param index agent index returned by addAgent
  146701. * @param result output world space position
  146702. */
  146703. getAgentPositionToRef(index: number, result: Vector3): void;
  146704. /**
  146705. * Gets the agent velocity in world space
  146706. * @param index agent index returned by addAgent
  146707. * @returns world space velocity
  146708. */
  146709. getAgentVelocity(index: number): Vector3;
  146710. /**
  146711. * Gets the agent velocity result in world space
  146712. * @param index agent index returned by addAgent
  146713. * @param result output world space velocity
  146714. */
  146715. getAgentVelocityToRef(index: number, result: Vector3): void;
  146716. /**
  146717. * remove a particular agent previously created
  146718. * @param index agent index returned by addAgent
  146719. */
  146720. removeAgent(index: number): void;
  146721. /**
  146722. * get the list of all agents attached to this crowd
  146723. * @returns list of agent indices
  146724. */
  146725. getAgents(): number[];
  146726. /**
  146727. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146728. * @param deltaTime in seconds
  146729. */
  146730. update(deltaTime: number): void;
  146731. /**
  146732. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146733. * @param index agent index returned by addAgent
  146734. * @param destination targeted world position
  146735. */
  146736. agentGoto(index: number, destination: Vector3): void;
  146737. /**
  146738. * Teleport the agent to a new position
  146739. * @param index agent index returned by addAgent
  146740. * @param destination targeted world position
  146741. */
  146742. agentTeleport(index: number, destination: Vector3): void;
  146743. /**
  146744. * Update agent parameters
  146745. * @param index agent index returned by addAgent
  146746. * @param parameters agent parameters
  146747. */
  146748. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146749. /**
  146750. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146751. * The queries will try to find a solution within those bounds
  146752. * default is (1,1,1)
  146753. * @param extent x,y,z value that define the extent around the queries point of reference
  146754. */
  146755. setDefaultQueryExtent(extent: Vector3): void;
  146756. /**
  146757. * Get the Bounding box extent specified by setDefaultQueryExtent
  146758. * @returns the box extent values
  146759. */
  146760. getDefaultQueryExtent(): Vector3;
  146761. /**
  146762. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146763. * @param result output the box extent values
  146764. */
  146765. getDefaultQueryExtentToRef(result: Vector3): void;
  146766. /**
  146767. * Release all resources
  146768. */
  146769. dispose(): void;
  146770. }
  146771. /**
  146772. * Configures an agent
  146773. */
  146774. export interface IAgentParameters {
  146775. /**
  146776. * Agent radius. [Limit: >= 0]
  146777. */
  146778. radius: number;
  146779. /**
  146780. * Agent height. [Limit: > 0]
  146781. */
  146782. height: number;
  146783. /**
  146784. * Maximum allowed acceleration. [Limit: >= 0]
  146785. */
  146786. maxAcceleration: number;
  146787. /**
  146788. * Maximum allowed speed. [Limit: >= 0]
  146789. */
  146790. maxSpeed: number;
  146791. /**
  146792. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  146793. */
  146794. collisionQueryRange: number;
  146795. /**
  146796. * The path visibility optimization range. [Limit: > 0]
  146797. */
  146798. pathOptimizationRange: number;
  146799. /**
  146800. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  146801. */
  146802. separationWeight: number;
  146803. }
  146804. /**
  146805. * Configures the navigation mesh creation
  146806. */
  146807. export interface INavMeshParameters {
  146808. /**
  146809. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  146810. */
  146811. cs: number;
  146812. /**
  146813. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  146814. */
  146815. ch: number;
  146816. /**
  146817. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  146818. */
  146819. walkableSlopeAngle: number;
  146820. /**
  146821. * Minimum floor to 'ceiling' height that will still allow the floor area to
  146822. * be considered walkable. [Limit: >= 3] [Units: vx]
  146823. */
  146824. walkableHeight: number;
  146825. /**
  146826. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  146827. */
  146828. walkableClimb: number;
  146829. /**
  146830. * The distance to erode/shrink the walkable area of the heightfield away from
  146831. * obstructions. [Limit: >=0] [Units: vx]
  146832. */
  146833. walkableRadius: number;
  146834. /**
  146835. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  146836. */
  146837. maxEdgeLen: number;
  146838. /**
  146839. * The maximum distance a simplfied contour's border edges should deviate
  146840. * the original raw contour. [Limit: >=0] [Units: vx]
  146841. */
  146842. maxSimplificationError: number;
  146843. /**
  146844. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  146845. */
  146846. minRegionArea: number;
  146847. /**
  146848. * Any regions with a span count smaller than this value will, if possible,
  146849. * be merged with larger regions. [Limit: >=0] [Units: vx]
  146850. */
  146851. mergeRegionArea: number;
  146852. /**
  146853. * The maximum number of vertices allowed for polygons generated during the
  146854. * contour to polygon conversion process. [Limit: >= 3]
  146855. */
  146856. maxVertsPerPoly: number;
  146857. /**
  146858. * Sets the sampling distance to use when generating the detail mesh.
  146859. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  146860. */
  146861. detailSampleDist: number;
  146862. /**
  146863. * The maximum distance the detail mesh surface should deviate from heightfield
  146864. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  146865. */
  146866. detailSampleMaxError: number;
  146867. }
  146868. }
  146869. declare module BABYLON {
  146870. /**
  146871. * RecastJS navigation plugin
  146872. */
  146873. export class RecastJSPlugin implements INavigationEnginePlugin {
  146874. /**
  146875. * Reference to the Recast library
  146876. */
  146877. bjsRECAST: any;
  146878. /**
  146879. * plugin name
  146880. */
  146881. name: string;
  146882. /**
  146883. * the first navmesh created. We might extend this to support multiple navmeshes
  146884. */
  146885. navMesh: any;
  146886. /**
  146887. * Initializes the recastJS plugin
  146888. * @param recastInjection can be used to inject your own recast reference
  146889. */
  146890. constructor(recastInjection?: any);
  146891. /**
  146892. * Creates a navigation mesh
  146893. * @param meshes array of all the geometry used to compute the navigatio mesh
  146894. * @param parameters bunch of parameters used to filter geometry
  146895. */
  146896. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146897. /**
  146898. * Create a navigation mesh debug mesh
  146899. * @param scene is where the mesh will be added
  146900. * @returns debug display mesh
  146901. */
  146902. createDebugNavMesh(scene: Scene): Mesh;
  146903. /**
  146904. * Get a navigation mesh constrained position, closest to the parameter position
  146905. * @param position world position
  146906. * @returns the closest point to position constrained by the navigation mesh
  146907. */
  146908. getClosestPoint(position: Vector3): Vector3;
  146909. /**
  146910. * Get a navigation mesh constrained position, closest to the parameter position
  146911. * @param position world position
  146912. * @param result output the closest point to position constrained by the navigation mesh
  146913. */
  146914. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146915. /**
  146916. * Get a navigation mesh constrained position, within a particular radius
  146917. * @param position world position
  146918. * @param maxRadius the maximum distance to the constrained world position
  146919. * @returns the closest point to position constrained by the navigation mesh
  146920. */
  146921. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146922. /**
  146923. * Get a navigation mesh constrained position, within a particular radius
  146924. * @param position world position
  146925. * @param maxRadius the maximum distance to the constrained world position
  146926. * @param result output the closest point to position constrained by the navigation mesh
  146927. */
  146928. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146929. /**
  146930. * Compute the final position from a segment made of destination-position
  146931. * @param position world position
  146932. * @param destination world position
  146933. * @returns the resulting point along the navmesh
  146934. */
  146935. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146936. /**
  146937. * Compute the final position from a segment made of destination-position
  146938. * @param position world position
  146939. * @param destination world position
  146940. * @param result output the resulting point along the navmesh
  146941. */
  146942. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146943. /**
  146944. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146945. * @param start world position
  146946. * @param end world position
  146947. * @returns array containing world position composing the path
  146948. */
  146949. computePath(start: Vector3, end: Vector3): Vector3[];
  146950. /**
  146951. * Create a new Crowd so you can add agents
  146952. * @param maxAgents the maximum agent count in the crowd
  146953. * @param maxAgentRadius the maximum radius an agent can have
  146954. * @param scene to attach the crowd to
  146955. * @returns the crowd you can add agents to
  146956. */
  146957. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146958. /**
  146959. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146960. * The queries will try to find a solution within those bounds
  146961. * default is (1,1,1)
  146962. * @param extent x,y,z value that define the extent around the queries point of reference
  146963. */
  146964. setDefaultQueryExtent(extent: Vector3): void;
  146965. /**
  146966. * Get the Bounding box extent specified by setDefaultQueryExtent
  146967. * @returns the box extent values
  146968. */
  146969. getDefaultQueryExtent(): Vector3;
  146970. /**
  146971. * build the navmesh from a previously saved state using getNavmeshData
  146972. * @param data the Uint8Array returned by getNavmeshData
  146973. */
  146974. buildFromNavmeshData(data: Uint8Array): void;
  146975. /**
  146976. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146977. * @returns data the Uint8Array that can be saved and reused
  146978. */
  146979. getNavmeshData(): Uint8Array;
  146980. /**
  146981. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146982. * @param result output the box extent values
  146983. */
  146984. getDefaultQueryExtentToRef(result: Vector3): void;
  146985. /**
  146986. * Disposes
  146987. */
  146988. dispose(): void;
  146989. /**
  146990. * If this plugin is supported
  146991. * @returns true if plugin is supported
  146992. */
  146993. isSupported(): boolean;
  146994. }
  146995. /**
  146996. * Recast detour crowd implementation
  146997. */
  146998. export class RecastJSCrowd implements ICrowd {
  146999. /**
  147000. * Recast/detour plugin
  147001. */
  147002. bjsRECASTPlugin: RecastJSPlugin;
  147003. /**
  147004. * Link to the detour crowd
  147005. */
  147006. recastCrowd: any;
  147007. /**
  147008. * One transform per agent
  147009. */
  147010. transforms: TransformNode[];
  147011. /**
  147012. * All agents created
  147013. */
  147014. agents: number[];
  147015. /**
  147016. * Link to the scene is kept to unregister the crowd from the scene
  147017. */
  147018. private _scene;
  147019. /**
  147020. * Observer for crowd updates
  147021. */
  147022. private _onBeforeAnimationsObserver;
  147023. /**
  147024. * Constructor
  147025. * @param plugin recastJS plugin
  147026. * @param maxAgents the maximum agent count in the crowd
  147027. * @param maxAgentRadius the maximum radius an agent can have
  147028. * @param scene to attach the crowd to
  147029. * @returns the crowd you can add agents to
  147030. */
  147031. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147032. /**
  147033. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147034. * You can attach anything to that node. The node position is updated in the scene update tick.
  147035. * @param pos world position that will be constrained by the navigation mesh
  147036. * @param parameters agent parameters
  147037. * @param transform hooked to the agent that will be update by the scene
  147038. * @returns agent index
  147039. */
  147040. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147041. /**
  147042. * Returns the agent position in world space
  147043. * @param index agent index returned by addAgent
  147044. * @returns world space position
  147045. */
  147046. getAgentPosition(index: number): Vector3;
  147047. /**
  147048. * Returns the agent position result in world space
  147049. * @param index agent index returned by addAgent
  147050. * @param result output world space position
  147051. */
  147052. getAgentPositionToRef(index: number, result: Vector3): void;
  147053. /**
  147054. * Returns the agent velocity in world space
  147055. * @param index agent index returned by addAgent
  147056. * @returns world space velocity
  147057. */
  147058. getAgentVelocity(index: number): Vector3;
  147059. /**
  147060. * Returns the agent velocity result in world space
  147061. * @param index agent index returned by addAgent
  147062. * @param result output world space velocity
  147063. */
  147064. getAgentVelocityToRef(index: number, result: Vector3): void;
  147065. /**
  147066. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147067. * @param index agent index returned by addAgent
  147068. * @param destination targeted world position
  147069. */
  147070. agentGoto(index: number, destination: Vector3): void;
  147071. /**
  147072. * Teleport the agent to a new position
  147073. * @param index agent index returned by addAgent
  147074. * @param destination targeted world position
  147075. */
  147076. agentTeleport(index: number, destination: Vector3): void;
  147077. /**
  147078. * Update agent parameters
  147079. * @param index agent index returned by addAgent
  147080. * @param parameters agent parameters
  147081. */
  147082. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147083. /**
  147084. * remove a particular agent previously created
  147085. * @param index agent index returned by addAgent
  147086. */
  147087. removeAgent(index: number): void;
  147088. /**
  147089. * get the list of all agents attached to this crowd
  147090. * @returns list of agent indices
  147091. */
  147092. getAgents(): number[];
  147093. /**
  147094. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147095. * @param deltaTime in seconds
  147096. */
  147097. update(deltaTime: number): void;
  147098. /**
  147099. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147100. * The queries will try to find a solution within those bounds
  147101. * default is (1,1,1)
  147102. * @param extent x,y,z value that define the extent around the queries point of reference
  147103. */
  147104. setDefaultQueryExtent(extent: Vector3): void;
  147105. /**
  147106. * Get the Bounding box extent specified by setDefaultQueryExtent
  147107. * @returns the box extent values
  147108. */
  147109. getDefaultQueryExtent(): Vector3;
  147110. /**
  147111. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147112. * @param result output the box extent values
  147113. */
  147114. getDefaultQueryExtentToRef(result: Vector3): void;
  147115. /**
  147116. * Release all resources
  147117. */
  147118. dispose(): void;
  147119. }
  147120. }
  147121. declare module BABYLON {
  147122. /**
  147123. * Class used to enable access to IndexedDB
  147124. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147125. */
  147126. export class Database implements IOfflineProvider {
  147127. private _callbackManifestChecked;
  147128. private _currentSceneUrl;
  147129. private _db;
  147130. private _enableSceneOffline;
  147131. private _enableTexturesOffline;
  147132. private _manifestVersionFound;
  147133. private _mustUpdateRessources;
  147134. private _hasReachedQuota;
  147135. private _isSupported;
  147136. private _idbFactory;
  147137. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147138. private static IsUASupportingBlobStorage;
  147139. /**
  147140. * Gets a boolean indicating if Database storate is enabled (off by default)
  147141. */
  147142. static IDBStorageEnabled: boolean;
  147143. /**
  147144. * Gets a boolean indicating if scene must be saved in the database
  147145. */
  147146. get enableSceneOffline(): boolean;
  147147. /**
  147148. * Gets a boolean indicating if textures must be saved in the database
  147149. */
  147150. get enableTexturesOffline(): boolean;
  147151. /**
  147152. * Creates a new Database
  147153. * @param urlToScene defines the url to load the scene
  147154. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147155. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147156. */
  147157. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147158. private static _ParseURL;
  147159. private static _ReturnFullUrlLocation;
  147160. private _checkManifestFile;
  147161. /**
  147162. * Open the database and make it available
  147163. * @param successCallback defines the callback to call on success
  147164. * @param errorCallback defines the callback to call on error
  147165. */
  147166. open(successCallback: () => void, errorCallback: () => void): void;
  147167. /**
  147168. * Loads an image from the database
  147169. * @param url defines the url to load from
  147170. * @param image defines the target DOM image
  147171. */
  147172. loadImage(url: string, image: HTMLImageElement): void;
  147173. private _loadImageFromDBAsync;
  147174. private _saveImageIntoDBAsync;
  147175. private _checkVersionFromDB;
  147176. private _loadVersionFromDBAsync;
  147177. private _saveVersionIntoDBAsync;
  147178. /**
  147179. * Loads a file from database
  147180. * @param url defines the URL to load from
  147181. * @param sceneLoaded defines a callback to call on success
  147182. * @param progressCallBack defines a callback to call when progress changed
  147183. * @param errorCallback defines a callback to call on error
  147184. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147185. */
  147186. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147187. private _loadFileAsync;
  147188. private _saveFileAsync;
  147189. /**
  147190. * Validates if xhr data is correct
  147191. * @param xhr defines the request to validate
  147192. * @param dataType defines the expected data type
  147193. * @returns true if data is correct
  147194. */
  147195. private static _ValidateXHRData;
  147196. }
  147197. }
  147198. declare module BABYLON {
  147199. /** @hidden */
  147200. export var gpuUpdateParticlesPixelShader: {
  147201. name: string;
  147202. shader: string;
  147203. };
  147204. }
  147205. declare module BABYLON {
  147206. /** @hidden */
  147207. export var gpuUpdateParticlesVertexShader: {
  147208. name: string;
  147209. shader: string;
  147210. };
  147211. }
  147212. declare module BABYLON {
  147213. /** @hidden */
  147214. export var clipPlaneFragmentDeclaration2: {
  147215. name: string;
  147216. shader: string;
  147217. };
  147218. }
  147219. declare module BABYLON {
  147220. /** @hidden */
  147221. export var gpuRenderParticlesPixelShader: {
  147222. name: string;
  147223. shader: string;
  147224. };
  147225. }
  147226. declare module BABYLON {
  147227. /** @hidden */
  147228. export var clipPlaneVertexDeclaration2: {
  147229. name: string;
  147230. shader: string;
  147231. };
  147232. }
  147233. declare module BABYLON {
  147234. /** @hidden */
  147235. export var gpuRenderParticlesVertexShader: {
  147236. name: string;
  147237. shader: string;
  147238. };
  147239. }
  147240. declare module BABYLON {
  147241. /**
  147242. * This represents a GPU particle system in Babylon
  147243. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147244. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147245. */
  147246. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147247. /**
  147248. * The layer mask we are rendering the particles through.
  147249. */
  147250. layerMask: number;
  147251. private _capacity;
  147252. private _activeCount;
  147253. private _currentActiveCount;
  147254. private _accumulatedCount;
  147255. private _renderEffect;
  147256. private _updateEffect;
  147257. private _buffer0;
  147258. private _buffer1;
  147259. private _spriteBuffer;
  147260. private _updateVAO;
  147261. private _renderVAO;
  147262. private _targetIndex;
  147263. private _sourceBuffer;
  147264. private _targetBuffer;
  147265. private _currentRenderId;
  147266. private _started;
  147267. private _stopped;
  147268. private _timeDelta;
  147269. private _randomTexture;
  147270. private _randomTexture2;
  147271. private _attributesStrideSize;
  147272. private _updateEffectOptions;
  147273. private _randomTextureSize;
  147274. private _actualFrame;
  147275. private _customEffect;
  147276. private readonly _rawTextureWidth;
  147277. /**
  147278. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147279. */
  147280. static get IsSupported(): boolean;
  147281. /**
  147282. * An event triggered when the system is disposed.
  147283. */
  147284. onDisposeObservable: Observable<IParticleSystem>;
  147285. /**
  147286. * Gets the maximum number of particles active at the same time.
  147287. * @returns The max number of active particles.
  147288. */
  147289. getCapacity(): number;
  147290. /**
  147291. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147292. * to override the particles.
  147293. */
  147294. forceDepthWrite: boolean;
  147295. /**
  147296. * Gets or set the number of active particles
  147297. */
  147298. get activeParticleCount(): number;
  147299. set activeParticleCount(value: number);
  147300. private _preWarmDone;
  147301. /**
  147302. * Specifies if the particles are updated in emitter local space or world space.
  147303. */
  147304. isLocal: boolean;
  147305. /** Gets or sets a matrix to use to compute projection */
  147306. defaultProjectionMatrix: Matrix;
  147307. /**
  147308. * Is this system ready to be used/rendered
  147309. * @return true if the system is ready
  147310. */
  147311. isReady(): boolean;
  147312. /**
  147313. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147314. * @returns True if it has been started, otherwise false.
  147315. */
  147316. isStarted(): boolean;
  147317. /**
  147318. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147319. * @returns True if it has been stopped, otherwise false.
  147320. */
  147321. isStopped(): boolean;
  147322. /**
  147323. * Gets a boolean indicating that the system is stopping
  147324. * @returns true if the system is currently stopping
  147325. */
  147326. isStopping(): boolean;
  147327. /**
  147328. * Gets the number of particles active at the same time.
  147329. * @returns The number of active particles.
  147330. */
  147331. getActiveCount(): number;
  147332. /**
  147333. * Starts the particle system and begins to emit
  147334. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147335. */
  147336. start(delay?: number): void;
  147337. /**
  147338. * Stops the particle system.
  147339. */
  147340. stop(): void;
  147341. /**
  147342. * Remove all active particles
  147343. */
  147344. reset(): void;
  147345. /**
  147346. * Returns the string "GPUParticleSystem"
  147347. * @returns a string containing the class name
  147348. */
  147349. getClassName(): string;
  147350. /**
  147351. * Gets the custom effect used to render the particles
  147352. * @param blendMode Blend mode for which the effect should be retrieved
  147353. * @returns The effect
  147354. */
  147355. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147356. /**
  147357. * Sets the custom effect used to render the particles
  147358. * @param effect The effect to set
  147359. * @param blendMode Blend mode for which the effect should be set
  147360. */
  147361. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147362. /** @hidden */
  147363. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147364. /**
  147365. * Observable that will be called just before the particles are drawn
  147366. */
  147367. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147368. /**
  147369. * Gets the name of the particle vertex shader
  147370. */
  147371. get vertexShaderName(): string;
  147372. private _colorGradientsTexture;
  147373. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147374. /**
  147375. * Adds a new color gradient
  147376. * @param gradient defines the gradient to use (between 0 and 1)
  147377. * @param color1 defines the color to affect to the specified gradient
  147378. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147379. * @returns the current particle system
  147380. */
  147381. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147382. private _refreshColorGradient;
  147383. /** Force the system to rebuild all gradients that need to be resync */
  147384. forceRefreshGradients(): void;
  147385. /**
  147386. * Remove a specific color gradient
  147387. * @param gradient defines the gradient to remove
  147388. * @returns the current particle system
  147389. */
  147390. removeColorGradient(gradient: number): GPUParticleSystem;
  147391. private _angularSpeedGradientsTexture;
  147392. private _sizeGradientsTexture;
  147393. private _velocityGradientsTexture;
  147394. private _limitVelocityGradientsTexture;
  147395. private _dragGradientsTexture;
  147396. private _addFactorGradient;
  147397. /**
  147398. * Adds a new size gradient
  147399. * @param gradient defines the gradient to use (between 0 and 1)
  147400. * @param factor defines the size factor to affect to the specified gradient
  147401. * @returns the current particle system
  147402. */
  147403. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147404. /**
  147405. * Remove a specific size gradient
  147406. * @param gradient defines the gradient to remove
  147407. * @returns the current particle system
  147408. */
  147409. removeSizeGradient(gradient: number): GPUParticleSystem;
  147410. private _refreshFactorGradient;
  147411. /**
  147412. * Adds a new angular speed gradient
  147413. * @param gradient defines the gradient to use (between 0 and 1)
  147414. * @param factor defines the angular speed to affect to the specified gradient
  147415. * @returns the current particle system
  147416. */
  147417. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147418. /**
  147419. * Remove a specific angular speed gradient
  147420. * @param gradient defines the gradient to remove
  147421. * @returns the current particle system
  147422. */
  147423. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147424. /**
  147425. * Adds a new velocity gradient
  147426. * @param gradient defines the gradient to use (between 0 and 1)
  147427. * @param factor defines the velocity to affect to the specified gradient
  147428. * @returns the current particle system
  147429. */
  147430. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147431. /**
  147432. * Remove a specific velocity gradient
  147433. * @param gradient defines the gradient to remove
  147434. * @returns the current particle system
  147435. */
  147436. removeVelocityGradient(gradient: number): GPUParticleSystem;
  147437. /**
  147438. * Adds a new limit velocity gradient
  147439. * @param gradient defines the gradient to use (between 0 and 1)
  147440. * @param factor defines the limit velocity value to affect to the specified gradient
  147441. * @returns the current particle system
  147442. */
  147443. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147444. /**
  147445. * Remove a specific limit velocity gradient
  147446. * @param gradient defines the gradient to remove
  147447. * @returns the current particle system
  147448. */
  147449. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  147450. /**
  147451. * Adds a new drag gradient
  147452. * @param gradient defines the gradient to use (between 0 and 1)
  147453. * @param factor defines the drag value to affect to the specified gradient
  147454. * @returns the current particle system
  147455. */
  147456. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  147457. /**
  147458. * Remove a specific drag gradient
  147459. * @param gradient defines the gradient to remove
  147460. * @returns the current particle system
  147461. */
  147462. removeDragGradient(gradient: number): GPUParticleSystem;
  147463. /**
  147464. * Not supported by GPUParticleSystem
  147465. * @param gradient defines the gradient to use (between 0 and 1)
  147466. * @param factor defines the emit rate value to affect to the specified gradient
  147467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147468. * @returns the current particle system
  147469. */
  147470. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147471. /**
  147472. * Not supported by GPUParticleSystem
  147473. * @param gradient defines the gradient to remove
  147474. * @returns the current particle system
  147475. */
  147476. removeEmitRateGradient(gradient: number): IParticleSystem;
  147477. /**
  147478. * Not supported by GPUParticleSystem
  147479. * @param gradient defines the gradient to use (between 0 and 1)
  147480. * @param factor defines the start size value to affect to the specified gradient
  147481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147482. * @returns the current particle system
  147483. */
  147484. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147485. /**
  147486. * Not supported by GPUParticleSystem
  147487. * @param gradient defines the gradient to remove
  147488. * @returns the current particle system
  147489. */
  147490. removeStartSizeGradient(gradient: number): IParticleSystem;
  147491. /**
  147492. * Not supported by GPUParticleSystem
  147493. * @param gradient defines the gradient to use (between 0 and 1)
  147494. * @param min defines the color remap minimal range
  147495. * @param max defines the color remap maximal range
  147496. * @returns the current particle system
  147497. */
  147498. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147499. /**
  147500. * Not supported by GPUParticleSystem
  147501. * @param gradient defines the gradient to remove
  147502. * @returns the current particle system
  147503. */
  147504. removeColorRemapGradient(): IParticleSystem;
  147505. /**
  147506. * Not supported by GPUParticleSystem
  147507. * @param gradient defines the gradient to use (between 0 and 1)
  147508. * @param min defines the alpha remap minimal range
  147509. * @param max defines the alpha remap maximal range
  147510. * @returns the current particle system
  147511. */
  147512. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147513. /**
  147514. * Not supported by GPUParticleSystem
  147515. * @param gradient defines the gradient to remove
  147516. * @returns the current particle system
  147517. */
  147518. removeAlphaRemapGradient(): IParticleSystem;
  147519. /**
  147520. * Not supported by GPUParticleSystem
  147521. * @param gradient defines the gradient to use (between 0 and 1)
  147522. * @param color defines the color to affect to the specified gradient
  147523. * @returns the current particle system
  147524. */
  147525. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  147526. /**
  147527. * Not supported by GPUParticleSystem
  147528. * @param gradient defines the gradient to remove
  147529. * @returns the current particle system
  147530. */
  147531. removeRampGradient(): IParticleSystem;
  147532. /**
  147533. * Not supported by GPUParticleSystem
  147534. * @returns the list of ramp gradients
  147535. */
  147536. getRampGradients(): Nullable<Array<Color3Gradient>>;
  147537. /**
  147538. * Not supported by GPUParticleSystem
  147539. * Gets or sets a boolean indicating that ramp gradients must be used
  147540. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  147541. */
  147542. get useRampGradients(): boolean;
  147543. set useRampGradients(value: boolean);
  147544. /**
  147545. * Not supported by GPUParticleSystem
  147546. * @param gradient defines the gradient to use (between 0 and 1)
  147547. * @param factor defines the life time factor to affect to the specified gradient
  147548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147549. * @returns the current particle system
  147550. */
  147551. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147552. /**
  147553. * Not supported by GPUParticleSystem
  147554. * @param gradient defines the gradient to remove
  147555. * @returns the current particle system
  147556. */
  147557. removeLifeTimeGradient(gradient: number): IParticleSystem;
  147558. /**
  147559. * Instantiates a GPU particle system.
  147560. * 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.
  147561. * @param name The name of the particle system
  147562. * @param options The options used to create the system
  147563. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  147564. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  147565. * @param customEffect a custom effect used to change the way particles are rendered by default
  147566. */
  147567. constructor(name: string, options: Partial<{
  147568. capacity: number;
  147569. randomTextureSize: number;
  147570. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  147571. protected _reset(): void;
  147572. private _createUpdateVAO;
  147573. private _createRenderVAO;
  147574. private _initialize;
  147575. /** @hidden */
  147576. _recreateUpdateEffect(): void;
  147577. private _getEffect;
  147578. /**
  147579. * Fill the defines array according to the current settings of the particle system
  147580. * @param defines Array to be updated
  147581. * @param blendMode blend mode to take into account when updating the array
  147582. */
  147583. fillDefines(defines: Array<string>, blendMode?: number): void;
  147584. /**
  147585. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  147586. * @param uniforms Uniforms array to fill
  147587. * @param attributes Attributes array to fill
  147588. * @param samplers Samplers array to fill
  147589. */
  147590. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  147591. /** @hidden */
  147592. _recreateRenderEffect(): Effect;
  147593. /**
  147594. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  147595. * @param preWarm defines if we are in the pre-warmimg phase
  147596. */
  147597. animate(preWarm?: boolean): void;
  147598. private _createFactorGradientTexture;
  147599. private _createSizeGradientTexture;
  147600. private _createAngularSpeedGradientTexture;
  147601. private _createVelocityGradientTexture;
  147602. private _createLimitVelocityGradientTexture;
  147603. private _createDragGradientTexture;
  147604. private _createColorGradientTexture;
  147605. /**
  147606. * Renders the particle system in its current state
  147607. * @param preWarm defines if the system should only update the particles but not render them
  147608. * @returns the current number of particles
  147609. */
  147610. render(preWarm?: boolean): number;
  147611. /**
  147612. * Rebuilds the particle system
  147613. */
  147614. rebuild(): void;
  147615. private _releaseBuffers;
  147616. private _releaseVAOs;
  147617. /**
  147618. * Disposes the particle system and free the associated resources
  147619. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  147620. */
  147621. dispose(disposeTexture?: boolean): void;
  147622. /**
  147623. * Clones the particle system.
  147624. * @param name The name of the cloned object
  147625. * @param newEmitter The new emitter to use
  147626. * @returns the cloned particle system
  147627. */
  147628. clone(name: string, newEmitter: any): GPUParticleSystem;
  147629. /**
  147630. * Serializes the particle system to a JSON object
  147631. * @param serializeTexture defines if the texture must be serialized as well
  147632. * @returns the JSON object
  147633. */
  147634. serialize(serializeTexture?: boolean): any;
  147635. /**
  147636. * Parses a JSON object to create a GPU particle system.
  147637. * @param parsedParticleSystem The JSON object to parse
  147638. * @param sceneOrEngine The scene or the engine to create the particle system in
  147639. * @param rootUrl The root url to use to load external dependencies like texture
  147640. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  147641. * @returns the parsed GPU particle system
  147642. */
  147643. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  147644. }
  147645. }
  147646. declare module BABYLON {
  147647. /**
  147648. * Represents a set of particle systems working together to create a specific effect
  147649. */
  147650. export class ParticleSystemSet implements IDisposable {
  147651. /**
  147652. * Gets or sets base Assets URL
  147653. */
  147654. static BaseAssetsUrl: string;
  147655. private _emitterCreationOptions;
  147656. private _emitterNode;
  147657. /**
  147658. * Gets the particle system list
  147659. */
  147660. systems: IParticleSystem[];
  147661. /**
  147662. * Gets the emitter node used with this set
  147663. */
  147664. get emitterNode(): Nullable<TransformNode>;
  147665. /**
  147666. * Creates a new emitter mesh as a sphere
  147667. * @param options defines the options used to create the sphere
  147668. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  147669. * @param scene defines the hosting scene
  147670. */
  147671. setEmitterAsSphere(options: {
  147672. diameter: number;
  147673. segments: number;
  147674. color: Color3;
  147675. }, renderingGroupId: number, scene: Scene): void;
  147676. /**
  147677. * Starts all particle systems of the set
  147678. * @param emitter defines an optional mesh to use as emitter for the particle systems
  147679. */
  147680. start(emitter?: AbstractMesh): void;
  147681. /**
  147682. * Release all associated resources
  147683. */
  147684. dispose(): void;
  147685. /**
  147686. * Serialize the set into a JSON compatible object
  147687. * @param serializeTexture defines if the texture must be serialized as well
  147688. * @returns a JSON compatible representation of the set
  147689. */
  147690. serialize(serializeTexture?: boolean): any;
  147691. /**
  147692. * Parse a new ParticleSystemSet from a serialized source
  147693. * @param data defines a JSON compatible representation of the set
  147694. * @param scene defines the hosting scene
  147695. * @param gpu defines if we want GPU particles or CPU particles
  147696. * @returns a new ParticleSystemSet
  147697. */
  147698. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  147699. }
  147700. }
  147701. declare module BABYLON {
  147702. /**
  147703. * This class is made for on one-liner static method to help creating particle system set.
  147704. */
  147705. export class ParticleHelper {
  147706. /**
  147707. * Gets or sets base Assets URL
  147708. */
  147709. static BaseAssetsUrl: string;
  147710. /** Define the Url to load snippets */
  147711. static SnippetUrl: string;
  147712. /**
  147713. * Create a default particle system that you can tweak
  147714. * @param emitter defines the emitter to use
  147715. * @param capacity defines the system capacity (default is 500 particles)
  147716. * @param scene defines the hosting scene
  147717. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  147718. * @returns the new Particle system
  147719. */
  147720. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147721. /**
  147722. * This is the main static method (one-liner) of this helper to create different particle systems
  147723. * @param type This string represents the type to the particle system to create
  147724. * @param scene The scene where the particle system should live
  147725. * @param gpu If the system will use gpu
  147726. * @returns the ParticleSystemSet created
  147727. */
  147728. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147729. /**
  147730. * Static function used to export a particle system to a ParticleSystemSet variable.
  147731. * Please note that the emitter shape is not exported
  147732. * @param systems defines the particle systems to export
  147733. * @returns the created particle system set
  147734. */
  147735. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147736. /**
  147737. * Creates a particle system from a snippet saved in a remote file
  147738. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147739. * @param url defines the url to load from
  147740. * @param scene defines the hosting scene
  147741. * @param gpu If the system will use gpu
  147742. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147743. * @returns a promise that will resolve to the new particle system
  147744. */
  147745. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147746. /**
  147747. * Creates a particle system from a snippet saved by the particle system editor
  147748. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147749. * @param scene defines the hosting scene
  147750. * @param gpu If the system will use gpu
  147751. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147752. * @returns a promise that will resolve to the new particle system
  147753. */
  147754. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147755. }
  147756. }
  147757. declare module BABYLON {
  147758. interface Engine {
  147759. /**
  147760. * Create an effect to use with particle systems.
  147761. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147762. * the particle system for which you want to create a custom effect in the last parameter
  147763. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147764. * @param uniformsNames defines a list of attribute names
  147765. * @param samplers defines an array of string used to represent textures
  147766. * @param defines defines the string containing the defines to use to compile the shaders
  147767. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147768. * @param onCompiled defines a function to call when the effect creation is successful
  147769. * @param onError defines a function to call when the effect creation has failed
  147770. * @param particleSystem the particle system you want to create the effect for
  147771. * @returns the new Effect
  147772. */
  147773. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147774. }
  147775. interface Mesh {
  147776. /**
  147777. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  147778. * @returns an array of IParticleSystem
  147779. */
  147780. getEmittedParticleSystems(): IParticleSystem[];
  147781. /**
  147782. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  147783. * @returns an array of IParticleSystem
  147784. */
  147785. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  147786. }
  147787. }
  147788. declare module BABYLON {
  147789. /** Defines the 4 color options */
  147790. export enum PointColor {
  147791. /** color value */
  147792. Color = 2,
  147793. /** uv value */
  147794. UV = 1,
  147795. /** random value */
  147796. Random = 0,
  147797. /** stated value */
  147798. Stated = 3
  147799. }
  147800. /**
  147801. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  147802. * 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.
  147803. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  147804. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  147805. *
  147806. * Full documentation here : TO BE ENTERED
  147807. */
  147808. export class PointsCloudSystem implements IDisposable {
  147809. /**
  147810. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  147811. * Example : var p = SPS.particles[i];
  147812. */
  147813. particles: CloudPoint[];
  147814. /**
  147815. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  147816. */
  147817. nbParticles: number;
  147818. /**
  147819. * This a counter for your own usage. It's not set by any SPS functions.
  147820. */
  147821. counter: number;
  147822. /**
  147823. * The PCS name. This name is also given to the underlying mesh.
  147824. */
  147825. name: string;
  147826. /**
  147827. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  147828. */
  147829. mesh: Mesh;
  147830. /**
  147831. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  147832. * Please read :
  147833. */
  147834. vars: any;
  147835. /**
  147836. * @hidden
  147837. */
  147838. _size: number;
  147839. private _scene;
  147840. private _promises;
  147841. private _positions;
  147842. private _indices;
  147843. private _normals;
  147844. private _colors;
  147845. private _uvs;
  147846. private _indices32;
  147847. private _positions32;
  147848. private _colors32;
  147849. private _uvs32;
  147850. private _updatable;
  147851. private _isVisibilityBoxLocked;
  147852. private _alwaysVisible;
  147853. private _groups;
  147854. private _groupCounter;
  147855. private _computeParticleColor;
  147856. private _computeParticleTexture;
  147857. private _computeParticleRotation;
  147858. private _computeBoundingBox;
  147859. private _isReady;
  147860. /**
  147861. * Creates a PCS (Points Cloud System) object
  147862. * @param name (String) is the PCS name, this will be the underlying mesh name
  147863. * @param pointSize (number) is the size for each point
  147864. * @param scene (Scene) is the scene in which the PCS is added
  147865. * @param options defines the options of the PCS e.g.
  147866. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  147867. */
  147868. constructor(name: string, pointSize: number, scene: Scene, options?: {
  147869. updatable?: boolean;
  147870. });
  147871. /**
  147872. * Builds the PCS underlying mesh. Returns a standard Mesh.
  147873. * If no points were added to the PCS, the returned mesh is just a single point.
  147874. * @returns a promise for the created mesh
  147875. */
  147876. buildMeshAsync(): Promise<Mesh>;
  147877. /**
  147878. * @hidden
  147879. */
  147880. private _buildMesh;
  147881. private _addParticle;
  147882. private _randomUnitVector;
  147883. private _getColorIndicesForCoord;
  147884. private _setPointsColorOrUV;
  147885. private _colorFromTexture;
  147886. private _calculateDensity;
  147887. /**
  147888. * Adds points to the PCS in random positions within a unit sphere
  147889. * @param nb (positive integer) the number of particles to be created from this model
  147890. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  147891. * @returns the number of groups in the system
  147892. */
  147893. addPoints(nb: number, pointFunction?: any): number;
  147894. /**
  147895. * Adds points to the PCS from the surface of the model shape
  147896. * @param mesh is any Mesh object that will be used as a surface model for the points
  147897. * @param nb (positive integer) the number of particles to be created from this model
  147898. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147899. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147900. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147901. * @returns the number of groups in the system
  147902. */
  147903. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147904. /**
  147905. * Adds points to the PCS inside the model shape
  147906. * @param mesh is any Mesh object that will be used as a surface model for the points
  147907. * @param nb (positive integer) the number of particles to be created from this model
  147908. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147909. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147910. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147911. * @returns the number of groups in the system
  147912. */
  147913. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147914. /**
  147915. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  147916. * This method calls `updateParticle()` for each particle of the SPS.
  147917. * For an animated SPS, it is usually called within the render loop.
  147918. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  147919. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  147920. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  147921. * @returns the PCS.
  147922. */
  147923. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  147924. /**
  147925. * Disposes the PCS.
  147926. */
  147927. dispose(): void;
  147928. /**
  147929. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  147930. * doc :
  147931. * @returns the PCS.
  147932. */
  147933. refreshVisibleSize(): PointsCloudSystem;
  147934. /**
  147935. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  147936. * @param size the size (float) of the visibility box
  147937. * note : this doesn't lock the PCS mesh bounding box.
  147938. * doc :
  147939. */
  147940. setVisibilityBox(size: number): void;
  147941. /**
  147942. * Gets whether the PCS is always visible or not
  147943. * doc :
  147944. */
  147945. get isAlwaysVisible(): boolean;
  147946. /**
  147947. * Sets the PCS as always visible or not
  147948. * doc :
  147949. */
  147950. set isAlwaysVisible(val: boolean);
  147951. /**
  147952. * Tells to `setParticles()` to compute the particle rotations or not
  147953. * Default value : false. The PCS is faster when it's set to false
  147954. * Note : particle rotations are only applied to parent particles
  147955. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  147956. */
  147957. set computeParticleRotation(val: boolean);
  147958. /**
  147959. * Tells to `setParticles()` to compute the particle colors or not.
  147960. * Default value : true. The PCS is faster when it's set to false.
  147961. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147962. */
  147963. set computeParticleColor(val: boolean);
  147964. set computeParticleTexture(val: boolean);
  147965. /**
  147966. * Gets if `setParticles()` computes the particle colors or not.
  147967. * Default value : false. The PCS is faster when it's set to false.
  147968. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147969. */
  147970. get computeParticleColor(): boolean;
  147971. /**
  147972. * Gets if `setParticles()` computes the particle textures or not.
  147973. * Default value : false. The PCS is faster when it's set to false.
  147974. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  147975. */
  147976. get computeParticleTexture(): boolean;
  147977. /**
  147978. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  147979. */
  147980. set computeBoundingBox(val: boolean);
  147981. /**
  147982. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  147983. */
  147984. get computeBoundingBox(): boolean;
  147985. /**
  147986. * This function does nothing. It may be overwritten to set all the particle first values.
  147987. * The PCS doesn't call this function, you may have to call it by your own.
  147988. * doc :
  147989. */
  147990. initParticles(): void;
  147991. /**
  147992. * This function does nothing. It may be overwritten to recycle a particle
  147993. * The PCS doesn't call this function, you can to call it
  147994. * doc :
  147995. * @param particle The particle to recycle
  147996. * @returns the recycled particle
  147997. */
  147998. recycleParticle(particle: CloudPoint): CloudPoint;
  147999. /**
  148000. * Updates a particle : this function should be overwritten by the user.
  148001. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148002. * doc :
  148003. * @example : just set a particle position or velocity and recycle conditions
  148004. * @param particle The particle to update
  148005. * @returns the updated particle
  148006. */
  148007. updateParticle(particle: CloudPoint): CloudPoint;
  148008. /**
  148009. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148010. * This does nothing and may be overwritten by the user.
  148011. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148012. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148013. * @param update the boolean update value actually passed to setParticles()
  148014. */
  148015. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148016. /**
  148017. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148018. * This will be passed three parameters.
  148019. * This does nothing and may be overwritten by the user.
  148020. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148021. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148022. * @param update the boolean update value actually passed to setParticles()
  148023. */
  148024. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148025. }
  148026. }
  148027. declare module BABYLON {
  148028. /**
  148029. * Represents one particle of a points cloud system.
  148030. */
  148031. export class CloudPoint {
  148032. /**
  148033. * particle global index
  148034. */
  148035. idx: number;
  148036. /**
  148037. * The color of the particle
  148038. */
  148039. color: Nullable<Color4>;
  148040. /**
  148041. * The world space position of the particle.
  148042. */
  148043. position: Vector3;
  148044. /**
  148045. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148046. */
  148047. rotation: Vector3;
  148048. /**
  148049. * The world space rotation quaternion of the particle.
  148050. */
  148051. rotationQuaternion: Nullable<Quaternion>;
  148052. /**
  148053. * The uv of the particle.
  148054. */
  148055. uv: Nullable<Vector2>;
  148056. /**
  148057. * The current speed of the particle.
  148058. */
  148059. velocity: Vector3;
  148060. /**
  148061. * The pivot point in the particle local space.
  148062. */
  148063. pivot: Vector3;
  148064. /**
  148065. * Must the particle be translated from its pivot point in its local space ?
  148066. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148067. * Default : false
  148068. */
  148069. translateFromPivot: boolean;
  148070. /**
  148071. * Index of this particle in the global "positions" array (Internal use)
  148072. * @hidden
  148073. */
  148074. _pos: number;
  148075. /**
  148076. * @hidden Index of this particle in the global "indices" array (Internal use)
  148077. */
  148078. _ind: number;
  148079. /**
  148080. * Group this particle belongs to
  148081. */
  148082. _group: PointsGroup;
  148083. /**
  148084. * Group id of this particle
  148085. */
  148086. groupId: number;
  148087. /**
  148088. * Index of the particle in its group id (Internal use)
  148089. */
  148090. idxInGroup: number;
  148091. /**
  148092. * @hidden Particle BoundingInfo object (Internal use)
  148093. */
  148094. _boundingInfo: BoundingInfo;
  148095. /**
  148096. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148097. */
  148098. _pcs: PointsCloudSystem;
  148099. /**
  148100. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148101. */
  148102. _stillInvisible: boolean;
  148103. /**
  148104. * @hidden Last computed particle rotation matrix
  148105. */
  148106. _rotationMatrix: number[];
  148107. /**
  148108. * Parent particle Id, if any.
  148109. * Default null.
  148110. */
  148111. parentId: Nullable<number>;
  148112. /**
  148113. * @hidden Internal global position in the PCS.
  148114. */
  148115. _globalPosition: Vector3;
  148116. /**
  148117. * Creates a Point Cloud object.
  148118. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148119. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148120. * @param group (PointsGroup) is the group the particle belongs to
  148121. * @param groupId (integer) is the group identifier in the PCS.
  148122. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148123. * @param pcs defines the PCS it is associated to
  148124. */
  148125. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148126. /**
  148127. * get point size
  148128. */
  148129. get size(): Vector3;
  148130. /**
  148131. * Set point size
  148132. */
  148133. set size(scale: Vector3);
  148134. /**
  148135. * Legacy support, changed quaternion to rotationQuaternion
  148136. */
  148137. get quaternion(): Nullable<Quaternion>;
  148138. /**
  148139. * Legacy support, changed quaternion to rotationQuaternion
  148140. */
  148141. set quaternion(q: Nullable<Quaternion>);
  148142. /**
  148143. * Returns a boolean. True if the particle intersects a mesh, else false
  148144. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148145. * @param target is the object (point or mesh) what the intersection is computed against
  148146. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148147. * @returns true if it intersects
  148148. */
  148149. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148150. /**
  148151. * get the rotation matrix of the particle
  148152. * @hidden
  148153. */
  148154. getRotationMatrix(m: Matrix): void;
  148155. }
  148156. /**
  148157. * Represents a group of points in a points cloud system
  148158. * * PCS internal tool, don't use it manually.
  148159. */
  148160. export class PointsGroup {
  148161. /**
  148162. * The group id
  148163. * @hidden
  148164. */
  148165. groupID: number;
  148166. /**
  148167. * image data for group (internal use)
  148168. * @hidden
  148169. */
  148170. _groupImageData: Nullable<ArrayBufferView>;
  148171. /**
  148172. * Image Width (internal use)
  148173. * @hidden
  148174. */
  148175. _groupImgWidth: number;
  148176. /**
  148177. * Image Height (internal use)
  148178. * @hidden
  148179. */
  148180. _groupImgHeight: number;
  148181. /**
  148182. * Custom position function (internal use)
  148183. * @hidden
  148184. */
  148185. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148186. /**
  148187. * density per facet for surface points
  148188. * @hidden
  148189. */
  148190. _groupDensity: number[];
  148191. /**
  148192. * Only when points are colored by texture carries pointer to texture list array
  148193. * @hidden
  148194. */
  148195. _textureNb: number;
  148196. /**
  148197. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148198. * PCS internal tool, don't use it manually.
  148199. * @hidden
  148200. */
  148201. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148202. }
  148203. }
  148204. declare module BABYLON {
  148205. interface Scene {
  148206. /** @hidden (Backing field) */
  148207. _physicsEngine: Nullable<IPhysicsEngine>;
  148208. /** @hidden */
  148209. _physicsTimeAccumulator: number;
  148210. /**
  148211. * Gets the current physics engine
  148212. * @returns a IPhysicsEngine or null if none attached
  148213. */
  148214. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148215. /**
  148216. * Enables physics to the current scene
  148217. * @param gravity defines the scene's gravity for the physics engine
  148218. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148219. * @return a boolean indicating if the physics engine was initialized
  148220. */
  148221. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148222. /**
  148223. * Disables and disposes the physics engine associated with the scene
  148224. */
  148225. disablePhysicsEngine(): void;
  148226. /**
  148227. * Gets a boolean indicating if there is an active physics engine
  148228. * @returns a boolean indicating if there is an active physics engine
  148229. */
  148230. isPhysicsEnabled(): boolean;
  148231. /**
  148232. * Deletes a physics compound impostor
  148233. * @param compound defines the compound to delete
  148234. */
  148235. deleteCompoundImpostor(compound: any): void;
  148236. /**
  148237. * An event triggered when physic simulation is about to be run
  148238. */
  148239. onBeforePhysicsObservable: Observable<Scene>;
  148240. /**
  148241. * An event triggered when physic simulation has been done
  148242. */
  148243. onAfterPhysicsObservable: Observable<Scene>;
  148244. }
  148245. interface AbstractMesh {
  148246. /** @hidden */
  148247. _physicsImpostor: Nullable<PhysicsImpostor>;
  148248. /**
  148249. * Gets or sets impostor used for physic simulation
  148250. * @see https://doc.babylonjs.com/features/physics_engine
  148251. */
  148252. physicsImpostor: Nullable<PhysicsImpostor>;
  148253. /**
  148254. * Gets the current physics impostor
  148255. * @see https://doc.babylonjs.com/features/physics_engine
  148256. * @returns a physics impostor or null
  148257. */
  148258. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148259. /** Apply a physic impulse to the mesh
  148260. * @param force defines the force to apply
  148261. * @param contactPoint defines where to apply the force
  148262. * @returns the current mesh
  148263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148264. */
  148265. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148266. /**
  148267. * Creates a physic joint between two meshes
  148268. * @param otherMesh defines the other mesh to use
  148269. * @param pivot1 defines the pivot to use on this mesh
  148270. * @param pivot2 defines the pivot to use on the other mesh
  148271. * @param options defines additional options (can be plugin dependent)
  148272. * @returns the current mesh
  148273. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148274. */
  148275. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148276. /** @hidden */
  148277. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148278. }
  148279. /**
  148280. * Defines the physics engine scene component responsible to manage a physics engine
  148281. */
  148282. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148283. /**
  148284. * The component name helpful to identify the component in the list of scene components.
  148285. */
  148286. readonly name: string;
  148287. /**
  148288. * The scene the component belongs to.
  148289. */
  148290. scene: Scene;
  148291. /**
  148292. * Creates a new instance of the component for the given scene
  148293. * @param scene Defines the scene to register the component in
  148294. */
  148295. constructor(scene: Scene);
  148296. /**
  148297. * Registers the component in a given scene
  148298. */
  148299. register(): void;
  148300. /**
  148301. * Rebuilds the elements related to this component in case of
  148302. * context lost for instance.
  148303. */
  148304. rebuild(): void;
  148305. /**
  148306. * Disposes the component and the associated ressources
  148307. */
  148308. dispose(): void;
  148309. }
  148310. }
  148311. declare module BABYLON {
  148312. /**
  148313. * A helper for physics simulations
  148314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148315. */
  148316. export class PhysicsHelper {
  148317. private _scene;
  148318. private _physicsEngine;
  148319. /**
  148320. * Initializes the Physics helper
  148321. * @param scene Babylon.js scene
  148322. */
  148323. constructor(scene: Scene);
  148324. /**
  148325. * Applies a radial explosion impulse
  148326. * @param origin the origin of the explosion
  148327. * @param radiusOrEventOptions the radius or the options of radial explosion
  148328. * @param strength the explosion strength
  148329. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148330. * @returns A physics radial explosion event, or null
  148331. */
  148332. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148333. /**
  148334. * Applies a radial explosion force
  148335. * @param origin the origin of the explosion
  148336. * @param radiusOrEventOptions the radius or the options of radial explosion
  148337. * @param strength the explosion strength
  148338. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148339. * @returns A physics radial explosion event, or null
  148340. */
  148341. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148342. /**
  148343. * Creates a gravitational field
  148344. * @param origin the origin of the explosion
  148345. * @param radiusOrEventOptions the radius or the options of radial explosion
  148346. * @param strength the explosion strength
  148347. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148348. * @returns A physics gravitational field event, or null
  148349. */
  148350. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148351. /**
  148352. * Creates a physics updraft event
  148353. * @param origin the origin of the updraft
  148354. * @param radiusOrEventOptions the radius or the options of the updraft
  148355. * @param strength the strength of the updraft
  148356. * @param height the height of the updraft
  148357. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148358. * @returns A physics updraft event, or null
  148359. */
  148360. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148361. /**
  148362. * Creates a physics vortex event
  148363. * @param origin the of the vortex
  148364. * @param radiusOrEventOptions the radius or the options of the vortex
  148365. * @param strength the strength of the vortex
  148366. * @param height the height of the vortex
  148367. * @returns a Physics vortex event, or null
  148368. * A physics vortex event or null
  148369. */
  148370. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148371. }
  148372. /**
  148373. * Represents a physics radial explosion event
  148374. */
  148375. class PhysicsRadialExplosionEvent {
  148376. private _scene;
  148377. private _options;
  148378. private _sphere;
  148379. private _dataFetched;
  148380. /**
  148381. * Initializes a radial explosioin event
  148382. * @param _scene BabylonJS scene
  148383. * @param _options The options for the vortex event
  148384. */
  148385. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148386. /**
  148387. * Returns the data related to the radial explosion event (sphere).
  148388. * @returns The radial explosion event data
  148389. */
  148390. getData(): PhysicsRadialExplosionEventData;
  148391. /**
  148392. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148393. * @param impostor A physics imposter
  148394. * @param origin the origin of the explosion
  148395. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148396. */
  148397. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148398. /**
  148399. * Triggers affecterd impostors callbacks
  148400. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148401. */
  148402. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148403. /**
  148404. * Disposes the sphere.
  148405. * @param force Specifies if the sphere should be disposed by force
  148406. */
  148407. dispose(force?: boolean): void;
  148408. /*** Helpers ***/
  148409. private _prepareSphere;
  148410. private _intersectsWithSphere;
  148411. }
  148412. /**
  148413. * Represents a gravitational field event
  148414. */
  148415. class PhysicsGravitationalFieldEvent {
  148416. private _physicsHelper;
  148417. private _scene;
  148418. private _origin;
  148419. private _options;
  148420. private _tickCallback;
  148421. private _sphere;
  148422. private _dataFetched;
  148423. /**
  148424. * Initializes the physics gravitational field event
  148425. * @param _physicsHelper A physics helper
  148426. * @param _scene BabylonJS scene
  148427. * @param _origin The origin position of the gravitational field event
  148428. * @param _options The options for the vortex event
  148429. */
  148430. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  148431. /**
  148432. * Returns the data related to the gravitational field event (sphere).
  148433. * @returns A gravitational field event
  148434. */
  148435. getData(): PhysicsGravitationalFieldEventData;
  148436. /**
  148437. * Enables the gravitational field.
  148438. */
  148439. enable(): void;
  148440. /**
  148441. * Disables the gravitational field.
  148442. */
  148443. disable(): void;
  148444. /**
  148445. * Disposes the sphere.
  148446. * @param force The force to dispose from the gravitational field event
  148447. */
  148448. dispose(force?: boolean): void;
  148449. private _tick;
  148450. }
  148451. /**
  148452. * Represents a physics updraft event
  148453. */
  148454. class PhysicsUpdraftEvent {
  148455. private _scene;
  148456. private _origin;
  148457. private _options;
  148458. private _physicsEngine;
  148459. private _originTop;
  148460. private _originDirection;
  148461. private _tickCallback;
  148462. private _cylinder;
  148463. private _cylinderPosition;
  148464. private _dataFetched;
  148465. /**
  148466. * Initializes the physics updraft event
  148467. * @param _scene BabylonJS scene
  148468. * @param _origin The origin position of the updraft
  148469. * @param _options The options for the updraft event
  148470. */
  148471. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  148472. /**
  148473. * Returns the data related to the updraft event (cylinder).
  148474. * @returns A physics updraft event
  148475. */
  148476. getData(): PhysicsUpdraftEventData;
  148477. /**
  148478. * Enables the updraft.
  148479. */
  148480. enable(): void;
  148481. /**
  148482. * Disables the updraft.
  148483. */
  148484. disable(): void;
  148485. /**
  148486. * Disposes the cylinder.
  148487. * @param force Specifies if the updraft should be disposed by force
  148488. */
  148489. dispose(force?: boolean): void;
  148490. private getImpostorHitData;
  148491. private _tick;
  148492. /*** Helpers ***/
  148493. private _prepareCylinder;
  148494. private _intersectsWithCylinder;
  148495. }
  148496. /**
  148497. * Represents a physics vortex event
  148498. */
  148499. class PhysicsVortexEvent {
  148500. private _scene;
  148501. private _origin;
  148502. private _options;
  148503. private _physicsEngine;
  148504. private _originTop;
  148505. private _tickCallback;
  148506. private _cylinder;
  148507. private _cylinderPosition;
  148508. private _dataFetched;
  148509. /**
  148510. * Initializes the physics vortex event
  148511. * @param _scene The BabylonJS scene
  148512. * @param _origin The origin position of the vortex
  148513. * @param _options The options for the vortex event
  148514. */
  148515. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  148516. /**
  148517. * Returns the data related to the vortex event (cylinder).
  148518. * @returns The physics vortex event data
  148519. */
  148520. getData(): PhysicsVortexEventData;
  148521. /**
  148522. * Enables the vortex.
  148523. */
  148524. enable(): void;
  148525. /**
  148526. * Disables the cortex.
  148527. */
  148528. disable(): void;
  148529. /**
  148530. * Disposes the sphere.
  148531. * @param force
  148532. */
  148533. dispose(force?: boolean): void;
  148534. private getImpostorHitData;
  148535. private _tick;
  148536. /*** Helpers ***/
  148537. private _prepareCylinder;
  148538. private _intersectsWithCylinder;
  148539. }
  148540. /**
  148541. * Options fot the radial explosion event
  148542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148543. */
  148544. export class PhysicsRadialExplosionEventOptions {
  148545. /**
  148546. * The radius of the sphere for the radial explosion.
  148547. */
  148548. radius: number;
  148549. /**
  148550. * The strenth of the explosion.
  148551. */
  148552. strength: number;
  148553. /**
  148554. * The strenght of the force in correspondence to the distance of the affected object
  148555. */
  148556. falloff: PhysicsRadialImpulseFalloff;
  148557. /**
  148558. * Sphere options for the radial explosion.
  148559. */
  148560. sphere: {
  148561. segments: number;
  148562. diameter: number;
  148563. };
  148564. /**
  148565. * Sphere options for the radial explosion.
  148566. */
  148567. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  148568. }
  148569. /**
  148570. * Options fot the updraft event
  148571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148572. */
  148573. export class PhysicsUpdraftEventOptions {
  148574. /**
  148575. * The radius of the cylinder for the vortex
  148576. */
  148577. radius: number;
  148578. /**
  148579. * The strenth of the updraft.
  148580. */
  148581. strength: number;
  148582. /**
  148583. * The height of the cylinder for the updraft.
  148584. */
  148585. height: number;
  148586. /**
  148587. * The mode for the the updraft.
  148588. */
  148589. updraftMode: PhysicsUpdraftMode;
  148590. }
  148591. /**
  148592. * Options fot the vortex event
  148593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148594. */
  148595. export class PhysicsVortexEventOptions {
  148596. /**
  148597. * The radius of the cylinder for the vortex
  148598. */
  148599. radius: number;
  148600. /**
  148601. * The strenth of the vortex.
  148602. */
  148603. strength: number;
  148604. /**
  148605. * The height of the cylinder for the vortex.
  148606. */
  148607. height: number;
  148608. /**
  148609. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  148610. */
  148611. centripetalForceThreshold: number;
  148612. /**
  148613. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  148614. */
  148615. centripetalForceMultiplier: number;
  148616. /**
  148617. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  148618. */
  148619. centrifugalForceMultiplier: number;
  148620. /**
  148621. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  148622. */
  148623. updraftForceMultiplier: number;
  148624. }
  148625. /**
  148626. * The strenght of the force in correspondence to the distance of the affected object
  148627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148628. */
  148629. export enum PhysicsRadialImpulseFalloff {
  148630. /** Defines that impulse is constant in strength across it's whole radius */
  148631. Constant = 0,
  148632. /** Defines that impulse gets weaker if it's further from the origin */
  148633. Linear = 1
  148634. }
  148635. /**
  148636. * The strength of the force in correspondence to the distance of the affected object
  148637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148638. */
  148639. export enum PhysicsUpdraftMode {
  148640. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  148641. Center = 0,
  148642. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  148643. Perpendicular = 1
  148644. }
  148645. /**
  148646. * Interface for a physics hit data
  148647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148648. */
  148649. export interface PhysicsHitData {
  148650. /**
  148651. * The force applied at the contact point
  148652. */
  148653. force: Vector3;
  148654. /**
  148655. * The contact point
  148656. */
  148657. contactPoint: Vector3;
  148658. /**
  148659. * The distance from the origin to the contact point
  148660. */
  148661. distanceFromOrigin: number;
  148662. }
  148663. /**
  148664. * Interface for radial explosion event data
  148665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148666. */
  148667. export interface PhysicsRadialExplosionEventData {
  148668. /**
  148669. * A sphere used for the radial explosion event
  148670. */
  148671. sphere: Mesh;
  148672. }
  148673. /**
  148674. * Interface for gravitational field event data
  148675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148676. */
  148677. export interface PhysicsGravitationalFieldEventData {
  148678. /**
  148679. * A sphere mesh used for the gravitational field event
  148680. */
  148681. sphere: Mesh;
  148682. }
  148683. /**
  148684. * Interface for updraft event data
  148685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148686. */
  148687. export interface PhysicsUpdraftEventData {
  148688. /**
  148689. * A cylinder used for the updraft event
  148690. */
  148691. cylinder: Mesh;
  148692. }
  148693. /**
  148694. * Interface for vortex event data
  148695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148696. */
  148697. export interface PhysicsVortexEventData {
  148698. /**
  148699. * A cylinder used for the vortex event
  148700. */
  148701. cylinder: Mesh;
  148702. }
  148703. /**
  148704. * Interface for an affected physics impostor
  148705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148706. */
  148707. export interface PhysicsAffectedImpostorWithData {
  148708. /**
  148709. * The impostor affected by the effect
  148710. */
  148711. impostor: PhysicsImpostor;
  148712. /**
  148713. * The data about the hit/horce from the explosion
  148714. */
  148715. hitData: PhysicsHitData;
  148716. }
  148717. }
  148718. declare module BABYLON {
  148719. /** @hidden */
  148720. export var blackAndWhitePixelShader: {
  148721. name: string;
  148722. shader: string;
  148723. };
  148724. }
  148725. declare module BABYLON {
  148726. /**
  148727. * Post process used to render in black and white
  148728. */
  148729. export class BlackAndWhitePostProcess extends PostProcess {
  148730. /**
  148731. * Linear about to convert he result to black and white (default: 1)
  148732. */
  148733. degree: number;
  148734. /**
  148735. * Gets a string identifying the name of the class
  148736. * @returns "BlackAndWhitePostProcess" string
  148737. */
  148738. getClassName(): string;
  148739. /**
  148740. * Creates a black and white post process
  148741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148742. * @param name The name of the effect.
  148743. * @param options The required width/height ratio to downsize to before computing the render pass.
  148744. * @param camera The camera to apply the render pass to.
  148745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148746. * @param engine The engine which the post process will be applied. (default: current engine)
  148747. * @param reusable If the post process can be reused on the same frame. (default: false)
  148748. */
  148749. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148750. /** @hidden */
  148751. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148752. }
  148753. }
  148754. declare module BABYLON {
  148755. /**
  148756. * This represents a set of one or more post processes in Babylon.
  148757. * A post process can be used to apply a shader to a texture after it is rendered.
  148758. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148759. */
  148760. export class PostProcessRenderEffect {
  148761. private _postProcesses;
  148762. private _getPostProcesses;
  148763. private _singleInstance;
  148764. private _cameras;
  148765. private _indicesForCamera;
  148766. /**
  148767. * Name of the effect
  148768. * @hidden
  148769. */
  148770. _name: string;
  148771. /**
  148772. * Instantiates a post process render effect.
  148773. * A post process can be used to apply a shader to a texture after it is rendered.
  148774. * @param engine The engine the effect is tied to
  148775. * @param name The name of the effect
  148776. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  148777. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  148778. */
  148779. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  148780. /**
  148781. * Checks if all the post processes in the effect are supported.
  148782. */
  148783. get isSupported(): boolean;
  148784. /**
  148785. * Updates the current state of the effect
  148786. * @hidden
  148787. */
  148788. _update(): void;
  148789. /**
  148790. * Attaches the effect on cameras
  148791. * @param cameras The camera to attach to.
  148792. * @hidden
  148793. */
  148794. _attachCameras(cameras: Camera): void;
  148795. /**
  148796. * Attaches the effect on cameras
  148797. * @param cameras The camera to attach to.
  148798. * @hidden
  148799. */
  148800. _attachCameras(cameras: Camera[]): void;
  148801. /**
  148802. * Detaches the effect on cameras
  148803. * @param cameras The camera to detatch from.
  148804. * @hidden
  148805. */
  148806. _detachCameras(cameras: Camera): void;
  148807. /**
  148808. * Detatches the effect on cameras
  148809. * @param cameras The camera to detatch from.
  148810. * @hidden
  148811. */
  148812. _detachCameras(cameras: Camera[]): void;
  148813. /**
  148814. * Enables the effect on given cameras
  148815. * @param cameras The camera to enable.
  148816. * @hidden
  148817. */
  148818. _enable(cameras: Camera): void;
  148819. /**
  148820. * Enables the effect on given cameras
  148821. * @param cameras The camera to enable.
  148822. * @hidden
  148823. */
  148824. _enable(cameras: Nullable<Camera[]>): void;
  148825. /**
  148826. * Disables the effect on the given cameras
  148827. * @param cameras The camera to disable.
  148828. * @hidden
  148829. */
  148830. _disable(cameras: Camera): void;
  148831. /**
  148832. * Disables the effect on the given cameras
  148833. * @param cameras The camera to disable.
  148834. * @hidden
  148835. */
  148836. _disable(cameras: Nullable<Camera[]>): void;
  148837. /**
  148838. * Gets a list of the post processes contained in the effect.
  148839. * @param camera The camera to get the post processes on.
  148840. * @returns The list of the post processes in the effect.
  148841. */
  148842. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  148843. }
  148844. }
  148845. declare module BABYLON {
  148846. /** @hidden */
  148847. export var extractHighlightsPixelShader: {
  148848. name: string;
  148849. shader: string;
  148850. };
  148851. }
  148852. declare module BABYLON {
  148853. /**
  148854. * 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.
  148855. */
  148856. export class ExtractHighlightsPostProcess extends PostProcess {
  148857. /**
  148858. * The luminance threshold, pixels below this value will be set to black.
  148859. */
  148860. threshold: number;
  148861. /** @hidden */
  148862. _exposure: number;
  148863. /**
  148864. * Post process which has the input texture to be used when performing highlight extraction
  148865. * @hidden
  148866. */
  148867. _inputPostProcess: Nullable<PostProcess>;
  148868. /**
  148869. * Gets a string identifying the name of the class
  148870. * @returns "ExtractHighlightsPostProcess" string
  148871. */
  148872. getClassName(): string;
  148873. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148874. }
  148875. }
  148876. declare module BABYLON {
  148877. /** @hidden */
  148878. export var bloomMergePixelShader: {
  148879. name: string;
  148880. shader: string;
  148881. };
  148882. }
  148883. declare module BABYLON {
  148884. /**
  148885. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148886. */
  148887. export class BloomMergePostProcess extends PostProcess {
  148888. /** Weight of the bloom to be added to the original input. */
  148889. weight: number;
  148890. /**
  148891. * Gets a string identifying the name of the class
  148892. * @returns "BloomMergePostProcess" string
  148893. */
  148894. getClassName(): string;
  148895. /**
  148896. * Creates a new instance of @see BloomMergePostProcess
  148897. * @param name The name of the effect.
  148898. * @param originalFromInput Post process which's input will be used for the merge.
  148899. * @param blurred Blurred highlights post process which's output will be used.
  148900. * @param weight Weight of the bloom to be added to the original input.
  148901. * @param options The required width/height ratio to downsize to before computing the render pass.
  148902. * @param camera The camera to apply the render pass to.
  148903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148904. * @param engine The engine which the post process will be applied. (default: current engine)
  148905. * @param reusable If the post process can be reused on the same frame. (default: false)
  148906. * @param textureType Type of textures used when performing the post process. (default: 0)
  148907. * @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)
  148908. */
  148909. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  148910. /** Weight of the bloom to be added to the original input. */
  148911. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148912. }
  148913. }
  148914. declare module BABYLON {
  148915. /**
  148916. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  148917. */
  148918. export class BloomEffect extends PostProcessRenderEffect {
  148919. private bloomScale;
  148920. /**
  148921. * @hidden Internal
  148922. */
  148923. _effects: Array<PostProcess>;
  148924. /**
  148925. * @hidden Internal
  148926. */
  148927. _downscale: ExtractHighlightsPostProcess;
  148928. private _blurX;
  148929. private _blurY;
  148930. private _merge;
  148931. /**
  148932. * The luminance threshold to find bright areas of the image to bloom.
  148933. */
  148934. get threshold(): number;
  148935. set threshold(value: number);
  148936. /**
  148937. * The strength of the bloom.
  148938. */
  148939. get weight(): number;
  148940. set weight(value: number);
  148941. /**
  148942. * Specifies the size of the bloom blur kernel, relative to the final output size
  148943. */
  148944. get kernel(): number;
  148945. set kernel(value: number);
  148946. /**
  148947. * Creates a new instance of @see BloomEffect
  148948. * @param scene The scene the effect belongs to.
  148949. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  148950. * @param bloomKernel The size of the kernel to be used when applying the blur.
  148951. * @param bloomWeight The the strength of bloom.
  148952. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148953. * @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)
  148954. */
  148955. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  148956. /**
  148957. * Disposes each of the internal effects for a given camera.
  148958. * @param camera The camera to dispose the effect on.
  148959. */
  148960. disposeEffects(camera: Camera): void;
  148961. /**
  148962. * @hidden Internal
  148963. */
  148964. _updateEffects(): void;
  148965. /**
  148966. * Internal
  148967. * @returns if all the contained post processes are ready.
  148968. * @hidden
  148969. */
  148970. _isReady(): boolean;
  148971. }
  148972. }
  148973. declare module BABYLON {
  148974. /** @hidden */
  148975. export var chromaticAberrationPixelShader: {
  148976. name: string;
  148977. shader: string;
  148978. };
  148979. }
  148980. declare module BABYLON {
  148981. /**
  148982. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  148983. */
  148984. export class ChromaticAberrationPostProcess extends PostProcess {
  148985. /**
  148986. * The amount of seperation of rgb channels (default: 30)
  148987. */
  148988. aberrationAmount: number;
  148989. /**
  148990. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  148991. */
  148992. radialIntensity: number;
  148993. /**
  148994. * 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))
  148995. */
  148996. direction: Vector2;
  148997. /**
  148998. * 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))
  148999. */
  149000. centerPosition: Vector2;
  149001. /** The width of the screen to apply the effect on */
  149002. screenWidth: number;
  149003. /** The height of the screen to apply the effect on */
  149004. screenHeight: number;
  149005. /**
  149006. * Gets a string identifying the name of the class
  149007. * @returns "ChromaticAberrationPostProcess" string
  149008. */
  149009. getClassName(): string;
  149010. /**
  149011. * Creates a new instance ChromaticAberrationPostProcess
  149012. * @param name The name of the effect.
  149013. * @param screenWidth The width of the screen to apply the effect on.
  149014. * @param screenHeight The height of the screen to apply the effect on.
  149015. * @param options The required width/height ratio to downsize to before computing the render pass.
  149016. * @param camera The camera to apply the render pass to.
  149017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149018. * @param engine The engine which the post process will be applied. (default: current engine)
  149019. * @param reusable If the post process can be reused on the same frame. (default: false)
  149020. * @param textureType Type of textures used when performing the post process. (default: 0)
  149021. * @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)
  149022. */
  149023. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149024. /** @hidden */
  149025. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149026. }
  149027. }
  149028. declare module BABYLON {
  149029. /** @hidden */
  149030. export var circleOfConfusionPixelShader: {
  149031. name: string;
  149032. shader: string;
  149033. };
  149034. }
  149035. declare module BABYLON {
  149036. /**
  149037. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149038. */
  149039. export class CircleOfConfusionPostProcess extends PostProcess {
  149040. /**
  149041. * 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.
  149042. */
  149043. lensSize: number;
  149044. /**
  149045. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149046. */
  149047. fStop: number;
  149048. /**
  149049. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149050. */
  149051. focusDistance: number;
  149052. /**
  149053. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149054. */
  149055. focalLength: number;
  149056. /**
  149057. * Gets a string identifying the name of the class
  149058. * @returns "CircleOfConfusionPostProcess" string
  149059. */
  149060. getClassName(): string;
  149061. private _depthTexture;
  149062. /**
  149063. * Creates a new instance CircleOfConfusionPostProcess
  149064. * @param name The name of the effect.
  149065. * @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.
  149066. * @param options The required width/height ratio to downsize to before computing the render pass.
  149067. * @param camera The camera to apply the render pass to.
  149068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149069. * @param engine The engine which the post process will be applied. (default: current engine)
  149070. * @param reusable If the post process can be reused on the same frame. (default: false)
  149071. * @param textureType Type of textures used when performing the post process. (default: 0)
  149072. * @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)
  149073. */
  149074. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149075. /**
  149076. * 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.
  149077. */
  149078. set depthTexture(value: RenderTargetTexture);
  149079. }
  149080. }
  149081. declare module BABYLON {
  149082. /** @hidden */
  149083. export var colorCorrectionPixelShader: {
  149084. name: string;
  149085. shader: string;
  149086. };
  149087. }
  149088. declare module BABYLON {
  149089. /**
  149090. *
  149091. * This post-process allows the modification of rendered colors by using
  149092. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149093. *
  149094. * The object needs to be provided an url to a texture containing the color
  149095. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149096. * Use an image editing software to tweak the LUT to match your needs.
  149097. *
  149098. * For an example of a color LUT, see here:
  149099. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149100. * For explanations on color grading, see here:
  149101. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149102. *
  149103. */
  149104. export class ColorCorrectionPostProcess extends PostProcess {
  149105. private _colorTableTexture;
  149106. /**
  149107. * Gets the color table url used to create the LUT texture
  149108. */
  149109. colorTableUrl: string;
  149110. /**
  149111. * Gets a string identifying the name of the class
  149112. * @returns "ColorCorrectionPostProcess" string
  149113. */
  149114. getClassName(): string;
  149115. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149116. /** @hidden */
  149117. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149118. }
  149119. }
  149120. declare module BABYLON {
  149121. /** @hidden */
  149122. export var convolutionPixelShader: {
  149123. name: string;
  149124. shader: string;
  149125. };
  149126. }
  149127. declare module BABYLON {
  149128. /**
  149129. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149130. * input texture to perform effects such as edge detection or sharpening
  149131. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149132. */
  149133. export class ConvolutionPostProcess extends PostProcess {
  149134. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149135. kernel: number[];
  149136. /**
  149137. * Gets a string identifying the name of the class
  149138. * @returns "ConvolutionPostProcess" string
  149139. */
  149140. getClassName(): string;
  149141. /**
  149142. * Creates a new instance ConvolutionPostProcess
  149143. * @param name The name of the effect.
  149144. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149145. * @param options The required width/height ratio to downsize to before computing the render pass.
  149146. * @param camera The camera to apply the render pass to.
  149147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149148. * @param engine The engine which the post process will be applied. (default: current engine)
  149149. * @param reusable If the post process can be reused on the same frame. (default: false)
  149150. * @param textureType Type of textures used when performing the post process. (default: 0)
  149151. */
  149152. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149153. /** @hidden */
  149154. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149155. /**
  149156. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149157. */
  149158. static EdgeDetect0Kernel: number[];
  149159. /**
  149160. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149161. */
  149162. static EdgeDetect1Kernel: number[];
  149163. /**
  149164. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149165. */
  149166. static EdgeDetect2Kernel: number[];
  149167. /**
  149168. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149169. */
  149170. static SharpenKernel: number[];
  149171. /**
  149172. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149173. */
  149174. static EmbossKernel: number[];
  149175. /**
  149176. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149177. */
  149178. static GaussianKernel: number[];
  149179. }
  149180. }
  149181. declare module BABYLON {
  149182. /**
  149183. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149184. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149185. * based on samples that have a large difference in distance than the center pixel.
  149186. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149187. */
  149188. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149189. /**
  149190. * The direction the blur should be applied
  149191. */
  149192. direction: Vector2;
  149193. /**
  149194. * Gets a string identifying the name of the class
  149195. * @returns "DepthOfFieldBlurPostProcess" string
  149196. */
  149197. getClassName(): string;
  149198. /**
  149199. * Creates a new instance CircleOfConfusionPostProcess
  149200. * @param name The name of the effect.
  149201. * @param scene The scene the effect belongs to.
  149202. * @param direction The direction the blur should be applied.
  149203. * @param kernel The size of the kernel used to blur.
  149204. * @param options The required width/height ratio to downsize to before computing the render pass.
  149205. * @param camera The camera to apply the render pass to.
  149206. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149207. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149209. * @param engine The engine which the post process will be applied. (default: current engine)
  149210. * @param reusable If the post process can be reused on the same frame. (default: false)
  149211. * @param textureType Type of textures used when performing the post process. (default: 0)
  149212. * @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)
  149213. */
  149214. 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);
  149215. }
  149216. }
  149217. declare module BABYLON {
  149218. /** @hidden */
  149219. export var depthOfFieldMergePixelShader: {
  149220. name: string;
  149221. shader: string;
  149222. };
  149223. }
  149224. declare module BABYLON {
  149225. /**
  149226. * Options to be set when merging outputs from the default pipeline.
  149227. */
  149228. export class DepthOfFieldMergePostProcessOptions {
  149229. /**
  149230. * The original image to merge on top of
  149231. */
  149232. originalFromInput: PostProcess;
  149233. /**
  149234. * Parameters to perform the merge of the depth of field effect
  149235. */
  149236. depthOfField?: {
  149237. circleOfConfusion: PostProcess;
  149238. blurSteps: Array<PostProcess>;
  149239. };
  149240. /**
  149241. * Parameters to perform the merge of bloom effect
  149242. */
  149243. bloom?: {
  149244. blurred: PostProcess;
  149245. weight: number;
  149246. };
  149247. }
  149248. /**
  149249. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149250. */
  149251. export class DepthOfFieldMergePostProcess extends PostProcess {
  149252. private blurSteps;
  149253. /**
  149254. * Gets a string identifying the name of the class
  149255. * @returns "DepthOfFieldMergePostProcess" string
  149256. */
  149257. getClassName(): string;
  149258. /**
  149259. * Creates a new instance of DepthOfFieldMergePostProcess
  149260. * @param name The name of the effect.
  149261. * @param originalFromInput Post process which's input will be used for the merge.
  149262. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149263. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149264. * @param options The required width/height ratio to downsize to before computing the render pass.
  149265. * @param camera The camera to apply the render pass to.
  149266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149267. * @param engine The engine which the post process will be applied. (default: current engine)
  149268. * @param reusable If the post process can be reused on the same frame. (default: false)
  149269. * @param textureType Type of textures used when performing the post process. (default: 0)
  149270. * @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)
  149271. */
  149272. 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);
  149273. /**
  149274. * Updates the effect with the current post process compile time values and recompiles the shader.
  149275. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149276. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149277. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149278. * @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
  149279. * @param onCompiled Called when the shader has been compiled.
  149280. * @param onError Called if there is an error when compiling a shader.
  149281. */
  149282. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149283. }
  149284. }
  149285. declare module BABYLON {
  149286. /**
  149287. * Specifies the level of max blur that should be applied when using the depth of field effect
  149288. */
  149289. export enum DepthOfFieldEffectBlurLevel {
  149290. /**
  149291. * Subtle blur
  149292. */
  149293. Low = 0,
  149294. /**
  149295. * Medium blur
  149296. */
  149297. Medium = 1,
  149298. /**
  149299. * Large blur
  149300. */
  149301. High = 2
  149302. }
  149303. /**
  149304. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149305. */
  149306. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149307. private _circleOfConfusion;
  149308. /**
  149309. * @hidden Internal, blurs from high to low
  149310. */
  149311. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149312. private _depthOfFieldBlurY;
  149313. private _dofMerge;
  149314. /**
  149315. * @hidden Internal post processes in depth of field effect
  149316. */
  149317. _effects: Array<PostProcess>;
  149318. /**
  149319. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149320. */
  149321. set focalLength(value: number);
  149322. get focalLength(): number;
  149323. /**
  149324. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149325. */
  149326. set fStop(value: number);
  149327. get fStop(): number;
  149328. /**
  149329. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149330. */
  149331. set focusDistance(value: number);
  149332. get focusDistance(): number;
  149333. /**
  149334. * 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.
  149335. */
  149336. set lensSize(value: number);
  149337. get lensSize(): number;
  149338. /**
  149339. * Creates a new instance DepthOfFieldEffect
  149340. * @param scene The scene the effect belongs to.
  149341. * @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.
  149342. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149343. * @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)
  149344. */
  149345. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149346. /**
  149347. * Get the current class name of the current effet
  149348. * @returns "DepthOfFieldEffect"
  149349. */
  149350. getClassName(): string;
  149351. /**
  149352. * 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.
  149353. */
  149354. set depthTexture(value: RenderTargetTexture);
  149355. /**
  149356. * Disposes each of the internal effects for a given camera.
  149357. * @param camera The camera to dispose the effect on.
  149358. */
  149359. disposeEffects(camera: Camera): void;
  149360. /**
  149361. * @hidden Internal
  149362. */
  149363. _updateEffects(): void;
  149364. /**
  149365. * Internal
  149366. * @returns if all the contained post processes are ready.
  149367. * @hidden
  149368. */
  149369. _isReady(): boolean;
  149370. }
  149371. }
  149372. declare module BABYLON {
  149373. /** @hidden */
  149374. export var displayPassPixelShader: {
  149375. name: string;
  149376. shader: string;
  149377. };
  149378. }
  149379. declare module BABYLON {
  149380. /**
  149381. * DisplayPassPostProcess which produces an output the same as it's input
  149382. */
  149383. export class DisplayPassPostProcess extends PostProcess {
  149384. /**
  149385. * Gets a string identifying the name of the class
  149386. * @returns "DisplayPassPostProcess" string
  149387. */
  149388. getClassName(): string;
  149389. /**
  149390. * Creates the DisplayPassPostProcess
  149391. * @param name The name of the effect.
  149392. * @param options The required width/height ratio to downsize to before computing the render pass.
  149393. * @param camera The camera to apply the render pass to.
  149394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149395. * @param engine The engine which the post process will be applied. (default: current engine)
  149396. * @param reusable If the post process can be reused on the same frame. (default: false)
  149397. */
  149398. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149399. /** @hidden */
  149400. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149401. }
  149402. }
  149403. declare module BABYLON {
  149404. /** @hidden */
  149405. export var filterPixelShader: {
  149406. name: string;
  149407. shader: string;
  149408. };
  149409. }
  149410. declare module BABYLON {
  149411. /**
  149412. * Applies a kernel filter to the image
  149413. */
  149414. export class FilterPostProcess extends PostProcess {
  149415. /** The matrix to be applied to the image */
  149416. kernelMatrix: Matrix;
  149417. /**
  149418. * Gets a string identifying the name of the class
  149419. * @returns "FilterPostProcess" string
  149420. */
  149421. getClassName(): string;
  149422. /**
  149423. *
  149424. * @param name The name of the effect.
  149425. * @param kernelMatrix The matrix to be applied to the image
  149426. * @param options The required width/height ratio to downsize to before computing the render pass.
  149427. * @param camera The camera to apply the render pass to.
  149428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149429. * @param engine The engine which the post process will be applied. (default: current engine)
  149430. * @param reusable If the post process can be reused on the same frame. (default: false)
  149431. */
  149432. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149433. /** @hidden */
  149434. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  149435. }
  149436. }
  149437. declare module BABYLON {
  149438. /** @hidden */
  149439. export var fxaaPixelShader: {
  149440. name: string;
  149441. shader: string;
  149442. };
  149443. }
  149444. declare module BABYLON {
  149445. /** @hidden */
  149446. export var fxaaVertexShader: {
  149447. name: string;
  149448. shader: string;
  149449. };
  149450. }
  149451. declare module BABYLON {
  149452. /**
  149453. * Fxaa post process
  149454. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  149455. */
  149456. export class FxaaPostProcess extends PostProcess {
  149457. /**
  149458. * Gets a string identifying the name of the class
  149459. * @returns "FxaaPostProcess" string
  149460. */
  149461. getClassName(): string;
  149462. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149463. private _getDefines;
  149464. /** @hidden */
  149465. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  149466. }
  149467. }
  149468. declare module BABYLON {
  149469. /** @hidden */
  149470. export var grainPixelShader: {
  149471. name: string;
  149472. shader: string;
  149473. };
  149474. }
  149475. declare module BABYLON {
  149476. /**
  149477. * The GrainPostProcess adds noise to the image at mid luminance levels
  149478. */
  149479. export class GrainPostProcess extends PostProcess {
  149480. /**
  149481. * The intensity of the grain added (default: 30)
  149482. */
  149483. intensity: number;
  149484. /**
  149485. * If the grain should be randomized on every frame
  149486. */
  149487. animated: boolean;
  149488. /**
  149489. * Gets a string identifying the name of the class
  149490. * @returns "GrainPostProcess" string
  149491. */
  149492. getClassName(): string;
  149493. /**
  149494. * Creates a new instance of @see GrainPostProcess
  149495. * @param name The name of the effect.
  149496. * @param options The required width/height ratio to downsize to before computing the render pass.
  149497. * @param camera The camera to apply the render pass to.
  149498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149499. * @param engine The engine which the post process will be applied. (default: current engine)
  149500. * @param reusable If the post process can be reused on the same frame. (default: false)
  149501. * @param textureType Type of textures used when performing the post process. (default: 0)
  149502. * @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)
  149503. */
  149504. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149505. /** @hidden */
  149506. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  149507. }
  149508. }
  149509. declare module BABYLON {
  149510. /** @hidden */
  149511. export var highlightsPixelShader: {
  149512. name: string;
  149513. shader: string;
  149514. };
  149515. }
  149516. declare module BABYLON {
  149517. /**
  149518. * Extracts highlights from the image
  149519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149520. */
  149521. export class HighlightsPostProcess extends PostProcess {
  149522. /**
  149523. * Gets a string identifying the name of the class
  149524. * @returns "HighlightsPostProcess" string
  149525. */
  149526. getClassName(): string;
  149527. /**
  149528. * Extracts highlights from the image
  149529. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149530. * @param name The name of the effect.
  149531. * @param options The required width/height ratio to downsize to before computing the render pass.
  149532. * @param camera The camera to apply the render pass to.
  149533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149534. * @param engine The engine which the post process will be applied. (default: current engine)
  149535. * @param reusable If the post process can be reused on the same frame. (default: false)
  149536. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  149537. */
  149538. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149539. }
  149540. }
  149541. declare module BABYLON {
  149542. /** @hidden */
  149543. export var mrtFragmentDeclaration: {
  149544. name: string;
  149545. shader: string;
  149546. };
  149547. }
  149548. declare module BABYLON {
  149549. /** @hidden */
  149550. export var geometryPixelShader: {
  149551. name: string;
  149552. shader: string;
  149553. };
  149554. }
  149555. declare module BABYLON {
  149556. /** @hidden */
  149557. export var geometryVertexShader: {
  149558. name: string;
  149559. shader: string;
  149560. };
  149561. }
  149562. declare module BABYLON {
  149563. /** @hidden */
  149564. interface ISavedTransformationMatrix {
  149565. world: Matrix;
  149566. viewProjection: Matrix;
  149567. }
  149568. /**
  149569. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  149570. */
  149571. export class GeometryBufferRenderer {
  149572. /**
  149573. * Constant used to retrieve the position texture index in the G-Buffer textures array
  149574. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  149575. */
  149576. static readonly POSITION_TEXTURE_TYPE: number;
  149577. /**
  149578. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  149579. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  149580. */
  149581. static readonly VELOCITY_TEXTURE_TYPE: number;
  149582. /**
  149583. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  149584. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  149585. */
  149586. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  149587. /**
  149588. * Dictionary used to store the previous transformation matrices of each rendered mesh
  149589. * in order to compute objects velocities when enableVelocity is set to "true"
  149590. * @hidden
  149591. */
  149592. _previousTransformationMatrices: {
  149593. [index: number]: ISavedTransformationMatrix;
  149594. };
  149595. /**
  149596. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  149597. * in order to compute objects velocities when enableVelocity is set to "true"
  149598. * @hidden
  149599. */
  149600. _previousBonesTransformationMatrices: {
  149601. [index: number]: Float32Array;
  149602. };
  149603. /**
  149604. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  149605. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  149606. */
  149607. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  149608. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  149609. renderTransparentMeshes: boolean;
  149610. private _scene;
  149611. private _resizeObserver;
  149612. private _multiRenderTarget;
  149613. private _ratio;
  149614. private _enablePosition;
  149615. private _enableVelocity;
  149616. private _enableReflectivity;
  149617. private _positionIndex;
  149618. private _velocityIndex;
  149619. private _reflectivityIndex;
  149620. protected _effect: Effect;
  149621. protected _cachedDefines: string;
  149622. /**
  149623. * Set the render list (meshes to be rendered) used in the G buffer.
  149624. */
  149625. set renderList(meshes: Mesh[]);
  149626. /**
  149627. * Gets wether or not G buffer are supported by the running hardware.
  149628. * This requires draw buffer supports
  149629. */
  149630. get isSupported(): boolean;
  149631. /**
  149632. * Returns the index of the given texture type in the G-Buffer textures array
  149633. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  149634. * @returns the index of the given texture type in the G-Buffer textures array
  149635. */
  149636. getTextureIndex(textureType: number): number;
  149637. /**
  149638. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  149639. */
  149640. get enablePosition(): boolean;
  149641. /**
  149642. * Sets whether or not objects positions are enabled for the G buffer.
  149643. */
  149644. set enablePosition(enable: boolean);
  149645. /**
  149646. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  149647. */
  149648. get enableVelocity(): boolean;
  149649. /**
  149650. * Sets wether or not objects velocities are enabled for the G buffer.
  149651. */
  149652. set enableVelocity(enable: boolean);
  149653. /**
  149654. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  149655. */
  149656. get enableReflectivity(): boolean;
  149657. /**
  149658. * Sets wether or not objects roughness are enabled for the G buffer.
  149659. */
  149660. set enableReflectivity(enable: boolean);
  149661. /**
  149662. * Gets the scene associated with the buffer.
  149663. */
  149664. get scene(): Scene;
  149665. /**
  149666. * Gets the ratio used by the buffer during its creation.
  149667. * How big is the buffer related to the main canvas.
  149668. */
  149669. get ratio(): number;
  149670. /** @hidden */
  149671. static _SceneComponentInitialization: (scene: Scene) => void;
  149672. /**
  149673. * Creates a new G Buffer for the scene
  149674. * @param scene The scene the buffer belongs to
  149675. * @param ratio How big is the buffer related to the main canvas.
  149676. */
  149677. constructor(scene: Scene, ratio?: number);
  149678. /**
  149679. * Checks wether everything is ready to render a submesh to the G buffer.
  149680. * @param subMesh the submesh to check readiness for
  149681. * @param useInstances is the mesh drawn using instance or not
  149682. * @returns true if ready otherwise false
  149683. */
  149684. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149685. /**
  149686. * Gets the current underlying G Buffer.
  149687. * @returns the buffer
  149688. */
  149689. getGBuffer(): MultiRenderTarget;
  149690. /**
  149691. * Gets the number of samples used to render the buffer (anti aliasing).
  149692. */
  149693. get samples(): number;
  149694. /**
  149695. * Sets the number of samples used to render the buffer (anti aliasing).
  149696. */
  149697. set samples(value: number);
  149698. /**
  149699. * Disposes the renderer and frees up associated resources.
  149700. */
  149701. dispose(): void;
  149702. protected _createRenderTargets(): void;
  149703. private _copyBonesTransformationMatrices;
  149704. }
  149705. }
  149706. declare module BABYLON {
  149707. interface Scene {
  149708. /** @hidden (Backing field) */
  149709. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149710. /**
  149711. * Gets or Sets the current geometry buffer associated to the scene.
  149712. */
  149713. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149714. /**
  149715. * Enables a GeometryBufferRender and associates it with the scene
  149716. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  149717. * @returns the GeometryBufferRenderer
  149718. */
  149719. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149720. /**
  149721. * Disables the GeometryBufferRender associated with the scene
  149722. */
  149723. disableGeometryBufferRenderer(): void;
  149724. }
  149725. /**
  149726. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149727. * in several rendering techniques.
  149728. */
  149729. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149730. /**
  149731. * The component name helpful to identify the component in the list of scene components.
  149732. */
  149733. readonly name: string;
  149734. /**
  149735. * The scene the component belongs to.
  149736. */
  149737. scene: Scene;
  149738. /**
  149739. * Creates a new instance of the component for the given scene
  149740. * @param scene Defines the scene to register the component in
  149741. */
  149742. constructor(scene: Scene);
  149743. /**
  149744. * Registers the component in a given scene
  149745. */
  149746. register(): void;
  149747. /**
  149748. * Rebuilds the elements related to this component in case of
  149749. * context lost for instance.
  149750. */
  149751. rebuild(): void;
  149752. /**
  149753. * Disposes the component and the associated ressources
  149754. */
  149755. dispose(): void;
  149756. private _gatherRenderTargets;
  149757. }
  149758. }
  149759. declare module BABYLON {
  149760. /** @hidden */
  149761. export var motionBlurPixelShader: {
  149762. name: string;
  149763. shader: string;
  149764. };
  149765. }
  149766. declare module BABYLON {
  149767. /**
  149768. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149769. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149770. * As an example, all you have to do is to create the post-process:
  149771. * var mb = new BABYLON.MotionBlurPostProcess(
  149772. * 'mb', // The name of the effect.
  149773. * scene, // The scene containing the objects to blur according to their velocity.
  149774. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149775. * camera // The camera to apply the render pass to.
  149776. * );
  149777. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  149778. */
  149779. export class MotionBlurPostProcess extends PostProcess {
  149780. /**
  149781. * Defines how much the image is blurred by the movement. Default value is equal to 1
  149782. */
  149783. motionStrength: number;
  149784. /**
  149785. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  149786. */
  149787. get motionBlurSamples(): number;
  149788. /**
  149789. * Sets the number of iterations to be used for motion blur quality
  149790. */
  149791. set motionBlurSamples(samples: number);
  149792. private _motionBlurSamples;
  149793. private _geometryBufferRenderer;
  149794. /**
  149795. * Gets a string identifying the name of the class
  149796. * @returns "MotionBlurPostProcess" string
  149797. */
  149798. getClassName(): string;
  149799. /**
  149800. * Creates a new instance MotionBlurPostProcess
  149801. * @param name The name of the effect.
  149802. * @param scene The scene containing the objects to blur according to their velocity.
  149803. * @param options The required width/height ratio to downsize to before computing the render pass.
  149804. * @param camera The camera to apply the render pass to.
  149805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149806. * @param engine The engine which the post process will be applied. (default: current engine)
  149807. * @param reusable If the post process can be reused on the same frame. (default: false)
  149808. * @param textureType Type of textures used when performing the post process. (default: 0)
  149809. * @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)
  149810. */
  149811. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149812. /**
  149813. * Excludes the given skinned mesh from computing bones velocities.
  149814. * 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.
  149815. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  149816. */
  149817. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149818. /**
  149819. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  149820. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  149821. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  149822. */
  149823. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149824. /**
  149825. * Disposes the post process.
  149826. * @param camera The camera to dispose the post process on.
  149827. */
  149828. dispose(camera?: Camera): void;
  149829. /** @hidden */
  149830. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  149831. }
  149832. }
  149833. declare module BABYLON {
  149834. /** @hidden */
  149835. export var refractionPixelShader: {
  149836. name: string;
  149837. shader: string;
  149838. };
  149839. }
  149840. declare module BABYLON {
  149841. /**
  149842. * Post process which applies a refractin texture
  149843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149844. */
  149845. export class RefractionPostProcess extends PostProcess {
  149846. private _refTexture;
  149847. private _ownRefractionTexture;
  149848. /** the base color of the refraction (used to taint the rendering) */
  149849. color: Color3;
  149850. /** simulated refraction depth */
  149851. depth: number;
  149852. /** the coefficient of the base color (0 to remove base color tainting) */
  149853. colorLevel: number;
  149854. /** Gets the url used to load the refraction texture */
  149855. refractionTextureUrl: string;
  149856. /**
  149857. * Gets or sets the refraction texture
  149858. * Please note that you are responsible for disposing the texture if you set it manually
  149859. */
  149860. get refractionTexture(): Texture;
  149861. set refractionTexture(value: Texture);
  149862. /**
  149863. * Gets a string identifying the name of the class
  149864. * @returns "RefractionPostProcess" string
  149865. */
  149866. getClassName(): string;
  149867. /**
  149868. * Initializes the RefractionPostProcess
  149869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149870. * @param name The name of the effect.
  149871. * @param refractionTextureUrl Url of the refraction texture to use
  149872. * @param color the base color of the refraction (used to taint the rendering)
  149873. * @param depth simulated refraction depth
  149874. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  149875. * @param camera The camera to apply the render pass to.
  149876. * @param options The required width/height ratio to downsize to before computing the render pass.
  149877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149878. * @param engine The engine which the post process will be applied. (default: current engine)
  149879. * @param reusable If the post process can be reused on the same frame. (default: false)
  149880. */
  149881. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149882. /**
  149883. * Disposes of the post process
  149884. * @param camera Camera to dispose post process on
  149885. */
  149886. dispose(camera: Camera): void;
  149887. /** @hidden */
  149888. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  149889. }
  149890. }
  149891. declare module BABYLON {
  149892. /** @hidden */
  149893. export var sharpenPixelShader: {
  149894. name: string;
  149895. shader: string;
  149896. };
  149897. }
  149898. declare module BABYLON {
  149899. /**
  149900. * The SharpenPostProcess applies a sharpen kernel to every pixel
  149901. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149902. */
  149903. export class SharpenPostProcess extends PostProcess {
  149904. /**
  149905. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  149906. */
  149907. colorAmount: number;
  149908. /**
  149909. * How much sharpness should be applied (default: 0.3)
  149910. */
  149911. edgeAmount: number;
  149912. /**
  149913. * Gets a string identifying the name of the class
  149914. * @returns "SharpenPostProcess" string
  149915. */
  149916. getClassName(): string;
  149917. /**
  149918. * Creates a new instance ConvolutionPostProcess
  149919. * @param name The name of the effect.
  149920. * @param options The required width/height ratio to downsize to before computing the render pass.
  149921. * @param camera The camera to apply the render pass to.
  149922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149923. * @param engine The engine which the post process will be applied. (default: current engine)
  149924. * @param reusable If the post process can be reused on the same frame. (default: false)
  149925. * @param textureType Type of textures used when performing the post process. (default: 0)
  149926. * @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)
  149927. */
  149928. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149929. /** @hidden */
  149930. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  149931. }
  149932. }
  149933. declare module BABYLON {
  149934. /**
  149935. * PostProcessRenderPipeline
  149936. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149937. */
  149938. export class PostProcessRenderPipeline {
  149939. private engine;
  149940. private _renderEffects;
  149941. private _renderEffectsForIsolatedPass;
  149942. /**
  149943. * List of inspectable custom properties (used by the Inspector)
  149944. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  149945. */
  149946. inspectableCustomProperties: IInspectable[];
  149947. /**
  149948. * @hidden
  149949. */
  149950. protected _cameras: Camera[];
  149951. /** @hidden */
  149952. _name: string;
  149953. /**
  149954. * Gets pipeline name
  149955. */
  149956. get name(): string;
  149957. /** Gets the list of attached cameras */
  149958. get cameras(): Camera[];
  149959. /**
  149960. * Initializes a PostProcessRenderPipeline
  149961. * @param engine engine to add the pipeline to
  149962. * @param name name of the pipeline
  149963. */
  149964. constructor(engine: Engine, name: string);
  149965. /**
  149966. * Gets the class name
  149967. * @returns "PostProcessRenderPipeline"
  149968. */
  149969. getClassName(): string;
  149970. /**
  149971. * If all the render effects in the pipeline are supported
  149972. */
  149973. get isSupported(): boolean;
  149974. /**
  149975. * Adds an effect to the pipeline
  149976. * @param renderEffect the effect to add
  149977. */
  149978. addEffect(renderEffect: PostProcessRenderEffect): void;
  149979. /** @hidden */
  149980. _rebuild(): void;
  149981. /** @hidden */
  149982. _enableEffect(renderEffectName: string, cameras: Camera): void;
  149983. /** @hidden */
  149984. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  149985. /** @hidden */
  149986. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149987. /** @hidden */
  149988. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149989. /** @hidden */
  149990. _attachCameras(cameras: Camera, unique: boolean): void;
  149991. /** @hidden */
  149992. _attachCameras(cameras: Camera[], unique: boolean): void;
  149993. /** @hidden */
  149994. _detachCameras(cameras: Camera): void;
  149995. /** @hidden */
  149996. _detachCameras(cameras: Nullable<Camera[]>): void;
  149997. /** @hidden */
  149998. _update(): void;
  149999. /** @hidden */
  150000. _reset(): void;
  150001. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150002. /**
  150003. * Sets the required values to the prepass renderer.
  150004. * @param prePassRenderer defines the prepass renderer to setup.
  150005. * @returns true if the pre pass is needed.
  150006. */
  150007. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150008. /**
  150009. * Disposes of the pipeline
  150010. */
  150011. dispose(): void;
  150012. }
  150013. }
  150014. declare module BABYLON {
  150015. /**
  150016. * PostProcessRenderPipelineManager class
  150017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150018. */
  150019. export class PostProcessRenderPipelineManager {
  150020. private _renderPipelines;
  150021. /**
  150022. * Initializes a PostProcessRenderPipelineManager
  150023. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150024. */
  150025. constructor();
  150026. /**
  150027. * Gets the list of supported render pipelines
  150028. */
  150029. get supportedPipelines(): PostProcessRenderPipeline[];
  150030. /**
  150031. * Adds a pipeline to the manager
  150032. * @param renderPipeline The pipeline to add
  150033. */
  150034. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150035. /**
  150036. * Attaches a camera to the pipeline
  150037. * @param renderPipelineName The name of the pipeline to attach to
  150038. * @param cameras the camera to attach
  150039. * @param unique if the camera can be attached multiple times to the pipeline
  150040. */
  150041. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150042. /**
  150043. * Detaches a camera from the pipeline
  150044. * @param renderPipelineName The name of the pipeline to detach from
  150045. * @param cameras the camera to detach
  150046. */
  150047. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150048. /**
  150049. * Enables an effect by name on a pipeline
  150050. * @param renderPipelineName the name of the pipeline to enable the effect in
  150051. * @param renderEffectName the name of the effect to enable
  150052. * @param cameras the cameras that the effect should be enabled on
  150053. */
  150054. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150055. /**
  150056. * Disables an effect by name on a pipeline
  150057. * @param renderPipelineName the name of the pipeline to disable the effect in
  150058. * @param renderEffectName the name of the effect to disable
  150059. * @param cameras the cameras that the effect should be disabled on
  150060. */
  150061. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150062. /**
  150063. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150064. */
  150065. update(): void;
  150066. /** @hidden */
  150067. _rebuild(): void;
  150068. /**
  150069. * Disposes of the manager and pipelines
  150070. */
  150071. dispose(): void;
  150072. }
  150073. }
  150074. declare module BABYLON {
  150075. interface Scene {
  150076. /** @hidden (Backing field) */
  150077. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150078. /**
  150079. * Gets the postprocess render pipeline manager
  150080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150081. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150082. */
  150083. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150084. }
  150085. /**
  150086. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150087. */
  150088. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150089. /**
  150090. * The component name helpfull to identify the component in the list of scene components.
  150091. */
  150092. readonly name: string;
  150093. /**
  150094. * The scene the component belongs to.
  150095. */
  150096. scene: Scene;
  150097. /**
  150098. * Creates a new instance of the component for the given scene
  150099. * @param scene Defines the scene to register the component in
  150100. */
  150101. constructor(scene: Scene);
  150102. /**
  150103. * Registers the component in a given scene
  150104. */
  150105. register(): void;
  150106. /**
  150107. * Rebuilds the elements related to this component in case of
  150108. * context lost for instance.
  150109. */
  150110. rebuild(): void;
  150111. /**
  150112. * Disposes the component and the associated ressources
  150113. */
  150114. dispose(): void;
  150115. private _gatherRenderTargets;
  150116. }
  150117. }
  150118. declare module BABYLON {
  150119. /**
  150120. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150121. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150122. */
  150123. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150124. private _scene;
  150125. private _camerasToBeAttached;
  150126. /**
  150127. * ID of the sharpen post process,
  150128. */
  150129. private readonly SharpenPostProcessId;
  150130. /**
  150131. * @ignore
  150132. * ID of the image processing post process;
  150133. */
  150134. readonly ImageProcessingPostProcessId: string;
  150135. /**
  150136. * @ignore
  150137. * ID of the Fast Approximate Anti-Aliasing post process;
  150138. */
  150139. readonly FxaaPostProcessId: string;
  150140. /**
  150141. * ID of the chromatic aberration post process,
  150142. */
  150143. private readonly ChromaticAberrationPostProcessId;
  150144. /**
  150145. * ID of the grain post process
  150146. */
  150147. private readonly GrainPostProcessId;
  150148. /**
  150149. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150150. */
  150151. sharpen: SharpenPostProcess;
  150152. private _sharpenEffect;
  150153. private bloom;
  150154. /**
  150155. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150156. */
  150157. depthOfField: DepthOfFieldEffect;
  150158. /**
  150159. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150160. */
  150161. fxaa: FxaaPostProcess;
  150162. /**
  150163. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150164. */
  150165. imageProcessing: ImageProcessingPostProcess;
  150166. /**
  150167. * Chromatic aberration post process which will shift rgb colors in the image
  150168. */
  150169. chromaticAberration: ChromaticAberrationPostProcess;
  150170. private _chromaticAberrationEffect;
  150171. /**
  150172. * Grain post process which add noise to the image
  150173. */
  150174. grain: GrainPostProcess;
  150175. private _grainEffect;
  150176. /**
  150177. * Glow post process which adds a glow to emissive areas of the image
  150178. */
  150179. private _glowLayer;
  150180. /**
  150181. * Animations which can be used to tweak settings over a period of time
  150182. */
  150183. animations: Animation[];
  150184. private _imageProcessingConfigurationObserver;
  150185. private _sharpenEnabled;
  150186. private _bloomEnabled;
  150187. private _depthOfFieldEnabled;
  150188. private _depthOfFieldBlurLevel;
  150189. private _fxaaEnabled;
  150190. private _imageProcessingEnabled;
  150191. private _defaultPipelineTextureType;
  150192. private _bloomScale;
  150193. private _chromaticAberrationEnabled;
  150194. private _grainEnabled;
  150195. private _buildAllowed;
  150196. /**
  150197. * Gets active scene
  150198. */
  150199. get scene(): Scene;
  150200. /**
  150201. * Enable or disable the sharpen process from the pipeline
  150202. */
  150203. set sharpenEnabled(enabled: boolean);
  150204. get sharpenEnabled(): boolean;
  150205. private _resizeObserver;
  150206. private _hardwareScaleLevel;
  150207. private _bloomKernel;
  150208. /**
  150209. * Specifies the size of the bloom blur kernel, relative to the final output size
  150210. */
  150211. get bloomKernel(): number;
  150212. set bloomKernel(value: number);
  150213. /**
  150214. * Specifies the weight of the bloom in the final rendering
  150215. */
  150216. private _bloomWeight;
  150217. /**
  150218. * Specifies the luma threshold for the area that will be blurred by the bloom
  150219. */
  150220. private _bloomThreshold;
  150221. private _hdr;
  150222. /**
  150223. * The strength of the bloom.
  150224. */
  150225. set bloomWeight(value: number);
  150226. get bloomWeight(): number;
  150227. /**
  150228. * The strength of the bloom.
  150229. */
  150230. set bloomThreshold(value: number);
  150231. get bloomThreshold(): number;
  150232. /**
  150233. * The scale of the bloom, lower value will provide better performance.
  150234. */
  150235. set bloomScale(value: number);
  150236. get bloomScale(): number;
  150237. /**
  150238. * Enable or disable the bloom from the pipeline
  150239. */
  150240. set bloomEnabled(enabled: boolean);
  150241. get bloomEnabled(): boolean;
  150242. private _rebuildBloom;
  150243. /**
  150244. * If the depth of field is enabled.
  150245. */
  150246. get depthOfFieldEnabled(): boolean;
  150247. set depthOfFieldEnabled(enabled: boolean);
  150248. /**
  150249. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150250. */
  150251. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150252. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150253. /**
  150254. * If the anti aliasing is enabled.
  150255. */
  150256. set fxaaEnabled(enabled: boolean);
  150257. get fxaaEnabled(): boolean;
  150258. private _samples;
  150259. /**
  150260. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150261. */
  150262. set samples(sampleCount: number);
  150263. get samples(): number;
  150264. /**
  150265. * If image processing is enabled.
  150266. */
  150267. set imageProcessingEnabled(enabled: boolean);
  150268. get imageProcessingEnabled(): boolean;
  150269. /**
  150270. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150271. */
  150272. set glowLayerEnabled(enabled: boolean);
  150273. get glowLayerEnabled(): boolean;
  150274. /**
  150275. * Gets the glow layer (or null if not defined)
  150276. */
  150277. get glowLayer(): Nullable<GlowLayer>;
  150278. /**
  150279. * Enable or disable the chromaticAberration process from the pipeline
  150280. */
  150281. set chromaticAberrationEnabled(enabled: boolean);
  150282. get chromaticAberrationEnabled(): boolean;
  150283. /**
  150284. * Enable or disable the grain process from the pipeline
  150285. */
  150286. set grainEnabled(enabled: boolean);
  150287. get grainEnabled(): boolean;
  150288. /**
  150289. * @constructor
  150290. * @param name - The rendering pipeline name (default: "")
  150291. * @param hdr - If high dynamic range textures should be used (default: true)
  150292. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150293. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150294. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150295. */
  150296. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150297. /**
  150298. * Get the class name
  150299. * @returns "DefaultRenderingPipeline"
  150300. */
  150301. getClassName(): string;
  150302. /**
  150303. * Force the compilation of the entire pipeline.
  150304. */
  150305. prepare(): void;
  150306. private _hasCleared;
  150307. private _prevPostProcess;
  150308. private _prevPrevPostProcess;
  150309. private _setAutoClearAndTextureSharing;
  150310. private _depthOfFieldSceneObserver;
  150311. private _buildPipeline;
  150312. private _disposePostProcesses;
  150313. /**
  150314. * Adds a camera to the pipeline
  150315. * @param camera the camera to be added
  150316. */
  150317. addCamera(camera: Camera): void;
  150318. /**
  150319. * Removes a camera from the pipeline
  150320. * @param camera the camera to remove
  150321. */
  150322. removeCamera(camera: Camera): void;
  150323. /**
  150324. * Dispose of the pipeline and stop all post processes
  150325. */
  150326. dispose(): void;
  150327. /**
  150328. * Serialize the rendering pipeline (Used when exporting)
  150329. * @returns the serialized object
  150330. */
  150331. serialize(): any;
  150332. /**
  150333. * Parse the serialized pipeline
  150334. * @param source Source pipeline.
  150335. * @param scene The scene to load the pipeline to.
  150336. * @param rootUrl The URL of the serialized pipeline.
  150337. * @returns An instantiated pipeline from the serialized object.
  150338. */
  150339. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150340. }
  150341. }
  150342. declare module BABYLON {
  150343. /** @hidden */
  150344. export var lensHighlightsPixelShader: {
  150345. name: string;
  150346. shader: string;
  150347. };
  150348. }
  150349. declare module BABYLON {
  150350. /** @hidden */
  150351. export var depthOfFieldPixelShader: {
  150352. name: string;
  150353. shader: string;
  150354. };
  150355. }
  150356. declare module BABYLON {
  150357. /**
  150358. * BABYLON.JS Chromatic Aberration GLSL Shader
  150359. * Author: Olivier Guyot
  150360. * Separates very slightly R, G and B colors on the edges of the screen
  150361. * Inspired by Francois Tarlier & Martins Upitis
  150362. */
  150363. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150364. /**
  150365. * @ignore
  150366. * The chromatic aberration PostProcess id in the pipeline
  150367. */
  150368. LensChromaticAberrationEffect: string;
  150369. /**
  150370. * @ignore
  150371. * The highlights enhancing PostProcess id in the pipeline
  150372. */
  150373. HighlightsEnhancingEffect: string;
  150374. /**
  150375. * @ignore
  150376. * The depth-of-field PostProcess id in the pipeline
  150377. */
  150378. LensDepthOfFieldEffect: string;
  150379. private _scene;
  150380. private _depthTexture;
  150381. private _grainTexture;
  150382. private _chromaticAberrationPostProcess;
  150383. private _highlightsPostProcess;
  150384. private _depthOfFieldPostProcess;
  150385. private _edgeBlur;
  150386. private _grainAmount;
  150387. private _chromaticAberration;
  150388. private _distortion;
  150389. private _highlightsGain;
  150390. private _highlightsThreshold;
  150391. private _dofDistance;
  150392. private _dofAperture;
  150393. private _dofDarken;
  150394. private _dofPentagon;
  150395. private _blurNoise;
  150396. /**
  150397. * @constructor
  150398. *
  150399. * Effect parameters are as follow:
  150400. * {
  150401. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150402. * edge_blur: number; // from 0 to x (1 for realism)
  150403. * distortion: number; // from 0 to x (1 for realism)
  150404. * grain_amount: number; // from 0 to 1
  150405. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150406. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150407. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150408. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150409. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150410. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150411. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150412. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150413. * }
  150414. * Note: if an effect parameter is unset, effect is disabled
  150415. *
  150416. * @param name The rendering pipeline name
  150417. * @param parameters - An object containing all parameters (see above)
  150418. * @param scene The scene linked to this pipeline
  150419. * @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)
  150420. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150421. */
  150422. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150423. /**
  150424. * Get the class name
  150425. * @returns "LensRenderingPipeline"
  150426. */
  150427. getClassName(): string;
  150428. /**
  150429. * Gets associated scene
  150430. */
  150431. get scene(): Scene;
  150432. /**
  150433. * Gets or sets the edge blur
  150434. */
  150435. get edgeBlur(): number;
  150436. set edgeBlur(value: number);
  150437. /**
  150438. * Gets or sets the grain amount
  150439. */
  150440. get grainAmount(): number;
  150441. set grainAmount(value: number);
  150442. /**
  150443. * Gets or sets the chromatic aberration amount
  150444. */
  150445. get chromaticAberration(): number;
  150446. set chromaticAberration(value: number);
  150447. /**
  150448. * Gets or sets the depth of field aperture
  150449. */
  150450. get dofAperture(): number;
  150451. set dofAperture(value: number);
  150452. /**
  150453. * Gets or sets the edge distortion
  150454. */
  150455. get edgeDistortion(): number;
  150456. set edgeDistortion(value: number);
  150457. /**
  150458. * Gets or sets the depth of field distortion
  150459. */
  150460. get dofDistortion(): number;
  150461. set dofDistortion(value: number);
  150462. /**
  150463. * Gets or sets the darken out of focus amount
  150464. */
  150465. get darkenOutOfFocus(): number;
  150466. set darkenOutOfFocus(value: number);
  150467. /**
  150468. * Gets or sets a boolean indicating if blur noise is enabled
  150469. */
  150470. get blurNoise(): boolean;
  150471. set blurNoise(value: boolean);
  150472. /**
  150473. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  150474. */
  150475. get pentagonBokeh(): boolean;
  150476. set pentagonBokeh(value: boolean);
  150477. /**
  150478. * Gets or sets the highlight grain amount
  150479. */
  150480. get highlightsGain(): number;
  150481. set highlightsGain(value: number);
  150482. /**
  150483. * Gets or sets the highlight threshold
  150484. */
  150485. get highlightsThreshold(): number;
  150486. set highlightsThreshold(value: number);
  150487. /**
  150488. * Sets the amount of blur at the edges
  150489. * @param amount blur amount
  150490. */
  150491. setEdgeBlur(amount: number): void;
  150492. /**
  150493. * Sets edge blur to 0
  150494. */
  150495. disableEdgeBlur(): void;
  150496. /**
  150497. * Sets the amout of grain
  150498. * @param amount Amount of grain
  150499. */
  150500. setGrainAmount(amount: number): void;
  150501. /**
  150502. * Set grain amount to 0
  150503. */
  150504. disableGrain(): void;
  150505. /**
  150506. * Sets the chromatic aberration amount
  150507. * @param amount amount of chromatic aberration
  150508. */
  150509. setChromaticAberration(amount: number): void;
  150510. /**
  150511. * Sets chromatic aberration amount to 0
  150512. */
  150513. disableChromaticAberration(): void;
  150514. /**
  150515. * Sets the EdgeDistortion amount
  150516. * @param amount amount of EdgeDistortion
  150517. */
  150518. setEdgeDistortion(amount: number): void;
  150519. /**
  150520. * Sets edge distortion to 0
  150521. */
  150522. disableEdgeDistortion(): void;
  150523. /**
  150524. * Sets the FocusDistance amount
  150525. * @param amount amount of FocusDistance
  150526. */
  150527. setFocusDistance(amount: number): void;
  150528. /**
  150529. * Disables depth of field
  150530. */
  150531. disableDepthOfField(): void;
  150532. /**
  150533. * Sets the Aperture amount
  150534. * @param amount amount of Aperture
  150535. */
  150536. setAperture(amount: number): void;
  150537. /**
  150538. * Sets the DarkenOutOfFocus amount
  150539. * @param amount amount of DarkenOutOfFocus
  150540. */
  150541. setDarkenOutOfFocus(amount: number): void;
  150542. private _pentagonBokehIsEnabled;
  150543. /**
  150544. * Creates a pentagon bokeh effect
  150545. */
  150546. enablePentagonBokeh(): void;
  150547. /**
  150548. * Disables the pentagon bokeh effect
  150549. */
  150550. disablePentagonBokeh(): void;
  150551. /**
  150552. * Enables noise blur
  150553. */
  150554. enableNoiseBlur(): void;
  150555. /**
  150556. * Disables noise blur
  150557. */
  150558. disableNoiseBlur(): void;
  150559. /**
  150560. * Sets the HighlightsGain amount
  150561. * @param amount amount of HighlightsGain
  150562. */
  150563. setHighlightsGain(amount: number): void;
  150564. /**
  150565. * Sets the HighlightsThreshold amount
  150566. * @param amount amount of HighlightsThreshold
  150567. */
  150568. setHighlightsThreshold(amount: number): void;
  150569. /**
  150570. * Disables highlights
  150571. */
  150572. disableHighlights(): void;
  150573. /**
  150574. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  150575. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  150576. */
  150577. dispose(disableDepthRender?: boolean): void;
  150578. private _createChromaticAberrationPostProcess;
  150579. private _createHighlightsPostProcess;
  150580. private _createDepthOfFieldPostProcess;
  150581. private _createGrainTexture;
  150582. }
  150583. }
  150584. declare module BABYLON {
  150585. /** @hidden */
  150586. export var ssao2PixelShader: {
  150587. name: string;
  150588. shader: string;
  150589. };
  150590. }
  150591. declare module BABYLON {
  150592. /** @hidden */
  150593. export var ssaoCombinePixelShader: {
  150594. name: string;
  150595. shader: string;
  150596. };
  150597. }
  150598. declare module BABYLON {
  150599. /**
  150600. * Render pipeline to produce ssao effect
  150601. */
  150602. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  150603. /**
  150604. * @ignore
  150605. * The PassPostProcess id in the pipeline that contains the original scene color
  150606. */
  150607. SSAOOriginalSceneColorEffect: string;
  150608. /**
  150609. * @ignore
  150610. * The SSAO PostProcess id in the pipeline
  150611. */
  150612. SSAORenderEffect: string;
  150613. /**
  150614. * @ignore
  150615. * The horizontal blur PostProcess id in the pipeline
  150616. */
  150617. SSAOBlurHRenderEffect: string;
  150618. /**
  150619. * @ignore
  150620. * The vertical blur PostProcess id in the pipeline
  150621. */
  150622. SSAOBlurVRenderEffect: string;
  150623. /**
  150624. * @ignore
  150625. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150626. */
  150627. SSAOCombineRenderEffect: string;
  150628. /**
  150629. * The output strength of the SSAO post-process. Default value is 1.0.
  150630. */
  150631. totalStrength: number;
  150632. /**
  150633. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  150634. */
  150635. maxZ: number;
  150636. /**
  150637. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  150638. */
  150639. minZAspect: number;
  150640. private _samples;
  150641. /**
  150642. * Number of samples used for the SSAO calculations. Default value is 8
  150643. */
  150644. set samples(n: number);
  150645. get samples(): number;
  150646. private _textureSamples;
  150647. /**
  150648. * Number of samples to use for antialiasing
  150649. */
  150650. set textureSamples(n: number);
  150651. get textureSamples(): number;
  150652. /**
  150653. * Force rendering the geometry through geometry buffer
  150654. */
  150655. private _forceGeometryBuffer;
  150656. /**
  150657. * Ratio object used for SSAO ratio and blur ratio
  150658. */
  150659. private _ratio;
  150660. /**
  150661. * Dynamically generated sphere sampler.
  150662. */
  150663. private _sampleSphere;
  150664. /**
  150665. * Blur filter offsets
  150666. */
  150667. private _samplerOffsets;
  150668. private _expensiveBlur;
  150669. /**
  150670. * If bilateral blur should be used
  150671. */
  150672. set expensiveBlur(b: boolean);
  150673. get expensiveBlur(): boolean;
  150674. /**
  150675. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  150676. */
  150677. radius: number;
  150678. /**
  150679. * The base color of the SSAO post-process
  150680. * The final result is "base + ssao" between [0, 1]
  150681. */
  150682. base: number;
  150683. /**
  150684. * Support test.
  150685. */
  150686. static get IsSupported(): boolean;
  150687. private _scene;
  150688. private _randomTexture;
  150689. private _originalColorPostProcess;
  150690. private _ssaoPostProcess;
  150691. private _blurHPostProcess;
  150692. private _blurVPostProcess;
  150693. private _ssaoCombinePostProcess;
  150694. private _prePassRenderer;
  150695. /**
  150696. * Gets active scene
  150697. */
  150698. get scene(): Scene;
  150699. /**
  150700. * @constructor
  150701. * @param name The rendering pipeline name
  150702. * @param scene The scene linked to this pipeline
  150703. * @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 }
  150704. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150705. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  150706. */
  150707. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  150708. /**
  150709. * Get the class name
  150710. * @returns "SSAO2RenderingPipeline"
  150711. */
  150712. getClassName(): string;
  150713. /**
  150714. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150715. */
  150716. dispose(disableGeometryBufferRenderer?: boolean): void;
  150717. private _createBlurPostProcess;
  150718. /** @hidden */
  150719. _rebuild(): void;
  150720. private _bits;
  150721. private _radicalInverse_VdC;
  150722. private _hammersley;
  150723. private _hemisphereSample_uniform;
  150724. private _generateHemisphere;
  150725. private _getDefinesForSSAO;
  150726. private _createSSAOPostProcess;
  150727. private _createSSAOCombinePostProcess;
  150728. private _createRandomTexture;
  150729. /**
  150730. * Serialize the rendering pipeline (Used when exporting)
  150731. * @returns the serialized object
  150732. */
  150733. serialize(): any;
  150734. /**
  150735. * Parse the serialized pipeline
  150736. * @param source Source pipeline.
  150737. * @param scene The scene to load the pipeline to.
  150738. * @param rootUrl The URL of the serialized pipeline.
  150739. * @returns An instantiated pipeline from the serialized object.
  150740. */
  150741. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150742. /**
  150743. * Sets the required values to the prepass renderer.
  150744. * @param prePassRenderer defines the prepass renderer to setup
  150745. * @returns true if the pre pass is needed.
  150746. */
  150747. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150748. }
  150749. }
  150750. declare module BABYLON {
  150751. /** @hidden */
  150752. export var ssaoPixelShader: {
  150753. name: string;
  150754. shader: string;
  150755. };
  150756. }
  150757. declare module BABYLON {
  150758. /**
  150759. * Render pipeline to produce ssao effect
  150760. */
  150761. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150762. /**
  150763. * @ignore
  150764. * The PassPostProcess id in the pipeline that contains the original scene color
  150765. */
  150766. SSAOOriginalSceneColorEffect: string;
  150767. /**
  150768. * @ignore
  150769. * The SSAO PostProcess id in the pipeline
  150770. */
  150771. SSAORenderEffect: string;
  150772. /**
  150773. * @ignore
  150774. * The horizontal blur PostProcess id in the pipeline
  150775. */
  150776. SSAOBlurHRenderEffect: string;
  150777. /**
  150778. * @ignore
  150779. * The vertical blur PostProcess id in the pipeline
  150780. */
  150781. SSAOBlurVRenderEffect: string;
  150782. /**
  150783. * @ignore
  150784. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150785. */
  150786. SSAOCombineRenderEffect: string;
  150787. /**
  150788. * The output strength of the SSAO post-process. Default value is 1.0.
  150789. */
  150790. totalStrength: number;
  150791. /**
  150792. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  150793. */
  150794. radius: number;
  150795. /**
  150796. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  150797. * Must not be equal to fallOff and superior to fallOff.
  150798. * Default value is 0.0075
  150799. */
  150800. area: number;
  150801. /**
  150802. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  150803. * Must not be equal to area and inferior to area.
  150804. * Default value is 0.000001
  150805. */
  150806. fallOff: number;
  150807. /**
  150808. * The base color of the SSAO post-process
  150809. * The final result is "base + ssao" between [0, 1]
  150810. */
  150811. base: number;
  150812. private _scene;
  150813. private _depthTexture;
  150814. private _randomTexture;
  150815. private _originalColorPostProcess;
  150816. private _ssaoPostProcess;
  150817. private _blurHPostProcess;
  150818. private _blurVPostProcess;
  150819. private _ssaoCombinePostProcess;
  150820. private _firstUpdate;
  150821. /**
  150822. * Gets active scene
  150823. */
  150824. get scene(): Scene;
  150825. /**
  150826. * @constructor
  150827. * @param name - The rendering pipeline name
  150828. * @param scene - The scene linked to this pipeline
  150829. * @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 }
  150830. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  150831. */
  150832. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  150833. /**
  150834. * Get the class name
  150835. * @returns "SSAORenderingPipeline"
  150836. */
  150837. getClassName(): string;
  150838. /**
  150839. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150840. */
  150841. dispose(disableDepthRender?: boolean): void;
  150842. private _createBlurPostProcess;
  150843. /** @hidden */
  150844. _rebuild(): void;
  150845. private _createSSAOPostProcess;
  150846. private _createSSAOCombinePostProcess;
  150847. private _createRandomTexture;
  150848. }
  150849. }
  150850. declare module BABYLON {
  150851. /** @hidden */
  150852. export var screenSpaceReflectionPixelShader: {
  150853. name: string;
  150854. shader: string;
  150855. };
  150856. }
  150857. declare module BABYLON {
  150858. /**
  150859. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  150860. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  150861. */
  150862. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  150863. /**
  150864. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  150865. */
  150866. threshold: number;
  150867. /**
  150868. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  150869. */
  150870. strength: number;
  150871. /**
  150872. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  150873. */
  150874. reflectionSpecularFalloffExponent: number;
  150875. /**
  150876. * 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]
  150877. */
  150878. step: number;
  150879. /**
  150880. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  150881. */
  150882. roughnessFactor: number;
  150883. private _geometryBufferRenderer;
  150884. private _enableSmoothReflections;
  150885. private _reflectionSamples;
  150886. private _smoothSteps;
  150887. /**
  150888. * Gets a string identifying the name of the class
  150889. * @returns "ScreenSpaceReflectionPostProcess" string
  150890. */
  150891. getClassName(): string;
  150892. /**
  150893. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  150894. * @param name The name of the effect.
  150895. * @param scene The scene containing the objects to calculate reflections.
  150896. * @param options The required width/height ratio to downsize to before computing the render pass.
  150897. * @param camera The camera to apply the render pass to.
  150898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150899. * @param engine The engine which the post process will be applied. (default: current engine)
  150900. * @param reusable If the post process can be reused on the same frame. (default: false)
  150901. * @param textureType Type of textures used when performing the post process. (default: 0)
  150902. * @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)
  150903. */
  150904. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150905. /**
  150906. * Gets wether or not smoothing reflections is enabled.
  150907. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150908. */
  150909. get enableSmoothReflections(): boolean;
  150910. /**
  150911. * Sets wether or not smoothing reflections is enabled.
  150912. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150913. */
  150914. set enableSmoothReflections(enabled: boolean);
  150915. /**
  150916. * Gets the number of samples taken while computing reflections. More samples count is high,
  150917. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150918. */
  150919. get reflectionSamples(): number;
  150920. /**
  150921. * Sets the number of samples taken while computing reflections. More samples count is high,
  150922. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150923. */
  150924. set reflectionSamples(samples: number);
  150925. /**
  150926. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  150927. * more the post-process will require GPU power and can generate a drop in FPS.
  150928. * Default value (5.0) work pretty well in all cases but can be adjusted.
  150929. */
  150930. get smoothSteps(): number;
  150931. set smoothSteps(steps: number);
  150932. private _updateEffectDefines;
  150933. /** @hidden */
  150934. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  150935. }
  150936. }
  150937. declare module BABYLON {
  150938. /** @hidden */
  150939. export var standardPixelShader: {
  150940. name: string;
  150941. shader: string;
  150942. };
  150943. }
  150944. declare module BABYLON {
  150945. /**
  150946. * Standard rendering pipeline
  150947. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150948. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  150949. */
  150950. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150951. /**
  150952. * Public members
  150953. */
  150954. /**
  150955. * Post-process which contains the original scene color before the pipeline applies all the effects
  150956. */
  150957. originalPostProcess: Nullable<PostProcess>;
  150958. /**
  150959. * Post-process used to down scale an image x4
  150960. */
  150961. downSampleX4PostProcess: Nullable<PostProcess>;
  150962. /**
  150963. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  150964. */
  150965. brightPassPostProcess: Nullable<PostProcess>;
  150966. /**
  150967. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  150968. */
  150969. blurHPostProcesses: PostProcess[];
  150970. /**
  150971. * Post-process array storing all the vertical blur post-processes used by the pipeline
  150972. */
  150973. blurVPostProcesses: PostProcess[];
  150974. /**
  150975. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  150976. */
  150977. textureAdderPostProcess: Nullable<PostProcess>;
  150978. /**
  150979. * Post-process used to create volumetric lighting effect
  150980. */
  150981. volumetricLightPostProcess: Nullable<PostProcess>;
  150982. /**
  150983. * Post-process used to smooth the previous volumetric light post-process on the X axis
  150984. */
  150985. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  150986. /**
  150987. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  150988. */
  150989. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  150990. /**
  150991. * Post-process used to merge the volumetric light effect and the real scene color
  150992. */
  150993. volumetricLightMergePostProces: Nullable<PostProcess>;
  150994. /**
  150995. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  150996. */
  150997. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  150998. /**
  150999. * Base post-process used to calculate the average luminance of the final image for HDR
  151000. */
  151001. luminancePostProcess: Nullable<PostProcess>;
  151002. /**
  151003. * Post-processes used to create down sample post-processes in order to get
  151004. * the average luminance of the final image for HDR
  151005. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151006. */
  151007. luminanceDownSamplePostProcesses: PostProcess[];
  151008. /**
  151009. * Post-process used to create a HDR effect (light adaptation)
  151010. */
  151011. hdrPostProcess: Nullable<PostProcess>;
  151012. /**
  151013. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151014. */
  151015. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151016. /**
  151017. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151018. */
  151019. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151020. /**
  151021. * Post-process used to merge the final HDR post-process and the real scene color
  151022. */
  151023. hdrFinalPostProcess: Nullable<PostProcess>;
  151024. /**
  151025. * Post-process used to create a lens flare effect
  151026. */
  151027. lensFlarePostProcess: Nullable<PostProcess>;
  151028. /**
  151029. * Post-process that merges the result of the lens flare post-process and the real scene color
  151030. */
  151031. lensFlareComposePostProcess: Nullable<PostProcess>;
  151032. /**
  151033. * Post-process used to create a motion blur effect
  151034. */
  151035. motionBlurPostProcess: Nullable<PostProcess>;
  151036. /**
  151037. * Post-process used to create a depth of field effect
  151038. */
  151039. depthOfFieldPostProcess: Nullable<PostProcess>;
  151040. /**
  151041. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151042. */
  151043. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151044. /**
  151045. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151046. */
  151047. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151048. /**
  151049. * Represents the brightness threshold in order to configure the illuminated surfaces
  151050. */
  151051. brightThreshold: number;
  151052. /**
  151053. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151054. */
  151055. blurWidth: number;
  151056. /**
  151057. * Sets if the blur for highlighted surfaces must be only horizontal
  151058. */
  151059. horizontalBlur: boolean;
  151060. /**
  151061. * Gets the overall exposure used by the pipeline
  151062. */
  151063. get exposure(): number;
  151064. /**
  151065. * Sets the overall exposure used by the pipeline
  151066. */
  151067. set exposure(value: number);
  151068. /**
  151069. * Texture used typically to simulate "dirty" on camera lens
  151070. */
  151071. lensTexture: Nullable<Texture>;
  151072. /**
  151073. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151074. */
  151075. volumetricLightCoefficient: number;
  151076. /**
  151077. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151078. */
  151079. volumetricLightPower: number;
  151080. /**
  151081. * Used the set the blur intensity to smooth the volumetric lights
  151082. */
  151083. volumetricLightBlurScale: number;
  151084. /**
  151085. * Light (spot or directional) used to generate the volumetric lights rays
  151086. * The source light must have a shadow generate so the pipeline can get its
  151087. * depth map
  151088. */
  151089. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151090. /**
  151091. * For eye adaptation, represents the minimum luminance the eye can see
  151092. */
  151093. hdrMinimumLuminance: number;
  151094. /**
  151095. * For eye adaptation, represents the decrease luminance speed
  151096. */
  151097. hdrDecreaseRate: number;
  151098. /**
  151099. * For eye adaptation, represents the increase luminance speed
  151100. */
  151101. hdrIncreaseRate: number;
  151102. /**
  151103. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151104. */
  151105. get hdrAutoExposure(): boolean;
  151106. /**
  151107. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151108. */
  151109. set hdrAutoExposure(value: boolean);
  151110. /**
  151111. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151112. */
  151113. lensColorTexture: Nullable<Texture>;
  151114. /**
  151115. * The overall strengh for the lens flare effect
  151116. */
  151117. lensFlareStrength: number;
  151118. /**
  151119. * Dispersion coefficient for lens flare ghosts
  151120. */
  151121. lensFlareGhostDispersal: number;
  151122. /**
  151123. * Main lens flare halo width
  151124. */
  151125. lensFlareHaloWidth: number;
  151126. /**
  151127. * Based on the lens distortion effect, defines how much the lens flare result
  151128. * is distorted
  151129. */
  151130. lensFlareDistortionStrength: number;
  151131. /**
  151132. * Configures the blur intensity used for for lens flare (halo)
  151133. */
  151134. lensFlareBlurWidth: number;
  151135. /**
  151136. * Lens star texture must be used to simulate rays on the flares and is available
  151137. * in the documentation
  151138. */
  151139. lensStarTexture: Nullable<Texture>;
  151140. /**
  151141. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151142. * flare effect by taking account of the dirt texture
  151143. */
  151144. lensFlareDirtTexture: Nullable<Texture>;
  151145. /**
  151146. * Represents the focal length for the depth of field effect
  151147. */
  151148. depthOfFieldDistance: number;
  151149. /**
  151150. * Represents the blur intensity for the blurred part of the depth of field effect
  151151. */
  151152. depthOfFieldBlurWidth: number;
  151153. /**
  151154. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151155. */
  151156. get motionStrength(): number;
  151157. /**
  151158. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151159. */
  151160. set motionStrength(strength: number);
  151161. /**
  151162. * Gets wether or not the motion blur post-process is object based or screen based.
  151163. */
  151164. get objectBasedMotionBlur(): boolean;
  151165. /**
  151166. * Sets wether or not the motion blur post-process should be object based or screen based
  151167. */
  151168. set objectBasedMotionBlur(value: boolean);
  151169. /**
  151170. * List of animations for the pipeline (IAnimatable implementation)
  151171. */
  151172. animations: Animation[];
  151173. /**
  151174. * Private members
  151175. */
  151176. private _scene;
  151177. private _currentDepthOfFieldSource;
  151178. private _basePostProcess;
  151179. private _fixedExposure;
  151180. private _currentExposure;
  151181. private _hdrAutoExposure;
  151182. private _hdrCurrentLuminance;
  151183. private _motionStrength;
  151184. private _isObjectBasedMotionBlur;
  151185. private _floatTextureType;
  151186. private _camerasToBeAttached;
  151187. private _ratio;
  151188. private _bloomEnabled;
  151189. private _depthOfFieldEnabled;
  151190. private _vlsEnabled;
  151191. private _lensFlareEnabled;
  151192. private _hdrEnabled;
  151193. private _motionBlurEnabled;
  151194. private _fxaaEnabled;
  151195. private _screenSpaceReflectionsEnabled;
  151196. private _motionBlurSamples;
  151197. private _volumetricLightStepsCount;
  151198. private _samples;
  151199. /**
  151200. * @ignore
  151201. * Specifies if the bloom pipeline is enabled
  151202. */
  151203. get BloomEnabled(): boolean;
  151204. set BloomEnabled(enabled: boolean);
  151205. /**
  151206. * @ignore
  151207. * Specifies if the depth of field pipeline is enabed
  151208. */
  151209. get DepthOfFieldEnabled(): boolean;
  151210. set DepthOfFieldEnabled(enabled: boolean);
  151211. /**
  151212. * @ignore
  151213. * Specifies if the lens flare pipeline is enabed
  151214. */
  151215. get LensFlareEnabled(): boolean;
  151216. set LensFlareEnabled(enabled: boolean);
  151217. /**
  151218. * @ignore
  151219. * Specifies if the HDR pipeline is enabled
  151220. */
  151221. get HDREnabled(): boolean;
  151222. set HDREnabled(enabled: boolean);
  151223. /**
  151224. * @ignore
  151225. * Specifies if the volumetric lights scattering effect is enabled
  151226. */
  151227. get VLSEnabled(): boolean;
  151228. set VLSEnabled(enabled: boolean);
  151229. /**
  151230. * @ignore
  151231. * Specifies if the motion blur effect is enabled
  151232. */
  151233. get MotionBlurEnabled(): boolean;
  151234. set MotionBlurEnabled(enabled: boolean);
  151235. /**
  151236. * Specifies if anti-aliasing is enabled
  151237. */
  151238. get fxaaEnabled(): boolean;
  151239. set fxaaEnabled(enabled: boolean);
  151240. /**
  151241. * Specifies if screen space reflections are enabled.
  151242. */
  151243. get screenSpaceReflectionsEnabled(): boolean;
  151244. set screenSpaceReflectionsEnabled(enabled: boolean);
  151245. /**
  151246. * Specifies the number of steps used to calculate the volumetric lights
  151247. * Typically in interval [50, 200]
  151248. */
  151249. get volumetricLightStepsCount(): number;
  151250. set volumetricLightStepsCount(count: number);
  151251. /**
  151252. * Specifies the number of samples used for the motion blur effect
  151253. * Typically in interval [16, 64]
  151254. */
  151255. get motionBlurSamples(): number;
  151256. set motionBlurSamples(samples: number);
  151257. /**
  151258. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151259. */
  151260. get samples(): number;
  151261. set samples(sampleCount: number);
  151262. /**
  151263. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151264. * @constructor
  151265. * @param name The rendering pipeline name
  151266. * @param scene The scene linked to this pipeline
  151267. * @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)
  151268. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151269. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151270. */
  151271. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151272. private _buildPipeline;
  151273. private _createDownSampleX4PostProcess;
  151274. private _createBrightPassPostProcess;
  151275. private _createBlurPostProcesses;
  151276. private _createTextureAdderPostProcess;
  151277. private _createVolumetricLightPostProcess;
  151278. private _createLuminancePostProcesses;
  151279. private _createHdrPostProcess;
  151280. private _createLensFlarePostProcess;
  151281. private _createDepthOfFieldPostProcess;
  151282. private _createMotionBlurPostProcess;
  151283. private _getDepthTexture;
  151284. private _disposePostProcesses;
  151285. /**
  151286. * Dispose of the pipeline and stop all post processes
  151287. */
  151288. dispose(): void;
  151289. /**
  151290. * Serialize the rendering pipeline (Used when exporting)
  151291. * @returns the serialized object
  151292. */
  151293. serialize(): any;
  151294. /**
  151295. * Parse the serialized pipeline
  151296. * @param source Source pipeline.
  151297. * @param scene The scene to load the pipeline to.
  151298. * @param rootUrl The URL of the serialized pipeline.
  151299. * @returns An instantiated pipeline from the serialized object.
  151300. */
  151301. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151302. /**
  151303. * Luminance steps
  151304. */
  151305. static LuminanceSteps: number;
  151306. }
  151307. }
  151308. declare module BABYLON {
  151309. /** @hidden */
  151310. export var stereoscopicInterlacePixelShader: {
  151311. name: string;
  151312. shader: string;
  151313. };
  151314. }
  151315. declare module BABYLON {
  151316. /**
  151317. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151318. */
  151319. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151320. private _stepSize;
  151321. private _passedProcess;
  151322. /**
  151323. * Gets a string identifying the name of the class
  151324. * @returns "StereoscopicInterlacePostProcessI" string
  151325. */
  151326. getClassName(): string;
  151327. /**
  151328. * Initializes a StereoscopicInterlacePostProcessI
  151329. * @param name The name of the effect.
  151330. * @param rigCameras The rig cameras to be appled to the post process
  151331. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151332. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151334. * @param engine The engine which the post process will be applied. (default: current engine)
  151335. * @param reusable If the post process can be reused on the same frame. (default: false)
  151336. */
  151337. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151338. }
  151339. /**
  151340. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151341. */
  151342. export class StereoscopicInterlacePostProcess extends PostProcess {
  151343. private _stepSize;
  151344. private _passedProcess;
  151345. /**
  151346. * Gets a string identifying the name of the class
  151347. * @returns "StereoscopicInterlacePostProcess" string
  151348. */
  151349. getClassName(): string;
  151350. /**
  151351. * Initializes a StereoscopicInterlacePostProcess
  151352. * @param name The name of the effect.
  151353. * @param rigCameras The rig cameras to be appled to the post process
  151354. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151356. * @param engine The engine which the post process will be applied. (default: current engine)
  151357. * @param reusable If the post process can be reused on the same frame. (default: false)
  151358. */
  151359. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151360. }
  151361. }
  151362. declare module BABYLON {
  151363. /** @hidden */
  151364. export var tonemapPixelShader: {
  151365. name: string;
  151366. shader: string;
  151367. };
  151368. }
  151369. declare module BABYLON {
  151370. /** Defines operator used for tonemapping */
  151371. export enum TonemappingOperator {
  151372. /** Hable */
  151373. Hable = 0,
  151374. /** Reinhard */
  151375. Reinhard = 1,
  151376. /** HejiDawson */
  151377. HejiDawson = 2,
  151378. /** Photographic */
  151379. Photographic = 3
  151380. }
  151381. /**
  151382. * Defines a post process to apply tone mapping
  151383. */
  151384. export class TonemapPostProcess extends PostProcess {
  151385. private _operator;
  151386. /** Defines the required exposure adjustement */
  151387. exposureAdjustment: number;
  151388. /**
  151389. * Gets a string identifying the name of the class
  151390. * @returns "TonemapPostProcess" string
  151391. */
  151392. getClassName(): string;
  151393. /**
  151394. * Creates a new TonemapPostProcess
  151395. * @param name defines the name of the postprocess
  151396. * @param _operator defines the operator to use
  151397. * @param exposureAdjustment defines the required exposure adjustement
  151398. * @param camera defines the camera to use (can be null)
  151399. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  151400. * @param engine defines the hosting engine (can be ignore if camera is set)
  151401. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151402. */
  151403. constructor(name: string, _operator: TonemappingOperator,
  151404. /** Defines the required exposure adjustement */
  151405. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  151406. }
  151407. }
  151408. declare module BABYLON {
  151409. /** @hidden */
  151410. export var volumetricLightScatteringPixelShader: {
  151411. name: string;
  151412. shader: string;
  151413. };
  151414. }
  151415. declare module BABYLON {
  151416. /** @hidden */
  151417. export var volumetricLightScatteringPassVertexShader: {
  151418. name: string;
  151419. shader: string;
  151420. };
  151421. }
  151422. declare module BABYLON {
  151423. /** @hidden */
  151424. export var volumetricLightScatteringPassPixelShader: {
  151425. name: string;
  151426. shader: string;
  151427. };
  151428. }
  151429. declare module BABYLON {
  151430. /**
  151431. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  151432. */
  151433. export class VolumetricLightScatteringPostProcess extends PostProcess {
  151434. private _volumetricLightScatteringPass;
  151435. private _volumetricLightScatteringRTT;
  151436. private _viewPort;
  151437. private _screenCoordinates;
  151438. private _cachedDefines;
  151439. /**
  151440. * If not undefined, the mesh position is computed from the attached node position
  151441. */
  151442. attachedNode: {
  151443. position: Vector3;
  151444. };
  151445. /**
  151446. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  151447. */
  151448. customMeshPosition: Vector3;
  151449. /**
  151450. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  151451. */
  151452. useCustomMeshPosition: boolean;
  151453. /**
  151454. * If the post-process should inverse the light scattering direction
  151455. */
  151456. invert: boolean;
  151457. /**
  151458. * The internal mesh used by the post-process
  151459. */
  151460. mesh: Mesh;
  151461. /**
  151462. * @hidden
  151463. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  151464. */
  151465. get useDiffuseColor(): boolean;
  151466. set useDiffuseColor(useDiffuseColor: boolean);
  151467. /**
  151468. * Array containing the excluded meshes not rendered in the internal pass
  151469. */
  151470. excludedMeshes: AbstractMesh[];
  151471. /**
  151472. * Controls the overall intensity of the post-process
  151473. */
  151474. exposure: number;
  151475. /**
  151476. * Dissipates each sample's contribution in range [0, 1]
  151477. */
  151478. decay: number;
  151479. /**
  151480. * Controls the overall intensity of each sample
  151481. */
  151482. weight: number;
  151483. /**
  151484. * Controls the density of each sample
  151485. */
  151486. density: number;
  151487. /**
  151488. * @constructor
  151489. * @param name The post-process name
  151490. * @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)
  151491. * @param camera The camera that the post-process will be attached to
  151492. * @param mesh The mesh used to create the light scattering
  151493. * @param samples The post-process quality, default 100
  151494. * @param samplingModeThe post-process filtering mode
  151495. * @param engine The babylon engine
  151496. * @param reusable If the post-process is reusable
  151497. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  151498. */
  151499. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  151500. /**
  151501. * Returns the string "VolumetricLightScatteringPostProcess"
  151502. * @returns "VolumetricLightScatteringPostProcess"
  151503. */
  151504. getClassName(): string;
  151505. private _isReady;
  151506. /**
  151507. * Sets the new light position for light scattering effect
  151508. * @param position The new custom light position
  151509. */
  151510. setCustomMeshPosition(position: Vector3): void;
  151511. /**
  151512. * Returns the light position for light scattering effect
  151513. * @return Vector3 The custom light position
  151514. */
  151515. getCustomMeshPosition(): Vector3;
  151516. /**
  151517. * Disposes the internal assets and detaches the post-process from the camera
  151518. */
  151519. dispose(camera: Camera): void;
  151520. /**
  151521. * Returns the render target texture used by the post-process
  151522. * @return the render target texture used by the post-process
  151523. */
  151524. getPass(): RenderTargetTexture;
  151525. private _meshExcluded;
  151526. private _createPass;
  151527. private _updateMeshScreenCoordinates;
  151528. /**
  151529. * Creates a default mesh for the Volumeric Light Scattering post-process
  151530. * @param name The mesh name
  151531. * @param scene The scene where to create the mesh
  151532. * @return the default mesh
  151533. */
  151534. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  151535. }
  151536. }
  151537. declare module BABYLON {
  151538. /** @hidden */
  151539. export var screenSpaceCurvaturePixelShader: {
  151540. name: string;
  151541. shader: string;
  151542. };
  151543. }
  151544. declare module BABYLON {
  151545. /**
  151546. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  151547. */
  151548. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  151549. /**
  151550. * Defines how much ridge the curvature effect displays.
  151551. */
  151552. ridge: number;
  151553. /**
  151554. * Defines how much valley the curvature effect displays.
  151555. */
  151556. valley: number;
  151557. private _geometryBufferRenderer;
  151558. /**
  151559. * Gets a string identifying the name of the class
  151560. * @returns "ScreenSpaceCurvaturePostProcess" string
  151561. */
  151562. getClassName(): string;
  151563. /**
  151564. * Creates a new instance ScreenSpaceCurvaturePostProcess
  151565. * @param name The name of the effect.
  151566. * @param scene The scene containing the objects to blur according to their velocity.
  151567. * @param options The required width/height ratio to downsize to before computing the render pass.
  151568. * @param camera The camera to apply the render pass to.
  151569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151570. * @param engine The engine which the post process will be applied. (default: current engine)
  151571. * @param reusable If the post process can be reused on the same frame. (default: false)
  151572. * @param textureType Type of textures used when performing the post process. (default: 0)
  151573. * @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)
  151574. */
  151575. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151576. /**
  151577. * Support test.
  151578. */
  151579. static get IsSupported(): boolean;
  151580. /** @hidden */
  151581. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  151582. }
  151583. }
  151584. declare module BABYLON {
  151585. interface Scene {
  151586. /** @hidden (Backing field) */
  151587. _boundingBoxRenderer: BoundingBoxRenderer;
  151588. /** @hidden (Backing field) */
  151589. _forceShowBoundingBoxes: boolean;
  151590. /**
  151591. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  151592. */
  151593. forceShowBoundingBoxes: boolean;
  151594. /**
  151595. * Gets the bounding box renderer associated with the scene
  151596. * @returns a BoundingBoxRenderer
  151597. */
  151598. getBoundingBoxRenderer(): BoundingBoxRenderer;
  151599. }
  151600. interface AbstractMesh {
  151601. /** @hidden (Backing field) */
  151602. _showBoundingBox: boolean;
  151603. /**
  151604. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  151605. */
  151606. showBoundingBox: boolean;
  151607. }
  151608. /**
  151609. * Component responsible of rendering the bounding box of the meshes in a scene.
  151610. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  151611. */
  151612. export class BoundingBoxRenderer implements ISceneComponent {
  151613. /**
  151614. * The component name helpfull to identify the component in the list of scene components.
  151615. */
  151616. readonly name: string;
  151617. /**
  151618. * The scene the component belongs to.
  151619. */
  151620. scene: Scene;
  151621. /**
  151622. * Color of the bounding box lines placed in front of an object
  151623. */
  151624. frontColor: Color3;
  151625. /**
  151626. * Color of the bounding box lines placed behind an object
  151627. */
  151628. backColor: Color3;
  151629. /**
  151630. * Defines if the renderer should show the back lines or not
  151631. */
  151632. showBackLines: boolean;
  151633. /**
  151634. * Observable raised before rendering a bounding box
  151635. */
  151636. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  151637. /**
  151638. * Observable raised after rendering a bounding box
  151639. */
  151640. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  151641. /**
  151642. * @hidden
  151643. */
  151644. renderList: SmartArray<BoundingBox>;
  151645. private _colorShader;
  151646. private _vertexBuffers;
  151647. private _indexBuffer;
  151648. private _fillIndexBuffer;
  151649. private _fillIndexData;
  151650. /**
  151651. * Instantiates a new bounding box renderer in a scene.
  151652. * @param scene the scene the renderer renders in
  151653. */
  151654. constructor(scene: Scene);
  151655. /**
  151656. * Registers the component in a given scene
  151657. */
  151658. register(): void;
  151659. private _evaluateSubMesh;
  151660. private _activeMesh;
  151661. private _prepareRessources;
  151662. private _createIndexBuffer;
  151663. /**
  151664. * Rebuilds the elements related to this component in case of
  151665. * context lost for instance.
  151666. */
  151667. rebuild(): void;
  151668. /**
  151669. * @hidden
  151670. */
  151671. reset(): void;
  151672. /**
  151673. * Render the bounding boxes of a specific rendering group
  151674. * @param renderingGroupId defines the rendering group to render
  151675. */
  151676. render(renderingGroupId: number): void;
  151677. /**
  151678. * In case of occlusion queries, we can render the occlusion bounding box through this method
  151679. * @param mesh Define the mesh to render the occlusion bounding box for
  151680. */
  151681. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  151682. /**
  151683. * Dispose and release the resources attached to this renderer.
  151684. */
  151685. dispose(): void;
  151686. }
  151687. }
  151688. declare module BABYLON {
  151689. interface Scene {
  151690. /** @hidden (Backing field) */
  151691. _depthRenderer: {
  151692. [id: string]: DepthRenderer;
  151693. };
  151694. /**
  151695. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  151696. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  151697. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  151698. * @returns the created depth renderer
  151699. */
  151700. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  151701. /**
  151702. * Disables a depth renderer for a given camera
  151703. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  151704. */
  151705. disableDepthRenderer(camera?: Nullable<Camera>): void;
  151706. }
  151707. /**
  151708. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  151709. * in several rendering techniques.
  151710. */
  151711. export class DepthRendererSceneComponent implements ISceneComponent {
  151712. /**
  151713. * The component name helpfull to identify the component in the list of scene components.
  151714. */
  151715. readonly name: string;
  151716. /**
  151717. * The scene the component belongs to.
  151718. */
  151719. scene: Scene;
  151720. /**
  151721. * Creates a new instance of the component for the given scene
  151722. * @param scene Defines the scene to register the component in
  151723. */
  151724. constructor(scene: Scene);
  151725. /**
  151726. * Registers the component in a given scene
  151727. */
  151728. register(): void;
  151729. /**
  151730. * Rebuilds the elements related to this component in case of
  151731. * context lost for instance.
  151732. */
  151733. rebuild(): void;
  151734. /**
  151735. * Disposes the component and the associated ressources
  151736. */
  151737. dispose(): void;
  151738. private _gatherRenderTargets;
  151739. private _gatherActiveCameraRenderTargets;
  151740. }
  151741. }
  151742. declare module BABYLON {
  151743. interface AbstractScene {
  151744. /** @hidden (Backing field) */
  151745. _prePassRenderer: Nullable<PrePassRenderer>;
  151746. /**
  151747. * Gets or Sets the current prepass renderer associated to the scene.
  151748. */
  151749. prePassRenderer: Nullable<PrePassRenderer>;
  151750. /**
  151751. * Enables the prepass and associates it with the scene
  151752. * @returns the PrePassRenderer
  151753. */
  151754. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151755. /**
  151756. * Disables the prepass associated with the scene
  151757. */
  151758. disablePrePassRenderer(): void;
  151759. }
  151760. /**
  151761. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151762. * in several rendering techniques.
  151763. */
  151764. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151765. /**
  151766. * The component name helpful to identify the component in the list of scene components.
  151767. */
  151768. readonly name: string;
  151769. /**
  151770. * The scene the component belongs to.
  151771. */
  151772. scene: Scene;
  151773. /**
  151774. * Creates a new instance of the component for the given scene
  151775. * @param scene Defines the scene to register the component in
  151776. */
  151777. constructor(scene: Scene);
  151778. /**
  151779. * Registers the component in a given scene
  151780. */
  151781. register(): void;
  151782. private _beforeCameraDraw;
  151783. private _afterCameraDraw;
  151784. private _beforeClearStage;
  151785. /**
  151786. * Serializes the component data to the specified json object
  151787. * @param serializationObject The object to serialize to
  151788. */
  151789. serialize(serializationObject: any): void;
  151790. /**
  151791. * Adds all the elements from the container to the scene
  151792. * @param container the container holding the elements
  151793. */
  151794. addFromContainer(container: AbstractScene): void;
  151795. /**
  151796. * Removes all the elements in the container from the scene
  151797. * @param container contains the elements to remove
  151798. * @param dispose if the removed element should be disposed (default: false)
  151799. */
  151800. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  151801. /**
  151802. * Rebuilds the elements related to this component in case of
  151803. * context lost for instance.
  151804. */
  151805. rebuild(): void;
  151806. /**
  151807. * Disposes the component and the associated ressources
  151808. */
  151809. dispose(): void;
  151810. }
  151811. }
  151812. declare module BABYLON {
  151813. /** @hidden */
  151814. export var outlinePixelShader: {
  151815. name: string;
  151816. shader: string;
  151817. };
  151818. }
  151819. declare module BABYLON {
  151820. /** @hidden */
  151821. export var outlineVertexShader: {
  151822. name: string;
  151823. shader: string;
  151824. };
  151825. }
  151826. declare module BABYLON {
  151827. interface Scene {
  151828. /** @hidden */
  151829. _outlineRenderer: OutlineRenderer;
  151830. /**
  151831. * Gets the outline renderer associated with the scene
  151832. * @returns a OutlineRenderer
  151833. */
  151834. getOutlineRenderer(): OutlineRenderer;
  151835. }
  151836. interface AbstractMesh {
  151837. /** @hidden (Backing field) */
  151838. _renderOutline: boolean;
  151839. /**
  151840. * Gets or sets a boolean indicating if the outline must be rendered as well
  151841. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  151842. */
  151843. renderOutline: boolean;
  151844. /** @hidden (Backing field) */
  151845. _renderOverlay: boolean;
  151846. /**
  151847. * Gets or sets a boolean indicating if the overlay must be rendered as well
  151848. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  151849. */
  151850. renderOverlay: boolean;
  151851. }
  151852. /**
  151853. * This class is responsible to draw bothe outline/overlay of meshes.
  151854. * It should not be used directly but through the available method on mesh.
  151855. */
  151856. export class OutlineRenderer implements ISceneComponent {
  151857. /**
  151858. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  151859. */
  151860. private static _StencilReference;
  151861. /**
  151862. * The name of the component. Each component must have a unique name.
  151863. */
  151864. name: string;
  151865. /**
  151866. * The scene the component belongs to.
  151867. */
  151868. scene: Scene;
  151869. /**
  151870. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  151871. */
  151872. zOffset: number;
  151873. private _engine;
  151874. private _effect;
  151875. private _cachedDefines;
  151876. private _savedDepthWrite;
  151877. /**
  151878. * Instantiates a new outline renderer. (There could be only one per scene).
  151879. * @param scene Defines the scene it belongs to
  151880. */
  151881. constructor(scene: Scene);
  151882. /**
  151883. * Register the component to one instance of a scene.
  151884. */
  151885. register(): void;
  151886. /**
  151887. * Rebuilds the elements related to this component in case of
  151888. * context lost for instance.
  151889. */
  151890. rebuild(): void;
  151891. /**
  151892. * Disposes the component and the associated ressources.
  151893. */
  151894. dispose(): void;
  151895. /**
  151896. * Renders the outline in the canvas.
  151897. * @param subMesh Defines the sumesh to render
  151898. * @param batch Defines the batch of meshes in case of instances
  151899. * @param useOverlay Defines if the rendering is for the overlay or the outline
  151900. */
  151901. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  151902. /**
  151903. * Returns whether or not the outline renderer is ready for a given submesh.
  151904. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  151905. * @param subMesh Defines the submesh to check readyness for
  151906. * @param useInstances Defines wheter wee are trying to render instances or not
  151907. * @returns true if ready otherwise false
  151908. */
  151909. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  151910. private _beforeRenderingMesh;
  151911. private _afterRenderingMesh;
  151912. }
  151913. }
  151914. declare module BABYLON {
  151915. /**
  151916. * Defines the basic options interface of a Sprite Frame Source Size.
  151917. */
  151918. export interface ISpriteJSONSpriteSourceSize {
  151919. /**
  151920. * number of the original width of the Frame
  151921. */
  151922. w: number;
  151923. /**
  151924. * number of the original height of the Frame
  151925. */
  151926. h: number;
  151927. }
  151928. /**
  151929. * Defines the basic options interface of a Sprite Frame Data.
  151930. */
  151931. export interface ISpriteJSONSpriteFrameData {
  151932. /**
  151933. * number of the x offset of the Frame
  151934. */
  151935. x: number;
  151936. /**
  151937. * number of the y offset of the Frame
  151938. */
  151939. y: number;
  151940. /**
  151941. * number of the width of the Frame
  151942. */
  151943. w: number;
  151944. /**
  151945. * number of the height of the Frame
  151946. */
  151947. h: number;
  151948. }
  151949. /**
  151950. * Defines the basic options interface of a JSON Sprite.
  151951. */
  151952. export interface ISpriteJSONSprite {
  151953. /**
  151954. * string name of the Frame
  151955. */
  151956. filename: string;
  151957. /**
  151958. * ISpriteJSONSpriteFrame basic object of the frame data
  151959. */
  151960. frame: ISpriteJSONSpriteFrameData;
  151961. /**
  151962. * boolean to flag is the frame was rotated.
  151963. */
  151964. rotated: boolean;
  151965. /**
  151966. * boolean to flag is the frame was trimmed.
  151967. */
  151968. trimmed: boolean;
  151969. /**
  151970. * ISpriteJSONSpriteFrame basic object of the source data
  151971. */
  151972. spriteSourceSize: ISpriteJSONSpriteFrameData;
  151973. /**
  151974. * ISpriteJSONSpriteFrame basic object of the source data
  151975. */
  151976. sourceSize: ISpriteJSONSpriteSourceSize;
  151977. }
  151978. /**
  151979. * Defines the basic options interface of a JSON atlas.
  151980. */
  151981. export interface ISpriteJSONAtlas {
  151982. /**
  151983. * Array of objects that contain the frame data.
  151984. */
  151985. frames: Array<ISpriteJSONSprite>;
  151986. /**
  151987. * object basic object containing the sprite meta data.
  151988. */
  151989. meta?: object;
  151990. }
  151991. }
  151992. declare module BABYLON {
  151993. /** @hidden */
  151994. export var spriteMapPixelShader: {
  151995. name: string;
  151996. shader: string;
  151997. };
  151998. }
  151999. declare module BABYLON {
  152000. /** @hidden */
  152001. export var spriteMapVertexShader: {
  152002. name: string;
  152003. shader: string;
  152004. };
  152005. }
  152006. declare module BABYLON {
  152007. /**
  152008. * Defines the basic options interface of a SpriteMap
  152009. */
  152010. export interface ISpriteMapOptions {
  152011. /**
  152012. * Vector2 of the number of cells in the grid.
  152013. */
  152014. stageSize?: Vector2;
  152015. /**
  152016. * Vector2 of the size of the output plane in World Units.
  152017. */
  152018. outputSize?: Vector2;
  152019. /**
  152020. * Vector3 of the position of the output plane in World Units.
  152021. */
  152022. outputPosition?: Vector3;
  152023. /**
  152024. * Vector3 of the rotation of the output plane.
  152025. */
  152026. outputRotation?: Vector3;
  152027. /**
  152028. * number of layers that the system will reserve in resources.
  152029. */
  152030. layerCount?: number;
  152031. /**
  152032. * number of max animation frames a single cell will reserve in resources.
  152033. */
  152034. maxAnimationFrames?: number;
  152035. /**
  152036. * number cell index of the base tile when the system compiles.
  152037. */
  152038. baseTile?: number;
  152039. /**
  152040. * boolean flip the sprite after its been repositioned by the framing data.
  152041. */
  152042. flipU?: boolean;
  152043. /**
  152044. * Vector3 scalar of the global RGB values of the SpriteMap.
  152045. */
  152046. colorMultiply?: Vector3;
  152047. }
  152048. /**
  152049. * Defines the IDisposable interface in order to be cleanable from resources.
  152050. */
  152051. export interface ISpriteMap extends IDisposable {
  152052. /**
  152053. * String name of the SpriteMap.
  152054. */
  152055. name: string;
  152056. /**
  152057. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152058. */
  152059. atlasJSON: ISpriteJSONAtlas;
  152060. /**
  152061. * Texture of the SpriteMap.
  152062. */
  152063. spriteSheet: Texture;
  152064. /**
  152065. * The parameters to initialize the SpriteMap with.
  152066. */
  152067. options: ISpriteMapOptions;
  152068. }
  152069. /**
  152070. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152071. */
  152072. export class SpriteMap implements ISpriteMap {
  152073. /** The Name of the spriteMap */
  152074. name: string;
  152075. /** The JSON file with the frame and meta data */
  152076. atlasJSON: ISpriteJSONAtlas;
  152077. /** The systems Sprite Sheet Texture */
  152078. spriteSheet: Texture;
  152079. /** Arguments passed with the Constructor */
  152080. options: ISpriteMapOptions;
  152081. /** Public Sprite Storage array, parsed from atlasJSON */
  152082. sprites: Array<ISpriteJSONSprite>;
  152083. /** Returns the Number of Sprites in the System */
  152084. get spriteCount(): number;
  152085. /** Returns the Position of Output Plane*/
  152086. get position(): Vector3;
  152087. /** Returns the Position of Output Plane*/
  152088. set position(v: Vector3);
  152089. /** Returns the Rotation of Output Plane*/
  152090. get rotation(): Vector3;
  152091. /** Returns the Rotation of Output Plane*/
  152092. set rotation(v: Vector3);
  152093. /** Sets the AnimationMap*/
  152094. get animationMap(): RawTexture;
  152095. /** Sets the AnimationMap*/
  152096. set animationMap(v: RawTexture);
  152097. /** Scene that the SpriteMap was created in */
  152098. private _scene;
  152099. /** Texture Buffer of Float32 that holds tile frame data*/
  152100. private _frameMap;
  152101. /** Texture Buffers of Float32 that holds tileMap data*/
  152102. private _tileMaps;
  152103. /** Texture Buffer of Float32 that holds Animation Data*/
  152104. private _animationMap;
  152105. /** Custom ShaderMaterial Central to the System*/
  152106. private _material;
  152107. /** Custom ShaderMaterial Central to the System*/
  152108. private _output;
  152109. /** Systems Time Ticker*/
  152110. private _time;
  152111. /**
  152112. * Creates a new SpriteMap
  152113. * @param name defines the SpriteMaps Name
  152114. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152115. * @param spriteSheet is the Texture that the Sprites are on.
  152116. * @param options a basic deployment configuration
  152117. * @param scene The Scene that the map is deployed on
  152118. */
  152119. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152120. /**
  152121. * Returns tileID location
  152122. * @returns Vector2 the cell position ID
  152123. */
  152124. getTileID(): Vector2;
  152125. /**
  152126. * Gets the UV location of the mouse over the SpriteMap.
  152127. * @returns Vector2 the UV position of the mouse interaction
  152128. */
  152129. getMousePosition(): Vector2;
  152130. /**
  152131. * Creates the "frame" texture Buffer
  152132. * -------------------------------------
  152133. * Structure of frames
  152134. * "filename": "Falling-Water-2.png",
  152135. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152136. * "rotated": true,
  152137. * "trimmed": true,
  152138. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152139. * "sourceSize": {"w":32,"h":32}
  152140. * @returns RawTexture of the frameMap
  152141. */
  152142. private _createFrameBuffer;
  152143. /**
  152144. * Creates the tileMap texture Buffer
  152145. * @param buffer normally and array of numbers, or a false to generate from scratch
  152146. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  152147. * @returns RawTexture of the tileMap
  152148. */
  152149. private _createTileBuffer;
  152150. /**
  152151. * Modifies the data of the tileMaps
  152152. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  152153. * @param pos is the iVector2 Coordinates of the Tile
  152154. * @param tile The SpriteIndex of the new Tile
  152155. */
  152156. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  152157. /**
  152158. * Creates the animationMap texture Buffer
  152159. * @param buffer normally and array of numbers, or a false to generate from scratch
  152160. * @returns RawTexture of the animationMap
  152161. */
  152162. private _createTileAnimationBuffer;
  152163. /**
  152164. * Modifies the data of the animationMap
  152165. * @param cellID is the Index of the Sprite
  152166. * @param _frame is the target Animation frame
  152167. * @param toCell is the Target Index of the next frame of the animation
  152168. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  152169. * @param speed is a global scalar of the time variable on the map.
  152170. */
  152171. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  152172. /**
  152173. * Exports the .tilemaps file
  152174. */
  152175. saveTileMaps(): void;
  152176. /**
  152177. * Imports the .tilemaps file
  152178. * @param url of the .tilemaps file
  152179. */
  152180. loadTileMaps(url: string): void;
  152181. /**
  152182. * Release associated resources
  152183. */
  152184. dispose(): void;
  152185. }
  152186. }
  152187. declare module BABYLON {
  152188. /**
  152189. * Class used to manage multiple sprites of different sizes on the same spritesheet
  152190. * @see https://doc.babylonjs.com/babylon101/sprites
  152191. */
  152192. export class SpritePackedManager extends SpriteManager {
  152193. /** defines the packed manager's name */
  152194. name: string;
  152195. /**
  152196. * Creates a new sprite manager from a packed sprite sheet
  152197. * @param name defines the manager's name
  152198. * @param imgUrl defines the sprite sheet url
  152199. * @param capacity defines the maximum allowed number of sprites
  152200. * @param scene defines the hosting scene
  152201. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  152202. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  152203. * @param samplingMode defines the smapling mode to use with spritesheet
  152204. * @param fromPacked set to true; do not alter
  152205. */
  152206. constructor(
  152207. /** defines the packed manager's name */
  152208. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  152209. }
  152210. }
  152211. declare module BABYLON {
  152212. /**
  152213. * Defines the list of states available for a task inside a AssetsManager
  152214. */
  152215. export enum AssetTaskState {
  152216. /**
  152217. * Initialization
  152218. */
  152219. INIT = 0,
  152220. /**
  152221. * Running
  152222. */
  152223. RUNNING = 1,
  152224. /**
  152225. * Done
  152226. */
  152227. DONE = 2,
  152228. /**
  152229. * Error
  152230. */
  152231. ERROR = 3
  152232. }
  152233. /**
  152234. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  152235. */
  152236. export abstract class AbstractAssetTask {
  152237. /**
  152238. * Task name
  152239. */ name: string;
  152240. /**
  152241. * Callback called when the task is successful
  152242. */
  152243. onSuccess: (task: any) => void;
  152244. /**
  152245. * Callback called when the task is not successful
  152246. */
  152247. onError: (task: any, message?: string, exception?: any) => void;
  152248. /**
  152249. * Creates a new AssetsManager
  152250. * @param name defines the name of the task
  152251. */
  152252. constructor(
  152253. /**
  152254. * Task name
  152255. */ name: string);
  152256. private _isCompleted;
  152257. private _taskState;
  152258. private _errorObject;
  152259. /**
  152260. * Get if the task is completed
  152261. */
  152262. get isCompleted(): boolean;
  152263. /**
  152264. * Gets the current state of the task
  152265. */
  152266. get taskState(): AssetTaskState;
  152267. /**
  152268. * Gets the current error object (if task is in error)
  152269. */
  152270. get errorObject(): {
  152271. message?: string;
  152272. exception?: any;
  152273. };
  152274. /**
  152275. * Internal only
  152276. * @hidden
  152277. */
  152278. _setErrorObject(message?: string, exception?: any): void;
  152279. /**
  152280. * Execute the current task
  152281. * @param scene defines the scene where you want your assets to be loaded
  152282. * @param onSuccess is a callback called when the task is successfully executed
  152283. * @param onError is a callback called if an error occurs
  152284. */
  152285. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152286. /**
  152287. * Execute the current task
  152288. * @param scene defines the scene where you want your assets to be loaded
  152289. * @param onSuccess is a callback called when the task is successfully executed
  152290. * @param onError is a callback called if an error occurs
  152291. */
  152292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152293. /**
  152294. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  152295. * This can be used with failed tasks that have the reason for failure fixed.
  152296. */
  152297. reset(): void;
  152298. private onErrorCallback;
  152299. private onDoneCallback;
  152300. }
  152301. /**
  152302. * Define the interface used by progress events raised during assets loading
  152303. */
  152304. export interface IAssetsProgressEvent {
  152305. /**
  152306. * Defines the number of remaining tasks to process
  152307. */
  152308. remainingCount: number;
  152309. /**
  152310. * Defines the total number of tasks
  152311. */
  152312. totalCount: number;
  152313. /**
  152314. * Defines the task that was just processed
  152315. */
  152316. task: AbstractAssetTask;
  152317. }
  152318. /**
  152319. * Class used to share progress information about assets loading
  152320. */
  152321. export class AssetsProgressEvent implements IAssetsProgressEvent {
  152322. /**
  152323. * Defines the number of remaining tasks to process
  152324. */
  152325. remainingCount: number;
  152326. /**
  152327. * Defines the total number of tasks
  152328. */
  152329. totalCount: number;
  152330. /**
  152331. * Defines the task that was just processed
  152332. */
  152333. task: AbstractAssetTask;
  152334. /**
  152335. * Creates a AssetsProgressEvent
  152336. * @param remainingCount defines the number of remaining tasks to process
  152337. * @param totalCount defines the total number of tasks
  152338. * @param task defines the task that was just processed
  152339. */
  152340. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  152341. }
  152342. /**
  152343. * Define a task used by AssetsManager to load assets into a container
  152344. */
  152345. export class ContainerAssetTask extends AbstractAssetTask {
  152346. /**
  152347. * Defines the name of the task
  152348. */
  152349. name: string;
  152350. /**
  152351. * Defines the list of mesh's names you want to load
  152352. */
  152353. meshesNames: any;
  152354. /**
  152355. * Defines the root url to use as a base to load your meshes and associated resources
  152356. */
  152357. rootUrl: string;
  152358. /**
  152359. * Defines the filename or File of the scene to load from
  152360. */
  152361. sceneFilename: string | File;
  152362. /**
  152363. * Get the loaded asset container
  152364. */
  152365. loadedContainer: AssetContainer;
  152366. /**
  152367. * Gets the list of loaded meshes
  152368. */
  152369. loadedMeshes: Array<AbstractMesh>;
  152370. /**
  152371. * Gets the list of loaded particle systems
  152372. */
  152373. loadedParticleSystems: Array<IParticleSystem>;
  152374. /**
  152375. * Gets the list of loaded skeletons
  152376. */
  152377. loadedSkeletons: Array<Skeleton>;
  152378. /**
  152379. * Gets the list of loaded animation groups
  152380. */
  152381. loadedAnimationGroups: Array<AnimationGroup>;
  152382. /**
  152383. * Callback called when the task is successful
  152384. */
  152385. onSuccess: (task: ContainerAssetTask) => void;
  152386. /**
  152387. * Callback called when the task is successful
  152388. */
  152389. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  152390. /**
  152391. * Creates a new ContainerAssetTask
  152392. * @param name defines the name of the task
  152393. * @param meshesNames defines the list of mesh's names you want to load
  152394. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152395. * @param sceneFilename defines the filename or File of the scene to load from
  152396. */
  152397. constructor(
  152398. /**
  152399. * Defines the name of the task
  152400. */
  152401. name: string,
  152402. /**
  152403. * Defines the list of mesh's names you want to load
  152404. */
  152405. meshesNames: any,
  152406. /**
  152407. * Defines the root url to use as a base to load your meshes and associated resources
  152408. */
  152409. rootUrl: string,
  152410. /**
  152411. * Defines the filename or File of the scene to load from
  152412. */
  152413. sceneFilename: string | File);
  152414. /**
  152415. * Execute the current task
  152416. * @param scene defines the scene where you want your assets to be loaded
  152417. * @param onSuccess is a callback called when the task is successfully executed
  152418. * @param onError is a callback called if an error occurs
  152419. */
  152420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152421. }
  152422. /**
  152423. * Define a task used by AssetsManager to load meshes
  152424. */
  152425. export class MeshAssetTask extends AbstractAssetTask {
  152426. /**
  152427. * Defines the name of the task
  152428. */
  152429. name: string;
  152430. /**
  152431. * Defines the list of mesh's names you want to load
  152432. */
  152433. meshesNames: any;
  152434. /**
  152435. * Defines the root url to use as a base to load your meshes and associated resources
  152436. */
  152437. rootUrl: string;
  152438. /**
  152439. * Defines the filename or File of the scene to load from
  152440. */
  152441. sceneFilename: string | File;
  152442. /**
  152443. * Gets the list of loaded meshes
  152444. */
  152445. loadedMeshes: Array<AbstractMesh>;
  152446. /**
  152447. * Gets the list of loaded particle systems
  152448. */
  152449. loadedParticleSystems: Array<IParticleSystem>;
  152450. /**
  152451. * Gets the list of loaded skeletons
  152452. */
  152453. loadedSkeletons: Array<Skeleton>;
  152454. /**
  152455. * Gets the list of loaded animation groups
  152456. */
  152457. loadedAnimationGroups: Array<AnimationGroup>;
  152458. /**
  152459. * Callback called when the task is successful
  152460. */
  152461. onSuccess: (task: MeshAssetTask) => void;
  152462. /**
  152463. * Callback called when the task is successful
  152464. */
  152465. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  152466. /**
  152467. * Creates a new MeshAssetTask
  152468. * @param name defines the name of the task
  152469. * @param meshesNames defines the list of mesh's names you want to load
  152470. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152471. * @param sceneFilename defines the filename or File of the scene to load from
  152472. */
  152473. constructor(
  152474. /**
  152475. * Defines the name of the task
  152476. */
  152477. name: string,
  152478. /**
  152479. * Defines the list of mesh's names you want to load
  152480. */
  152481. meshesNames: any,
  152482. /**
  152483. * Defines the root url to use as a base to load your meshes and associated resources
  152484. */
  152485. rootUrl: string,
  152486. /**
  152487. * Defines the filename or File of the scene to load from
  152488. */
  152489. sceneFilename: string | File);
  152490. /**
  152491. * Execute the current task
  152492. * @param scene defines the scene where you want your assets to be loaded
  152493. * @param onSuccess is a callback called when the task is successfully executed
  152494. * @param onError is a callback called if an error occurs
  152495. */
  152496. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152497. }
  152498. /**
  152499. * Define a task used by AssetsManager to load text content
  152500. */
  152501. export class TextFileAssetTask extends AbstractAssetTask {
  152502. /**
  152503. * Defines the name of the task
  152504. */
  152505. name: string;
  152506. /**
  152507. * Defines the location of the file to load
  152508. */
  152509. url: string;
  152510. /**
  152511. * Gets the loaded text string
  152512. */
  152513. text: string;
  152514. /**
  152515. * Callback called when the task is successful
  152516. */
  152517. onSuccess: (task: TextFileAssetTask) => void;
  152518. /**
  152519. * Callback called when the task is successful
  152520. */
  152521. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  152522. /**
  152523. * Creates a new TextFileAssetTask object
  152524. * @param name defines the name of the task
  152525. * @param url defines the location of the file to load
  152526. */
  152527. constructor(
  152528. /**
  152529. * Defines the name of the task
  152530. */
  152531. name: string,
  152532. /**
  152533. * Defines the location of the file to load
  152534. */
  152535. url: string);
  152536. /**
  152537. * Execute the current task
  152538. * @param scene defines the scene where you want your assets to be loaded
  152539. * @param onSuccess is a callback called when the task is successfully executed
  152540. * @param onError is a callback called if an error occurs
  152541. */
  152542. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152543. }
  152544. /**
  152545. * Define a task used by AssetsManager to load binary data
  152546. */
  152547. export class BinaryFileAssetTask extends AbstractAssetTask {
  152548. /**
  152549. * Defines the name of the task
  152550. */
  152551. name: string;
  152552. /**
  152553. * Defines the location of the file to load
  152554. */
  152555. url: string;
  152556. /**
  152557. * Gets the lodaded data (as an array buffer)
  152558. */
  152559. data: ArrayBuffer;
  152560. /**
  152561. * Callback called when the task is successful
  152562. */
  152563. onSuccess: (task: BinaryFileAssetTask) => void;
  152564. /**
  152565. * Callback called when the task is successful
  152566. */
  152567. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  152568. /**
  152569. * Creates a new BinaryFileAssetTask object
  152570. * @param name defines the name of the new task
  152571. * @param url defines the location of the file to load
  152572. */
  152573. constructor(
  152574. /**
  152575. * Defines the name of the task
  152576. */
  152577. name: string,
  152578. /**
  152579. * Defines the location of the file to load
  152580. */
  152581. url: string);
  152582. /**
  152583. * Execute the current task
  152584. * @param scene defines the scene where you want your assets to be loaded
  152585. * @param onSuccess is a callback called when the task is successfully executed
  152586. * @param onError is a callback called if an error occurs
  152587. */
  152588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152589. }
  152590. /**
  152591. * Define a task used by AssetsManager to load images
  152592. */
  152593. export class ImageAssetTask extends AbstractAssetTask {
  152594. /**
  152595. * Defines the name of the task
  152596. */
  152597. name: string;
  152598. /**
  152599. * Defines the location of the image to load
  152600. */
  152601. url: string;
  152602. /**
  152603. * Gets the loaded images
  152604. */
  152605. image: HTMLImageElement;
  152606. /**
  152607. * Callback called when the task is successful
  152608. */
  152609. onSuccess: (task: ImageAssetTask) => void;
  152610. /**
  152611. * Callback called when the task is successful
  152612. */
  152613. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  152614. /**
  152615. * Creates a new ImageAssetTask
  152616. * @param name defines the name of the task
  152617. * @param url defines the location of the image to load
  152618. */
  152619. constructor(
  152620. /**
  152621. * Defines the name of the task
  152622. */
  152623. name: string,
  152624. /**
  152625. * Defines the location of the image to load
  152626. */
  152627. url: string);
  152628. /**
  152629. * Execute the current task
  152630. * @param scene defines the scene where you want your assets to be loaded
  152631. * @param onSuccess is a callback called when the task is successfully executed
  152632. * @param onError is a callback called if an error occurs
  152633. */
  152634. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152635. }
  152636. /**
  152637. * Defines the interface used by texture loading tasks
  152638. */
  152639. export interface ITextureAssetTask<TEX extends BaseTexture> {
  152640. /**
  152641. * Gets the loaded texture
  152642. */
  152643. texture: TEX;
  152644. }
  152645. /**
  152646. * Define a task used by AssetsManager to load 2D textures
  152647. */
  152648. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  152649. /**
  152650. * Defines the name of the task
  152651. */
  152652. name: string;
  152653. /**
  152654. * Defines the location of the file to load
  152655. */
  152656. url: string;
  152657. /**
  152658. * Defines if mipmap should not be generated (default is false)
  152659. */
  152660. noMipmap?: boolean | undefined;
  152661. /**
  152662. * Defines if texture must be inverted on Y axis (default is true)
  152663. */
  152664. invertY: boolean;
  152665. /**
  152666. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152667. */
  152668. samplingMode: number;
  152669. /**
  152670. * Gets the loaded texture
  152671. */
  152672. texture: Texture;
  152673. /**
  152674. * Callback called when the task is successful
  152675. */
  152676. onSuccess: (task: TextureAssetTask) => void;
  152677. /**
  152678. * Callback called when the task is successful
  152679. */
  152680. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  152681. /**
  152682. * Creates a new TextureAssetTask object
  152683. * @param name defines the name of the task
  152684. * @param url defines the location of the file to load
  152685. * @param noMipmap defines if mipmap should not be generated (default is false)
  152686. * @param invertY defines if texture must be inverted on Y axis (default is true)
  152687. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152688. */
  152689. constructor(
  152690. /**
  152691. * Defines the name of the task
  152692. */
  152693. name: string,
  152694. /**
  152695. * Defines the location of the file to load
  152696. */
  152697. url: string,
  152698. /**
  152699. * Defines if mipmap should not be generated (default is false)
  152700. */
  152701. noMipmap?: boolean | undefined,
  152702. /**
  152703. * Defines if texture must be inverted on Y axis (default is true)
  152704. */
  152705. invertY?: boolean,
  152706. /**
  152707. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152708. */
  152709. samplingMode?: number);
  152710. /**
  152711. * Execute the current task
  152712. * @param scene defines the scene where you want your assets to be loaded
  152713. * @param onSuccess is a callback called when the task is successfully executed
  152714. * @param onError is a callback called if an error occurs
  152715. */
  152716. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152717. }
  152718. /**
  152719. * Define a task used by AssetsManager to load cube textures
  152720. */
  152721. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152722. /**
  152723. * Defines the name of the task
  152724. */
  152725. name: string;
  152726. /**
  152727. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152728. */
  152729. url: string;
  152730. /**
  152731. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152732. */
  152733. extensions?: string[] | undefined;
  152734. /**
  152735. * Defines if mipmaps should not be generated (default is false)
  152736. */
  152737. noMipmap?: boolean | undefined;
  152738. /**
  152739. * Defines the explicit list of files (undefined by default)
  152740. */
  152741. files?: string[] | undefined;
  152742. /**
  152743. * Gets the loaded texture
  152744. */
  152745. texture: CubeTexture;
  152746. /**
  152747. * Callback called when the task is successful
  152748. */
  152749. onSuccess: (task: CubeTextureAssetTask) => void;
  152750. /**
  152751. * Callback called when the task is successful
  152752. */
  152753. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152754. /**
  152755. * Creates a new CubeTextureAssetTask
  152756. * @param name defines the name of the task
  152757. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152758. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152759. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152760. * @param files defines the explicit list of files (undefined by default)
  152761. */
  152762. constructor(
  152763. /**
  152764. * Defines the name of the task
  152765. */
  152766. name: string,
  152767. /**
  152768. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152769. */
  152770. url: string,
  152771. /**
  152772. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152773. */
  152774. extensions?: string[] | undefined,
  152775. /**
  152776. * Defines if mipmaps should not be generated (default is false)
  152777. */
  152778. noMipmap?: boolean | undefined,
  152779. /**
  152780. * Defines the explicit list of files (undefined by default)
  152781. */
  152782. files?: string[] | undefined);
  152783. /**
  152784. * Execute the current task
  152785. * @param scene defines the scene where you want your assets to be loaded
  152786. * @param onSuccess is a callback called when the task is successfully executed
  152787. * @param onError is a callback called if an error occurs
  152788. */
  152789. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152790. }
  152791. /**
  152792. * Define a task used by AssetsManager to load HDR cube textures
  152793. */
  152794. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  152795. /**
  152796. * Defines the name of the task
  152797. */
  152798. name: string;
  152799. /**
  152800. * Defines the location of the file to load
  152801. */
  152802. url: string;
  152803. /**
  152804. * Defines the desired size (the more it increases the longer the generation will be)
  152805. */
  152806. size: number;
  152807. /**
  152808. * Defines if mipmaps should not be generated (default is false)
  152809. */
  152810. noMipmap: boolean;
  152811. /**
  152812. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152813. */
  152814. generateHarmonics: boolean;
  152815. /**
  152816. * 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)
  152817. */
  152818. gammaSpace: boolean;
  152819. /**
  152820. * Internal Use Only
  152821. */
  152822. reserved: boolean;
  152823. /**
  152824. * Gets the loaded texture
  152825. */
  152826. texture: HDRCubeTexture;
  152827. /**
  152828. * Callback called when the task is successful
  152829. */
  152830. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  152831. /**
  152832. * Callback called when the task is successful
  152833. */
  152834. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  152835. /**
  152836. * Creates a new HDRCubeTextureAssetTask object
  152837. * @param name defines the name of the task
  152838. * @param url defines the location of the file to load
  152839. * @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.
  152840. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152841. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152842. * @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)
  152843. * @param reserved Internal use only
  152844. */
  152845. constructor(
  152846. /**
  152847. * Defines the name of the task
  152848. */
  152849. name: string,
  152850. /**
  152851. * Defines the location of the file to load
  152852. */
  152853. url: string,
  152854. /**
  152855. * Defines the desired size (the more it increases the longer the generation will be)
  152856. */
  152857. size: number,
  152858. /**
  152859. * Defines if mipmaps should not be generated (default is false)
  152860. */
  152861. noMipmap?: boolean,
  152862. /**
  152863. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152864. */
  152865. generateHarmonics?: boolean,
  152866. /**
  152867. * 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)
  152868. */
  152869. gammaSpace?: boolean,
  152870. /**
  152871. * Internal Use Only
  152872. */
  152873. reserved?: boolean);
  152874. /**
  152875. * Execute the current task
  152876. * @param scene defines the scene where you want your assets to be loaded
  152877. * @param onSuccess is a callback called when the task is successfully executed
  152878. * @param onError is a callback called if an error occurs
  152879. */
  152880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152881. }
  152882. /**
  152883. * Define a task used by AssetsManager to load Equirectangular cube textures
  152884. */
  152885. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  152886. /**
  152887. * Defines the name of the task
  152888. */
  152889. name: string;
  152890. /**
  152891. * Defines the location of the file to load
  152892. */
  152893. url: string;
  152894. /**
  152895. * Defines the desired size (the more it increases the longer the generation will be)
  152896. */
  152897. size: number;
  152898. /**
  152899. * Defines if mipmaps should not be generated (default is false)
  152900. */
  152901. noMipmap: boolean;
  152902. /**
  152903. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152904. * but the standard material would require them in Gamma space) (default is true)
  152905. */
  152906. gammaSpace: boolean;
  152907. /**
  152908. * Gets the loaded texture
  152909. */
  152910. texture: EquiRectangularCubeTexture;
  152911. /**
  152912. * Callback called when the task is successful
  152913. */
  152914. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  152915. /**
  152916. * Callback called when the task is successful
  152917. */
  152918. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  152919. /**
  152920. * Creates a new EquiRectangularCubeTextureAssetTask object
  152921. * @param name defines the name of the task
  152922. * @param url defines the location of the file to load
  152923. * @param size defines the desired size (the more it increases the longer the generation will be)
  152924. * If the size is omitted this implies you are using a preprocessed cubemap.
  152925. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152926. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  152927. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  152928. * (default is true)
  152929. */
  152930. constructor(
  152931. /**
  152932. * Defines the name of the task
  152933. */
  152934. name: string,
  152935. /**
  152936. * Defines the location of the file to load
  152937. */
  152938. url: string,
  152939. /**
  152940. * Defines the desired size (the more it increases the longer the generation will be)
  152941. */
  152942. size: number,
  152943. /**
  152944. * Defines if mipmaps should not be generated (default is false)
  152945. */
  152946. noMipmap?: boolean,
  152947. /**
  152948. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152949. * but the standard material would require them in Gamma space) (default is true)
  152950. */
  152951. gammaSpace?: boolean);
  152952. /**
  152953. * Execute the current task
  152954. * @param scene defines the scene where you want your assets to be loaded
  152955. * @param onSuccess is a callback called when the task is successfully executed
  152956. * @param onError is a callback called if an error occurs
  152957. */
  152958. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152959. }
  152960. /**
  152961. * This class can be used to easily import assets into a scene
  152962. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  152963. */
  152964. export class AssetsManager {
  152965. private _scene;
  152966. private _isLoading;
  152967. protected _tasks: AbstractAssetTask[];
  152968. protected _waitingTasksCount: number;
  152969. protected _totalTasksCount: number;
  152970. /**
  152971. * Callback called when all tasks are processed
  152972. */
  152973. onFinish: (tasks: AbstractAssetTask[]) => void;
  152974. /**
  152975. * Callback called when a task is successful
  152976. */
  152977. onTaskSuccess: (task: AbstractAssetTask) => void;
  152978. /**
  152979. * Callback called when a task had an error
  152980. */
  152981. onTaskError: (task: AbstractAssetTask) => void;
  152982. /**
  152983. * Callback called when a task is done (whatever the result is)
  152984. */
  152985. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  152986. /**
  152987. * Observable called when all tasks are processed
  152988. */
  152989. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  152990. /**
  152991. * Observable called when a task had an error
  152992. */
  152993. onTaskErrorObservable: Observable<AbstractAssetTask>;
  152994. /**
  152995. * Observable called when all tasks were executed
  152996. */
  152997. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  152998. /**
  152999. * Observable called when a task is done (whatever the result is)
  153000. */
  153001. onProgressObservable: Observable<IAssetsProgressEvent>;
  153002. /**
  153003. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153004. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153005. */
  153006. useDefaultLoadingScreen: boolean;
  153007. /**
  153008. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153009. * when all assets have been downloaded.
  153010. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153011. */
  153012. autoHideLoadingUI: boolean;
  153013. /**
  153014. * Creates a new AssetsManager
  153015. * @param scene defines the scene to work on
  153016. */
  153017. constructor(scene: Scene);
  153018. /**
  153019. * Add a ContainerAssetTask to the list of active tasks
  153020. * @param taskName defines the name of the new task
  153021. * @param meshesNames defines the name of meshes to load
  153022. * @param rootUrl defines the root url to use to locate files
  153023. * @param sceneFilename defines the filename of the scene file
  153024. * @returns a new ContainerAssetTask object
  153025. */
  153026. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153027. /**
  153028. * Add a MeshAssetTask to the list of active tasks
  153029. * @param taskName defines the name of the new task
  153030. * @param meshesNames defines the name of meshes to load
  153031. * @param rootUrl defines the root url to use to locate files
  153032. * @param sceneFilename defines the filename of the scene file
  153033. * @returns a new MeshAssetTask object
  153034. */
  153035. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153036. /**
  153037. * Add a TextFileAssetTask to the list of active tasks
  153038. * @param taskName defines the name of the new task
  153039. * @param url defines the url of the file to load
  153040. * @returns a new TextFileAssetTask object
  153041. */
  153042. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153043. /**
  153044. * Add a BinaryFileAssetTask to the list of active tasks
  153045. * @param taskName defines the name of the new task
  153046. * @param url defines the url of the file to load
  153047. * @returns a new BinaryFileAssetTask object
  153048. */
  153049. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153050. /**
  153051. * Add a ImageAssetTask to the list of active tasks
  153052. * @param taskName defines the name of the new task
  153053. * @param url defines the url of the file to load
  153054. * @returns a new ImageAssetTask object
  153055. */
  153056. addImageTask(taskName: string, url: string): ImageAssetTask;
  153057. /**
  153058. * Add a TextureAssetTask to the list of active tasks
  153059. * @param taskName defines the name of the new task
  153060. * @param url defines the url of the file to load
  153061. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153062. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153063. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153064. * @returns a new TextureAssetTask object
  153065. */
  153066. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153067. /**
  153068. * Add a CubeTextureAssetTask to the list of active tasks
  153069. * @param taskName defines the name of the new task
  153070. * @param url defines the url of the file to load
  153071. * @param extensions defines the extension to use to load the cube map (can be null)
  153072. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153073. * @param files defines the list of files to load (can be null)
  153074. * @returns a new CubeTextureAssetTask object
  153075. */
  153076. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153077. /**
  153078. *
  153079. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153080. * @param taskName defines the name of the new task
  153081. * @param url defines the url of the file to load
  153082. * @param size defines the size you want for the cubemap (can be null)
  153083. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153084. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153085. * @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)
  153086. * @param reserved Internal use only
  153087. * @returns a new HDRCubeTextureAssetTask object
  153088. */
  153089. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153090. /**
  153091. *
  153092. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153093. * @param taskName defines the name of the new task
  153094. * @param url defines the url of the file to load
  153095. * @param size defines the size you want for the cubemap (can be null)
  153096. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153097. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153098. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153099. * @returns a new EquiRectangularCubeTextureAssetTask object
  153100. */
  153101. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153102. /**
  153103. * Remove a task from the assets manager.
  153104. * @param task the task to remove
  153105. */
  153106. removeTask(task: AbstractAssetTask): void;
  153107. private _decreaseWaitingTasksCount;
  153108. private _runTask;
  153109. /**
  153110. * Reset the AssetsManager and remove all tasks
  153111. * @return the current instance of the AssetsManager
  153112. */
  153113. reset(): AssetsManager;
  153114. /**
  153115. * Start the loading process
  153116. * @return the current instance of the AssetsManager
  153117. */
  153118. load(): AssetsManager;
  153119. /**
  153120. * Start the loading process as an async operation
  153121. * @return a promise returning the list of failed tasks
  153122. */
  153123. loadAsync(): Promise<void>;
  153124. }
  153125. }
  153126. declare module BABYLON {
  153127. /**
  153128. * Wrapper class for promise with external resolve and reject.
  153129. */
  153130. export class Deferred<T> {
  153131. /**
  153132. * The promise associated with this deferred object.
  153133. */
  153134. readonly promise: Promise<T>;
  153135. private _resolve;
  153136. private _reject;
  153137. /**
  153138. * The resolve method of the promise associated with this deferred object.
  153139. */
  153140. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153141. /**
  153142. * The reject method of the promise associated with this deferred object.
  153143. */
  153144. get reject(): (reason?: any) => void;
  153145. /**
  153146. * Constructor for this deferred object.
  153147. */
  153148. constructor();
  153149. }
  153150. }
  153151. declare module BABYLON {
  153152. /**
  153153. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  153154. */
  153155. export class MeshExploder {
  153156. private _centerMesh;
  153157. private _meshes;
  153158. private _meshesOrigins;
  153159. private _toCenterVectors;
  153160. private _scaledDirection;
  153161. private _newPosition;
  153162. private _centerPosition;
  153163. /**
  153164. * Explodes meshes from a center mesh.
  153165. * @param meshes The meshes to explode.
  153166. * @param centerMesh The mesh to be center of explosion.
  153167. */
  153168. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  153169. private _setCenterMesh;
  153170. /**
  153171. * Get class name
  153172. * @returns "MeshExploder"
  153173. */
  153174. getClassName(): string;
  153175. /**
  153176. * "Exploded meshes"
  153177. * @returns Array of meshes with the centerMesh at index 0.
  153178. */
  153179. getMeshes(): Array<Mesh>;
  153180. /**
  153181. * Explodes meshes giving a specific direction
  153182. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  153183. */
  153184. explode(direction?: number): void;
  153185. }
  153186. }
  153187. declare module BABYLON {
  153188. /**
  153189. * Class used to help managing file picking and drag'n'drop
  153190. */
  153191. export class FilesInput {
  153192. /**
  153193. * List of files ready to be loaded
  153194. */
  153195. static get FilesToLoad(): {
  153196. [key: string]: File;
  153197. };
  153198. /**
  153199. * Callback called when a file is processed
  153200. */
  153201. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  153202. private _engine;
  153203. private _currentScene;
  153204. private _sceneLoadedCallback;
  153205. private _progressCallback;
  153206. private _additionalRenderLoopLogicCallback;
  153207. private _textureLoadingCallback;
  153208. private _startingProcessingFilesCallback;
  153209. private _onReloadCallback;
  153210. private _errorCallback;
  153211. private _elementToMonitor;
  153212. private _sceneFileToLoad;
  153213. private _filesToLoad;
  153214. /**
  153215. * Creates a new FilesInput
  153216. * @param engine defines the rendering engine
  153217. * @param scene defines the hosting scene
  153218. * @param sceneLoadedCallback callback called when scene is loaded
  153219. * @param progressCallback callback called to track progress
  153220. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  153221. * @param textureLoadingCallback callback called when a texture is loading
  153222. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  153223. * @param onReloadCallback callback called when a reload is requested
  153224. * @param errorCallback callback call if an error occurs
  153225. */
  153226. 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>);
  153227. private _dragEnterHandler;
  153228. private _dragOverHandler;
  153229. private _dropHandler;
  153230. /**
  153231. * Calls this function to listen to drag'n'drop events on a specific DOM element
  153232. * @param elementToMonitor defines the DOM element to track
  153233. */
  153234. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  153235. /** Gets the current list of files to load */
  153236. get filesToLoad(): File[];
  153237. /**
  153238. * Release all associated resources
  153239. */
  153240. dispose(): void;
  153241. private renderFunction;
  153242. private drag;
  153243. private drop;
  153244. private _traverseFolder;
  153245. private _processFiles;
  153246. /**
  153247. * Load files from a drop event
  153248. * @param event defines the drop event to use as source
  153249. */
  153250. loadFiles(event: any): void;
  153251. private _processReload;
  153252. /**
  153253. * Reload the current scene from the loaded files
  153254. */
  153255. reload(): void;
  153256. }
  153257. }
  153258. declare module BABYLON {
  153259. /**
  153260. * Defines the root class used to create scene optimization to use with SceneOptimizer
  153261. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153262. */
  153263. export class SceneOptimization {
  153264. /**
  153265. * Defines the priority of this optimization (0 by default which means first in the list)
  153266. */
  153267. priority: number;
  153268. /**
  153269. * Gets a string describing the action executed by the current optimization
  153270. * @returns description string
  153271. */
  153272. getDescription(): string;
  153273. /**
  153274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153275. * @param scene defines the current scene where to apply this optimization
  153276. * @param optimizer defines the current optimizer
  153277. * @returns true if everything that can be done was applied
  153278. */
  153279. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153280. /**
  153281. * Creates the SceneOptimization object
  153282. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153283. * @param desc defines the description associated with the optimization
  153284. */
  153285. constructor(
  153286. /**
  153287. * Defines the priority of this optimization (0 by default which means first in the list)
  153288. */
  153289. priority?: number);
  153290. }
  153291. /**
  153292. * Defines an optimization used to reduce the size of render target textures
  153293. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153294. */
  153295. export class TextureOptimization extends SceneOptimization {
  153296. /**
  153297. * Defines the priority of this optimization (0 by default which means first in the list)
  153298. */
  153299. priority: number;
  153300. /**
  153301. * 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
  153302. */
  153303. maximumSize: number;
  153304. /**
  153305. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153306. */
  153307. step: number;
  153308. /**
  153309. * Gets a string describing the action executed by the current optimization
  153310. * @returns description string
  153311. */
  153312. getDescription(): string;
  153313. /**
  153314. * Creates the TextureOptimization object
  153315. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153316. * @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
  153317. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153318. */
  153319. constructor(
  153320. /**
  153321. * Defines the priority of this optimization (0 by default which means first in the list)
  153322. */
  153323. priority?: number,
  153324. /**
  153325. * 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
  153326. */
  153327. maximumSize?: number,
  153328. /**
  153329. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153330. */
  153331. step?: number);
  153332. /**
  153333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153334. * @param scene defines the current scene where to apply this optimization
  153335. * @param optimizer defines the current optimizer
  153336. * @returns true if everything that can be done was applied
  153337. */
  153338. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153339. }
  153340. /**
  153341. * Defines an optimization used to increase or decrease the rendering resolution
  153342. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153343. */
  153344. export class HardwareScalingOptimization extends SceneOptimization {
  153345. /**
  153346. * Defines the priority of this optimization (0 by default which means first in the list)
  153347. */
  153348. priority: number;
  153349. /**
  153350. * Defines the maximum scale to use (2 by default)
  153351. */
  153352. maximumScale: number;
  153353. /**
  153354. * Defines the step to use between two passes (0.5 by default)
  153355. */
  153356. step: number;
  153357. private _currentScale;
  153358. private _directionOffset;
  153359. /**
  153360. * Gets a string describing the action executed by the current optimization
  153361. * @return description string
  153362. */
  153363. getDescription(): string;
  153364. /**
  153365. * Creates the HardwareScalingOptimization object
  153366. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153367. * @param maximumScale defines the maximum scale to use (2 by default)
  153368. * @param step defines the step to use between two passes (0.5 by default)
  153369. */
  153370. constructor(
  153371. /**
  153372. * Defines the priority of this optimization (0 by default which means first in the list)
  153373. */
  153374. priority?: number,
  153375. /**
  153376. * Defines the maximum scale to use (2 by default)
  153377. */
  153378. maximumScale?: number,
  153379. /**
  153380. * Defines the step to use between two passes (0.5 by default)
  153381. */
  153382. step?: number);
  153383. /**
  153384. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153385. * @param scene defines the current scene where to apply this optimization
  153386. * @param optimizer defines the current optimizer
  153387. * @returns true if everything that can be done was applied
  153388. */
  153389. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153390. }
  153391. /**
  153392. * Defines an optimization used to remove shadows
  153393. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153394. */
  153395. export class ShadowsOptimization extends SceneOptimization {
  153396. /**
  153397. * Gets a string describing the action executed by the current optimization
  153398. * @return description string
  153399. */
  153400. getDescription(): string;
  153401. /**
  153402. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153403. * @param scene defines the current scene where to apply this optimization
  153404. * @param optimizer defines the current optimizer
  153405. * @returns true if everything that can be done was applied
  153406. */
  153407. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153408. }
  153409. /**
  153410. * Defines an optimization used to turn post-processes off
  153411. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153412. */
  153413. export class PostProcessesOptimization extends SceneOptimization {
  153414. /**
  153415. * Gets a string describing the action executed by the current optimization
  153416. * @return description string
  153417. */
  153418. getDescription(): string;
  153419. /**
  153420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153421. * @param scene defines the current scene where to apply this optimization
  153422. * @param optimizer defines the current optimizer
  153423. * @returns true if everything that can be done was applied
  153424. */
  153425. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153426. }
  153427. /**
  153428. * Defines an optimization used to turn lens flares off
  153429. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153430. */
  153431. export class LensFlaresOptimization extends SceneOptimization {
  153432. /**
  153433. * Gets a string describing the action executed by the current optimization
  153434. * @return description string
  153435. */
  153436. getDescription(): string;
  153437. /**
  153438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153439. * @param scene defines the current scene where to apply this optimization
  153440. * @param optimizer defines the current optimizer
  153441. * @returns true if everything that can be done was applied
  153442. */
  153443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153444. }
  153445. /**
  153446. * Defines an optimization based on user defined callback.
  153447. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153448. */
  153449. export class CustomOptimization extends SceneOptimization {
  153450. /**
  153451. * Callback called to apply the custom optimization.
  153452. */
  153453. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  153454. /**
  153455. * Callback called to get custom description
  153456. */
  153457. onGetDescription: () => string;
  153458. /**
  153459. * Gets a string describing the action executed by the current optimization
  153460. * @returns description string
  153461. */
  153462. getDescription(): string;
  153463. /**
  153464. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153465. * @param scene defines the current scene where to apply this optimization
  153466. * @param optimizer defines the current optimizer
  153467. * @returns true if everything that can be done was applied
  153468. */
  153469. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153470. }
  153471. /**
  153472. * Defines an optimization used to turn particles off
  153473. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153474. */
  153475. export class ParticlesOptimization extends SceneOptimization {
  153476. /**
  153477. * Gets a string describing the action executed by the current optimization
  153478. * @return description string
  153479. */
  153480. getDescription(): string;
  153481. /**
  153482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153483. * @param scene defines the current scene where to apply this optimization
  153484. * @param optimizer defines the current optimizer
  153485. * @returns true if everything that can be done was applied
  153486. */
  153487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153488. }
  153489. /**
  153490. * Defines an optimization used to turn render targets off
  153491. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153492. */
  153493. export class RenderTargetsOptimization extends SceneOptimization {
  153494. /**
  153495. * Gets a string describing the action executed by the current optimization
  153496. * @return description string
  153497. */
  153498. getDescription(): string;
  153499. /**
  153500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153501. * @param scene defines the current scene where to apply this optimization
  153502. * @param optimizer defines the current optimizer
  153503. * @returns true if everything that can be done was applied
  153504. */
  153505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153506. }
  153507. /**
  153508. * Defines an optimization used to merge meshes with compatible materials
  153509. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153510. */
  153511. export class MergeMeshesOptimization extends SceneOptimization {
  153512. private static _UpdateSelectionTree;
  153513. /**
  153514. * Gets or sets a boolean which defines if optimization octree has to be updated
  153515. */
  153516. static get UpdateSelectionTree(): boolean;
  153517. /**
  153518. * Gets or sets a boolean which defines if optimization octree has to be updated
  153519. */
  153520. static set UpdateSelectionTree(value: boolean);
  153521. /**
  153522. * Gets a string describing the action executed by the current optimization
  153523. * @return description string
  153524. */
  153525. getDescription(): string;
  153526. private _canBeMerged;
  153527. /**
  153528. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153529. * @param scene defines the current scene where to apply this optimization
  153530. * @param optimizer defines the current optimizer
  153531. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  153532. * @returns true if everything that can be done was applied
  153533. */
  153534. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  153535. }
  153536. /**
  153537. * Defines a list of options used by SceneOptimizer
  153538. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153539. */
  153540. export class SceneOptimizerOptions {
  153541. /**
  153542. * Defines the target frame rate to reach (60 by default)
  153543. */
  153544. targetFrameRate: number;
  153545. /**
  153546. * Defines the interval between two checkes (2000ms by default)
  153547. */
  153548. trackerDuration: number;
  153549. /**
  153550. * Gets the list of optimizations to apply
  153551. */
  153552. optimizations: SceneOptimization[];
  153553. /**
  153554. * Creates a new list of options used by SceneOptimizer
  153555. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  153556. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  153557. */
  153558. constructor(
  153559. /**
  153560. * Defines the target frame rate to reach (60 by default)
  153561. */
  153562. targetFrameRate?: number,
  153563. /**
  153564. * Defines the interval between two checkes (2000ms by default)
  153565. */
  153566. trackerDuration?: number);
  153567. /**
  153568. * Add a new optimization
  153569. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  153570. * @returns the current SceneOptimizerOptions
  153571. */
  153572. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  153573. /**
  153574. * Add a new custom optimization
  153575. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  153576. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  153577. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153578. * @returns the current SceneOptimizerOptions
  153579. */
  153580. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  153581. /**
  153582. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  153583. * @param targetFrameRate defines the target frame rate (60 by default)
  153584. * @returns a SceneOptimizerOptions object
  153585. */
  153586. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153587. /**
  153588. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  153589. * @param targetFrameRate defines the target frame rate (60 by default)
  153590. * @returns a SceneOptimizerOptions object
  153591. */
  153592. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153593. /**
  153594. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  153595. * @param targetFrameRate defines the target frame rate (60 by default)
  153596. * @returns a SceneOptimizerOptions object
  153597. */
  153598. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153599. }
  153600. /**
  153601. * Class used to run optimizations in order to reach a target frame rate
  153602. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153603. */
  153604. export class SceneOptimizer implements IDisposable {
  153605. private _isRunning;
  153606. private _options;
  153607. private _scene;
  153608. private _currentPriorityLevel;
  153609. private _targetFrameRate;
  153610. private _trackerDuration;
  153611. private _currentFrameRate;
  153612. private _sceneDisposeObserver;
  153613. private _improvementMode;
  153614. /**
  153615. * Defines an observable called when the optimizer reaches the target frame rate
  153616. */
  153617. onSuccessObservable: Observable<SceneOptimizer>;
  153618. /**
  153619. * Defines an observable called when the optimizer enables an optimization
  153620. */
  153621. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  153622. /**
  153623. * Defines an observable called when the optimizer is not able to reach the target frame rate
  153624. */
  153625. onFailureObservable: Observable<SceneOptimizer>;
  153626. /**
  153627. * Gets a boolean indicating if the optimizer is in improvement mode
  153628. */
  153629. get isInImprovementMode(): boolean;
  153630. /**
  153631. * Gets the current priority level (0 at start)
  153632. */
  153633. get currentPriorityLevel(): number;
  153634. /**
  153635. * Gets the current frame rate checked by the SceneOptimizer
  153636. */
  153637. get currentFrameRate(): number;
  153638. /**
  153639. * Gets or sets the current target frame rate (60 by default)
  153640. */
  153641. get targetFrameRate(): number;
  153642. /**
  153643. * Gets or sets the current target frame rate (60 by default)
  153644. */
  153645. set targetFrameRate(value: number);
  153646. /**
  153647. * Gets or sets the current interval between two checks (every 2000ms by default)
  153648. */
  153649. get trackerDuration(): number;
  153650. /**
  153651. * Gets or sets the current interval between two checks (every 2000ms by default)
  153652. */
  153653. set trackerDuration(value: number);
  153654. /**
  153655. * Gets the list of active optimizations
  153656. */
  153657. get optimizations(): SceneOptimization[];
  153658. /**
  153659. * Creates a new SceneOptimizer
  153660. * @param scene defines the scene to work on
  153661. * @param options defines the options to use with the SceneOptimizer
  153662. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  153663. * @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)
  153664. */
  153665. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  153666. /**
  153667. * Stops the current optimizer
  153668. */
  153669. stop(): void;
  153670. /**
  153671. * Reset the optimizer to initial step (current priority level = 0)
  153672. */
  153673. reset(): void;
  153674. /**
  153675. * Start the optimizer. By default it will try to reach a specific framerate
  153676. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  153677. */
  153678. start(): void;
  153679. private _checkCurrentState;
  153680. /**
  153681. * Release all resources
  153682. */
  153683. dispose(): void;
  153684. /**
  153685. * Helper function to create a SceneOptimizer with one single line of code
  153686. * @param scene defines the scene to work on
  153687. * @param options defines the options to use with the SceneOptimizer
  153688. * @param onSuccess defines a callback to call on success
  153689. * @param onFailure defines a callback to call on failure
  153690. * @returns the new SceneOptimizer object
  153691. */
  153692. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  153693. }
  153694. }
  153695. declare module BABYLON {
  153696. /**
  153697. * Class used to serialize a scene into a string
  153698. */
  153699. export class SceneSerializer {
  153700. /**
  153701. * Clear cache used by a previous serialization
  153702. */
  153703. static ClearCache(): void;
  153704. /**
  153705. * Serialize a scene into a JSON compatible object
  153706. * @param scene defines the scene to serialize
  153707. * @returns a JSON compatible object
  153708. */
  153709. static Serialize(scene: Scene): any;
  153710. /**
  153711. * Serialize a mesh into a JSON compatible object
  153712. * @param toSerialize defines the mesh to serialize
  153713. * @param withParents defines if parents must be serialized as well
  153714. * @param withChildren defines if children must be serialized as well
  153715. * @returns a JSON compatible object
  153716. */
  153717. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  153718. }
  153719. }
  153720. declare module BABYLON {
  153721. /**
  153722. * Class used to host texture specific utilities
  153723. */
  153724. export class TextureTools {
  153725. /**
  153726. * Uses the GPU to create a copy texture rescaled at a given size
  153727. * @param texture Texture to copy from
  153728. * @param width defines the desired width
  153729. * @param height defines the desired height
  153730. * @param useBilinearMode defines if bilinear mode has to be used
  153731. * @return the generated texture
  153732. */
  153733. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153734. }
  153735. }
  153736. declare module BABYLON {
  153737. /**
  153738. * This represents the different options available for the video capture.
  153739. */
  153740. export interface VideoRecorderOptions {
  153741. /** Defines the mime type of the video. */
  153742. mimeType: string;
  153743. /** Defines the FPS the video should be recorded at. */
  153744. fps: number;
  153745. /** Defines the chunk size for the recording data. */
  153746. recordChunckSize: number;
  153747. /** The audio tracks to attach to the recording. */
  153748. audioTracks?: MediaStreamTrack[];
  153749. }
  153750. /**
  153751. * This can help with recording videos from BabylonJS.
  153752. * This is based on the available WebRTC functionalities of the browser.
  153753. *
  153754. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153755. */
  153756. export class VideoRecorder {
  153757. private static readonly _defaultOptions;
  153758. /**
  153759. * Returns whether or not the VideoRecorder is available in your browser.
  153760. * @param engine Defines the Babylon Engine.
  153761. * @returns true if supported otherwise false.
  153762. */
  153763. static IsSupported(engine: Engine): boolean;
  153764. private readonly _options;
  153765. private _canvas;
  153766. private _mediaRecorder;
  153767. private _recordedChunks;
  153768. private _fileName;
  153769. private _resolve;
  153770. private _reject;
  153771. /**
  153772. * True when a recording is already in progress.
  153773. */
  153774. get isRecording(): boolean;
  153775. /**
  153776. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  153777. * @param engine Defines the BabylonJS Engine you wish to record.
  153778. * @param options Defines options that can be used to customize the capture.
  153779. */
  153780. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  153781. /**
  153782. * Stops the current recording before the default capture timeout passed in the startRecording function.
  153783. */
  153784. stopRecording(): void;
  153785. /**
  153786. * Starts recording the canvas for a max duration specified in parameters.
  153787. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  153788. * If null no automatic download will start and you can rely on the promise to get the data back.
  153789. * @param maxDuration Defines the maximum recording time in seconds.
  153790. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  153791. * @return A promise callback at the end of the recording with the video data in Blob.
  153792. */
  153793. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  153794. /**
  153795. * Releases internal resources used during the recording.
  153796. */
  153797. dispose(): void;
  153798. private _handleDataAvailable;
  153799. private _handleError;
  153800. private _handleStop;
  153801. }
  153802. }
  153803. declare module BABYLON {
  153804. /**
  153805. * Class containing a set of static utilities functions for screenshots
  153806. */
  153807. export class ScreenshotTools {
  153808. /**
  153809. * Captures a screenshot of the current rendering
  153810. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153811. * @param engine defines the rendering engine
  153812. * @param camera defines the source camera
  153813. * @param size This parameter can be set to a single number or to an object with the
  153814. * following (optional) properties: precision, width, height. If a single number is passed,
  153815. * it will be used for both width and height. If an object is passed, the screenshot size
  153816. * will be derived from the parameters. The precision property is a multiplier allowing
  153817. * rendering at a higher or lower resolution
  153818. * @param successCallback defines the callback receives a single parameter which contains the
  153819. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153820. * src parameter of an <img> to display it
  153821. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153822. * Check your browser for supported MIME types
  153823. */
  153824. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  153825. /**
  153826. * Captures a screenshot of the current rendering
  153827. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153828. * @param engine defines the rendering engine
  153829. * @param camera defines the source camera
  153830. * @param size This parameter can be set to a single number or to an object with the
  153831. * following (optional) properties: precision, width, height. If a single number is passed,
  153832. * it will be used for both width and height. If an object is passed, the screenshot size
  153833. * will be derived from the parameters. The precision property is a multiplier allowing
  153834. * rendering at a higher or lower resolution
  153835. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153836. * Check your browser for supported MIME types
  153837. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153838. * to the src parameter of an <img> to display it
  153839. */
  153840. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  153841. /**
  153842. * Generates an image screenshot from the specified camera.
  153843. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153844. * @param engine The engine to use for rendering
  153845. * @param camera The camera to use for rendering
  153846. * @param size This parameter can be set to a single number or to an object with the
  153847. * following (optional) properties: precision, width, height. If a single number is passed,
  153848. * it will be used for both width and height. If an object is passed, the screenshot size
  153849. * will be derived from the parameters. The precision property is a multiplier allowing
  153850. * rendering at a higher or lower resolution
  153851. * @param successCallback The callback receives a single parameter which contains the
  153852. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153853. * src parameter of an <img> to display it
  153854. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153855. * Check your browser for supported MIME types
  153856. * @param samples Texture samples (default: 1)
  153857. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153858. * @param fileName A name for for the downloaded file.
  153859. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153860. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  153861. */
  153862. 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;
  153863. /**
  153864. * Generates an image screenshot from the specified camera.
  153865. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153866. * @param engine The engine to use for rendering
  153867. * @param camera The camera to use for rendering
  153868. * @param size This parameter can be set to a single number or to an object with the
  153869. * following (optional) properties: precision, width, height. If a single number is passed,
  153870. * it will be used for both width and height. If an object is passed, the screenshot size
  153871. * will be derived from the parameters. The precision property is a multiplier allowing
  153872. * rendering at a higher or lower resolution
  153873. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153874. * Check your browser for supported MIME types
  153875. * @param samples Texture samples (default: 1)
  153876. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153877. * @param fileName A name for for the downloaded file.
  153878. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153879. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153880. * to the src parameter of an <img> to display it
  153881. */
  153882. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  153883. /**
  153884. * Gets height and width for screenshot size
  153885. * @private
  153886. */
  153887. private static _getScreenshotSize;
  153888. }
  153889. }
  153890. declare module BABYLON {
  153891. /**
  153892. * Interface for a data buffer
  153893. */
  153894. export interface IDataBuffer {
  153895. /**
  153896. * Reads bytes from the data buffer.
  153897. * @param byteOffset The byte offset to read
  153898. * @param byteLength The byte length to read
  153899. * @returns A promise that resolves when the bytes are read
  153900. */
  153901. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  153902. /**
  153903. * The byte length of the buffer.
  153904. */
  153905. readonly byteLength: number;
  153906. }
  153907. /**
  153908. * Utility class for reading from a data buffer
  153909. */
  153910. export class DataReader {
  153911. /**
  153912. * The data buffer associated with this data reader.
  153913. */
  153914. readonly buffer: IDataBuffer;
  153915. /**
  153916. * The current byte offset from the beginning of the data buffer.
  153917. */
  153918. byteOffset: number;
  153919. private _dataView;
  153920. private _dataByteOffset;
  153921. /**
  153922. * Constructor
  153923. * @param buffer The buffer to read
  153924. */
  153925. constructor(buffer: IDataBuffer);
  153926. /**
  153927. * Loads the given byte length.
  153928. * @param byteLength The byte length to load
  153929. * @returns A promise that resolves when the load is complete
  153930. */
  153931. loadAsync(byteLength: number): Promise<void>;
  153932. /**
  153933. * Read a unsigned 32-bit integer from the currently loaded data range.
  153934. * @returns The 32-bit integer read
  153935. */
  153936. readUint32(): number;
  153937. /**
  153938. * Read a byte array from the currently loaded data range.
  153939. * @param byteLength The byte length to read
  153940. * @returns The byte array read
  153941. */
  153942. readUint8Array(byteLength: number): Uint8Array;
  153943. /**
  153944. * Read a string from the currently loaded data range.
  153945. * @param byteLength The byte length to read
  153946. * @returns The string read
  153947. */
  153948. readString(byteLength: number): string;
  153949. /**
  153950. * Skips the given byte length the currently loaded data range.
  153951. * @param byteLength The byte length to skip
  153952. */
  153953. skipBytes(byteLength: number): void;
  153954. }
  153955. }
  153956. declare module BABYLON {
  153957. /**
  153958. * Class for storing data to local storage if available or in-memory storage otherwise
  153959. */
  153960. export class DataStorage {
  153961. private static _Storage;
  153962. private static _GetStorage;
  153963. /**
  153964. * Reads a string from the data storage
  153965. * @param key The key to read
  153966. * @param defaultValue The value if the key doesn't exist
  153967. * @returns The string value
  153968. */
  153969. static ReadString(key: string, defaultValue: string): string;
  153970. /**
  153971. * Writes a string to the data storage
  153972. * @param key The key to write
  153973. * @param value The value to write
  153974. */
  153975. static WriteString(key: string, value: string): void;
  153976. /**
  153977. * Reads a boolean from the data storage
  153978. * @param key The key to read
  153979. * @param defaultValue The value if the key doesn't exist
  153980. * @returns The boolean value
  153981. */
  153982. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  153983. /**
  153984. * Writes a boolean to the data storage
  153985. * @param key The key to write
  153986. * @param value The value to write
  153987. */
  153988. static WriteBoolean(key: string, value: boolean): void;
  153989. /**
  153990. * Reads a number from the data storage
  153991. * @param key The key to read
  153992. * @param defaultValue The value if the key doesn't exist
  153993. * @returns The number value
  153994. */
  153995. static ReadNumber(key: string, defaultValue: number): number;
  153996. /**
  153997. * Writes a number to the data storage
  153998. * @param key The key to write
  153999. * @param value The value to write
  154000. */
  154001. static WriteNumber(key: string, value: number): void;
  154002. }
  154003. }
  154004. declare module BABYLON {
  154005. /**
  154006. * Class used to record delta files between 2 scene states
  154007. */
  154008. export class SceneRecorder {
  154009. private _trackedScene;
  154010. private _savedJSON;
  154011. /**
  154012. * Track a given scene. This means the current scene state will be considered the original state
  154013. * @param scene defines the scene to track
  154014. */
  154015. track(scene: Scene): void;
  154016. /**
  154017. * Get the delta between current state and original state
  154018. * @returns a string containing the delta
  154019. */
  154020. getDelta(): any;
  154021. private _compareArray;
  154022. private _compareObjects;
  154023. private _compareCollections;
  154024. private static GetShadowGeneratorById;
  154025. /**
  154026. * Apply a given delta to a given scene
  154027. * @param deltaJSON defines the JSON containing the delta
  154028. * @param scene defines the scene to apply the delta to
  154029. */
  154030. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154031. private static _ApplyPropertiesToEntity;
  154032. private static _ApplyDeltaForEntity;
  154033. }
  154034. }
  154035. declare module BABYLON {
  154036. /**
  154037. * An interface for all Hit test features
  154038. */
  154039. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  154040. /**
  154041. * Triggered when new babylon (transformed) hit test results are available
  154042. */
  154043. onHitTestResultObservable: Observable<T[]>;
  154044. }
  154045. /**
  154046. * Options used for hit testing
  154047. */
  154048. export interface IWebXRLegacyHitTestOptions {
  154049. /**
  154050. * Only test when user interacted with the scene. Default - hit test every frame
  154051. */
  154052. testOnPointerDownOnly?: boolean;
  154053. /**
  154054. * The node to use to transform the local results to world coordinates
  154055. */
  154056. worldParentNode?: TransformNode;
  154057. }
  154058. /**
  154059. * Interface defining the babylon result of raycasting/hit-test
  154060. */
  154061. export interface IWebXRLegacyHitResult {
  154062. /**
  154063. * Transformation matrix that can be applied to a node that will put it in the hit point location
  154064. */
  154065. transformationMatrix: Matrix;
  154066. /**
  154067. * The native hit test result
  154068. */
  154069. xrHitResult: XRHitResult | XRHitTestResult;
  154070. }
  154071. /**
  154072. * The currently-working hit-test module.
  154073. * Hit test (or Ray-casting) is used to interact with the real world.
  154074. * For further information read here - https://github.com/immersive-web/hit-test
  154075. */
  154076. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  154077. /**
  154078. * options to use when constructing this feature
  154079. */
  154080. readonly options: IWebXRLegacyHitTestOptions;
  154081. private _direction;
  154082. private _mat;
  154083. private _onSelectEnabled;
  154084. private _origin;
  154085. /**
  154086. * The module's name
  154087. */
  154088. static readonly Name: string;
  154089. /**
  154090. * The (Babylon) version of this module.
  154091. * This is an integer representing the implementation version.
  154092. * This number does not correspond to the WebXR specs version
  154093. */
  154094. static readonly Version: number;
  154095. /**
  154096. * Populated with the last native XR Hit Results
  154097. */
  154098. lastNativeXRHitResults: XRHitResult[];
  154099. /**
  154100. * Triggered when new babylon (transformed) hit test results are available
  154101. */
  154102. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  154103. /**
  154104. * Creates a new instance of the (legacy version) hit test feature
  154105. * @param _xrSessionManager an instance of WebXRSessionManager
  154106. * @param options options to use when constructing this feature
  154107. */
  154108. constructor(_xrSessionManager: WebXRSessionManager,
  154109. /**
  154110. * options to use when constructing this feature
  154111. */
  154112. options?: IWebXRLegacyHitTestOptions);
  154113. /**
  154114. * execute a hit test with an XR Ray
  154115. *
  154116. * @param xrSession a native xrSession that will execute this hit test
  154117. * @param xrRay the ray (position and direction) to use for ray-casting
  154118. * @param referenceSpace native XR reference space to use for the hit-test
  154119. * @param filter filter function that will filter the results
  154120. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154121. */
  154122. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  154123. /**
  154124. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  154125. * @param event the (select) event to use to select with
  154126. * @param referenceSpace the reference space to use for this hit test
  154127. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154128. */
  154129. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154130. /**
  154131. * attach this feature
  154132. * Will usually be called by the features manager
  154133. *
  154134. * @returns true if successful.
  154135. */
  154136. attach(): boolean;
  154137. /**
  154138. * detach this feature.
  154139. * Will usually be called by the features manager
  154140. *
  154141. * @returns true if successful.
  154142. */
  154143. detach(): boolean;
  154144. /**
  154145. * Dispose this feature and all of the resources attached
  154146. */
  154147. dispose(): void;
  154148. protected _onXRFrame(frame: XRFrame): void;
  154149. private _onHitTestResults;
  154150. private _onSelect;
  154151. }
  154152. }
  154153. declare module BABYLON {
  154154. /**
  154155. * Options used for hit testing (version 2)
  154156. */
  154157. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  154158. /**
  154159. * Do not create a permanent hit test. Will usually be used when only
  154160. * transient inputs are needed.
  154161. */
  154162. disablePermanentHitTest?: boolean;
  154163. /**
  154164. * Enable transient (for example touch-based) hit test inspections
  154165. */
  154166. enableTransientHitTest?: boolean;
  154167. /**
  154168. * Offset ray for the permanent hit test
  154169. */
  154170. offsetRay?: Vector3;
  154171. /**
  154172. * Offset ray for the transient hit test
  154173. */
  154174. transientOffsetRay?: Vector3;
  154175. /**
  154176. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  154177. */
  154178. useReferenceSpace?: boolean;
  154179. /**
  154180. * Override the default entity type(s) of the hit-test result
  154181. */
  154182. entityTypes?: XRHitTestTrackableType[];
  154183. }
  154184. /**
  154185. * Interface defining the babylon result of hit-test
  154186. */
  154187. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  154188. /**
  154189. * The input source that generated this hit test (if transient)
  154190. */
  154191. inputSource?: XRInputSource;
  154192. /**
  154193. * Is this a transient hit test
  154194. */
  154195. isTransient?: boolean;
  154196. /**
  154197. * Position of the hit test result
  154198. */
  154199. position: Vector3;
  154200. /**
  154201. * Rotation of the hit test result
  154202. */
  154203. rotationQuaternion: Quaternion;
  154204. /**
  154205. * The native hit test result
  154206. */
  154207. xrHitResult: XRHitTestResult;
  154208. }
  154209. /**
  154210. * The currently-working hit-test module.
  154211. * Hit test (or Ray-casting) is used to interact with the real world.
  154212. * For further information read here - https://github.com/immersive-web/hit-test
  154213. *
  154214. * Tested on chrome (mobile) 80.
  154215. */
  154216. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  154217. /**
  154218. * options to use when constructing this feature
  154219. */
  154220. readonly options: IWebXRHitTestOptions;
  154221. private _tmpMat;
  154222. private _tmpPos;
  154223. private _tmpQuat;
  154224. private _transientXrHitTestSource;
  154225. private _xrHitTestSource;
  154226. private initHitTestSource;
  154227. /**
  154228. * The module's name
  154229. */
  154230. static readonly Name: string;
  154231. /**
  154232. * The (Babylon) version of this module.
  154233. * This is an integer representing the implementation version.
  154234. * This number does not correspond to the WebXR specs version
  154235. */
  154236. static readonly Version: number;
  154237. /**
  154238. * When set to true, each hit test will have its own position/rotation objects
  154239. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  154240. * the developers will clone them or copy them as they see fit.
  154241. */
  154242. autoCloneTransformation: boolean;
  154243. /**
  154244. * Triggered when new babylon (transformed) hit test results are available
  154245. */
  154246. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  154247. /**
  154248. * Use this to temporarily pause hit test checks.
  154249. */
  154250. paused: boolean;
  154251. /**
  154252. * Creates a new instance of the hit test feature
  154253. * @param _xrSessionManager an instance of WebXRSessionManager
  154254. * @param options options to use when constructing this feature
  154255. */
  154256. constructor(_xrSessionManager: WebXRSessionManager,
  154257. /**
  154258. * options to use when constructing this feature
  154259. */
  154260. options?: IWebXRHitTestOptions);
  154261. /**
  154262. * attach this feature
  154263. * Will usually be called by the features manager
  154264. *
  154265. * @returns true if successful.
  154266. */
  154267. attach(): boolean;
  154268. /**
  154269. * detach this feature.
  154270. * Will usually be called by the features manager
  154271. *
  154272. * @returns true if successful.
  154273. */
  154274. detach(): boolean;
  154275. /**
  154276. * Dispose this feature and all of the resources attached
  154277. */
  154278. dispose(): void;
  154279. protected _onXRFrame(frame: XRFrame): void;
  154280. private _processWebXRHitTestResult;
  154281. }
  154282. }
  154283. declare module BABYLON {
  154284. /**
  154285. * Configuration options of the anchor system
  154286. */
  154287. export interface IWebXRAnchorSystemOptions {
  154288. /**
  154289. * a node that will be used to convert local to world coordinates
  154290. */
  154291. worldParentNode?: TransformNode;
  154292. /**
  154293. * If set to true a reference of the created anchors will be kept until the next session starts
  154294. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  154295. */
  154296. doNotRemoveAnchorsOnSessionEnded?: boolean;
  154297. }
  154298. /**
  154299. * A babylon container for an XR Anchor
  154300. */
  154301. export interface IWebXRAnchor {
  154302. /**
  154303. * A babylon-assigned ID for this anchor
  154304. */
  154305. id: number;
  154306. /**
  154307. * Transformation matrix to apply to an object attached to this anchor
  154308. */
  154309. transformationMatrix: Matrix;
  154310. /**
  154311. * The native anchor object
  154312. */
  154313. xrAnchor: XRAnchor;
  154314. /**
  154315. * if defined, this object will be constantly updated by the anchor's position and rotation
  154316. */
  154317. attachedNode?: TransformNode;
  154318. }
  154319. /**
  154320. * An implementation of the anchor system for WebXR.
  154321. * For further information see https://github.com/immersive-web/anchors/
  154322. */
  154323. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  154324. private _options;
  154325. private _lastFrameDetected;
  154326. private _trackedAnchors;
  154327. private _referenceSpaceForFrameAnchors;
  154328. private _futureAnchors;
  154329. /**
  154330. * The module's name
  154331. */
  154332. static readonly Name: string;
  154333. /**
  154334. * The (Babylon) version of this module.
  154335. * This is an integer representing the implementation version.
  154336. * This number does not correspond to the WebXR specs version
  154337. */
  154338. static readonly Version: number;
  154339. /**
  154340. * Observers registered here will be executed when a new anchor was added to the session
  154341. */
  154342. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  154343. /**
  154344. * Observers registered here will be executed when an anchor was removed from the session
  154345. */
  154346. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  154347. /**
  154348. * Observers registered here will be executed when an existing anchor updates
  154349. * This can execute N times every frame
  154350. */
  154351. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  154352. /**
  154353. * Set the reference space to use for anchor creation, when not using a hit test.
  154354. * Will default to the session's reference space if not defined
  154355. */
  154356. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  154357. /**
  154358. * constructs a new anchor system
  154359. * @param _xrSessionManager an instance of WebXRSessionManager
  154360. * @param _options configuration object for this feature
  154361. */
  154362. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  154363. private _tmpVector;
  154364. private _tmpQuaternion;
  154365. private _populateTmpTransformation;
  154366. /**
  154367. * Create a new anchor point using a hit test result at a specific point in the scene
  154368. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154369. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154370. *
  154371. * @param hitTestResult The hit test result to use for this anchor creation
  154372. * @param position an optional position offset for this anchor
  154373. * @param rotationQuaternion an optional rotation offset for this anchor
  154374. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154375. */
  154376. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  154377. /**
  154378. * Add a new anchor at a specific position and rotation
  154379. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  154380. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  154381. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154382. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154383. *
  154384. * @param position the position in which to add an anchor
  154385. * @param rotationQuaternion an optional rotation for the anchor transformation
  154386. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  154387. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154388. */
  154389. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  154390. /**
  154391. * detach this feature.
  154392. * Will usually be called by the features manager
  154393. *
  154394. * @returns true if successful.
  154395. */
  154396. detach(): boolean;
  154397. /**
  154398. * Dispose this feature and all of the resources attached
  154399. */
  154400. dispose(): void;
  154401. protected _onXRFrame(frame: XRFrame): void;
  154402. /**
  154403. * avoiding using Array.find for global support.
  154404. * @param xrAnchor the plane to find in the array
  154405. */
  154406. private _findIndexInAnchorArray;
  154407. private _updateAnchorWithXRFrame;
  154408. private _createAnchorAtTransformation;
  154409. }
  154410. }
  154411. declare module BABYLON {
  154412. /**
  154413. * Options used in the plane detector module
  154414. */
  154415. export interface IWebXRPlaneDetectorOptions {
  154416. /**
  154417. * The node to use to transform the local results to world coordinates
  154418. */
  154419. worldParentNode?: TransformNode;
  154420. /**
  154421. * If set to true a reference of the created planes will be kept until the next session starts
  154422. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  154423. */
  154424. doNotRemovePlanesOnSessionEnded?: boolean;
  154425. }
  154426. /**
  154427. * A babylon interface for a WebXR plane.
  154428. * A Plane is actually a polygon, built from N points in space
  154429. *
  154430. * Supported in chrome 79, not supported in canary 81 ATM
  154431. */
  154432. export interface IWebXRPlane {
  154433. /**
  154434. * a babylon-assigned ID for this polygon
  154435. */
  154436. id: number;
  154437. /**
  154438. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  154439. */
  154440. polygonDefinition: Array<Vector3>;
  154441. /**
  154442. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  154443. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  154444. */
  154445. transformationMatrix: Matrix;
  154446. /**
  154447. * the native xr-plane object
  154448. */
  154449. xrPlane: XRPlane;
  154450. }
  154451. /**
  154452. * The plane detector is used to detect planes in the real world when in AR
  154453. * For more information see https://github.com/immersive-web/real-world-geometry/
  154454. */
  154455. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  154456. private _options;
  154457. private _detectedPlanes;
  154458. private _enabled;
  154459. private _lastFrameDetected;
  154460. /**
  154461. * The module's name
  154462. */
  154463. static readonly Name: string;
  154464. /**
  154465. * The (Babylon) version of this module.
  154466. * This is an integer representing the implementation version.
  154467. * This number does not correspond to the WebXR specs version
  154468. */
  154469. static readonly Version: number;
  154470. /**
  154471. * Observers registered here will be executed when a new plane was added to the session
  154472. */
  154473. onPlaneAddedObservable: Observable<IWebXRPlane>;
  154474. /**
  154475. * Observers registered here will be executed when a plane is no longer detected in the session
  154476. */
  154477. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  154478. /**
  154479. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  154480. * This can execute N times every frame
  154481. */
  154482. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  154483. /**
  154484. * construct a new Plane Detector
  154485. * @param _xrSessionManager an instance of xr Session manager
  154486. * @param _options configuration to use when constructing this feature
  154487. */
  154488. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  154489. /**
  154490. * detach this feature.
  154491. * Will usually be called by the features manager
  154492. *
  154493. * @returns true if successful.
  154494. */
  154495. detach(): boolean;
  154496. /**
  154497. * Dispose this feature and all of the resources attached
  154498. */
  154499. dispose(): void;
  154500. protected _onXRFrame(frame: XRFrame): void;
  154501. private _init;
  154502. private _updatePlaneWithXRPlane;
  154503. /**
  154504. * avoiding using Array.find for global support.
  154505. * @param xrPlane the plane to find in the array
  154506. */
  154507. private findIndexInPlaneArray;
  154508. }
  154509. }
  154510. declare module BABYLON {
  154511. /**
  154512. * Options interface for the background remover plugin
  154513. */
  154514. export interface IWebXRBackgroundRemoverOptions {
  154515. /**
  154516. * Further background meshes to disable when entering AR
  154517. */
  154518. backgroundMeshes?: AbstractMesh[];
  154519. /**
  154520. * flags to configure the removal of the environment helper.
  154521. * If not set, the entire background will be removed. If set, flags should be set as well.
  154522. */
  154523. environmentHelperRemovalFlags?: {
  154524. /**
  154525. * Should the skybox be removed (default false)
  154526. */
  154527. skyBox?: boolean;
  154528. /**
  154529. * Should the ground be removed (default false)
  154530. */
  154531. ground?: boolean;
  154532. };
  154533. /**
  154534. * don't disable the environment helper
  154535. */
  154536. ignoreEnvironmentHelper?: boolean;
  154537. }
  154538. /**
  154539. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  154540. */
  154541. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  154542. /**
  154543. * read-only options to be used in this module
  154544. */
  154545. readonly options: IWebXRBackgroundRemoverOptions;
  154546. /**
  154547. * The module's name
  154548. */
  154549. static readonly Name: string;
  154550. /**
  154551. * The (Babylon) version of this module.
  154552. * This is an integer representing the implementation version.
  154553. * This number does not correspond to the WebXR specs version
  154554. */
  154555. static readonly Version: number;
  154556. /**
  154557. * registered observers will be triggered when the background state changes
  154558. */
  154559. onBackgroundStateChangedObservable: Observable<boolean>;
  154560. /**
  154561. * constructs a new background remover module
  154562. * @param _xrSessionManager the session manager for this module
  154563. * @param options read-only options to be used in this module
  154564. */
  154565. constructor(_xrSessionManager: WebXRSessionManager,
  154566. /**
  154567. * read-only options to be used in this module
  154568. */
  154569. options?: IWebXRBackgroundRemoverOptions);
  154570. /**
  154571. * attach this feature
  154572. * Will usually be called by the features manager
  154573. *
  154574. * @returns true if successful.
  154575. */
  154576. attach(): boolean;
  154577. /**
  154578. * detach this feature.
  154579. * Will usually be called by the features manager
  154580. *
  154581. * @returns true if successful.
  154582. */
  154583. detach(): boolean;
  154584. /**
  154585. * Dispose this feature and all of the resources attached
  154586. */
  154587. dispose(): void;
  154588. protected _onXRFrame(_xrFrame: XRFrame): void;
  154589. private _setBackgroundState;
  154590. }
  154591. }
  154592. declare module BABYLON {
  154593. /**
  154594. * Options for the controller physics feature
  154595. */
  154596. export class IWebXRControllerPhysicsOptions {
  154597. /**
  154598. * Should the headset get its own impostor
  154599. */
  154600. enableHeadsetImpostor?: boolean;
  154601. /**
  154602. * Optional parameters for the headset impostor
  154603. */
  154604. headsetImpostorParams?: {
  154605. /**
  154606. * The type of impostor to create. Default is sphere
  154607. */
  154608. impostorType: number;
  154609. /**
  154610. * the size of the impostor. Defaults to 10cm
  154611. */
  154612. impostorSize?: number | {
  154613. width: number;
  154614. height: number;
  154615. depth: number;
  154616. };
  154617. /**
  154618. * Friction definitions
  154619. */
  154620. friction?: number;
  154621. /**
  154622. * Restitution
  154623. */
  154624. restitution?: number;
  154625. };
  154626. /**
  154627. * The physics properties of the future impostors
  154628. */
  154629. physicsProperties?: {
  154630. /**
  154631. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  154632. * Note that this requires a physics engine that supports mesh impostors!
  154633. */
  154634. useControllerMesh?: boolean;
  154635. /**
  154636. * The type of impostor to create. Default is sphere
  154637. */
  154638. impostorType?: number;
  154639. /**
  154640. * the size of the impostor. Defaults to 10cm
  154641. */
  154642. impostorSize?: number | {
  154643. width: number;
  154644. height: number;
  154645. depth: number;
  154646. };
  154647. /**
  154648. * Friction definitions
  154649. */
  154650. friction?: number;
  154651. /**
  154652. * Restitution
  154653. */
  154654. restitution?: number;
  154655. };
  154656. /**
  154657. * the xr input to use with this pointer selection
  154658. */
  154659. xrInput: WebXRInput;
  154660. }
  154661. /**
  154662. * Add physics impostor to your webxr controllers,
  154663. * including naive calculation of their linear and angular velocity
  154664. */
  154665. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  154666. private readonly _options;
  154667. private _attachController;
  154668. private _controllers;
  154669. private _debugMode;
  154670. private _delta;
  154671. private _headsetImpostor?;
  154672. private _headsetMesh?;
  154673. private _lastTimestamp;
  154674. private _tmpQuaternion;
  154675. private _tmpVector;
  154676. /**
  154677. * The module's name
  154678. */
  154679. static readonly Name: string;
  154680. /**
  154681. * The (Babylon) version of this module.
  154682. * This is an integer representing the implementation version.
  154683. * This number does not correspond to the webxr specs version
  154684. */
  154685. static readonly Version: number;
  154686. /**
  154687. * Construct a new Controller Physics Feature
  154688. * @param _xrSessionManager the corresponding xr session manager
  154689. * @param _options options to create this feature with
  154690. */
  154691. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  154692. /**
  154693. * @hidden
  154694. * enable debugging - will show console outputs and the impostor mesh
  154695. */
  154696. _enablePhysicsDebug(): void;
  154697. /**
  154698. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  154699. * @param xrController the controller to add
  154700. */
  154701. addController(xrController: WebXRInputSource): void;
  154702. /**
  154703. * attach this feature
  154704. * Will usually be called by the features manager
  154705. *
  154706. * @returns true if successful.
  154707. */
  154708. attach(): boolean;
  154709. /**
  154710. * detach this feature.
  154711. * Will usually be called by the features manager
  154712. *
  154713. * @returns true if successful.
  154714. */
  154715. detach(): boolean;
  154716. /**
  154717. * Get the headset impostor, if enabled
  154718. * @returns the impostor
  154719. */
  154720. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154721. /**
  154722. * Get the physics impostor of a specific controller.
  154723. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154724. * @param controller the controller or the controller id of which to get the impostor
  154725. * @returns the impostor or null
  154726. */
  154727. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154728. /**
  154729. * Update the physics properties provided in the constructor
  154730. * @param newProperties the new properties object
  154731. */
  154732. setPhysicsProperties(newProperties: {
  154733. impostorType?: number;
  154734. impostorSize?: number | {
  154735. width: number;
  154736. height: number;
  154737. depth: number;
  154738. };
  154739. friction?: number;
  154740. restitution?: number;
  154741. }): void;
  154742. protected _onXRFrame(_xrFrame: any): void;
  154743. private _detachController;
  154744. }
  154745. }
  154746. declare module BABYLON {
  154747. /**
  154748. * A babylon interface for a "WebXR" feature point.
  154749. * Represents the position and confidence value of a given feature point.
  154750. */
  154751. export interface IWebXRFeaturePoint {
  154752. /**
  154753. * Represents the position of the feature point in world space.
  154754. */
  154755. position: Vector3;
  154756. /**
  154757. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  154758. */
  154759. confidenceValue: number;
  154760. }
  154761. /**
  154762. * The feature point system is used to detect feature points from real world geometry.
  154763. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  154764. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  154765. */
  154766. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  154767. private _enabled;
  154768. private _featurePointCloud;
  154769. /**
  154770. * The module's name
  154771. */
  154772. static readonly Name: string;
  154773. /**
  154774. * The (Babylon) version of this module.
  154775. * This is an integer representing the implementation version.
  154776. * This number does not correspond to the WebXR specs version
  154777. */
  154778. static readonly Version: number;
  154779. /**
  154780. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  154781. * Will notify the observers about which feature points have been added.
  154782. */
  154783. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  154784. /**
  154785. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  154786. * Will notify the observers about which feature points have been updated.
  154787. */
  154788. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  154789. /**
  154790. * The current feature point cloud maintained across frames.
  154791. */
  154792. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  154793. /**
  154794. * construct the feature point system
  154795. * @param _xrSessionManager an instance of xr Session manager
  154796. */
  154797. constructor(_xrSessionManager: WebXRSessionManager);
  154798. /**
  154799. * Detach this feature.
  154800. * Will usually be called by the features manager
  154801. *
  154802. * @returns true if successful.
  154803. */
  154804. detach(): boolean;
  154805. /**
  154806. * Dispose this feature and all of the resources attached
  154807. */
  154808. dispose(): void;
  154809. /**
  154810. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  154811. */
  154812. protected _onXRFrame(frame: XRFrame): void;
  154813. /**
  154814. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  154815. */
  154816. private _init;
  154817. }
  154818. }
  154819. declare module BABYLON {
  154820. /**
  154821. * Configuration interface for the hand tracking feature
  154822. */
  154823. export interface IWebXRHandTrackingOptions {
  154824. /**
  154825. * The xrInput that will be used as source for new hands
  154826. */
  154827. xrInput: WebXRInput;
  154828. /**
  154829. * Configuration object for the joint meshes
  154830. */
  154831. jointMeshes?: {
  154832. /**
  154833. * Should the meshes created be invisible (defaults to false)
  154834. */
  154835. invisible?: boolean;
  154836. /**
  154837. * A source mesh to be used to create instances. Defaults to a sphere.
  154838. * This mesh will be the source for all other (25) meshes.
  154839. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  154840. */
  154841. sourceMesh?: Mesh;
  154842. /**
  154843. * Should the source mesh stay visible. Defaults to false
  154844. */
  154845. keepOriginalVisible?: boolean;
  154846. /**
  154847. * Scale factor for all instances (defaults to 2)
  154848. */
  154849. scaleFactor?: number;
  154850. /**
  154851. * Should each instance have its own physics impostor
  154852. */
  154853. enablePhysics?: boolean;
  154854. /**
  154855. * If enabled, override default physics properties
  154856. */
  154857. physicsProps?: {
  154858. friction?: number;
  154859. restitution?: number;
  154860. impostorType?: number;
  154861. };
  154862. /**
  154863. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  154864. */
  154865. handMesh?: AbstractMesh;
  154866. };
  154867. }
  154868. /**
  154869. * Parts of the hands divided to writs and finger names
  154870. */
  154871. export const enum HandPart {
  154872. /**
  154873. * HandPart - Wrist
  154874. */
  154875. WRIST = "wrist",
  154876. /**
  154877. * HandPart - The THumb
  154878. */
  154879. THUMB = "thumb",
  154880. /**
  154881. * HandPart - Index finger
  154882. */
  154883. INDEX = "index",
  154884. /**
  154885. * HandPart - Middle finger
  154886. */
  154887. MIDDLE = "middle",
  154888. /**
  154889. * HandPart - Ring finger
  154890. */
  154891. RING = "ring",
  154892. /**
  154893. * HandPart - Little finger
  154894. */
  154895. LITTLE = "little"
  154896. }
  154897. /**
  154898. * Representing a single hand (with its corresponding native XRHand object)
  154899. */
  154900. export class WebXRHand implements IDisposable {
  154901. /** the controller to which the hand correlates */
  154902. readonly xrController: WebXRInputSource;
  154903. /** the meshes to be used to track the hand joints */
  154904. readonly trackedMeshes: AbstractMesh[];
  154905. /**
  154906. * Hand-parts definition (key is HandPart)
  154907. */
  154908. handPartsDefinition: {
  154909. [key: string]: number[];
  154910. };
  154911. /**
  154912. * Populate the HandPartsDefinition object.
  154913. * This is called as a side effect since certain browsers don't have XRHand defined.
  154914. */
  154915. private generateHandPartsDefinition;
  154916. /**
  154917. * Construct a new hand object
  154918. * @param xrController the controller to which the hand correlates
  154919. * @param trackedMeshes the meshes to be used to track the hand joints
  154920. */
  154921. constructor(
  154922. /** the controller to which the hand correlates */
  154923. xrController: WebXRInputSource,
  154924. /** the meshes to be used to track the hand joints */
  154925. trackedMeshes: AbstractMesh[]);
  154926. /**
  154927. * Update this hand from the latest xr frame
  154928. * @param xrFrame xrFrame to update from
  154929. * @param referenceSpace The current viewer reference space
  154930. * @param scaleFactor optional scale factor for the meshes
  154931. */
  154932. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  154933. /**
  154934. * Get meshes of part of the hand
  154935. * @param part the part of hand to get
  154936. * @returns An array of meshes that correlate to the hand part requested
  154937. */
  154938. getHandPartMeshes(part: HandPart): AbstractMesh[];
  154939. /**
  154940. * Dispose this Hand object
  154941. */
  154942. dispose(): void;
  154943. }
  154944. /**
  154945. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  154946. */
  154947. export class WebXRHandTracking extends WebXRAbstractFeature {
  154948. /**
  154949. * options to use when constructing this feature
  154950. */
  154951. readonly options: IWebXRHandTrackingOptions;
  154952. private static _idCounter;
  154953. /**
  154954. * The module's name
  154955. */
  154956. static readonly Name: string;
  154957. /**
  154958. * The (Babylon) version of this module.
  154959. * This is an integer representing the implementation version.
  154960. * This number does not correspond to the WebXR specs version
  154961. */
  154962. static readonly Version: number;
  154963. /**
  154964. * This observable will notify registered observers when a new hand object was added and initialized
  154965. */
  154966. onHandAddedObservable: Observable<WebXRHand>;
  154967. /**
  154968. * This observable will notify its observers right before the hand object is disposed
  154969. */
  154970. onHandRemovedObservable: Observable<WebXRHand>;
  154971. private _hands;
  154972. /**
  154973. * Creates a new instance of the hit test feature
  154974. * @param _xrSessionManager an instance of WebXRSessionManager
  154975. * @param options options to use when constructing this feature
  154976. */
  154977. constructor(_xrSessionManager: WebXRSessionManager,
  154978. /**
  154979. * options to use when constructing this feature
  154980. */
  154981. options: IWebXRHandTrackingOptions);
  154982. /**
  154983. * Check if the needed objects are defined.
  154984. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  154985. */
  154986. isCompatible(): boolean;
  154987. /**
  154988. * attach this feature
  154989. * Will usually be called by the features manager
  154990. *
  154991. * @returns true if successful.
  154992. */
  154993. attach(): boolean;
  154994. /**
  154995. * detach this feature.
  154996. * Will usually be called by the features manager
  154997. *
  154998. * @returns true if successful.
  154999. */
  155000. detach(): boolean;
  155001. /**
  155002. * Dispose this feature and all of the resources attached
  155003. */
  155004. dispose(): void;
  155005. /**
  155006. * Get the hand object according to the controller id
  155007. * @param controllerId the controller id to which we want to get the hand
  155008. * @returns null if not found or the WebXRHand object if found
  155009. */
  155010. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155011. /**
  155012. * Get a hand object according to the requested handedness
  155013. * @param handedness the handedness to request
  155014. * @returns null if not found or the WebXRHand object if found
  155015. */
  155016. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  155017. protected _onXRFrame(_xrFrame: XRFrame): void;
  155018. private _attachHand;
  155019. private _detachHand;
  155020. }
  155021. }
  155022. declare module BABYLON {
  155023. /**
  155024. * The motion controller class for all microsoft mixed reality controllers
  155025. */
  155026. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  155027. protected readonly _mapping: {
  155028. defaultButton: {
  155029. valueNodeName: string;
  155030. unpressedNodeName: string;
  155031. pressedNodeName: string;
  155032. };
  155033. defaultAxis: {
  155034. valueNodeName: string;
  155035. minNodeName: string;
  155036. maxNodeName: string;
  155037. };
  155038. buttons: {
  155039. "xr-standard-trigger": {
  155040. rootNodeName: string;
  155041. componentProperty: string;
  155042. states: string[];
  155043. };
  155044. "xr-standard-squeeze": {
  155045. rootNodeName: string;
  155046. componentProperty: string;
  155047. states: string[];
  155048. };
  155049. "xr-standard-touchpad": {
  155050. rootNodeName: string;
  155051. labelAnchorNodeName: string;
  155052. touchPointNodeName: string;
  155053. };
  155054. "xr-standard-thumbstick": {
  155055. rootNodeName: string;
  155056. componentProperty: string;
  155057. states: string[];
  155058. };
  155059. };
  155060. axes: {
  155061. "xr-standard-touchpad": {
  155062. "x-axis": {
  155063. rootNodeName: string;
  155064. };
  155065. "y-axis": {
  155066. rootNodeName: string;
  155067. };
  155068. };
  155069. "xr-standard-thumbstick": {
  155070. "x-axis": {
  155071. rootNodeName: string;
  155072. };
  155073. "y-axis": {
  155074. rootNodeName: string;
  155075. };
  155076. };
  155077. };
  155078. };
  155079. /**
  155080. * The base url used to load the left and right controller models
  155081. */
  155082. static MODEL_BASE_URL: string;
  155083. /**
  155084. * The name of the left controller model file
  155085. */
  155086. static MODEL_LEFT_FILENAME: string;
  155087. /**
  155088. * The name of the right controller model file
  155089. */
  155090. static MODEL_RIGHT_FILENAME: string;
  155091. profileId: string;
  155092. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155093. protected _getFilenameAndPath(): {
  155094. filename: string;
  155095. path: string;
  155096. };
  155097. protected _getModelLoadingConstraints(): boolean;
  155098. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155099. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155100. protected _updateModel(): void;
  155101. }
  155102. }
  155103. declare module BABYLON {
  155104. /**
  155105. * The motion controller class for oculus touch (quest, rift).
  155106. * This class supports legacy mapping as well the standard xr mapping
  155107. */
  155108. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  155109. private _forceLegacyControllers;
  155110. private _modelRootNode;
  155111. /**
  155112. * The base url used to load the left and right controller models
  155113. */
  155114. static MODEL_BASE_URL: string;
  155115. /**
  155116. * The name of the left controller model file
  155117. */
  155118. static MODEL_LEFT_FILENAME: string;
  155119. /**
  155120. * The name of the right controller model file
  155121. */
  155122. static MODEL_RIGHT_FILENAME: string;
  155123. /**
  155124. * Base Url for the Quest controller model.
  155125. */
  155126. static QUEST_MODEL_BASE_URL: string;
  155127. profileId: string;
  155128. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  155129. protected _getFilenameAndPath(): {
  155130. filename: string;
  155131. path: string;
  155132. };
  155133. protected _getModelLoadingConstraints(): boolean;
  155134. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155135. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155136. protected _updateModel(): void;
  155137. /**
  155138. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  155139. * between the touch and touch 2.
  155140. */
  155141. private _isQuest;
  155142. }
  155143. }
  155144. declare module BABYLON {
  155145. /**
  155146. * The motion controller class for the standard HTC-Vive controllers
  155147. */
  155148. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  155149. private _modelRootNode;
  155150. /**
  155151. * The base url used to load the left and right controller models
  155152. */
  155153. static MODEL_BASE_URL: string;
  155154. /**
  155155. * File name for the controller model.
  155156. */
  155157. static MODEL_FILENAME: string;
  155158. profileId: string;
  155159. /**
  155160. * Create a new Vive motion controller object
  155161. * @param scene the scene to use to create this controller
  155162. * @param gamepadObject the corresponding gamepad object
  155163. * @param handedness the handedness of the controller
  155164. */
  155165. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155166. protected _getFilenameAndPath(): {
  155167. filename: string;
  155168. path: string;
  155169. };
  155170. protected _getModelLoadingConstraints(): boolean;
  155171. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155172. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155173. protected _updateModel(): void;
  155174. }
  155175. }
  155176. declare module BABYLON {
  155177. /**
  155178. * A cursor which tracks a point on a path
  155179. */
  155180. export class PathCursor {
  155181. private path;
  155182. /**
  155183. * Stores path cursor callbacks for when an onchange event is triggered
  155184. */
  155185. private _onchange;
  155186. /**
  155187. * The value of the path cursor
  155188. */
  155189. value: number;
  155190. /**
  155191. * The animation array of the path cursor
  155192. */
  155193. animations: Animation[];
  155194. /**
  155195. * Initializes the path cursor
  155196. * @param path The path to track
  155197. */
  155198. constructor(path: Path2);
  155199. /**
  155200. * Gets the cursor point on the path
  155201. * @returns A point on the path cursor at the cursor location
  155202. */
  155203. getPoint(): Vector3;
  155204. /**
  155205. * Moves the cursor ahead by the step amount
  155206. * @param step The amount to move the cursor forward
  155207. * @returns This path cursor
  155208. */
  155209. moveAhead(step?: number): PathCursor;
  155210. /**
  155211. * Moves the cursor behind by the step amount
  155212. * @param step The amount to move the cursor back
  155213. * @returns This path cursor
  155214. */
  155215. moveBack(step?: number): PathCursor;
  155216. /**
  155217. * Moves the cursor by the step amount
  155218. * If the step amount is greater than one, an exception is thrown
  155219. * @param step The amount to move the cursor
  155220. * @returns This path cursor
  155221. */
  155222. move(step: number): PathCursor;
  155223. /**
  155224. * Ensures that the value is limited between zero and one
  155225. * @returns This path cursor
  155226. */
  155227. private ensureLimits;
  155228. /**
  155229. * Runs onchange callbacks on change (used by the animation engine)
  155230. * @returns This path cursor
  155231. */
  155232. private raiseOnChange;
  155233. /**
  155234. * Executes a function on change
  155235. * @param f A path cursor onchange callback
  155236. * @returns This path cursor
  155237. */
  155238. onchange(f: (cursor: PathCursor) => void): PathCursor;
  155239. }
  155240. }
  155241. declare module BABYLON {
  155242. /** @hidden */
  155243. export var blurPixelShader: {
  155244. name: string;
  155245. shader: string;
  155246. };
  155247. }
  155248. declare module BABYLON {
  155249. /** @hidden */
  155250. export var pointCloudVertexDeclaration: {
  155251. name: string;
  155252. shader: string;
  155253. };
  155254. }
  155255. // Mixins
  155256. interface Window {
  155257. mozIndexedDB: IDBFactory;
  155258. webkitIndexedDB: IDBFactory;
  155259. msIndexedDB: IDBFactory;
  155260. webkitURL: typeof URL;
  155261. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  155262. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  155263. WebGLRenderingContext: WebGLRenderingContext;
  155264. MSGesture: MSGesture;
  155265. CANNON: any;
  155266. AudioContext: AudioContext;
  155267. webkitAudioContext: AudioContext;
  155268. PointerEvent: any;
  155269. Math: Math;
  155270. Uint8Array: Uint8ArrayConstructor;
  155271. Float32Array: Float32ArrayConstructor;
  155272. mozURL: typeof URL;
  155273. msURL: typeof URL;
  155274. VRFrameData: any; // WebVR, from specs 1.1
  155275. DracoDecoderModule: any;
  155276. setImmediate(handler: (...args: any[]) => void): number;
  155277. }
  155278. interface HTMLCanvasElement {
  155279. requestPointerLock(): void;
  155280. msRequestPointerLock?(): void;
  155281. mozRequestPointerLock?(): void;
  155282. webkitRequestPointerLock?(): void;
  155283. /** Track wether a record is in progress */
  155284. isRecording: boolean;
  155285. /** Capture Stream method defined by some browsers */
  155286. captureStream(fps?: number): MediaStream;
  155287. }
  155288. interface CanvasRenderingContext2D {
  155289. msImageSmoothingEnabled: boolean;
  155290. }
  155291. interface MouseEvent {
  155292. mozMovementX: number;
  155293. mozMovementY: number;
  155294. webkitMovementX: number;
  155295. webkitMovementY: number;
  155296. msMovementX: number;
  155297. msMovementY: number;
  155298. }
  155299. interface Navigator {
  155300. mozGetVRDevices: (any: any) => any;
  155301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155304. webkitGetGamepads(): Gamepad[];
  155305. msGetGamepads(): Gamepad[];
  155306. webkitGamepads(): Gamepad[];
  155307. }
  155308. interface HTMLVideoElement {
  155309. mozSrcObject: any;
  155310. }
  155311. interface Math {
  155312. fround(x: number): number;
  155313. imul(a: number, b: number): number;
  155314. }
  155315. interface WebGLRenderingContext {
  155316. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  155317. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  155318. vertexAttribDivisor(index: number, divisor: number): void;
  155319. createVertexArray(): any;
  155320. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  155321. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  155322. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  155323. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  155324. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  155325. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  155326. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  155327. // Queries
  155328. createQuery(): WebGLQuery;
  155329. deleteQuery(query: WebGLQuery): void;
  155330. beginQuery(target: number, query: WebGLQuery): void;
  155331. endQuery(target: number): void;
  155332. getQueryParameter(query: WebGLQuery, pname: number): any;
  155333. getQuery(target: number, pname: number): any;
  155334. MAX_SAMPLES: number;
  155335. RGBA8: number;
  155336. READ_FRAMEBUFFER: number;
  155337. DRAW_FRAMEBUFFER: number;
  155338. UNIFORM_BUFFER: number;
  155339. HALF_FLOAT_OES: number;
  155340. RGBA16F: number;
  155341. RGBA32F: number;
  155342. R32F: number;
  155343. RG32F: number;
  155344. RGB32F: number;
  155345. R16F: number;
  155346. RG16F: number;
  155347. RGB16F: number;
  155348. RED: number;
  155349. RG: number;
  155350. R8: number;
  155351. RG8: number;
  155352. UNSIGNED_INT_24_8: number;
  155353. DEPTH24_STENCIL8: number;
  155354. MIN: number;
  155355. MAX: number;
  155356. /* Multiple Render Targets */
  155357. drawBuffers(buffers: number[]): void;
  155358. readBuffer(src: number): void;
  155359. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  155360. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  155361. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  155362. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  155363. // Occlusion Query
  155364. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  155365. ANY_SAMPLES_PASSED: number;
  155366. QUERY_RESULT_AVAILABLE: number;
  155367. QUERY_RESULT: number;
  155368. }
  155369. interface WebGLProgram {
  155370. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  155371. }
  155372. interface EXT_disjoint_timer_query {
  155373. QUERY_COUNTER_BITS_EXT: number;
  155374. TIME_ELAPSED_EXT: number;
  155375. TIMESTAMP_EXT: number;
  155376. GPU_DISJOINT_EXT: number;
  155377. QUERY_RESULT_EXT: number;
  155378. QUERY_RESULT_AVAILABLE_EXT: number;
  155379. queryCounterEXT(query: WebGLQuery, target: number): void;
  155380. createQueryEXT(): WebGLQuery;
  155381. beginQueryEXT(target: number, query: WebGLQuery): void;
  155382. endQueryEXT(target: number): void;
  155383. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  155384. deleteQueryEXT(query: WebGLQuery): void;
  155385. }
  155386. interface WebGLUniformLocation {
  155387. _currentState: any;
  155388. }
  155389. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  155390. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  155391. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  155392. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155393. interface WebGLRenderingContext {
  155394. readonly RASTERIZER_DISCARD: number;
  155395. readonly DEPTH_COMPONENT24: number;
  155396. readonly TEXTURE_3D: number;
  155397. readonly TEXTURE_2D_ARRAY: number;
  155398. readonly TEXTURE_COMPARE_FUNC: number;
  155399. readonly TEXTURE_COMPARE_MODE: number;
  155400. readonly COMPARE_REF_TO_TEXTURE: number;
  155401. readonly TEXTURE_WRAP_R: number;
  155402. readonly HALF_FLOAT: number;
  155403. readonly RGB8: number;
  155404. readonly RED_INTEGER: number;
  155405. readonly RG_INTEGER: number;
  155406. readonly RGB_INTEGER: number;
  155407. readonly RGBA_INTEGER: number;
  155408. readonly R8_SNORM: number;
  155409. readonly RG8_SNORM: number;
  155410. readonly RGB8_SNORM: number;
  155411. readonly RGBA8_SNORM: number;
  155412. readonly R8I: number;
  155413. readonly RG8I: number;
  155414. readonly RGB8I: number;
  155415. readonly RGBA8I: number;
  155416. readonly R8UI: number;
  155417. readonly RG8UI: number;
  155418. readonly RGB8UI: number;
  155419. readonly RGBA8UI: number;
  155420. readonly R16I: number;
  155421. readonly RG16I: number;
  155422. readonly RGB16I: number;
  155423. readonly RGBA16I: number;
  155424. readonly R16UI: number;
  155425. readonly RG16UI: number;
  155426. readonly RGB16UI: number;
  155427. readonly RGBA16UI: number;
  155428. readonly R32I: number;
  155429. readonly RG32I: number;
  155430. readonly RGB32I: number;
  155431. readonly RGBA32I: number;
  155432. readonly R32UI: number;
  155433. readonly RG32UI: number;
  155434. readonly RGB32UI: number;
  155435. readonly RGBA32UI: number;
  155436. readonly RGB10_A2UI: number;
  155437. readonly R11F_G11F_B10F: number;
  155438. readonly RGB9_E5: number;
  155439. readonly RGB10_A2: number;
  155440. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  155441. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  155442. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  155443. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  155444. readonly DEPTH_COMPONENT32F: number;
  155445. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  155446. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  155447. 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;
  155448. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  155449. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  155450. readonly TRANSFORM_FEEDBACK: number;
  155451. readonly INTERLEAVED_ATTRIBS: number;
  155452. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  155453. createTransformFeedback(): WebGLTransformFeedback;
  155454. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  155455. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  155456. beginTransformFeedback(primitiveMode: number): void;
  155457. endTransformFeedback(): void;
  155458. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  155459. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155460. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155461. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155462. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  155463. }
  155464. interface ImageBitmap {
  155465. readonly width: number;
  155466. readonly height: number;
  155467. close(): void;
  155468. }
  155469. interface WebGLQuery extends WebGLObject {
  155470. }
  155471. declare var WebGLQuery: {
  155472. prototype: WebGLQuery;
  155473. new(): WebGLQuery;
  155474. };
  155475. interface WebGLSampler extends WebGLObject {
  155476. }
  155477. declare var WebGLSampler: {
  155478. prototype: WebGLSampler;
  155479. new(): WebGLSampler;
  155480. };
  155481. interface WebGLSync extends WebGLObject {
  155482. }
  155483. declare var WebGLSync: {
  155484. prototype: WebGLSync;
  155485. new(): WebGLSync;
  155486. };
  155487. interface WebGLTransformFeedback extends WebGLObject {
  155488. }
  155489. declare var WebGLTransformFeedback: {
  155490. prototype: WebGLTransformFeedback;
  155491. new(): WebGLTransformFeedback;
  155492. };
  155493. interface WebGLVertexArrayObject extends WebGLObject {
  155494. }
  155495. declare var WebGLVertexArrayObject: {
  155496. prototype: WebGLVertexArrayObject;
  155497. new(): WebGLVertexArrayObject;
  155498. };
  155499. // Type definitions for WebVR API
  155500. // Project: https://w3c.github.io/webvr/
  155501. // Definitions by: six a <https://github.com/lostfictions>
  155502. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155503. interface VRDisplay extends EventTarget {
  155504. /**
  155505. * Dictionary of capabilities describing the VRDisplay.
  155506. */
  155507. readonly capabilities: VRDisplayCapabilities;
  155508. /**
  155509. * z-depth defining the far plane of the eye view frustum
  155510. * enables mapping of values in the render target depth
  155511. * attachment to scene coordinates. Initially set to 10000.0.
  155512. */
  155513. depthFar: number;
  155514. /**
  155515. * z-depth defining the near plane of the eye view frustum
  155516. * enables mapping of values in the render target depth
  155517. * attachment to scene coordinates. Initially set to 0.01.
  155518. */
  155519. depthNear: number;
  155520. /**
  155521. * An identifier for this distinct VRDisplay. Used as an
  155522. * association point in the Gamepad API.
  155523. */
  155524. readonly displayId: number;
  155525. /**
  155526. * A display name, a user-readable name identifying it.
  155527. */
  155528. readonly displayName: string;
  155529. readonly isConnected: boolean;
  155530. readonly isPresenting: boolean;
  155531. /**
  155532. * If this VRDisplay supports room-scale experiences, the optional
  155533. * stage attribute contains details on the room-scale parameters.
  155534. */
  155535. readonly stageParameters: VRStageParameters | null;
  155536. /**
  155537. * Passing the value returned by `requestAnimationFrame` to
  155538. * `cancelAnimationFrame` will unregister the callback.
  155539. * @param handle Define the hanle of the request to cancel
  155540. */
  155541. cancelAnimationFrame(handle: number): void;
  155542. /**
  155543. * Stops presenting to the VRDisplay.
  155544. * @returns a promise to know when it stopped
  155545. */
  155546. exitPresent(): Promise<void>;
  155547. /**
  155548. * Return the current VREyeParameters for the given eye.
  155549. * @param whichEye Define the eye we want the parameter for
  155550. * @returns the eye parameters
  155551. */
  155552. getEyeParameters(whichEye: string): VREyeParameters;
  155553. /**
  155554. * Populates the passed VRFrameData with the information required to render
  155555. * the current frame.
  155556. * @param frameData Define the data structure to populate
  155557. * @returns true if ok otherwise false
  155558. */
  155559. getFrameData(frameData: VRFrameData): boolean;
  155560. /**
  155561. * Get the layers currently being presented.
  155562. * @returns the list of VR layers
  155563. */
  155564. getLayers(): VRLayer[];
  155565. /**
  155566. * Return a VRPose containing the future predicted pose of the VRDisplay
  155567. * when the current frame will be presented. The value returned will not
  155568. * change until JavaScript has returned control to the browser.
  155569. *
  155570. * The VRPose will contain the position, orientation, velocity,
  155571. * and acceleration of each of these properties.
  155572. * @returns the pose object
  155573. */
  155574. getPose(): VRPose;
  155575. /**
  155576. * Return the current instantaneous pose of the VRDisplay, with no
  155577. * prediction applied.
  155578. * @returns the current instantaneous pose
  155579. */
  155580. getImmediatePose(): VRPose;
  155581. /**
  155582. * The callback passed to `requestAnimationFrame` will be called
  155583. * any time a new frame should be rendered. When the VRDisplay is
  155584. * presenting the callback will be called at the native refresh
  155585. * rate of the HMD. When not presenting this function acts
  155586. * identically to how window.requestAnimationFrame acts. Content should
  155587. * make no assumptions of frame rate or vsync behavior as the HMD runs
  155588. * asynchronously from other displays and at differing refresh rates.
  155589. * @param callback Define the eaction to run next frame
  155590. * @returns the request handle it
  155591. */
  155592. requestAnimationFrame(callback: FrameRequestCallback): number;
  155593. /**
  155594. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  155595. * Repeat calls while already presenting will update the VRLayers being displayed.
  155596. * @param layers Define the list of layer to present
  155597. * @returns a promise to know when the request has been fulfilled
  155598. */
  155599. requestPresent(layers: VRLayer[]): Promise<void>;
  155600. /**
  155601. * Reset the pose for this display, treating its current position and
  155602. * orientation as the "origin/zero" values. VRPose.position,
  155603. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  155604. * updated when calling resetPose(). This should be called in only
  155605. * sitting-space experiences.
  155606. */
  155607. resetPose(): void;
  155608. /**
  155609. * The VRLayer provided to the VRDisplay will be captured and presented
  155610. * in the HMD. Calling this function has the same effect on the source
  155611. * canvas as any other operation that uses its source image, and canvases
  155612. * created without preserveDrawingBuffer set to true will be cleared.
  155613. * @param pose Define the pose to submit
  155614. */
  155615. submitFrame(pose?: VRPose): void;
  155616. }
  155617. declare var VRDisplay: {
  155618. prototype: VRDisplay;
  155619. new(): VRDisplay;
  155620. };
  155621. interface VRLayer {
  155622. leftBounds?: number[] | Float32Array | null;
  155623. rightBounds?: number[] | Float32Array | null;
  155624. source?: HTMLCanvasElement | null;
  155625. }
  155626. interface VRDisplayCapabilities {
  155627. readonly canPresent: boolean;
  155628. readonly hasExternalDisplay: boolean;
  155629. readonly hasOrientation: boolean;
  155630. readonly hasPosition: boolean;
  155631. readonly maxLayers: number;
  155632. }
  155633. interface VREyeParameters {
  155634. /** @deprecated */
  155635. readonly fieldOfView: VRFieldOfView;
  155636. readonly offset: Float32Array;
  155637. readonly renderHeight: number;
  155638. readonly renderWidth: number;
  155639. }
  155640. interface VRFieldOfView {
  155641. readonly downDegrees: number;
  155642. readonly leftDegrees: number;
  155643. readonly rightDegrees: number;
  155644. readonly upDegrees: number;
  155645. }
  155646. interface VRFrameData {
  155647. readonly leftProjectionMatrix: Float32Array;
  155648. readonly leftViewMatrix: Float32Array;
  155649. readonly pose: VRPose;
  155650. readonly rightProjectionMatrix: Float32Array;
  155651. readonly rightViewMatrix: Float32Array;
  155652. readonly timestamp: number;
  155653. }
  155654. interface VRPose {
  155655. readonly angularAcceleration: Float32Array | null;
  155656. readonly angularVelocity: Float32Array | null;
  155657. readonly linearAcceleration: Float32Array | null;
  155658. readonly linearVelocity: Float32Array | null;
  155659. readonly orientation: Float32Array | null;
  155660. readonly position: Float32Array | null;
  155661. readonly timestamp: number;
  155662. }
  155663. interface VRStageParameters {
  155664. sittingToStandingTransform?: Float32Array;
  155665. sizeX?: number;
  155666. sizeY?: number;
  155667. }
  155668. interface Navigator {
  155669. getVRDisplays(): Promise<VRDisplay[]>;
  155670. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  155671. }
  155672. interface Window {
  155673. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  155674. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  155675. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  155676. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155677. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155678. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  155679. }
  155680. interface Gamepad {
  155681. readonly displayId: number;
  155682. }
  155683. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  155684. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  155685. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  155686. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  155687. type XRHandedness = "none" | "left" | "right";
  155688. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  155689. type XREye = "none" | "left" | "right";
  155690. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  155691. interface XRSpace extends EventTarget {}
  155692. interface XRRenderState {
  155693. depthNear?: number;
  155694. depthFar?: number;
  155695. inlineVerticalFieldOfView?: number;
  155696. baseLayer?: XRWebGLLayer;
  155697. }
  155698. interface XRInputSource {
  155699. handedness: XRHandedness;
  155700. targetRayMode: XRTargetRayMode;
  155701. targetRaySpace: XRSpace;
  155702. gripSpace: XRSpace | undefined;
  155703. gamepad: Gamepad | undefined;
  155704. profiles: Array<string>;
  155705. hand: XRHand | undefined;
  155706. }
  155707. interface XRSessionInit {
  155708. optionalFeatures?: string[];
  155709. requiredFeatures?: string[];
  155710. }
  155711. interface XRSession {
  155712. addEventListener: Function;
  155713. removeEventListener: Function;
  155714. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  155715. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  155716. requestAnimationFrame: Function;
  155717. end(): Promise<void>;
  155718. renderState: XRRenderState;
  155719. inputSources: Array<XRInputSource>;
  155720. // hit test
  155721. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  155722. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  155723. // legacy AR hit test
  155724. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155725. // legacy plane detection
  155726. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  155727. }
  155728. interface XRReferenceSpace extends XRSpace {
  155729. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  155730. onreset: any;
  155731. }
  155732. type XRPlaneSet = Set<XRPlane>;
  155733. type XRAnchorSet = Set<XRAnchor>;
  155734. interface XRFrame {
  155735. session: XRSession;
  155736. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  155737. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  155738. // AR
  155739. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  155740. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  155741. // Anchors
  155742. trackedAnchors?: XRAnchorSet;
  155743. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  155744. // Planes
  155745. worldInformation: {
  155746. detectedPlanes?: XRPlaneSet;
  155747. };
  155748. // Hand tracking
  155749. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  155750. }
  155751. interface XRViewerPose extends XRPose {
  155752. views: Array<XRView>;
  155753. }
  155754. interface XRPose {
  155755. transform: XRRigidTransform;
  155756. emulatedPosition: boolean;
  155757. }
  155758. interface XRWebGLLayerOptions {
  155759. antialias?: boolean;
  155760. depth?: boolean;
  155761. stencil?: boolean;
  155762. alpha?: boolean;
  155763. multiview?: boolean;
  155764. framebufferScaleFactor?: number;
  155765. }
  155766. declare var XRWebGLLayer: {
  155767. prototype: XRWebGLLayer;
  155768. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  155769. };
  155770. interface XRWebGLLayer {
  155771. framebuffer: WebGLFramebuffer;
  155772. framebufferWidth: number;
  155773. framebufferHeight: number;
  155774. getViewport: Function;
  155775. }
  155776. declare class XRRigidTransform {
  155777. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  155778. position: DOMPointReadOnly;
  155779. orientation: DOMPointReadOnly;
  155780. matrix: Float32Array;
  155781. inverse: XRRigidTransform;
  155782. }
  155783. interface XRView {
  155784. eye: XREye;
  155785. projectionMatrix: Float32Array;
  155786. transform: XRRigidTransform;
  155787. }
  155788. interface XRInputSourceChangeEvent {
  155789. session: XRSession;
  155790. removed: Array<XRInputSource>;
  155791. added: Array<XRInputSource>;
  155792. }
  155793. interface XRInputSourceEvent extends Event {
  155794. readonly frame: XRFrame;
  155795. readonly inputSource: XRInputSource;
  155796. }
  155797. // Experimental(er) features
  155798. declare class XRRay {
  155799. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  155800. origin: DOMPointReadOnly;
  155801. direction: DOMPointReadOnly;
  155802. matrix: Float32Array;
  155803. }
  155804. declare enum XRHitTestTrackableType {
  155805. "point",
  155806. "plane",
  155807. "mesh",
  155808. }
  155809. interface XRHitResult {
  155810. hitMatrix: Float32Array;
  155811. }
  155812. interface XRTransientInputHitTestResult {
  155813. readonly inputSource: XRInputSource;
  155814. readonly results: Array<XRHitTestResult>;
  155815. }
  155816. interface XRHitTestResult {
  155817. getPose(baseSpace: XRSpace): XRPose | undefined;
  155818. // When anchor system is enabled
  155819. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  155820. }
  155821. interface XRHitTestSource {
  155822. cancel(): void;
  155823. }
  155824. interface XRTransientInputHitTestSource {
  155825. cancel(): void;
  155826. }
  155827. interface XRHitTestOptionsInit {
  155828. space: XRSpace;
  155829. entityTypes?: Array<XRHitTestTrackableType>;
  155830. offsetRay?: XRRay;
  155831. }
  155832. interface XRTransientInputHitTestOptionsInit {
  155833. profile: string;
  155834. entityTypes?: Array<XRHitTestTrackableType>;
  155835. offsetRay?: XRRay;
  155836. }
  155837. interface XRAnchor {
  155838. anchorSpace: XRSpace;
  155839. delete(): void;
  155840. }
  155841. interface XRPlane {
  155842. orientation: "Horizontal" | "Vertical";
  155843. planeSpace: XRSpace;
  155844. polygon: Array<DOMPointReadOnly>;
  155845. lastChangedTime: number;
  155846. }
  155847. interface XRJointSpace extends XRSpace {}
  155848. interface XRJointPose extends XRPose {
  155849. radius: number | undefined;
  155850. }
  155851. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  155852. readonly length: number;
  155853. [index: number]: XRJointSpace;
  155854. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  155855. readonly WRIST: number;
  155856. readonly THUMB_METACARPAL: number;
  155857. readonly THUMB_PHALANX_PROXIMAL: number;
  155858. readonly THUMB_PHALANX_DISTAL: number;
  155859. readonly THUMB_PHALANX_TIP: number;
  155860. readonly INDEX_METACARPAL: number;
  155861. readonly INDEX_PHALANX_PROXIMAL: number;
  155862. readonly INDEX_PHALANX_INTERMEDIATE: number;
  155863. readonly INDEX_PHALANX_DISTAL: number;
  155864. readonly INDEX_PHALANX_TIP: number;
  155865. readonly MIDDLE_METACARPAL: number;
  155866. readonly MIDDLE_PHALANX_PROXIMAL: number;
  155867. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  155868. readonly MIDDLE_PHALANX_DISTAL: number;
  155869. readonly MIDDLE_PHALANX_TIP: number;
  155870. readonly RING_METACARPAL: number;
  155871. readonly RING_PHALANX_PROXIMAL: number;
  155872. readonly RING_PHALANX_INTERMEDIATE: number;
  155873. readonly RING_PHALANX_DISTAL: number;
  155874. readonly RING_PHALANX_TIP: number;
  155875. readonly LITTLE_METACARPAL: number;
  155876. readonly LITTLE_PHALANX_PROXIMAL: number;
  155877. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  155878. readonly LITTLE_PHALANX_DISTAL: number;
  155879. readonly LITTLE_PHALANX_TIP: number;
  155880. }
  155881. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  155882. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  155883. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  155884. interface XRSession {
  155885. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  155886. }
  155887. interface XRFrame {
  155888. featurePointCloud? : Array<number>;
  155889. }